Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Apache RocketMQ
Rocketmq
提交
5f730028
R
Rocketmq
项目概览
Apache RocketMQ
/
Rocketmq
上一次同步 大约 3 年
通知
268
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看板
提交
5f730028
编写于
11月 06, 2018
作者:
D
dongeforever
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add role change handler for broker controller
上级
515bc353
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
190 addition
and
60 deletion
+190
-60
broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java
...ain/java/org/apache/rocketmq/broker/BrokerController.java
+102
-39
broker/src/main/java/org/apache/rocketmq/broker/dleger/DLegerRoleChangeHandler.java
...pache/rocketmq/broker/dleger/DLegerRoleChangeHandler.java
+49
-0
broker/src/main/java/org/apache/rocketmq/broker/slave/SlaveSynchronize.java
...va/org/apache/rocketmq/broker/slave/SlaveSynchronize.java
+4
-4
store/src/main/java/org/apache/rocketmq/store/DefaultMessageStore.java
...n/java/org/apache/rocketmq/store/DefaultMessageStore.java
+22
-8
store/src/main/java/org/apache/rocketmq/store/MessageStore.java
...src/main/java/org/apache/rocketmq/store/MessageStore.java
+7
-0
store/src/main/java/org/apache/rocketmq/store/dleger/DLegerCommitLog.java
...ava/org/apache/rocketmq/store/dleger/DLegerCommitLog.java
+4
-0
store/src/test/java/org/apache/rocketmq/store/dleger/DLegerCommitlogTest.java
...org/apache/rocketmq/store/dleger/DLegerCommitlogTest.java
+1
-0
test/src/test/java/org/apache/rocketmq/test/base/IntegrationTestBase.java
...va/org/apache/rocketmq/test/base/IntegrationTestBase.java
+1
-9
未找到文件。
broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java
浏览文件 @
5f730028
...
@@ -27,6 +27,7 @@ import java.util.concurrent.ConcurrentHashMap;
...
@@ -27,6 +27,7 @@ import java.util.concurrent.ConcurrentHashMap;
import
java.util.concurrent.ConcurrentMap
;
import
java.util.concurrent.ConcurrentMap
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.Future
;
import
java.util.concurrent.LinkedBlockingQueue
;
import
java.util.concurrent.LinkedBlockingQueue
;
import
java.util.concurrent.ScheduledExecutorService
;
import
java.util.concurrent.ScheduledExecutorService
;
import
java.util.concurrent.ThreadPoolExecutor
;
import
java.util.concurrent.ThreadPoolExecutor
;
...
@@ -38,6 +39,7 @@ import org.apache.rocketmq.broker.client.DefaultConsumerIdsChangeListener;
...
@@ -38,6 +39,7 @@ import org.apache.rocketmq.broker.client.DefaultConsumerIdsChangeListener;
import
org.apache.rocketmq.broker.client.ProducerManager
;
import
org.apache.rocketmq.broker.client.ProducerManager
;
import
org.apache.rocketmq.broker.client.net.Broker2Client
;
import
org.apache.rocketmq.broker.client.net.Broker2Client
;
import
org.apache.rocketmq.broker.client.rebalance.RebalanceLockManager
;
import
org.apache.rocketmq.broker.client.rebalance.RebalanceLockManager
;
import
org.apache.rocketmq.broker.dleger.DLegerRoleChangeHandler
;
import
org.apache.rocketmq.broker.filter.CommitLogDispatcherCalcBitMap
;
import
org.apache.rocketmq.broker.filter.CommitLogDispatcherCalcBitMap
;
import
org.apache.rocketmq.broker.filter.ConsumerFilterManager
;
import
org.apache.rocketmq.broker.filter.ConsumerFilterManager
;
import
org.apache.rocketmq.broker.filtersrv.FilterServerManager
;
import
org.apache.rocketmq.broker.filtersrv.FilterServerManager
;
...
@@ -97,6 +99,7 @@ import org.apache.rocketmq.store.MessageArrivingListener;
...
@@ -97,6 +99,7 @@ import org.apache.rocketmq.store.MessageArrivingListener;
import
org.apache.rocketmq.store.MessageStore
;
import
org.apache.rocketmq.store.MessageStore
;
import
org.apache.rocketmq.store.config.BrokerRole
;
import
org.apache.rocketmq.store.config.BrokerRole
;
import
org.apache.rocketmq.store.config.MessageStoreConfig
;
import
org.apache.rocketmq.store.config.MessageStoreConfig
;
import
org.apache.rocketmq.store.dleger.DLegerCommitLog
;
import
org.apache.rocketmq.store.stats.BrokerStats
;
import
org.apache.rocketmq.store.stats.BrokerStats
;
import
org.apache.rocketmq.store.stats.BrokerStatsManager
;
import
org.apache.rocketmq.store.stats.BrokerStatsManager
;
...
@@ -156,6 +159,7 @@ public class BrokerController {
...
@@ -156,6 +159,7 @@ public class BrokerController {
private
TransactionalMessageCheckService
transactionalMessageCheckService
;
private
TransactionalMessageCheckService
transactionalMessageCheckService
;
private
TransactionalMessageService
transactionalMessageService
;
private
TransactionalMessageService
transactionalMessageService
;
private
AbstractTransactionalMessageCheckListener
transactionalMessageCheckListener
;
private
AbstractTransactionalMessageCheckListener
transactionalMessageCheckListener
;
private
Future
<?>
slaveSyncFuture
;
public
BrokerController
(
public
BrokerController
(
final
BrokerConfig
brokerConfig
,
final
BrokerConfig
brokerConfig
,
...
@@ -231,6 +235,10 @@ public class BrokerController {
...
@@ -231,6 +235,10 @@ public class BrokerController {
this
.
messageStore
=
this
.
messageStore
=
new
DefaultMessageStore
(
this
.
messageStoreConfig
,
this
.
brokerStatsManager
,
this
.
messageArrivingListener
,
new
DefaultMessageStore
(
this
.
messageStoreConfig
,
this
.
brokerStatsManager
,
this
.
messageArrivingListener
,
this
.
brokerConfig
);
this
.
brokerConfig
);
if
(
messageStoreConfig
.
isEnableDLegerCommitLog
())
{
DLegerRoleChangeHandler
roleChangeHandler
=
new
DLegerRoleChangeHandler
(
this
,
(
DefaultMessageStore
)
messageStore
);
((
DLegerCommitLog
)((
DefaultMessageStore
)
messageStore
).
getCommitLog
()).
getdLegerServer
().
getdLegerLeaderElector
().
addRoleChangeHandler
(
roleChangeHandler
);
}
this
.
brokerStats
=
new
BrokerStats
((
DefaultMessageStore
)
this
.
messageStore
);
this
.
brokerStats
=
new
BrokerStats
((
DefaultMessageStore
)
this
.
messageStore
);
//load plugin
//load plugin
MessageStorePluginContext
context
=
new
MessageStorePluginContext
(
messageStoreConfig
,
brokerStatsManager
,
messageArrivingListener
,
brokerConfig
);
MessageStorePluginContext
context
=
new
MessageStorePluginContext
(
messageStoreConfig
,
brokerStatsManager
,
messageArrivingListener
,
brokerConfig
);
...
@@ -392,40 +400,6 @@ public class BrokerController {
...
@@ -392,40 +400,6 @@ public class BrokerController {
}
}
},
1000
*
10
,
1000
*
60
*
2
,
TimeUnit
.
MILLISECONDS
);
},
1000
*
10
,
1000
*
60
*
2
,
TimeUnit
.
MILLISECONDS
);
}
}
if
(
BrokerRole
.
SLAVE
==
this
.
messageStoreConfig
.
getBrokerRole
())
{
if
(
this
.
messageStoreConfig
.
getHaMasterAddress
()
!=
null
&&
this
.
messageStoreConfig
.
getHaMasterAddress
().
length
()
>=
6
)
{
this
.
messageStore
.
updateHaMasterAddress
(
this
.
messageStoreConfig
.
getHaMasterAddress
());
this
.
updateMasterHAServerAddrPeriodically
=
false
;
}
else
{
this
.
updateMasterHAServerAddrPeriodically
=
true
;
}
this
.
scheduledExecutorService
.
scheduleAtFixedRate
(
new
Runnable
()
{
@Override
public
void
run
()
{
try
{
BrokerController
.
this
.
slaveSynchronize
.
syncAll
();
}
catch
(
Throwable
e
)
{
log
.
error
(
"ScheduledTask syncAll slave exception"
,
e
);
}
}
},
1000
*
10
,
1000
*
60
,
TimeUnit
.
MILLISECONDS
);
}
else
{
this
.
scheduledExecutorService
.
scheduleAtFixedRate
(
new
Runnable
()
{
@Override
public
void
run
()
{
try
{
BrokerController
.
this
.
printMasterAndSlaveDiff
();
}
catch
(
Throwable
e
)
{
log
.
error
(
"schedule printMasterAndSlaveDiff error."
,
e
);
}
}
},
1000
*
10
,
1000
*
60
,
TimeUnit
.
MILLISECONDS
);
}
if
(
TlsSystemConfig
.
tlsMode
!=
TlsMode
.
DISABLED
)
{
if
(
TlsSystemConfig
.
tlsMode
!=
TlsMode
.
DISABLED
)
{
// Register a listener to reload SslContext
// Register a listener to reload SslContext
try
{
try
{
...
@@ -831,11 +805,9 @@ public class BrokerController {
...
@@ -831,11 +805,9 @@ public class BrokerController {
this
.
brokerFastFailure
.
start
();
this
.
brokerFastFailure
.
start
();
}
}
if
(
BrokerRole
.
SLAVE
!=
messageStoreConfig
.
getBrokerRole
())
{
if
(!
messageStoreConfig
.
isEnableDLegerCommitLog
())
{
if
(
this
.
transactionalMessageCheckService
!=
null
)
{
startProcessorByHa
();
log
.
info
(
"Start transaction service!"
);
handleSlaveSynchronize
(
messageStoreConfig
.
getBrokerRole
());
this
.
transactionalMessageCheckService
.
start
();
}
}
}
}
}
...
@@ -1052,4 +1024,95 @@ public class BrokerController {
...
@@ -1052,4 +1024,95 @@ public class BrokerController {
public
BlockingQueue
<
Runnable
>
getEndTransactionThreadPoolQueue
()
{
public
BlockingQueue
<
Runnable
>
getEndTransactionThreadPoolQueue
()
{
return
endTransactionThreadPoolQueue
;
return
endTransactionThreadPoolQueue
;
}
}
private
void
handleSlaveSynchronize
(
BrokerRole
role
)
{
if
(
role
==
BrokerRole
.
SLAVE
)
{
if
(
null
!=
slaveSyncFuture
){
slaveSyncFuture
.
cancel
(
false
);
}
this
.
slaveSynchronize
.
setMasterAddr
(
null
);
slaveSyncFuture
=
this
.
scheduledExecutorService
.
scheduleAtFixedRate
(
new
Runnable
()
{
@Override
public
void
run
()
{
try
{
BrokerController
.
this
.
slaveSynchronize
.
syncAll
();
}
catch
(
Throwable
e
)
{
log
.
error
(
"ScheduledTask SlaveSynchronize syncAll error."
,
e
);
}
}
},
1000
*
10
,
1000
*
60
,
TimeUnit
.
MILLISECONDS
);
}
else
{
//handle the slave synchronise
if
(
null
!=
slaveSyncFuture
){
slaveSyncFuture
.
cancel
(
false
);
}
this
.
slaveSynchronize
.
setMasterAddr
(
null
);
}
}
public
void
changeToSlave
()
{
//change the role
brokerConfig
.
setBrokerId
(
1
);
//TO DO check
messageStoreConfig
.
setBrokerRole
(
BrokerRole
.
SLAVE
);
//handle the scheduled service
this
.
messageStore
.
handleScheduleMessageService
(
BrokerRole
.
SLAVE
);
//handle the transactional service
this
.
shutdownProcessorByHa
();
//handle the slave synchronise
handleSlaveSynchronize
(
BrokerRole
.
SLAVE
);
try
{
this
.
registerBrokerAll
(
true
,
true
,
brokerConfig
.
isForceRegister
());
}
catch
(
Throwable
ignored
)
{
}
}
public
void
changeToMaster
(
BrokerRole
role
)
{
if
(
role
==
BrokerRole
.
SLAVE
)
{
return
;
}
//handle the slave synchronise
handleSlaveSynchronize
(
role
);
//change the role
brokerConfig
.
setBrokerId
(
0
);
//TO DO check
messageStoreConfig
.
setBrokerRole
(
role
);
//handle the scheduled service
this
.
messageStore
.
handleScheduleMessageService
(
role
);
//handle the transactional service
this
.
startProcessorByHa
();
try
{
this
.
registerBrokerAll
(
true
,
true
,
brokerConfig
.
isForceRegister
());
}
catch
(
Throwable
ignored
)
{
}
}
private
void
startProcessorByHa
()
{
if
(
BrokerRole
.
SLAVE
!=
messageStoreConfig
.
getBrokerRole
())
{
if
(
this
.
transactionalMessageCheckService
!=
null
)
{
this
.
transactionalMessageCheckService
.
start
();
}
}
}
private
void
shutdownProcessorByHa
()
{
if
(
this
.
transactionalMessageCheckService
!=
null
)
{
this
.
transactionalMessageCheckService
.
shutdown
(
true
);
}
}
}
}
broker/src/main/java/org/apache/rocketmq/broker/dleger/DLegerRoleChangeHandler.java
0 → 100644
浏览文件 @
5f730028
package
org.apache.rocketmq.broker.dleger
;
import
org.apache.rocketmq.broker.BrokerController
;
import
org.apache.rocketmq.common.constant.LoggerName
;
import
org.apache.rocketmq.dleger.DLegerLeaderElector
;
import
org.apache.rocketmq.dleger.MemberState
;
import
org.apache.rocketmq.logging.InternalLogger
;
import
org.apache.rocketmq.logging.InternalLoggerFactory
;
import
org.apache.rocketmq.store.DefaultMessageStore
;
import
org.apache.rocketmq.store.config.BrokerRole
;
public
class
DLegerRoleChangeHandler
implements
DLegerLeaderElector
.
RoleChangeHandler
{
private
static
final
InternalLogger
log
=
InternalLoggerFactory
.
getLogger
(
LoggerName
.
BROKER_LOGGER_NAME
);
private
BrokerController
brokerController
;
private
DefaultMessageStore
messageStore
;
public
DLegerRoleChangeHandler
(
BrokerController
brokerController
,
DefaultMessageStore
messageStore
)
{
this
.
brokerController
=
brokerController
;
this
.
messageStore
=
messageStore
;
}
@Override
public
void
handle
(
long
term
,
MemberState
.
Role
role
)
{
try
{
log
.
info
(
"Begin handling lastRole change term={} lastRole={} currStoreRole={}"
,
term
,
role
,
messageStore
.
getMessageStoreConfig
().
getBrokerRole
());
switch
(
role
)
{
case
CANDIDATE:
if
(
messageStore
.
getMessageStoreConfig
().
getBrokerRole
()
!=
BrokerRole
.
SLAVE
)
{
brokerController
.
changeToSlave
();
}
break
;
case
FOLLOWER:
brokerController
.
changeToSlave
();
break
;
case
LEADER:
while
(
messageStore
.
dispatchBehindBytes
()
!=
0
)
{
Thread
.
sleep
(
100
);
}
messageStore
.
recoverTopicQueueTable
();
brokerController
.
changeToMaster
(
BrokerRole
.
SYNC_MASTER
);
break
;
default
:
break
;
}
log
.
info
(
"Finish handling lastRole change term={} lastRole={} currStoreRole={}"
,
term
,
role
,
messageStore
.
getMessageStoreConfig
().
getBrokerRole
());
}
catch
(
Throwable
t
)
{
log
.
info
(
"Failed handling lastRole change term={} lastRole={} currStoreRole={}"
,
term
,
role
,
messageStore
.
getMessageStoreConfig
().
getBrokerRole
(),
t
);
}
}
}
broker/src/main/java/org/apache/rocketmq/broker/slave/SlaveSynchronize.java
浏览文件 @
5f730028
...
@@ -54,7 +54,7 @@ public class SlaveSynchronize {
...
@@ -54,7 +54,7 @@ public class SlaveSynchronize {
private
void
syncTopicConfig
()
{
private
void
syncTopicConfig
()
{
String
masterAddrBak
=
this
.
masterAddr
;
String
masterAddrBak
=
this
.
masterAddr
;
if
(
masterAddrBak
!=
null
)
{
if
(
masterAddrBak
!=
null
&&
!
masterAddrBak
.
equals
(
brokerController
.
getBrokerAddr
())
)
{
try
{
try
{
TopicConfigSerializeWrapper
topicWrapper
=
TopicConfigSerializeWrapper
topicWrapper
=
this
.
brokerController
.
getBrokerOuterAPI
().
getAllTopicConfig
(
masterAddrBak
);
this
.
brokerController
.
getBrokerOuterAPI
().
getAllTopicConfig
(
masterAddrBak
);
...
@@ -78,7 +78,7 @@ public class SlaveSynchronize {
...
@@ -78,7 +78,7 @@ public class SlaveSynchronize {
private
void
syncConsumerOffset
()
{
private
void
syncConsumerOffset
()
{
String
masterAddrBak
=
this
.
masterAddr
;
String
masterAddrBak
=
this
.
masterAddr
;
if
(
masterAddrBak
!=
null
)
{
if
(
masterAddrBak
!=
null
&&
!
masterAddrBak
.
equals
(
brokerController
.
getBrokerAddr
())
)
{
try
{
try
{
ConsumerOffsetSerializeWrapper
offsetWrapper
=
ConsumerOffsetSerializeWrapper
offsetWrapper
=
this
.
brokerController
.
getBrokerOuterAPI
().
getAllConsumerOffset
(
masterAddrBak
);
this
.
brokerController
.
getBrokerOuterAPI
().
getAllConsumerOffset
(
masterAddrBak
);
...
@@ -94,7 +94,7 @@ public class SlaveSynchronize {
...
@@ -94,7 +94,7 @@ public class SlaveSynchronize {
private
void
syncDelayOffset
()
{
private
void
syncDelayOffset
()
{
String
masterAddrBak
=
this
.
masterAddr
;
String
masterAddrBak
=
this
.
masterAddr
;
if
(
masterAddrBak
!=
null
)
{
if
(
masterAddrBak
!=
null
&&
!
masterAddrBak
.
equals
(
brokerController
.
getBrokerAddr
())
)
{
try
{
try
{
String
delayOffset
=
String
delayOffset
=
this
.
brokerController
.
getBrokerOuterAPI
().
getAllDelayOffset
(
masterAddrBak
);
this
.
brokerController
.
getBrokerOuterAPI
().
getAllDelayOffset
(
masterAddrBak
);
...
@@ -118,7 +118,7 @@ public class SlaveSynchronize {
...
@@ -118,7 +118,7 @@ public class SlaveSynchronize {
private
void
syncSubscriptionGroupConfig
()
{
private
void
syncSubscriptionGroupConfig
()
{
String
masterAddrBak
=
this
.
masterAddr
;
String
masterAddrBak
=
this
.
masterAddr
;
if
(
masterAddrBak
!=
null
)
{
if
(
masterAddrBak
!=
null
&&
!
masterAddrBak
.
equals
(
brokerController
.
getBrokerAddr
())
)
{
try
{
try
{
SubscriptionGroupWrapper
subscriptionWrapper
=
SubscriptionGroupWrapper
subscriptionWrapper
=
this
.
brokerController
.
getBrokerOuterAPI
()
this
.
brokerController
.
getBrokerOuterAPI
()
...
...
store/src/main/java/org/apache/rocketmq/store/DefaultMessageStore.java
浏览文件 @
5f730028
...
@@ -226,10 +226,6 @@ public class DefaultMessageStore implements MessageStore {
...
@@ -226,10 +226,6 @@ public class DefaultMessageStore implements MessageStore {
this
.
commitLog
.
start
();
this
.
commitLog
.
start
();
this
.
storeStatsService
.
start
();
this
.
storeStatsService
.
start
();
if
(
this
.
scheduleMessageService
!=
null
&&
SLAVE
!=
messageStoreConfig
.
getBrokerRole
())
{
this
.
scheduleMessageService
.
start
();
}
if
(
this
.
getMessageStoreConfig
().
isDuplicationEnable
())
{
if
(
this
.
getMessageStoreConfig
().
isDuplicationEnable
())
{
this
.
reputMessageService
.
setReputFromOffset
(
this
.
commitLog
.
getConfirmOffset
());
this
.
reputMessageService
.
setReputFromOffset
(
this
.
commitLog
.
getConfirmOffset
());
}
else
{
}
else
{
...
@@ -237,13 +233,18 @@ public class DefaultMessageStore implements MessageStore {
...
@@ -237,13 +233,18 @@ public class DefaultMessageStore implements MessageStore {
}
}
this
.
reputMessageService
.
start
();
this
.
reputMessageService
.
start
();
this
.
haService
.
start
();
if
(!
messageStoreConfig
.
isEnableDLegerCommitLog
())
{
this
.
haService
.
start
();
this
.
handleScheduleMessageService
(
messageStoreConfig
.
getBrokerRole
());
}
this
.
createTempFile
();
this
.
createTempFile
();
this
.
addScheduleTask
();
this
.
addScheduleTask
();
this
.
shutdown
=
false
;
this
.
shutdown
=
false
;
}
}
public
void
shutdown
()
{
public
void
shutdown
()
{
if
(!
this
.
shutdown
)
{
if
(!
this
.
shutdown
)
{
this
.
shutdown
=
true
;
this
.
shutdown
=
true
;
...
@@ -260,8 +261,9 @@ public class DefaultMessageStore implements MessageStore {
...
@@ -260,8 +261,9 @@ public class DefaultMessageStore implements MessageStore {
if
(
this
.
scheduleMessageService
!=
null
)
{
if
(
this
.
scheduleMessageService
!=
null
)
{
this
.
scheduleMessageService
.
shutdown
();
this
.
scheduleMessageService
.
shutdown
();
}
}
if
(
this
.
haService
!=
null
)
{
this
.
haService
.
shutdown
();
this
.
haService
.
shutdown
();
}
this
.
storeStatsService
.
shutdown
();
this
.
storeStatsService
.
shutdown
();
this
.
indexService
.
shutdown
();
this
.
indexService
.
shutdown
();
...
@@ -1325,7 +1327,7 @@ public class DefaultMessageStore implements MessageStore {
...
@@ -1325,7 +1327,7 @@ public class DefaultMessageStore implements MessageStore {
return
maxPhysicOffset
;
return
maxPhysicOffset
;
}
}
p
rivate
void
recoverTopicQueueTable
()
{
p
ublic
void
recoverTopicQueueTable
()
{
HashMap
<
String
/* topic-queueid */
,
Long
/* offset */
>
table
=
new
HashMap
<
String
,
Long
>(
1024
);
HashMap
<
String
/* topic-queueid */
,
Long
/* offset */
>
table
=
new
HashMap
<
String
,
Long
>(
1024
);
long
minPhyOffset
=
this
.
commitLog
.
getMinOffset
();
long
minPhyOffset
=
this
.
commitLog
.
getMinOffset
();
for
(
ConcurrentMap
<
Integer
,
ConsumeQueue
>
maps
:
this
.
consumeQueueTable
.
values
())
{
for
(
ConcurrentMap
<
Integer
,
ConsumeQueue
>
maps
:
this
.
consumeQueueTable
.
values
())
{
...
@@ -1387,6 +1389,18 @@ public class DefaultMessageStore implements MessageStore {
...
@@ -1387,6 +1389,18 @@ public class DefaultMessageStore implements MessageStore {
return
brokerStatsManager
;
return
brokerStatsManager
;
}
}
@Override
public
void
handleScheduleMessageService
(
final
BrokerRole
brokerRole
)
{
if
(
this
.
scheduleMessageService
!=
null
)
{
if
(
brokerRole
==
BrokerRole
.
SLAVE
)
{
this
.
scheduleMessageService
.
shutdown
();
}
else
{
this
.
scheduleMessageService
.
start
();
}
}
}
public
int
remainTransientStoreBufferNumbs
()
{
public
int
remainTransientStoreBufferNumbs
()
{
return
this
.
transientStorePool
.
remainBufferNumbs
();
return
this
.
transientStorePool
.
remainBufferNumbs
();
}
}
...
...
store/src/main/java/org/apache/rocketmq/store/MessageStore.java
浏览文件 @
5f730028
...
@@ -21,6 +21,7 @@ import java.util.LinkedList;
...
@@ -21,6 +21,7 @@ import java.util.LinkedList;
import
java.util.Set
;
import
java.util.Set
;
import
org.apache.rocketmq.common.message.MessageExt
;
import
org.apache.rocketmq.common.message.MessageExt
;
import
org.apache.rocketmq.common.message.MessageExtBatch
;
import
org.apache.rocketmq.common.message.MessageExtBatch
;
import
org.apache.rocketmq.store.config.BrokerRole
;
import
org.apache.rocketmq.store.stats.BrokerStatsManager
;
import
org.apache.rocketmq.store.stats.BrokerStatsManager
;
/**
/**
...
@@ -366,4 +367,10 @@ public interface MessageStore {
...
@@ -366,4 +367,10 @@ public interface MessageStore {
* @return BrokerStatsManager.
* @return BrokerStatsManager.
*/
*/
BrokerStatsManager
getBrokerStatsManager
();
BrokerStatsManager
getBrokerStatsManager
();
/**
* handle
* @param brokerRole
*/
void
handleScheduleMessageService
(
BrokerRole
brokerRole
);
}
}
store/src/main/java/org/apache/rocketmq/store/dleger/DLegerCommitLog.java
浏览文件 @
5f730028
...
@@ -626,4 +626,8 @@ public class DLegerCommitLog extends CommitLog {
...
@@ -626,4 +626,8 @@ public class DLegerCommitLog extends CommitLog {
}
}
}
}
public
DLegerServer
getdLegerServer
()
{
return
dLegerServer
;
}
}
}
store/src/test/java/org/apache/rocketmq/store/dleger/DLegerCommitlogTest.java
浏览文件 @
5f730028
...
@@ -87,6 +87,7 @@ public class DLegerCommitlogTest extends StoreTestBase {
...
@@ -87,6 +87,7 @@ public class DLegerCommitlogTest extends StoreTestBase {
Assert
.
assertEquals
(
results
.
get
(
i
).
getAppendMessageResult
().
getMsgId
(),
messageExt
.
getMsgId
());
Assert
.
assertEquals
(
results
.
get
(
i
).
getAppendMessageResult
().
getMsgId
(),
messageExt
.
getMsgId
());
Assert
.
assertEquals
(
results
.
get
(
i
).
getAppendMessageResult
().
getWroteOffset
(),
messageExt
.
getCommitLogOffset
());
Assert
.
assertEquals
(
results
.
get
(
i
).
getAppendMessageResult
().
getWroteOffset
(),
messageExt
.
getCommitLogOffset
());
}
}
messageStore
.
destroy
();
}
}
...
...
test/src/test/java/org/apache/rocketmq/test/base/IntegrationTestBase.java
浏览文件 @
5f730028
...
@@ -179,15 +179,7 @@ public class IntegrationTestBase {
...
@@ -179,15 +179,7 @@ public class IntegrationTestBase {
if
(!
file
.
exists
())
{
if
(!
file
.
exists
())
{
return
;
return
;
}
}
if
(
file
.
isFile
())
{
UtilAll
.
deleteFile
(
file
);
file
.
delete
();
}
else
if
(
file
.
isDirectory
())
{
File
[]
files
=
file
.
listFiles
();
for
(
File
file1
:
files
)
{
deleteFile
(
file1
);
}
file
.
delete
();
}
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录