Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
pulsar
提交
19399e0f
pulsar
项目概览
apache
/
pulsar
通知
129
Star
40
Fork
3
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Wiki
1
Wiki
分析
仓库
DevOps
项目成员
Pages
pulsar
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Pages
分析
分析
仓库分析
DevOps
Wiki
1
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
提交
体验新版 GitCode,发现更多精彩内容 >>
提交
19399e0f
编写于
4月 13, 2017
作者:
R
Rajan
提交者:
Matteo Merli
4月 13, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Delete local-policies and invalidate cache when namespace is deleted (#352)
上级
bd5a6222
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
40 addition
and
8 deletion
+40
-8
pulsar-broker/src/main/java/com/yahoo/pulsar/broker/admin/Namespaces.java
...c/main/java/com/yahoo/pulsar/broker/admin/Namespaces.java
+7
-2
pulsar-broker/src/main/java/com/yahoo/pulsar/broker/namespace/NamespaceService.java
...a/com/yahoo/pulsar/broker/namespace/NamespaceService.java
+3
-0
pulsar-broker/src/test/java/com/yahoo/pulsar/broker/admin/AdminApiTest.java
...test/java/com/yahoo/pulsar/broker/admin/AdminApiTest.java
+30
-6
未找到文件。
pulsar-broker/src/main/java/com/yahoo/pulsar/broker/admin/Namespaces.java
浏览文件 @
19399e0f
...
...
@@ -52,6 +52,7 @@ import org.slf4j.LoggerFactory;
import
com.google.common.collect.Lists
;
import
com.yahoo.pulsar.broker.PulsarServerException
;
import
static
com
.
yahoo
.
pulsar
.
broker
.
cache
.
LocalZooKeeperCacheService
.
LOCAL_POLICIES_ROOT
;
import
com.yahoo.pulsar.broker.service.BrokerServiceException.SubscriptionBusyException
;
import
com.yahoo.pulsar.broker.service.persistent.PersistentReplicator
;
import
com.yahoo.pulsar.broker.service.persistent.PersistentSubscription
;
...
...
@@ -318,8 +319,12 @@ public class Namespaces extends AdminResource {
}
// we have successfully removed all the ownership for the namespace, the policies znode can be deleted now
globalZk
().
delete
(
path
(
"policies"
,
property
,
cluster
,
namespace
),
-
1
);
policiesCache
().
invalidate
(
path
(
"policies"
,
property
,
cluster
,
namespace
));
final
String
globalZkPolicyPath
=
path
(
"policies"
,
property
,
cluster
,
namespace
);
final
String
lcaolZkPolicyPath
=
joinPath
(
LOCAL_POLICIES_ROOT
,
property
,
cluster
,
namespace
);
globalZk
().
delete
(
globalZkPolicyPath
,
-
1
);
localZk
().
delete
(
lcaolZkPolicyPath
,
-
1
);
policiesCache
().
invalidate
(
globalZkPolicyPath
);
localCacheService
().
policiesCache
().
invalidate
(
lcaolZkPolicyPath
);
}
catch
(
PulsarAdminException
cae
)
{
throw
new
RestException
(
cae
);
}
catch
(
Exception
e
)
{
...
...
pulsar-broker/src/main/java/com/yahoo/pulsar/broker/namespace/NamespaceService.java
浏览文件 @
19399e0f
...
...
@@ -668,14 +668,17 @@ public class NamespaceService {
public
void
removeOwnedServiceUnit
(
NamespaceName
nsName
)
throws
Exception
{
ownershipCache
.
removeOwnership
(
getFullBundle
(
nsName
)).
get
();
bundleFactory
.
invalidateBundleCache
(
nsName
);
}
public
void
removeOwnedServiceUnit
(
NamespaceBundle
nsBundle
)
throws
Exception
{
ownershipCache
.
removeOwnership
(
nsBundle
).
get
();
bundleFactory
.
invalidateBundleCache
(
nsBundle
.
getNamespaceObject
());
}
public
void
removeOwnedServiceUnits
(
NamespaceName
nsName
,
BundlesData
bundleData
)
throws
Exception
{
ownershipCache
.
removeOwnership
(
bundleFactory
.
getBundles
(
nsName
,
bundleData
)).
get
();
bundleFactory
.
invalidateBundleCache
(
nsName
);
}
public
NamespaceBundleFactory
getNamespaceBundleFactory
()
{
...
...
pulsar-broker/src/test/java/com/yahoo/pulsar/broker/admin/AdminApiTest.java
浏览文件 @
19399e0f
...
...
@@ -15,7 +15,6 @@
*/
package
com.yahoo.pulsar.broker.admin
;
import
static
com
.
yahoo
.
pulsar
.
broker
.
service
.
BrokerService
.
BROKER_SERVICE_CONFIGURATION_PATH
;
import
static
org
.
testng
.
Assert
.
assertEquals
;
import
static
org
.
testng
.
Assert
.
assertNotEquals
;
import
static
org
.
testng
.
Assert
.
assertFalse
;
...
...
@@ -23,7 +22,6 @@ import static org.testng.Assert.assertTrue;
import
static
org
.
testng
.
Assert
.
fail
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.Method
;
import
java.net.URL
;
import
java.util.ArrayList
;
import
java.util.EnumSet
;
...
...
@@ -39,9 +37,6 @@ import javax.ws.rs.client.InvocationCallback;
import
javax.ws.rs.client.WebTarget
;
import
org.apache.bookkeeper.test.PortManager
;
import
org.apache.bookkeeper.util.ZkUtils
;
import
org.apache.zookeeper.CreateMode
;
import
org.apache.zookeeper.ZooDefs
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.testng.Assert
;
...
...
@@ -62,7 +57,6 @@ import com.yahoo.pulsar.broker.ServiceConfiguration;
import
com.yahoo.pulsar.broker.auth.MockedPulsarServiceBaseTest
;
import
com.yahoo.pulsar.broker.namespace.NamespaceEphemeralData
;
import
com.yahoo.pulsar.broker.namespace.NamespaceService
;
import
com.yahoo.pulsar.broker.service.BrokerService
;
import
com.yahoo.pulsar.client.admin.PulsarAdmin
;
import
com.yahoo.pulsar.client.admin.PulsarAdminException
;
import
com.yahoo.pulsar.client.admin.PulsarAdminException.ConflictException
;
...
...
@@ -1703,4 +1697,34 @@ public class AdminApiTest extends MockedPulsarServiceBaseTest {
assertEquals
(
uriStats
.
get
().
subscriptions
.
size
(),
1
);
}
/**
* Verifies that deleteNamespace cleans up policies(global,local), bundle cache and bundle ownership
*
* @throws Exception
*/
@Test
public
void
testDeleteNamespace
()
throws
Exception
{
final
String
namespace
=
"prop-xyz/use/deleteNs"
;
admin
.
namespaces
().
createNamespace
(
namespace
,
100
);
assertEquals
(
admin
.
namespaces
().
getPolicies
(
namespace
).
bundles
.
numBundles
,
100
);
// (1) Force topic creation and namespace being loaded
final
String
topicName
=
"persistent://"
+
namespace
+
"/my-topic"
;
DestinationName
destination
=
DestinationName
.
get
(
topicName
);
Producer
producer
=
pulsarClient
.
createProducer
(
topicName
);
producer
.
close
();
NamespaceBundle
bundle1
=
pulsar
.
getNamespaceService
().
getBundle
(
destination
);
// (2) Delete topic
admin
.
persistentTopics
().
delete
(
topicName
);
// (3) Delete ns
admin
.
namespaces
().
deleteNamespace
(
namespace
);
// (4) check bundle
NamespaceBundle
bundle2
=
pulsar
.
getNamespaceService
().
getBundle
(
destination
);
assertNotEquals
(
bundle1
.
getBundleRange
(),
bundle2
.
getBundleRange
());
// returns full bundle if policies not present
assertEquals
(
"0x00000000_0xffffffff"
,
bundle2
.
getBundleRange
());
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录