Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Apache RocketMQ
Rocketmq
提交
9c8fa5e1
R
Rocketmq
项目概览
Apache RocketMQ
/
Rocketmq
上一次同步 大约 3 年
通知
269
Star
16139
Fork
68
代码
文件
提交
分支
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看板
提交
9c8fa5e1
编写于
12月 05, 2018
作者:
D
dongeforever
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Catch service thread exception of scheduledMessage and transactionalMessage when changing role
上级
30028a11
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
26 addition
and
28 deletion
+26
-28
broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java
...ain/java/org/apache/rocketmq/broker/BrokerController.java
+20
-4
broker/src/main/java/org/apache/rocketmq/broker/dledger/DLedgerRoleChangeHandler.java
...che/rocketmq/broker/dledger/DLedgerRoleChangeHandler.java
+5
-2
broker/src/main/java/org/apache/rocketmq/broker/out/BrokerOuterAPI.java
...n/java/org/apache/rocketmq/broker/out/BrokerOuterAPI.java
+1
-1
broker/src/main/java/org/apache/rocketmq/broker/transaction/TransactionalMessageCheckService.java
.../broker/transaction/TransactionalMessageCheckService.java
+0
-21
未找到文件。
broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java
浏览文件 @
9c8fa5e1
...
...
@@ -1067,10 +1067,18 @@ public class BrokerController {
messageStoreConfig
.
setBrokerRole
(
BrokerRole
.
SLAVE
);
//handle the scheduled service
this
.
messageStore
.
handleScheduleMessageService
(
BrokerRole
.
SLAVE
);
try
{
this
.
messageStore
.
handleScheduleMessageService
(
BrokerRole
.
SLAVE
);
}
catch
(
Throwable
t
)
{
log
.
error
(
"[MONITOR] handleScheduleMessageService failed when changing to slave"
,
t
);
}
//handle the transactional service
this
.
shutdownProcessorByHa
();
try
{
this
.
shutdownProcessorByHa
();
}
catch
(
Throwable
t
)
{
log
.
error
(
"[MONITOR] shutdownProcessorByHa failed when changing to slave"
,
t
);
}
//handle the slave synchronise
handleSlaveSynchronize
(
BrokerRole
.
SLAVE
);
...
...
@@ -1095,10 +1103,18 @@ public class BrokerController {
handleSlaveSynchronize
(
role
);
//handle the scheduled service
this
.
messageStore
.
handleScheduleMessageService
(
role
);
try
{
this
.
messageStore
.
handleScheduleMessageService
(
role
);
}
catch
(
Throwable
t
)
{
log
.
error
(
"[MONITOR] handleScheduleMessageService failed when changing to master"
,
t
);
}
//handle the transactional service
this
.
startProcessorByHa
(
BrokerRole
.
SYNC_MASTER
);
try
{
this
.
startProcessorByHa
(
BrokerRole
.
SYNC_MASTER
);
}
catch
(
Throwable
t
)
{
log
.
error
(
"[MONITOR] startProcessorByHa failed when changing to master"
,
t
);
}
//if the operations above are totally successful, we change to master
brokerConfig
.
setBrokerId
(
0
);
//TO DO check
...
...
broker/src/main/java/org/apache/rocketmq/broker/dledger/DLedgerRoleChangeHandler.java
浏览文件 @
9c8fa5e1
...
...
@@ -51,33 +51,36 @@ public class DLedgerRoleChangeHandler implements DLedgerLeaderElector.RoleChange
@Override
public
void
run
()
{
long
start
=
System
.
currentTimeMillis
();
try
{
boolean
succ
=
false
;
log
.
info
(
"Begin handling broker role change term={} role={} currStoreRole={}"
,
term
,
role
,
messageStore
.
getMessageStoreConfig
().
getBrokerRole
());
switch
(
role
)
{
case
CANDIDATE:
if
(
messageStore
.
getMessageStoreConfig
().
getBrokerRole
()
!=
BrokerRole
.
SLAVE
)
{
brokerController
.
changeToSlave
(
dLedgerCommitLog
.
getId
());
}
succ
=
true
;
break
;
case
FOLLOWER:
brokerController
.
changeToSlave
(
dLedgerCommitLog
.
getId
());
succ
=
true
;
break
;
case
LEADER:
while
(
dLegerServer
.
getMemberState
().
isLeader
()
&&
(
dLegerServer
.
getdLedgerStore
().
getLedgerEndIndex
()
!=
dLegerServer
.
getdLedgerStore
().
getCommittedIndex
()
||
messageStore
.
dispatchBehindBytes
()
!=
0
))
{
UtilAll
.
sleep
(
100
);
}
boolean
succ
=
dLegerServer
.
getMemberState
().
isLeader
()
succ
=
dLegerServer
.
getMemberState
().
isLeader
()
&&
dLegerServer
.
getdLedgerStore
().
getLedgerEndIndex
()
==
dLegerServer
.
getdLedgerStore
().
getCommittedIndex
()
&&
messageStore
.
dispatchBehindBytes
()
==
0
;
if
(
succ
)
{
messageStore
.
recoverTopicQueueTable
();
brokerController
.
changeToMaster
(
BrokerRole
.
SYNC_MASTER
);
}
log
.
info
(
"Finish handling broker role change succ={} term={} role={} currStoreRole={} cost={}"
,
succ
,
term
,
role
,
messageStore
.
getMessageStoreConfig
().
getBrokerRole
(),
UtilAll
.
elapsed
(
start
));
break
;
default
:
break
;
}
log
.
info
(
"Finish handling broker role change succ={} term={} role={} currStoreRole={} cost={}"
,
succ
,
term
,
role
,
messageStore
.
getMessageStoreConfig
().
getBrokerRole
(),
UtilAll
.
elapsed
(
start
));
}
catch
(
Throwable
t
)
{
log
.
info
(
"[MONITOR]Failed handling broker role change term={} role={} currStoreRole={} cost={}"
,
term
,
role
,
messageStore
.
getMessageStoreConfig
().
getBrokerRole
(),
UtilAll
.
elapsed
(
start
),
t
);
}
...
...
broker/src/main/java/org/apache/rocketmq/broker/out/BrokerOuterAPI.java
浏览文件 @
9c8fa5e1
...
...
@@ -152,7 +152,7 @@ public class BrokerOuterAPI {
registerBrokerResultList
.
add
(
result
);
}
log
.
info
(
"register broker
to name server {} OK"
,
namesrvAddr
);
log
.
info
(
"register broker
[{}]to name server {} OK"
,
brokerId
,
namesrvAddr
);
}
catch
(
Exception
e
)
{
log
.
warn
(
"registerBroker Exception, {}"
,
namesrvAddr
,
e
);
}
finally
{
...
...
broker/src/main/java/org/apache/rocketmq/broker/transaction/TransactionalMessageCheckService.java
浏览文件 @
9c8fa5e1
...
...
@@ -29,31 +29,10 @@ public class TransactionalMessageCheckService extends ServiceThread {
private
BrokerController
brokerController
;
private
final
AtomicBoolean
started
=
new
AtomicBoolean
(
false
);
public
TransactionalMessageCheckService
(
BrokerController
brokerController
)
{
this
.
brokerController
=
brokerController
;
}
@Override
public
void
start
()
{
if
(
started
.
compareAndSet
(
false
,
true
))
{
super
.
start
();
//no need to do this
//this.brokerController.getTransactionalMessageService().open();
}
}
@Override
public
void
shutdown
(
boolean
interrupt
)
{
if
(
started
.
compareAndSet
(
true
,
false
))
{
super
.
shutdown
(
interrupt
);
//no need to do this
//this.brokerController.getTransactionalMessageService().close();
//this.brokerController.getTransactionalMessageCheckListener().shutDown();
}
}
@Override
public
String
getServiceName
()
{
return
TransactionalMessageCheckService
.
class
.
getSimpleName
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录