Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
pulsar
提交
07d2daf4
pulsar
项目概览
apache
/
pulsar
通知
129
Star
40
Fork
3
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Wiki
1
Wiki
分析
仓库
DevOps
项目成员
Pages
pulsar
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Pages
分析
分析
仓库分析
DevOps
Wiki
1
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
提交
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
07d2daf4
编写于
6月 18, 2017
作者:
M
Matteo Merli
提交者:
GitHub
6月 18, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Shutdown load manager executor on pulsar service close (#489)
上级
02198296
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
22 addition
and
14 deletion
+22
-14
pulsar-broker/src/main/java/com/yahoo/pulsar/broker/PulsarService.java
.../src/main/java/com/yahoo/pulsar/broker/PulsarService.java
+10
-6
pulsar-broker/src/main/java/com/yahoo/pulsar/broker/loadbalance/impl/ModularLoadManagerImpl.java
...ulsar/broker/loadbalance/impl/ModularLoadManagerImpl.java
+9
-7
pulsar-broker/src/main/java/com/yahoo/pulsar/broker/loadbalance/impl/SimpleLoadManagerImpl.java
...pulsar/broker/loadbalance/impl/SimpleLoadManagerImpl.java
+3
-1
未找到文件。
pulsar-broker/src/main/java/com/yahoo/pulsar/broker/PulsarService.java
浏览文件 @
07d2daf4
...
...
@@ -94,7 +94,7 @@ public class PulsarService implements AutoCloseable {
private
final
ScheduledExecutorService
cacheExecutor
=
Executors
.
newScheduledThreadPool
(
10
,
new
DefaultThreadFactory
(
"zk-cache-callback"
));
private
final
OrderedSafeExecutor
orderedExecutor
=
new
OrderedSafeExecutor
(
8
,
"pulsar-ordered"
);
private
ScheduledExecutorService
loadManagerExecutor
=
null
;
private
final
ScheduledExecutorService
loadManagerExecutor
;
private
ScheduledFuture
<?>
loadReportTask
=
null
;
private
ScheduledFuture
<?>
loadSheddingTask
=
null
;
private
ScheduledFuture
<?>
loadResourceQuotaTask
=
null
;
...
...
@@ -133,7 +133,8 @@ public class PulsarService implements AutoCloseable {
this
.
brokerVersion
=
PulsarBrokerVersionStringUtils
.
getNormalizedVersionString
();
this
.
config
=
config
;
this
.
shutdownService
=
new
MessagingServiceShutdownHook
(
this
);
loadManagerExecutor
=
Executors
.
newSingleThreadScheduledExecutor
();
this
.
loadManagerExecutor
=
Executors
.
newSingleThreadScheduledExecutor
(
new
DefaultThreadFactory
(
"pulsar-load-manager"
));
}
/**
...
...
@@ -174,10 +175,7 @@ public class PulsarService implements AutoCloseable {
this
.
leaderElectionService
=
null
;
}
if
(
loadManagerExecutor
!=
null
)
{
loadManagerExecutor
.
shutdownNow
();
}
loadManager
=
null
;
loadManagerExecutor
.
shutdown
();
if
(
globalZkCache
!=
null
)
{
globalZkCache
.
close
();
...
...
@@ -205,6 +203,12 @@ public class PulsarService implements AutoCloseable {
orderedExecutor
.
shutdown
();
cacheExecutor
.
shutdown
();
LoadManager
loadManager
=
this
.
loadManager
.
get
();
if
(
loadManager
!=
null
)
{
loadManager
.
stop
();
}
state
=
State
.
Closed
;
}
catch
(
Exception
e
)
{
...
...
pulsar-broker/src/main/java/com/yahoo/pulsar/broker/loadbalance/impl/ModularLoadManagerImpl.java
浏览文件 @
07d2daf4
...
...
@@ -60,6 +60,8 @@ import com.yahoo.pulsar.zookeeper.ZooKeeperCacheListener;
import
com.yahoo.pulsar.zookeeper.ZooKeeperChildrenCache
;
import
com.yahoo.pulsar.zookeeper.ZooKeeperDataCache
;
import
io.netty.util.concurrent.DefaultThreadFactory
;
public
class
ModularLoadManagerImpl
implements
ModularLoadManager
,
ZooKeeperCacheListener
<
LocalBrokerData
>
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
ModularLoadManagerImpl
.
class
);
...
...
@@ -163,13 +165,13 @@ public class ModularLoadManagerImpl implements ModularLoadManager, ZooKeeperCach
loadSheddingPipeline
=
new
ArrayList
<>();
loadSheddingPipeline
.
add
(
new
OverloadShedder
(
conf
));
preallocatedBundleToBroker
=
new
ConcurrentHashMap
<>();
scheduler
=
Executors
.
newS
cheduledThreadPool
(
1
);
scheduler
=
Executors
.
newS
ingleThreadScheduledExecutor
(
new
DefaultThreadFactory
(
"pulsar-modular-load-manager"
)
);
}
/**
* Initialize this load manager using the given PulsarService. Should be called only once, after invoking the
* default constructor.
*
*
* @param pulsar
* The service to initialize with.
*/
...
...
@@ -224,7 +226,7 @@ public class ModularLoadManagerImpl implements ModularLoadManager, ZooKeeperCach
/**
* Initialize this load manager.
*
*
* @param pulsar
* Client to construct this manager from.
*/
...
...
@@ -475,7 +477,7 @@ public class ModularLoadManagerImpl implements ModularLoadManager, ZooKeeperCach
/**
* As any broker, disable the broker this manager is running on.
*
*
* @throws PulsarServerException
* If ZooKeeper failed to disable the broker.
*/
...
...
@@ -548,7 +550,7 @@ public class ModularLoadManagerImpl implements ModularLoadManager, ZooKeeperCach
/**
* As the leader broker, find a suitable broker for the assignment of the given bundle.
*
*
* @param serviceUnit
* ServiceUnitId for the bundle.
* @return The name of the selected broker, as it appears on ZooKeeper.
...
...
@@ -610,7 +612,7 @@ public class ModularLoadManagerImpl implements ModularLoadManager, ZooKeeperCach
/**
* As any broker, start the load manager.
*
*
* @throws PulsarServerException
* If an unexpected error prevented the load manager from being started.
*/
...
...
@@ -647,7 +649,7 @@ public class ModularLoadManagerImpl implements ModularLoadManager, ZooKeeperCach
/**
* As any broker, stop the load manager.
*
*
* @throws PulsarServerException
* If an unexpected error occurred when attempting to stop the load manager.
*/
...
...
pulsar-broker/src/main/java/com/yahoo/pulsar/broker/loadbalance/impl/SimpleLoadManagerImpl.java
浏览文件 @
07d2daf4
...
...
@@ -74,6 +74,8 @@ import com.yahoo.pulsar.zookeeper.ZooKeeperCacheListener;
import
com.yahoo.pulsar.zookeeper.ZooKeeperChildrenCache
;
import
com.yahoo.pulsar.zookeeper.ZooKeeperDataCache
;
import
io.netty.util.concurrent.DefaultThreadFactory
;
public
class
SimpleLoadManagerImpl
implements
LoadManager
,
ZooKeeperCacheListener
<
LoadReport
>
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
SimpleLoadManagerImpl
.
class
);
...
...
@@ -179,7 +181,7 @@ public class SimpleLoadManagerImpl implements LoadManager, ZooKeeperCacheListene
// Perform initializations which may be done without a PulsarService.
public
SimpleLoadManagerImpl
()
{
scheduler
=
Executors
.
newS
cheduledThreadPool
(
1
);
scheduler
=
Executors
.
newS
ingleThreadScheduledExecutor
(
new
DefaultThreadFactory
(
"pulsar-simple-load-manager"
)
);
this
.
sortedRankings
.
set
(
new
TreeMap
<>());
this
.
currentLoadReports
=
new
HashMap
<>();
this
.
resourceUnitRankings
=
new
HashMap
<>();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录