Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
pulsar
提交
4e1bde9f
pulsar
项目概览
apache
/
pulsar
通知
129
Star
40
Fork
3
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Wiki
1
Wiki
分析
仓库
DevOps
项目成员
Pages
pulsar
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Pages
分析
分析
仓库分析
DevOps
Wiki
1
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
提交
体验新版 GitCode,发现更多精彩内容 >>
提交
4e1bde9f
编写于
9月 21, 2016
作者:
M
Matteo Merli
提交者:
GitHub
9月 21, 2016
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
In unit tests, do ZK cache reloads in same thread, to avoid race conditions (#31)
上级
afc771bd
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
56 addition
and
3 deletion
+56
-3
pulsar-broker/src/main/java/com/yahoo/pulsar/broker/PulsarService.java
.../src/main/java/com/yahoo/pulsar/broker/PulsarService.java
+3
-3
pulsar-broker/src/test/java/com/yahoo/pulsar/broker/auth/MockedPulsarServiceBaseTest.java
...yahoo/pulsar/broker/auth/MockedPulsarServiceBaseTest.java
+7
-0
pulsar-broker/src/test/java/com/yahoo/pulsar/broker/auth/SameThreadOrderedSafeExecutor.java
...hoo/pulsar/broker/auth/SameThreadOrderedSafeExecutor.java
+46
-0
未找到文件。
pulsar-broker/src/main/java/com/yahoo/pulsar/broker/PulsarService.java
浏览文件 @
4e1bde9f
...
...
@@ -180,7 +180,7 @@ public class PulsarService implements AutoCloseable {
adminClient
.
close
();
adminClient
=
null
;
}
nsservice
=
null
;
// executor is not initialized in mocks even when real close method is called
...
...
@@ -357,10 +357,10 @@ public class PulsarService implements AutoCloseable {
LOG
.
info
(
"starting configuration cache service"
);
this
.
localZkCache
=
new
LocalZooKeeperCache
(
getZkClient
(),
this
.
orderedExecutor
);
this
.
localZkCache
=
new
LocalZooKeeperCache
(
getZkClient
(),
getOrderedExecutor
()
);
this
.
globalZkCache
=
new
GlobalZooKeeperCache
(
getZooKeeperClientFactory
(),
(
int
)
config
.
getZooKeeperSessionTimeoutMillis
(),
config
.
getGlobalZookeeperServers
(),
this
.
orderedExecutor
,
this
.
executor
);
getOrderedExecutor
()
,
this
.
executor
);
try
{
this
.
globalZkCache
.
start
();
}
catch
(
IOException
e
)
{
...
...
pulsar-broker/src/test/java/com/yahoo/pulsar/broker/auth/MockedPulsarServiceBaseTest.java
浏览文件 @
4e1bde9f
...
...
@@ -68,6 +68,8 @@ public abstract class MockedPulsarServiceBaseTest {
protected
MockZooKeeper
mockZookKeeper
;
protected
NonClosableMockBookKeeper
mockBookKeeper
;
private
SameThreadOrderedSafeExecutor
sameThreadOrderedSafeExecutor
;
public
MockedPulsarServiceBaseTest
()
{
this
.
conf
=
new
ServiceConfiguration
();
this
.
conf
.
setBrokerServicePort
(
BROKER_PORT
);
...
...
@@ -96,6 +98,8 @@ public abstract class MockedPulsarServiceBaseTest {
mockZookKeeper
=
createMockZooKeeper
();
mockBookKeeper
=
new
NonClosableMockBookKeeper
(
new
ClientConfiguration
(),
mockZookKeeper
);
sameThreadOrderedSafeExecutor
=
new
SameThreadOrderedSafeExecutor
();
startBroker
();
brokerUrl
=
new
URL
(
"http://localhost:"
+
BROKER_WEBSERVICE_PORT
);
...
...
@@ -110,6 +114,7 @@ public abstract class MockedPulsarServiceBaseTest {
pulsar
.
close
();
mockBookKeeper
.
reallyShutdow
();
mockZookKeeper
.
shutdown
();
sameThreadOrderedSafeExecutor
.
shutdown
();
}
protected
abstract
void
setup
()
throws
Exception
;
...
...
@@ -146,6 +151,8 @@ public abstract class MockedPulsarServiceBaseTest {
Supplier
<
NamespaceService
>
namespaceServiceSupplier
=
()
->
spy
(
new
NamespaceService
(
pulsar
));
doReturn
(
namespaceServiceSupplier
).
when
(
pulsar
).
getNamespaceServiceProvider
();
doReturn
(
sameThreadOrderedSafeExecutor
).
when
(
pulsar
).
getOrderedExecutor
();
}
private
MockZooKeeper
createMockZooKeeper
()
throws
Exception
{
...
...
pulsar-broker/src/test/java/com/yahoo/pulsar/broker/auth/SameThreadOrderedSafeExecutor.java
0 → 100644
浏览文件 @
4e1bde9f
/**
* Copyright 2016 Yahoo Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com.yahoo.pulsar.broker.auth
;
import
org.apache.bookkeeper.util.OrderedSafeExecutor
;
import
org.apache.bookkeeper.util.SafeRunnable
;
public
class
SameThreadOrderedSafeExecutor
extends
OrderedSafeExecutor
{
public
SameThreadOrderedSafeExecutor
()
{
super
(
1
,
"ordered-executor"
);
}
@Override
public
void
submit
(
SafeRunnable
r
)
{
r
.
run
();
}
@Override
public
void
submitOrdered
(
int
orderingKey
,
SafeRunnable
r
)
{
r
.
run
();
}
@Override
public
void
submitOrdered
(
long
orderingKey
,
SafeRunnable
r
)
{
r
.
run
();
}
@Override
public
void
submitOrdered
(
Object
orderingKey
,
SafeRunnable
r
)
{
r
.
run
();
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录