Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Kwan的解忧杂货铺@新空间代码工作室
Rocketmq
提交
d8c446e8
R
Rocketmq
项目概览
Kwan的解忧杂货铺@新空间代码工作室
/
Rocketmq
与 Fork 源项目一致
Fork自
Apache RocketMQ / Rocketmq
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rocketmq
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
d8c446e8
编写于
7月 16, 2018
作者:
F
fuyou001
提交者:
von gosling
7月 16, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[ISSUE #314] Heartbeat handler use independently thread pool (#315)
上级
76233ed8
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
63 addition
and
21 deletion
+63
-21
broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java
...ain/java/org/apache/rocketmq/broker/BrokerController.java
+33
-21
broker/src/main/java/org/apache/rocketmq/broker/latency/BrokerFastFailure.java
...org/apache/rocketmq/broker/latency/BrokerFastFailure.java
+3
-0
common/src/main/java/org/apache/rocketmq/common/BrokerConfig.java
...rc/main/java/org/apache/rocketmq/common/BrokerConfig.java
+27
-0
未找到文件。
broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java
浏览文件 @
d8c446e8
...
...
@@ -16,6 +16,21 @@
*/
package
org.apache.rocketmq.broker
;
import
java.io.IOException
;
import
java.net.InetSocketAddress
;
import
java.util.ArrayList
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.BlockingQueue
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentMap
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.LinkedBlockingQueue
;
import
java.util.concurrent.ScheduledExecutorService
;
import
java.util.concurrent.ThreadPoolExecutor
;
import
java.util.concurrent.TimeUnit
;
import
org.apache.rocketmq.broker.client.ClientHousekeepingService
;
import
org.apache.rocketmq.broker.client.ConsumerIdsChangeListener
;
import
org.apache.rocketmq.broker.client.ConsumerManager
;
...
...
@@ -85,21 +100,6 @@ import org.apache.rocketmq.store.config.MessageStoreConfig;
import
org.apache.rocketmq.store.stats.BrokerStats
;
import
org.apache.rocketmq.store.stats.BrokerStatsManager
;
import
java.io.IOException
;
import
java.net.InetSocketAddress
;
import
java.util.ArrayList
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.BlockingQueue
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentMap
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.LinkedBlockingQueue
;
import
java.util.concurrent.ScheduledExecutorService
;
import
java.util.concurrent.ThreadPoolExecutor
;
import
java.util.concurrent.TimeUnit
;
public
class
BrokerController
{
private
static
final
InternalLogger
log
=
InternalLoggerFactory
.
getLogger
(
LoggerName
.
BROKER_LOGGER_NAME
);
...
...
@@ -129,6 +129,7 @@ public class BrokerController {
private
final
BlockingQueue
<
Runnable
>
pullThreadPoolQueue
;
private
final
BlockingQueue
<
Runnable
>
queryThreadPoolQueue
;
private
final
BlockingQueue
<
Runnable
>
clientManagerThreadPoolQueue
;
private
final
BlockingQueue
<
Runnable
>
heartbeatThreadPoolQueue
;
private
final
BlockingQueue
<
Runnable
>
consumerManagerThreadPoolQueue
;
private
final
FilterServerManager
filterServerManager
;
private
final
BrokerStatsManager
brokerStatsManager
;
...
...
@@ -143,6 +144,7 @@ public class BrokerController {
private
ExecutorService
queryMessageExecutor
;
private
ExecutorService
adminBrokerExecutor
;
private
ExecutorService
clientManageExecutor
;
private
ExecutorService
heartbeatExecutor
;
private
ExecutorService
consumerManageExecutor
;
private
boolean
updateMasterHAServerAddrPeriodically
=
false
;
private
BrokerStats
brokerStats
;
...
...
@@ -186,6 +188,7 @@ public class BrokerController {
this
.
queryThreadPoolQueue
=
new
LinkedBlockingQueue
<
Runnable
>(
this
.
brokerConfig
.
getQueryThreadPoolQueueCapacity
());
this
.
clientManagerThreadPoolQueue
=
new
LinkedBlockingQueue
<
Runnable
>(
this
.
brokerConfig
.
getClientManagerThreadPoolQueueCapacity
());
this
.
consumerManagerThreadPoolQueue
=
new
LinkedBlockingQueue
<
Runnable
>(
this
.
brokerConfig
.
getConsumerManagerThreadPoolQueueCapacity
());
this
.
heartbeatThreadPoolQueue
=
new
LinkedBlockingQueue
<
Runnable
>(
this
.
brokerConfig
.
getHeartbeatThreadPoolQueueCapacity
());
this
.
brokerStatsManager
=
new
BrokerStatsManager
(
this
.
brokerConfig
.
getBrokerClusterName
());
this
.
setStoreHost
(
new
InetSocketAddress
(
this
.
getBrokerConfig
().
getBrokerIP1
(),
this
.
getNettyServerConfig
().
getListenPort
()));
...
...
@@ -280,6 +283,15 @@ public class BrokerController {
this
.
clientManagerThreadPoolQueue
,
new
ThreadFactoryImpl
(
"ClientManageThread_"
));
this
.
heartbeatExecutor
=
new
BrokerFixedThreadPoolExecutor
(
this
.
brokerConfig
.
getHeartbeatThreadPoolNums
(),
this
.
brokerConfig
.
getHeartbeatThreadPoolNums
(),
1000
*
60
,
TimeUnit
.
MILLISECONDS
,
this
.
heartbeatThreadPoolQueue
,
new
ThreadFactoryImpl
(
"HeartbeatThread_"
,
true
));
this
.
consumerManageExecutor
=
Executors
.
newFixedThreadPool
(
this
.
brokerConfig
.
getConsumerManageThreadPoolNums
(),
new
ThreadFactoryImpl
(
"ConsumerManageThread_"
));
...
...
@@ -501,11 +513,11 @@ public class BrokerController {
* ClientManageProcessor
*/
ClientManageProcessor
clientProcessor
=
new
ClientManageProcessor
(
this
);
this
.
remotingServer
.
registerProcessor
(
RequestCode
.
HEART_BEAT
,
clientProcessor
,
this
.
clientManage
Executor
);
this
.
remotingServer
.
registerProcessor
(
RequestCode
.
HEART_BEAT
,
clientProcessor
,
this
.
heartbeat
Executor
);
this
.
remotingServer
.
registerProcessor
(
RequestCode
.
UNREGISTER_CLIENT
,
clientProcessor
,
this
.
clientManageExecutor
);
this
.
remotingServer
.
registerProcessor
(
RequestCode
.
CHECK_CLIENT_CONFIG
,
clientProcessor
,
this
.
clientManageExecutor
);
this
.
fastRemotingServer
.
registerProcessor
(
RequestCode
.
HEART_BEAT
,
clientProcessor
,
this
.
clientManage
Executor
);
this
.
fastRemotingServer
.
registerProcessor
(
RequestCode
.
HEART_BEAT
,
clientProcessor
,
this
.
heartbeat
Executor
);
this
.
fastRemotingServer
.
registerProcessor
(
RequestCode
.
UNREGISTER_CLIENT
,
clientProcessor
,
this
.
clientManageExecutor
);
this
.
fastRemotingServer
.
registerProcessor
(
RequestCode
.
CHECK_CLIENT_CONFIG
,
clientProcessor
,
this
.
clientManageExecutor
);
...
...
@@ -729,10 +741,6 @@ public class BrokerController {
if
(
this
.
fileWatchService
!=
null
)
{
this
.
fileWatchService
.
shutdown
();
}
if
(
this
.
transactionalMessageCheckService
!=
null
)
{
this
.
transactionalMessageCheckService
.
shutdown
(
false
);
}
}
private
void
unregisterBrokerAll
()
{
...
...
@@ -990,6 +998,10 @@ public class BrokerController {
return
this
.
configuration
;
}
public
BlockingQueue
<
Runnable
>
getHeartbeatThreadPoolQueue
()
{
return
heartbeatThreadPoolQueue
;
}
public
TransactionalMessageCheckService
getTransactionalMessageCheckService
()
{
return
transactionalMessageCheckService
;
}
...
...
broker/src/main/java/org/apache/rocketmq/broker/latency/BrokerFastFailure.java
浏览文件 @
d8c446e8
...
...
@@ -89,6 +89,9 @@ public class BrokerFastFailure {
cleanExpiredRequestInQueue
(
this
.
brokerController
.
getPullThreadPoolQueue
(),
this
.
brokerController
.
getBrokerConfig
().
getWaitTimeMillsInPullQueue
());
cleanExpiredRequestInQueue
(
this
.
brokerController
.
getHeartbeatThreadPoolQueue
(),
this
.
brokerController
.
getBrokerConfig
().
getWaitTimeMillsInHeartbeatQueue
());
}
void
cleanExpiredRequestInQueue
(
final
BlockingQueue
<
Runnable
>
blockingQueue
,
final
long
maxWaitTimeMillsInQueue
)
{
...
...
common/src/main/java/org/apache/rocketmq/common/BrokerConfig.java
浏览文件 @
d8c446e8
...
...
@@ -63,6 +63,7 @@ public class BrokerConfig {
private
int
adminBrokerThreadPoolNums
=
16
;
private
int
clientManageThreadPoolNums
=
32
;
private
int
consumerManageThreadPoolNums
=
32
;
private
int
heartbeatThreadPoolNums
=
Math
.
min
(
32
,
Runtime
.
getRuntime
().
availableProcessors
());
private
int
flushConsumerOffsetInterval
=
1000
*
5
;
...
...
@@ -77,6 +78,7 @@ public class BrokerConfig {
private
int
queryThreadPoolQueueCapacity
=
20000
;
private
int
clientManagerThreadPoolQueueCapacity
=
1000000
;
private
int
consumerManagerThreadPoolQueueCapacity
=
1000000
;
private
int
heartbeatThreadPoolQueueCapacity
=
50000
;
private
int
filterServerNums
=
0
;
...
...
@@ -108,6 +110,7 @@ public class BrokerConfig {
private
boolean
brokerFastFailureEnable
=
true
;
private
long
waitTimeMillsInSendQueue
=
200
;
private
long
waitTimeMillsInPullQueue
=
5
*
1000
;
private
long
waitTimeMillsInHeartbeatQueue
=
31
*
1000
;
private
long
startAcceptSendRequestTimeStamp
=
0L
;
...
...
@@ -643,6 +646,30 @@ public class BrokerConfig {
this
.
forceRegister
=
forceRegister
;
}
public
int
getHeartbeatThreadPoolQueueCapacity
()
{
return
heartbeatThreadPoolQueueCapacity
;
}
public
void
setHeartbeatThreadPoolQueueCapacity
(
int
heartbeatThreadPoolQueueCapacity
)
{
this
.
heartbeatThreadPoolQueueCapacity
=
heartbeatThreadPoolQueueCapacity
;
}
public
int
getHeartbeatThreadPoolNums
()
{
return
heartbeatThreadPoolNums
;
}
public
void
setHeartbeatThreadPoolNums
(
int
heartbeatThreadPoolNums
)
{
this
.
heartbeatThreadPoolNums
=
heartbeatThreadPoolNums
;
}
public
long
getWaitTimeMillsInHeartbeatQueue
()
{
return
waitTimeMillsInHeartbeatQueue
;
}
public
void
setWaitTimeMillsInHeartbeatQueue
(
long
waitTimeMillsInHeartbeatQueue
)
{
this
.
waitTimeMillsInHeartbeatQueue
=
waitTimeMillsInHeartbeatQueue
;
}
public
int
getRegisterNameServerPeriod
()
{
return
registerNameServerPeriod
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录