You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by ji...@apache.org on 2022/04/23 07:01:11 UTC
[rocketmq] branch 5.0.0-beta updated: [ISSUE #4192] Fix log split not work for dLedger in container (#4193)
This is an automated email from the ASF dual-hosted git repository.
jinrongtong pushed a commit to branch 5.0.0-beta
in repository https://gitbox.apache.org/repos/asf/rocketmq.git
The following commit(s) were added to refs/heads/5.0.0-beta by this push:
new 7a5fff4f1 [ISSUE #4192] Fix log split not work for dLedger in container (#4193)
7a5fff4f1 is described below
commit 7a5fff4f10d2a381397b9f4893df500ac38e50c8
Author: cserwen <cs...@163.com>
AuthorDate: Sat Apr 23 15:00:52 2022 +0800
[ISSUE #4192] Fix log split not work for dLedger in container (#4193)
---
.../rocketmq/apis/consumer/MessageListener.java | 2 +-
.../apache/rocketmq/broker/BrokerController.java | 43 ++++++++++++++--------
.../broker/client/ClientHousekeepingService.java | 2 +-
.../broker/dledger/DLedgerRoleChangeHandler.java | 4 +-
.../broker/loadbalance/AssignmentManager.java | 2 +-
.../longpolling/LmqPullRequestHoldService.java | 3 ++
.../broker/longpolling/PullRequestHoldService.java | 2 +-
.../apache/rocketmq/broker/out/BrokerOuterAPI.java | 8 ++--
.../broker/processor/PopBufferMergeService.java | 2 +-
.../broker/processor/PopMessageProcessor.java | 8 ++--
.../broker/processor/PopReviveService.java | 2 +-
.../topic/TopicQueueMappingCleanService.java | 4 +-
.../AbstractTransactionalMessageCheckListener.java | 2 +-
.../TransactionalMessageCheckService.java | 2 +-
.../apache/rocketmq/broker/BrokerOuterAPITest.java | 5 ++-
.../java/org/apache/rocketmq/common/UtilAll.java | 12 +++---
.../apache/rocketmq/container/BrokerContainer.java | 9 ++---
.../rocketmq/container/BrokerPreOnlineService.java | 2 +-
.../rocketmq/container/InnerBrokerController.java | 12 +++---
.../rocketmq/container/BrokerContainerTest.java | 6 ++-
.../rocketmq/store/AllocateMappedFileService.java | 2 +-
.../java/org/apache/rocketmq/store/CommitLog.java | 2 +-
.../apache/rocketmq/store/DefaultMessageStore.java | 29 +++++++++++----
.../apache/rocketmq/store/StoreStatsService.java | 12 +++---
.../apache/rocketmq/store/ha/DefaultHAClient.java | 2 +-
.../rocketmq/store/ha/DefaultHAConnection.java | 2 +-
.../apache/rocketmq/store/ha/DefaultHAService.java | 2 +-
.../rocketmq/store/ha/GroupTransferService.java | 2 +-
.../ha/HAConnectionStateNotificationService.java | 2 +-
.../org/apache/rocketmq/store/ha/HAServerTest.java | 2 +-
30 files changed, 112 insertions(+), 77 deletions(-)
diff --git a/apis/src/main/java/org/apache/rocketmq/apis/consumer/MessageListener.java b/apis/src/main/java/org/apache/rocketmq/apis/consumer/MessageListener.java
index a2aa96365..bcfab9748 100644
--- a/apis/src/main/java/org/apache/rocketmq/apis/consumer/MessageListener.java
+++ b/apis/src/main/java/org/apache/rocketmq/apis/consumer/MessageListener.java
@@ -52,5 +52,5 @@ public interface MessageListener {
* @return {@link ConsumeResult#SUCCESS} if <code>message</code> is properly processed; {@link ConsumeResult#FAILURE}
* otherwise.
*/
- ConsumeResult onMessage(MessageView message);
+ ConsumeResult onMessage(MessageView message);
}
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java b/broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java
index 00de39e9a..bab68c481 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java
@@ -98,6 +98,7 @@ import org.apache.rocketmq.broker.transaction.queue.TransactionalMessageBridge;
import org.apache.rocketmq.broker.transaction.queue.TransactionalMessageServiceImpl;
import org.apache.rocketmq.broker.util.HookUtils;
import org.apache.rocketmq.common.BrokerConfig;
+import org.apache.rocketmq.common.BrokerIdentity;
import org.apache.rocketmq.common.Configuration;
import org.apache.rocketmq.common.DataVersion;
import org.apache.rocketmq.common.MixAll;
@@ -394,7 +395,7 @@ public class BrokerController {
*/
protected void initializeResources() {
this.scheduledExecutorService = new ScheduledThreadPoolExecutor(1,
- new ThreadFactoryImpl("BrokerControllerScheduledThread", true, brokerConfig));
+ new ThreadFactoryImpl("BrokerControllerScheduledThread", true, getBrokerIdentity()));
this.sendMessageExecutor = new BrokerFixedThreadPoolExecutor(
this.brokerConfig.getSendMessageThreadPoolNums(),
@@ -402,7 +403,7 @@ public class BrokerController {
1000 * 60,
TimeUnit.MILLISECONDS,
this.sendThreadPoolQueue,
- new ThreadFactoryImpl("SendMessageThread_", brokerConfig));
+ new ThreadFactoryImpl("SendMessageThread_", getBrokerIdentity()));
this.pullMessageExecutor = new BrokerFixedThreadPoolExecutor(
this.brokerConfig.getPullMessageThreadPoolNums(),
@@ -410,7 +411,7 @@ public class BrokerController {
1000 * 60,
TimeUnit.MILLISECONDS,
this.pullThreadPoolQueue,
- new ThreadFactoryImpl("PullMessageThread_", brokerConfig));
+ new ThreadFactoryImpl("PullMessageThread_", getBrokerIdentity()));
this.litePullMessageExecutor = new BrokerFixedThreadPoolExecutor(
this.brokerConfig.getLitePullMessageThreadPoolNums(),
@@ -418,7 +419,7 @@ public class BrokerController {
1000 * 60,
TimeUnit.MILLISECONDS,
this.litePullThreadPoolQueue,
- new ThreadFactoryImpl("LitePullMessageThread_", brokerConfig));
+ new ThreadFactoryImpl("LitePullMessageThread_", getBrokerIdentity()));
this.putMessageFutureExecutor = new BrokerFixedThreadPoolExecutor(
this.brokerConfig.getPutMessageFutureThreadPoolNums(),
@@ -426,7 +427,7 @@ public class BrokerController {
1000 * 60,
TimeUnit.MILLISECONDS,
this.putThreadPoolQueue,
- new ThreadFactoryImpl("SendMessageThread_", brokerConfig));
+ new ThreadFactoryImpl("SendMessageThread_", getBrokerIdentity()));
this.ackMessageExecutor = new BrokerFixedThreadPoolExecutor(
this.brokerConfig.getAckMessageThreadPoolNums(),
@@ -434,7 +435,7 @@ public class BrokerController {
1000 * 60,
TimeUnit.MILLISECONDS,
this.ackThreadPoolQueue,
- new ThreadFactoryImpl("AckMessageThread_", brokerConfig));
+ new ThreadFactoryImpl("AckMessageThread_", getBrokerIdentity()));
this.queryMessageExecutor = new BrokerFixedThreadPoolExecutor(
this.brokerConfig.getQueryMessageThreadPoolNums(),
@@ -442,7 +443,7 @@ public class BrokerController {
1000 * 60,
TimeUnit.MILLISECONDS,
this.queryThreadPoolQueue,
- new ThreadFactoryImpl("QueryMessageThread_", brokerConfig));
+ new ThreadFactoryImpl("QueryMessageThread_", getBrokerIdentity()));
this.adminBrokerExecutor = new BrokerFixedThreadPoolExecutor(
this.brokerConfig.getAdminBrokerThreadPoolNums(),
@@ -450,7 +451,7 @@ public class BrokerController {
1000 * 60,
TimeUnit.MILLISECONDS,
this.adminBrokerThreadPoolQueue,
- new ThreadFactoryImpl("AdminBrokerThread_", brokerConfig));
+ new ThreadFactoryImpl("AdminBrokerThread_", getBrokerIdentity()));
this.clientManageExecutor = new BrokerFixedThreadPoolExecutor(
this.brokerConfig.getClientManageThreadPoolNums(),
@@ -458,7 +459,7 @@ public class BrokerController {
1000 * 60,
TimeUnit.MILLISECONDS,
this.clientManagerThreadPoolQueue,
- new ThreadFactoryImpl("ClientManageThread_", brokerConfig));
+ new ThreadFactoryImpl("ClientManageThread_", getBrokerIdentity()));
this.heartbeatExecutor = new BrokerFixedThreadPoolExecutor(
this.brokerConfig.getHeartbeatThreadPoolNums(),
@@ -466,7 +467,7 @@ public class BrokerController {
1000 * 60,
TimeUnit.MILLISECONDS,
this.heartbeatThreadPoolQueue,
- new ThreadFactoryImpl("HeartbeatThread_", true, brokerConfig));
+ new ThreadFactoryImpl("HeartbeatThread_", true, getBrokerIdentity()));
this.consumerManageExecutor = new BrokerFixedThreadPoolExecutor(
this.brokerConfig.getConsumerManageThreadPoolNums(),
@@ -474,7 +475,7 @@ public class BrokerController {
1000 * 60,
TimeUnit.MILLISECONDS,
this.consumerManagerThreadPoolQueue,
- new ThreadFactoryImpl("ConsumerManageThread_", true, brokerConfig));
+ new ThreadFactoryImpl("ConsumerManageThread_", true, getBrokerIdentity()));
this.replyMessageExecutor = new BrokerFixedThreadPoolExecutor(
this.brokerConfig.getProcessReplyMessageThreadPoolNums(),
@@ -482,7 +483,7 @@ public class BrokerController {
1000 * 60,
TimeUnit.MILLISECONDS,
this.replyThreadPoolQueue,
- new ThreadFactoryImpl("ProcessReplyMessageThread_", brokerConfig));
+ new ThreadFactoryImpl("ProcessReplyMessageThread_", getBrokerIdentity()));
this.endTransactionExecutor = new BrokerFixedThreadPoolExecutor(
this.brokerConfig.getEndTransactionThreadPoolNums(),
@@ -490,7 +491,7 @@ public class BrokerController {
1000 * 60,
TimeUnit.MILLISECONDS,
this.endTransactionThreadPoolQueue,
- new ThreadFactoryImpl("EndTransactionThread_", brokerConfig));
+ new ThreadFactoryImpl("EndTransactionThread_", getBrokerIdentity()));
this.loadBalanceExecutor = new BrokerFixedThreadPoolExecutor(
this.brokerConfig.getLoadBalanceProcessorThreadPoolNums(),
@@ -498,7 +499,7 @@ public class BrokerController {
1000 * 60,
TimeUnit.MILLISECONDS,
this.loadBalanceThreadPoolQueue,
- new ThreadFactoryImpl("LoadBalanceProcessorThread_", brokerConfig));
+ new ThreadFactoryImpl("LoadBalanceProcessorThread_", getBrokerIdentity()));
this.topicQueueMappingCleanService = new TopicQueueMappingCleanService(this);
}
@@ -1517,7 +1518,7 @@ public class BrokerController {
this.brokerConfig.getRegisterBrokerTimeoutMills(),
this.brokerConfig.isEnableSlaveActingMaster(),
this.brokerConfig.isCompressedRegister(),
- this.brokerConfig.isInBrokerContainer());
+ this.getBrokerIdentity());
handleRegisterBrokerResult(registerBrokerResultList, checkOrderConfig);
}
@@ -1859,4 +1860,16 @@ public class BrokerController {
}
return null;
}
+
+ public BrokerIdentity getBrokerIdentity() {
+ if (messageStoreConfig.isEnableDLegerCommitLog()) {
+ return new BrokerIdentity(
+ brokerConfig.getBrokerClusterName(), brokerConfig.getBrokerName(),
+ Integer.parseInt(messageStoreConfig.getdLegerSelfId().substring(1)), brokerConfig.isInBrokerContainer());
+ } else {
+ return new BrokerIdentity(
+ brokerConfig.getBrokerClusterName(), brokerConfig.getBrokerName(),
+ brokerConfig.getBrokerId(), brokerConfig.isInBrokerContainer());
+ }
+ }
}
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/client/ClientHousekeepingService.java b/broker/src/main/java/org/apache/rocketmq/broker/client/ClientHousekeepingService.java
index e7890a45f..28f2e92fd 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/client/ClientHousekeepingService.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/client/ClientHousekeepingService.java
@@ -36,7 +36,7 @@ public class ClientHousekeepingService implements ChannelEventListener {
public ClientHousekeepingService(final BrokerController brokerController) {
this.brokerController = brokerController;
scheduledExecutorService = new ScheduledThreadPoolExecutor(1,
- new ThreadFactoryImpl("ClientHousekeepingScheduledThread", brokerController.getBrokerConfig()));
+ new ThreadFactoryImpl("ClientHousekeepingScheduledThread", brokerController.getBrokerIdentity()));
}
public void start() {
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/dledger/DLedgerRoleChangeHandler.java b/broker/src/main/java/org/apache/rocketmq/broker/dledger/DLedgerRoleChangeHandler.java
index 3f5f024ef..ab202c308 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/dledger/DLedgerRoleChangeHandler.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/dledger/DLedgerRoleChangeHandler.java
@@ -36,7 +36,7 @@ import org.apache.rocketmq.store.dledger.DLedgerCommitLog;
public class DLedgerRoleChangeHandler implements DLedgerLeaderElector.RoleChangeHandler {
private static final InternalLogger LOGGER = InternalLoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
- private ExecutorService executorService = Executors.newSingleThreadExecutor(new ThreadFactoryImpl("DLegerRoleChangeHandler_"));
+ private ExecutorService executorService;
private BrokerController brokerController;
private DefaultMessageStore messageStore;
private DLedgerCommitLog dLedgerCommitLog;
@@ -48,6 +48,8 @@ public class DLedgerRoleChangeHandler implements DLedgerLeaderElector.RoleChange
this.messageStore = messageStore;
this.dLedgerCommitLog = (DLedgerCommitLog) messageStore.getCommitLog();
this.dLegerServer = dLedgerCommitLog.getdLedgerServer();
+ this.executorService = Executors.newSingleThreadExecutor(
+ new ThreadFactoryImpl("DLegerRoleChangeHandler_", brokerController.getBrokerIdentity()));
}
@Override public void handle(long term, MemberState.Role role) {
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/loadbalance/AssignmentManager.java b/broker/src/main/java/org/apache/rocketmq/broker/loadbalance/AssignmentManager.java
index fe5d5d0fd..a4dfe0ce3 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/loadbalance/AssignmentManager.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/loadbalance/AssignmentManager.java
@@ -65,7 +65,7 @@ public class AssignmentManager {
ignoreRouteTopics.add(brokerController.getBrokerConfig().getBrokerClusterName());
ignoreRouteTopics.add(brokerController.getBrokerConfig().getBrokerName());
scheduledExecutorService = Executors
- .newSingleThreadScheduledExecutor(new ThreadFactoryImpl("LoadBalanceManagerScheduledThread", brokerController.getBrokerConfig()));
+ .newSingleThreadScheduledExecutor(new ThreadFactoryImpl("LoadBalanceManagerScheduledThread", brokerController.getBrokerIdentity()));
}
public void start() {
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/longpolling/LmqPullRequestHoldService.java b/broker/src/main/java/org/apache/rocketmq/broker/longpolling/LmqPullRequestHoldService.java
index 42b44b6ab..b3eeea276 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/longpolling/LmqPullRequestHoldService.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/longpolling/LmqPullRequestHoldService.java
@@ -32,6 +32,9 @@ public class LmqPullRequestHoldService extends PullRequestHoldService {
@Override
public String getServiceName() {
+ if (brokerController != null && brokerController.getBrokerConfig().isInBrokerContainer()) {
+ return this.brokerController.getBrokerIdentity().getLoggerIdentifier() + LmqPullRequestHoldService.class.getSimpleName();
+ }
return LmqPullRequestHoldService.class.getSimpleName();
}
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/longpolling/PullRequestHoldService.java b/broker/src/main/java/org/apache/rocketmq/broker/longpolling/PullRequestHoldService.java
index 0a05dbac5..bf3f66866 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/longpolling/PullRequestHoldService.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/longpolling/PullRequestHoldService.java
@@ -92,7 +92,7 @@ public class PullRequestHoldService extends ServiceThread {
@Override
public String getServiceName() {
if (brokerController != null && brokerController.getBrokerConfig().isInBrokerContainer()) {
- return this.brokerController.getBrokerConfig().getLoggerIdentifier() + PullRequestHoldService.class.getSimpleName();
+ return this.brokerController.getBrokerIdentity().getLoggerIdentifier() + PullRequestHoldService.class.getSimpleName();
}
return PullRequestHoldService.class.getSimpleName();
}
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/out/BrokerOuterAPI.java b/broker/src/main/java/org/apache/rocketmq/broker/out/BrokerOuterAPI.java
index 00b1cbb4d..78e1dec27 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/out/BrokerOuterAPI.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/out/BrokerOuterAPI.java
@@ -366,7 +366,7 @@ public class BrokerOuterAPI {
final int timeoutMills,
final boolean enableActingMaster,
final boolean compressed,
- final boolean isInBrokerContainer) {
+ final BrokerIdentity brokerIdentity) {
return registerBrokerAll(clusterName,
brokerAddr,
brokerName,
@@ -378,7 +378,7 @@ public class BrokerOuterAPI {
enableActingMaster,
compressed,
null,
- isInBrokerContainer);
+ brokerIdentity);
}
/**
@@ -410,7 +410,7 @@ public class BrokerOuterAPI {
final boolean enableActingMaster,
final boolean compressed,
final Long heartbeatTimeoutMillis,
- final boolean isInBrokerContainer) {
+ final BrokerIdentity brokerIdentity) {
final List<RegisterBrokerResult> registerBrokerResultList = new CopyOnWriteArrayList<>();
List<String> nameServerAddressList = this.remotingClient.getAvailableNameSrvList();
@@ -436,7 +436,7 @@ public class BrokerOuterAPI {
requestHeader.setBodyCrc32(bodyCrc32);
final CountDownLatch countDownLatch = new CountDownLatch(nameServerAddressList.size());
for (final String namesrvAddr : nameServerAddressList) {
- brokerOuterExecutor.execute(new AbstractBrokerRunnable(new BrokerIdentity(clusterName, brokerName, brokerId, isInBrokerContainer)) {
+ brokerOuterExecutor.execute(new AbstractBrokerRunnable(brokerIdentity) {
@Override public void run2() {
try {
RegisterBrokerResult result = registerBroker(namesrvAddr, oneway, timeoutMills, requestHeader, body);
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/PopBufferMergeService.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/PopBufferMergeService.java
index cee84e616..c21dec6b1 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/processor/PopBufferMergeService.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/PopBufferMergeService.java
@@ -77,7 +77,7 @@ public class PopBufferMergeService extends ServiceThread {
@Override
public String getServiceName() {
if (this.brokerController != null && this.brokerController.getBrokerConfig().isInBrokerContainer()) {
- return brokerController.getBrokerConfig().getLoggerIdentifier() + PopBufferMergeService.class.getSimpleName();
+ return brokerController.getBrokerIdentity().getLoggerIdentifier() + PopBufferMergeService.class.getSimpleName();
}
return PopBufferMergeService.class.getSimpleName();
}
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/PopMessageProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/PopMessageProcessor.java
index ef2cf1505..f54d20bf8 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/processor/PopMessageProcessor.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/PopMessageProcessor.java
@@ -730,9 +730,9 @@ public class PopMessageProcessor implements NettyRequestProcessor {
@Override
public String getServiceName() {
if (PopMessageProcessor.this.brokerController.getBrokerConfig().isInBrokerContainer()) {
- return PopMessageProcessor.this.brokerController.getBrokerConfig().getLoggerIdentifier() + PopLongPollingService.class.getName();
+ return PopMessageProcessor.this.brokerController.getBrokerIdentity().getLoggerIdentifier() + PopLongPollingService.class.getSimpleName();
}
- return PopLongPollingService.class.getName();
+ return PopLongPollingService.class.getSimpleName();
}
private void cleanUnusedResource() {
@@ -961,9 +961,9 @@ public class PopMessageProcessor implements NettyRequestProcessor {
@Override
public String getServiceName() {
if (PopMessageProcessor.this.brokerController.getBrokerConfig().isInBrokerContainer()) {
- return PopMessageProcessor.this.brokerController.getBrokerConfig().getLoggerIdentifier() + QueueLockManager.class.getName();
+ return PopMessageProcessor.this.brokerController.getBrokerIdentity().getLoggerIdentifier() + QueueLockManager.class.getSimpleName();
}
- return QueueLockManager.class.getName();
+ return QueueLockManager.class.getSimpleName();
}
@Override
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/PopReviveService.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/PopReviveService.java
index 858ad61a6..cbe38a3b8 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/processor/PopReviveService.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/PopReviveService.java
@@ -66,7 +66,7 @@ public class PopReviveService extends ServiceThread {
@Override
public String getServiceName() {
if (brokerController != null && brokerController.getBrokerConfig().isInBrokerContainer()) {
- return brokerController.getBrokerConfig().getLoggerIdentifier() + "PopReviveService_" + this.queueId;
+ return brokerController.getBrokerIdentity().getLoggerIdentifier() + "PopReviveService_" + this.queueId;
}
return "PopReviveService_" + this.queueId;
}
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/topic/TopicQueueMappingCleanService.java b/broker/src/main/java/org/apache/rocketmq/broker/topic/TopicQueueMappingCleanService.java
index cff68f088..bfa643f6a 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/topic/TopicQueueMappingCleanService.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/topic/TopicQueueMappingCleanService.java
@@ -57,8 +57,10 @@ public class TopicQueueMappingCleanService extends ServiceThread {
private RpcClient rpcClient;
private MessageStoreConfig messageStoreConfig;
private BrokerConfig brokerConfig;
+ private BrokerController brokerController;
public TopicQueueMappingCleanService(BrokerController brokerController) {
+ this.brokerController = brokerController;
this.topicQueueMappingManager = brokerController.getTopicQueueMappingManager();
this.rpcClient = brokerController.getBrokerOuterAPI().getRpcClient();
this.messageStoreConfig = brokerController.getMessageStoreConfig();
@@ -69,7 +71,7 @@ public class TopicQueueMappingCleanService extends ServiceThread {
@Override
public String getServiceName() {
if (this.brokerConfig.isInBrokerContainer()) {
- return this.brokerConfig.getLoggerIdentifier() + TopicQueueMappingCleanService.class.getSimpleName();
+ return this.brokerController.getBrokerIdentity().getLoggerIdentifier() + TopicQueueMappingCleanService.class.getSimpleName();
}
return TopicQueueMappingCleanService.class.getSimpleName();
}
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/transaction/AbstractTransactionalMessageCheckListener.java b/broker/src/main/java/org/apache/rocketmq/broker/transaction/AbstractTransactionalMessageCheckListener.java
index a3a8ca68a..2ed0d9d1c 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/transaction/AbstractTransactionalMessageCheckListener.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/transaction/AbstractTransactionalMessageCheckListener.java
@@ -98,7 +98,7 @@ public abstract class AbstractTransactionalMessageCheckListener {
public synchronized void initExecutorService() {
if (executorService == null) {
executorService = new ThreadPoolExecutor(2, 5, 100, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(2000),
- new ThreadFactoryImpl("Transaction-msg-check-thread", brokerController.getBrokerConfig()), new CallerRunsPolicy());
+ new ThreadFactoryImpl("Transaction-msg-check-thread", brokerController.getBrokerIdentity()), new CallerRunsPolicy());
}
}
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/transaction/TransactionalMessageCheckService.java b/broker/src/main/java/org/apache/rocketmq/broker/transaction/TransactionalMessageCheckService.java
index 2a841c131..143889a19 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/transaction/TransactionalMessageCheckService.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/transaction/TransactionalMessageCheckService.java
@@ -34,7 +34,7 @@ public class TransactionalMessageCheckService extends ServiceThread {
@Override
public String getServiceName() {
if (brokerController != null && brokerController.getBrokerConfig().isInBrokerContainer()) {
- return brokerController.getBrokerConfig().getLoggerIdentifier() + TransactionalMessageCheckService.class.getSimpleName();
+ return brokerController.getBrokerIdentity().getLoggerIdentifier() + TransactionalMessageCheckService.class.getSimpleName();
}
return TransactionalMessageCheckService.class.getSimpleName();
}
diff --git a/broker/src/test/java/org/apache/rocketmq/broker/BrokerOuterAPITest.java b/broker/src/test/java/org/apache/rocketmq/broker/BrokerOuterAPITest.java
index d5cd0685b..5db36eafb 100644
--- a/broker/src/test/java/org/apache/rocketmq/broker/BrokerOuterAPITest.java
+++ b/broker/src/test/java/org/apache/rocketmq/broker/BrokerOuterAPITest.java
@@ -28,6 +28,7 @@ import java.util.List;
import java.util.concurrent.TimeUnit;
import org.apache.rocketmq.broker.out.BrokerOuterAPI;
import org.apache.rocketmq.common.BrokerConfig;
+import org.apache.rocketmq.common.BrokerIdentity;
import org.apache.rocketmq.common.MixAll;
import org.apache.rocketmq.common.namesrv.RegisterBrokerResult;
import org.apache.rocketmq.common.protocol.RequestCode;
@@ -171,7 +172,7 @@ public class BrokerOuterAPITest {
timeOut,
false,
true,
- false);
+ new BrokerIdentity());
assertTrue(registerBrokerResultList.size() > 0);
}
@@ -202,7 +203,7 @@ public class BrokerOuterAPITest {
return response;
}
});
- List<RegisterBrokerResult> registerBrokerResultList = brokerOuterAPI.registerBrokerAll(clusterName, brokerAddr, brokerName, brokerId, "hasServerAddr", topicConfigSerializeWrapper, Lists.<String>newArrayList(), false, timeOut, false, true, false);
+ List<RegisterBrokerResult> registerBrokerResultList = brokerOuterAPI.registerBrokerAll(clusterName, brokerAddr, brokerName, brokerId, "hasServerAddr", topicConfigSerializeWrapper, Lists.<String>newArrayList(), false, timeOut, false, true, new BrokerIdentity());
assertEquals(2, registerBrokerResultList.size());
}
diff --git a/common/src/main/java/org/apache/rocketmq/common/UtilAll.java b/common/src/main/java/org/apache/rocketmq/common/UtilAll.java
index 772754420..c62a64510 100644
--- a/common/src/main/java/org/apache/rocketmq/common/UtilAll.java
+++ b/common/src/main/java/org/apache/rocketmq/common/UtilAll.java
@@ -50,6 +50,8 @@ import org.apache.rocketmq.remoting.common.RemotingHelper;
public class UtilAll {
private static final InternalLogger log = InternalLoggerFactory.getLogger(LoggerName.COMMON_LOGGER_NAME);
+ private static final InternalLogger STORE_LOG = InternalLoggerFactory.getLogger(LoggerName.STORE_LOGGER_NAME);
+
public static final String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
public static final String YYYY_MM_DD_HH_MM_SS_SSS = "yyyy-MM-dd#HH:mm:ss:SSS";
@@ -220,7 +222,7 @@ public class UtilAll {
public static double getDiskPartitionSpaceUsedPercent(final String path) {
if (null == path || path.isEmpty()) {
- log.error("Error when measuring disk space usage, path is null or empty, path : {}", path);
+ STORE_LOG.error("Error when measuring disk space usage, path is null or empty, path : {}", path);
return -1;
}
@@ -229,7 +231,7 @@ public class UtilAll {
File file = new File(path);
if (!file.exists()) {
- log.error("Error when measuring disk space usage, file doesn't exist on this path: {}", path);
+ STORE_LOG.error("Error when measuring disk space usage, file doesn't exist on this path: {}", path);
return -1;
}
@@ -247,7 +249,7 @@ public class UtilAll {
return result / 100.0;
}
} catch (Exception e) {
- log.error("Error when measuring disk space usage, got exception: :", e);
+ STORE_LOG.error("Error when measuring disk space usage, got exception: :", e);
return -1;
}
@@ -652,7 +654,7 @@ public class UtilAll {
File[] files = file.listFiles();
if (files == null || files.length <= 0) {
file.delete();
- log.info("delete empty direct, {}", file.getPath());
+ STORE_LOG.info("delete empty direct, {}", file.getPath());
}
}
@@ -722,7 +724,7 @@ public class UtilAll {
File f = new File(dirName);
if (!f.exists()) {
boolean result = f.mkdirs();
- log.info(dirName + " mkdir " + (result ? "OK" : "Failed"));
+ STORE_LOG.info(dirName + " mkdir " + (result ? "OK" : "Failed"));
}
}
}
diff --git a/container/src/main/java/org/apache/rocketmq/container/BrokerContainer.java b/container/src/main/java/org/apache/rocketmq/container/BrokerContainer.java
index db6672beb..4b6c41c61 100644
--- a/container/src/main/java/org/apache/rocketmq/container/BrokerContainer.java
+++ b/container/src/main/java/org/apache/rocketmq/container/BrokerContainer.java
@@ -284,8 +284,7 @@ public class BrokerContainer implements IBrokerContainer {
throw new Exception("Can not add broker to container when duplicationEnable is true currently");
}
InnerBrokerController brokerController = new InnerBrokerController(this, brokerConfig, storeConfig);
- BrokerIdentity brokerIdentity = new BrokerIdentity(brokerConfig.getBrokerClusterName(),
- brokerConfig.getBrokerName(), Integer.parseInt(storeConfig.getdLegerSelfId().substring(1)));
+ BrokerIdentity brokerIdentity = brokerController.getBrokerIdentity();
final BrokerController previousBroker = dLedgerBrokerControllers.putIfAbsent(brokerIdentity, brokerController);
if (previousBroker == null) {
// New dLedger broker added, start it
@@ -317,8 +316,7 @@ public class BrokerContainer implements IBrokerContainer {
throw new Exception("Can not add broker to container when duplicationEnable is true currently");
}
InnerBrokerController masterBroker = new InnerBrokerController(this, masterBrokerConfig, storeConfig);
- BrokerIdentity brokerIdentity = new BrokerIdentity(masterBrokerConfig.getBrokerClusterName(),
- masterBrokerConfig.getBrokerName(), masterBrokerConfig.getBrokerId());
+ BrokerIdentity brokerIdentity = masterBroker.getBrokerIdentity();
final BrokerController previousBroker = masterBrokerControllers.putIfAbsent(brokerIdentity, masterBroker);
if (previousBroker == null) {
// New master broker added, start it
@@ -365,8 +363,7 @@ public class BrokerContainer implements IBrokerContainer {
int ratio = storeConfig.getAccessMessageInMemoryMaxRatio() - 10;
storeConfig.setAccessMessageInMemoryMaxRatio(Math.max(ratio, 0));
InnerSalveBrokerController slaveBroker = new InnerSalveBrokerController(this, slaveBrokerConfig, storeConfig);
- BrokerIdentity brokerIdentity = new BrokerIdentity(slaveBrokerConfig.getBrokerClusterName(),
- slaveBrokerConfig.getBrokerName(), slaveBrokerConfig.getBrokerId());
+ BrokerIdentity brokerIdentity = slaveBroker.getBrokerIdentity();
final InnerSalveBrokerController previousBroker = slaveBrokerControllers.putIfAbsent(brokerIdentity, slaveBroker);
if (previousBroker == null) {
// New slave broker added, start it
diff --git a/container/src/main/java/org/apache/rocketmq/container/BrokerPreOnlineService.java b/container/src/main/java/org/apache/rocketmq/container/BrokerPreOnlineService.java
index 40a018760..c85eb654e 100644
--- a/container/src/main/java/org/apache/rocketmq/container/BrokerPreOnlineService.java
+++ b/container/src/main/java/org/apache/rocketmq/container/BrokerPreOnlineService.java
@@ -53,7 +53,7 @@ public class BrokerPreOnlineService extends ServiceThread {
@Override
public String getServiceName() {
if (this.brokerController != null && this.brokerController.getBrokerConfig().isInBrokerContainer()) {
- return brokerController.getBrokerConfig().getLoggerIdentifier() + BrokerPreOnlineService.class.getSimpleName();
+ return brokerController.getBrokerIdentity().getLoggerIdentifier() + BrokerPreOnlineService.class.getSimpleName();
}
return BrokerPreOnlineService.class.getSimpleName();
}
diff --git a/container/src/main/java/org/apache/rocketmq/container/InnerBrokerController.java b/container/src/main/java/org/apache/rocketmq/container/InnerBrokerController.java
index 4603164f2..1f0d0fe91 100644
--- a/container/src/main/java/org/apache/rocketmq/container/InnerBrokerController.java
+++ b/container/src/main/java/org/apache/rocketmq/container/InnerBrokerController.java
@@ -74,9 +74,9 @@ public class InnerBrokerController extends BrokerController {
protected void initializeResources() {
super.initializeResources();
this.syncBrokerMemberGroupExecutorService = new ScheduledThreadPoolExecutor(1,
- new ThreadFactoryImpl("BrokerControllerSyncBrokerScheduledThread", brokerConfig));
+ new ThreadFactoryImpl("BrokerControllerSyncBrokerScheduledThread", super.getBrokerIdentity()));
this.brokerHeartbeatExecutorService = new ScheduledThreadPoolExecutor(1,
- new ThreadFactoryImpl("rokerControllerHeartbeatScheduledThread", brokerConfig));
+ new ThreadFactoryImpl("rokerControllerHeartbeatScheduledThread", super.getBrokerIdentity()));
}
@Override
@@ -134,7 +134,7 @@ public class InnerBrokerController extends BrokerController {
this.registerBrokerAll(true, false, true);
}
- scheduledFutures.add(this.scheduledExecutorService.scheduleAtFixedRate(new AbstractBrokerRunnable(this.brokerConfig) {
+ scheduledFutures.add(this.scheduledExecutorService.scheduleAtFixedRate(new AbstractBrokerRunnable(this.getBrokerIdentity()) {
@Override
public void run2() {
try {
@@ -154,7 +154,7 @@ public class InnerBrokerController extends BrokerController {
}, 1000 * 10, Math.max(10000, Math.min(brokerConfig.getRegisterNameServerPeriod(), 60000)), TimeUnit.MILLISECONDS));
if (this.brokerConfig.isEnableSlaveActingMaster()) {
- scheduledFutures.add(this.brokerHeartbeatExecutorService.scheduleAtFixedRate(new AbstractBrokerRunnable(this.brokerConfig) {
+ scheduledFutures.add(this.brokerHeartbeatExecutorService.scheduleAtFixedRate(new AbstractBrokerRunnable(this.getBrokerIdentity()) {
@Override
public void run2() {
if (isIsolated) {
@@ -169,7 +169,7 @@ public class InnerBrokerController extends BrokerController {
}
}, 1000, brokerConfig.getBrokerHeartbeatInterval(), TimeUnit.MILLISECONDS));
- scheduledFutures.add(this.syncBrokerMemberGroupExecutorService.scheduleAtFixedRate(new AbstractBrokerRunnable(this.brokerConfig) {
+ scheduledFutures.add(this.syncBrokerMemberGroupExecutorService.scheduleAtFixedRate(new AbstractBrokerRunnable(this.getBrokerIdentity()) {
@Override public void run2() {
try {
InnerBrokerController.this.syncBrokerMemberGroup();
@@ -261,7 +261,7 @@ public class InnerBrokerController extends BrokerController {
this.brokerConfig.isEnableSlaveActingMaster(),
this.brokerConfig.isCompressedRegister(),
this.brokerConfig.isEnableSlaveActingMaster() ? this.brokerConfig.getBrokerNotActiveTimeoutMillis() : null,
- this.brokerConfig.isInBrokerContainer());
+ this.getBrokerIdentity());
handleRegisterBrokerResult(registerBrokerResultList, checkOrderConfig);
}
diff --git a/container/src/test/java/org/apache/rocketmq/container/BrokerContainerTest.java b/container/src/test/java/org/apache/rocketmq/container/BrokerContainerTest.java
index d63446e99..351d88def 100644
--- a/container/src/test/java/org/apache/rocketmq/container/BrokerContainerTest.java
+++ b/container/src/test/java/org/apache/rocketmq/container/BrokerContainerTest.java
@@ -126,8 +126,9 @@ public class BrokerContainerTest {
brokerController.registerIncrementBrokerData(topicConfigList, dataVersion);
// Get topicConfigSerializeWrapper created by registerIncrementBrokerData() from brokerOuterAPI.registerBrokerAll()
ArgumentCaptor<TopicConfigSerializeWrapper> captor = ArgumentCaptor.forClass(TopicConfigSerializeWrapper.class);
+ ArgumentCaptor<BrokerIdentity> brokerIdentityCaptor = ArgumentCaptor.forClass(BrokerIdentity.class);
verify(brokerOuterAPI).registerBrokerAll(anyString(), anyString(), anyString(), anyLong(), anyString(),
- captor.capture(), ArgumentMatchers.anyList(), anyBoolean(), anyInt(), anyBoolean(), anyBoolean(), anyBoolean());
+ captor.capture(), ArgumentMatchers.anyList(), anyBoolean(), anyInt(), anyBoolean(), anyBoolean(), brokerIdentityCaptor.capture());
TopicConfigSerializeWrapper wrapper = captor.getValue();
for (Map.Entry<String, TopicConfig> entry : wrapper.getTopicConfigTable().entrySet()) {
assertThat(entry.getValue().getPerm()).isEqualTo(brokerController.getBrokerConfig().getBrokerPermission());
@@ -351,8 +352,9 @@ public class BrokerContainerTest {
brokerController.registerIncrementBrokerData(topicConfigList, dataVersion);
// Get topicConfigSerializeWrapper created by registerIncrementBrokerData() from brokerOuterAPI.registerBrokerAll()
ArgumentCaptor<TopicConfigSerializeWrapper> captor = ArgumentCaptor.forClass(TopicConfigSerializeWrapper.class);
+ ArgumentCaptor<BrokerIdentity> brokerIdentityCaptor = ArgumentCaptor.forClass(BrokerIdentity.class);
verify(brokerOuterAPI, times(times)).registerBrokerAll(anyString(), anyString(), anyString(), anyLong(),
- anyString(), captor.capture(), ArgumentMatchers.anyList(), anyBoolean(), anyInt(), anyBoolean(), anyBoolean(), anyBoolean());
+ anyString(), captor.capture(), ArgumentMatchers.anyList(), anyBoolean(), anyInt(), anyBoolean(), anyBoolean(), brokerIdentityCaptor.capture());
TopicConfigSerializeWrapper wrapper = captor.getValue();
for (TopicConfig topicConfig : topicConfigList) {
diff --git a/store/src/main/java/org/apache/rocketmq/store/AllocateMappedFileService.java b/store/src/main/java/org/apache/rocketmq/store/AllocateMappedFileService.java
index 47ee11e5c..93ded625a 100644
--- a/store/src/main/java/org/apache/rocketmq/store/AllocateMappedFileService.java
+++ b/store/src/main/java/org/apache/rocketmq/store/AllocateMappedFileService.java
@@ -122,7 +122,7 @@ public class AllocateMappedFileService extends ServiceThread {
@Override
public String getServiceName() {
if (messageStore != null && messageStore.getBrokerConfig().isInBrokerContainer()) {
- return messageStore.getBrokerConfig().getLoggerIdentifier() + AllocateMappedFileService.class.getSimpleName();
+ return messageStore.getBrokerIdentity().getLoggerIdentifier() + AllocateMappedFileService.class.getSimpleName();
}
return AllocateMappedFileService.class.getSimpleName();
}
diff --git a/store/src/main/java/org/apache/rocketmq/store/CommitLog.java b/store/src/main/java/org/apache/rocketmq/store/CommitLog.java
index 383e2cca5..be013e9d4 100644
--- a/store/src/main/java/org/apache/rocketmq/store/CommitLog.java
+++ b/store/src/main/java/org/apache/rocketmq/store/CommitLog.java
@@ -1250,7 +1250,7 @@ public class CommitLog implements Swappable {
@Override
public String getServiceName() {
if (CommitLog.this.defaultMessageStore.getBrokerConfig().isInBrokerContainer()) {
- return CommitLog.this.defaultMessageStore.getBrokerConfig().getLoggerIdentifier() + CommitRealTimeService.class.getSimpleName();
+ return CommitLog.this.defaultMessageStore.getBrokerIdentity().getLoggerIdentifier() + CommitRealTimeService.class.getSimpleName();
}
return CommitRealTimeService.class.getSimpleName();
}
diff --git a/store/src/main/java/org/apache/rocketmq/store/DefaultMessageStore.java b/store/src/main/java/org/apache/rocketmq/store/DefaultMessageStore.java
index dc6cbf591..bcb826e53 100644
--- a/store/src/main/java/org/apache/rocketmq/store/DefaultMessageStore.java
+++ b/store/src/main/java/org/apache/rocketmq/store/DefaultMessageStore.java
@@ -49,6 +49,7 @@ import java.util.concurrent.atomic.AtomicLong;
import org.apache.commons.lang3.StringUtils;
import org.apache.rocketmq.common.AbstractBrokerRunnable;
import org.apache.rocketmq.common.BrokerConfig;
+import org.apache.rocketmq.common.BrokerIdentity;
import org.apache.rocketmq.common.MixAll;
import org.apache.rocketmq.common.ServiceThread;
import org.apache.rocketmq.common.SystemClock;
@@ -184,7 +185,7 @@ public class DefaultMessageStore implements MessageStore {
this.cleanCommitLogService = new CleanCommitLogService();
this.cleanConsumeQueueService = new CleanConsumeQueueService();
this.correctLogicOffsetService = new CorrectLogicOffsetService();
- this.storeStatsService = new StoreStatsService(brokerConfig);
+ this.storeStatsService = new StoreStatsService(getBrokerIdentity());
this.indexService = new IndexService(this);
if (!messageStoreConfig.isEnableDLegerCommitLog() && !this.messageStoreConfig.isDuplicationEnable()) {
this.haService = ServiceProvider.loadClass(ServiceProvider.HA_SERVICE_ID, HAService.class);
@@ -208,7 +209,7 @@ public class DefaultMessageStore implements MessageStore {
this.indexService.start();
this.scheduledExecutorService =
- Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl("StoreScheduledThread", brokerConfig));
+ Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl("StoreScheduledThread", getBrokerIdentity()));
this.dispatcherList = new LinkedList<>();
this.dispatcherList.addLast(new CommitLogDispatcherBuildConsumeQueue());
@@ -1532,21 +1533,21 @@ public class DefaultMessageStore implements MessageStore {
private void addScheduleTask() {
- this.scheduledExecutorService.scheduleAtFixedRate(new AbstractBrokerRunnable(this.brokerConfig) {
+ this.scheduledExecutorService.scheduleAtFixedRate(new AbstractBrokerRunnable(this.getBrokerIdentity()) {
@Override
public void run2() {
DefaultMessageStore.this.cleanFilesPeriodically();
}
}, 1000 * 60, this.messageStoreConfig.getCleanResourceInterval(), TimeUnit.MILLISECONDS);
- this.scheduledExecutorService.scheduleAtFixedRate(new AbstractBrokerRunnable(this.brokerConfig) {
+ this.scheduledExecutorService.scheduleAtFixedRate(new AbstractBrokerRunnable(this.getBrokerIdentity()) {
@Override
public void run2() {
DefaultMessageStore.this.checkSelf();
}
}, 1, 10, TimeUnit.MINUTES);
- this.scheduledExecutorService.scheduleAtFixedRate(new AbstractBrokerRunnable(this.brokerConfig) {
+ this.scheduledExecutorService.scheduleAtFixedRate(new AbstractBrokerRunnable(this.getBrokerIdentity()) {
@Override
public void run2() {
if (DefaultMessageStore.this.getMessageStoreConfig().isDebugLockEnable()) {
@@ -1567,7 +1568,7 @@ public class DefaultMessageStore implements MessageStore {
}
}, 1, 1, TimeUnit.SECONDS);
- this.scheduledExecutorService.scheduleAtFixedRate(new AbstractBrokerRunnable(this.brokerConfig) {
+ this.scheduledExecutorService.scheduleAtFixedRate(new AbstractBrokerRunnable(this.getBrokerIdentity()) {
@Override
public void run2() {
DefaultMessageStore.this.storeCheckpoint.flush();
@@ -1807,6 +1808,18 @@ public class DefaultMessageStore implements MessageStore {
this.consumeQueueStore.setTopicConfigTable(topicConfigTable);
}
+ public BrokerIdentity getBrokerIdentity() {
+ if (messageStoreConfig.isEnableDLegerCommitLog()) {
+ return new BrokerIdentity(
+ brokerConfig.getBrokerClusterName(), brokerConfig.getBrokerName(),
+ Integer.parseInt(messageStoreConfig.getdLegerSelfId().substring(1)), brokerConfig.isInBrokerContainer());
+ } else {
+ return new BrokerIdentity(
+ brokerConfig.getBrokerClusterName(), brokerConfig.getBrokerName(),
+ brokerConfig.getBrokerId(), brokerConfig.isInBrokerContainer());
+ }
+ }
+
class CommitLogDispatcherBuildConsumeQueue implements CommitLogDispatcher {
@Override
@@ -2334,7 +2347,7 @@ public class DefaultMessageStore implements MessageStore {
@Override
public String getServiceName() {
if (DefaultMessageStore.this.brokerConfig.isInBrokerContainer()) {
- return DefaultMessageStore.this.brokerConfig.getLoggerIdentifier() + FlushConsumeQueueService.class.getSimpleName();
+ return DefaultMessageStore.this.getBrokerIdentity().getLoggerIdentifier() + FlushConsumeQueueService.class.getSimpleName();
}
return FlushConsumeQueueService.class.getSimpleName();
}
@@ -2510,7 +2523,7 @@ public class DefaultMessageStore implements MessageStore {
@Override
public String getServiceName() {
if (DefaultMessageStore.this.getBrokerConfig().isInBrokerContainer()) {
- return DefaultMessageStore.this.getBrokerConfig().getLoggerIdentifier() + ReputMessageService.class.getSimpleName();
+ return DefaultMessageStore.this.getBrokerIdentity().getLoggerIdentifier() + ReputMessageService.class.getSimpleName();
}
return ReputMessageService.class.getSimpleName();
}
diff --git a/store/src/main/java/org/apache/rocketmq/store/StoreStatsService.java b/store/src/main/java/org/apache/rocketmq/store/StoreStatsService.java
index 99b8bb472..37023f24b 100644
--- a/store/src/main/java/org/apache/rocketmq/store/StoreStatsService.java
+++ b/store/src/main/java/org/apache/rocketmq/store/StoreStatsService.java
@@ -28,7 +28,7 @@ import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.LongAdder;
import java.util.concurrent.locks.ReentrantLock;
-import org.apache.rocketmq.common.BrokerConfig;
+import org.apache.rocketmq.common.BrokerIdentity;
import org.apache.rocketmq.common.ServiceThread;
import org.apache.rocketmq.common.constant.LoggerName;
import org.apache.rocketmq.logging.InternalLogger;
@@ -82,11 +82,11 @@ public class StoreStatsService extends ServiceThread {
private ReentrantLock samplingLock = new ReentrantLock();
private long lastPrintTimestamp = System.currentTimeMillis();
- private BrokerConfig brokerConfig;
+ private BrokerIdentity brokerIdentity;
- public StoreStatsService(BrokerConfig brokerConfig) {
+ public StoreStatsService(BrokerIdentity brokerIdentity) {
this();
- this.brokerConfig = brokerConfig;
+ this.brokerIdentity = brokerIdentity;
}
public StoreStatsService() {
@@ -545,8 +545,8 @@ public class StoreStatsService extends ServiceThread {
@Override
public String getServiceName() {
- if (this.brokerConfig != null && this.brokerConfig.isInBrokerContainer()) {
- return brokerConfig.getLoggerIdentifier() + StoreStatsService.class.getSimpleName();
+ if (this.brokerIdentity != null && this.brokerIdentity.isInBrokerContainer()) {
+ return brokerIdentity.getLoggerIdentifier() + StoreStatsService.class.getSimpleName();
}
return StoreStatsService.class.getSimpleName();
}
diff --git a/store/src/main/java/org/apache/rocketmq/store/ha/DefaultHAClient.java b/store/src/main/java/org/apache/rocketmq/store/ha/DefaultHAClient.java
index 5f651dab5..ba33842f4 100644
--- a/store/src/main/java/org/apache/rocketmq/store/ha/DefaultHAClient.java
+++ b/store/src/main/java/org/apache/rocketmq/store/ha/DefaultHAClient.java
@@ -385,7 +385,7 @@ public class DefaultHAClient extends ServiceThread implements HAClient {
@Override
public String getServiceName() {
if (this.defaultMessageStore != null && this.defaultMessageStore.getBrokerConfig().isInBrokerContainer()) {
- return this.defaultMessageStore.getBrokerConfig().getLoggerIdentifier() + DefaultHAClient.class.getSimpleName();
+ return this.defaultMessageStore.getBrokerIdentity().getLoggerIdentifier() + DefaultHAClient.class.getSimpleName();
}
return DefaultHAClient.class.getSimpleName();
}
diff --git a/store/src/main/java/org/apache/rocketmq/store/ha/DefaultHAConnection.java b/store/src/main/java/org/apache/rocketmq/store/ha/DefaultHAConnection.java
index 4c16959e3..3b7241065 100644
--- a/store/src/main/java/org/apache/rocketmq/store/ha/DefaultHAConnection.java
+++ b/store/src/main/java/org/apache/rocketmq/store/ha/DefaultHAConnection.java
@@ -177,7 +177,7 @@ public class DefaultHAConnection implements HAConnection {
@Override
public String getServiceName() {
if (haService.getDefaultMessageStore().getBrokerConfig().isInBrokerContainer()) {
- return haService.getDefaultMessageStore().getBrokerConfig().getLoggerIdentifier() + ReadSocketService.class.getSimpleName();
+ return haService.getDefaultMessageStore().getBrokerIdentity().getLoggerIdentifier() + ReadSocketService.class.getSimpleName();
}
return ReadSocketService.class.getSimpleName();
}
diff --git a/store/src/main/java/org/apache/rocketmq/store/ha/DefaultHAService.java b/store/src/main/java/org/apache/rocketmq/store/ha/DefaultHAService.java
index 8c480a017..489843b4a 100644
--- a/store/src/main/java/org/apache/rocketmq/store/ha/DefaultHAService.java
+++ b/store/src/main/java/org/apache/rocketmq/store/ha/DefaultHAService.java
@@ -331,7 +331,7 @@ public class DefaultHAService implements HAService {
@Override
public String getServiceName() {
if (defaultMessageStore.getBrokerConfig().isInBrokerContainer()) {
- return defaultMessageStore.getBrokerConfig().getLoggerIdentifier() + AcceptSocketService.class.getSimpleName();
+ return defaultMessageStore.getBrokerIdentity().getLoggerIdentifier() + AcceptSocketService.class.getSimpleName();
}
return AcceptSocketService.class.getSimpleName();
}
diff --git a/store/src/main/java/org/apache/rocketmq/store/ha/GroupTransferService.java b/store/src/main/java/org/apache/rocketmq/store/ha/GroupTransferService.java
index b1c48ca21..dc41279b5 100644
--- a/store/src/main/java/org/apache/rocketmq/store/ha/GroupTransferService.java
+++ b/store/src/main/java/org/apache/rocketmq/store/ha/GroupTransferService.java
@@ -133,7 +133,7 @@ public class GroupTransferService extends ServiceThread {
@Override
public String getServiceName() {
if (defaultMessageStore != null && defaultMessageStore.getBrokerConfig().isInBrokerContainer()) {
- return defaultMessageStore.getBrokerConfig().getLoggerIdentifier() + GroupTransferService.class.getSimpleName();
+ return defaultMessageStore.getBrokerIdentity().getLoggerIdentifier() + GroupTransferService.class.getSimpleName();
}
return GroupTransferService.class.getSimpleName();
}
diff --git a/store/src/main/java/org/apache/rocketmq/store/ha/HAConnectionStateNotificationService.java b/store/src/main/java/org/apache/rocketmq/store/ha/HAConnectionStateNotificationService.java
index d63d8d676..f4e08ccaa 100644
--- a/store/src/main/java/org/apache/rocketmq/store/ha/HAConnectionStateNotificationService.java
+++ b/store/src/main/java/org/apache/rocketmq/store/ha/HAConnectionStateNotificationService.java
@@ -47,7 +47,7 @@ public class HAConnectionStateNotificationService extends ServiceThread {
@Override
public String getServiceName() {
if (defaultMessageStore != null && defaultMessageStore.getBrokerConfig().isInBrokerContainer()) {
- return defaultMessageStore.getBrokerConfig().getLoggerIdentifier() + HAConnectionStateNotificationService.class.getSimpleName();
+ return defaultMessageStore.getBrokerIdentity().getLoggerIdentifier() + HAConnectionStateNotificationService.class.getSimpleName();
}
return HAConnectionStateNotificationService.class.getSimpleName();
}
diff --git a/store/src/test/java/org/apache/rocketmq/store/ha/HAServerTest.java b/store/src/test/java/org/apache/rocketmq/store/ha/HAServerTest.java
index be8ecb2af..e55fedc97 100644
--- a/store/src/test/java/org/apache/rocketmq/store/ha/HAServerTest.java
+++ b/store/src/test/java/org/apache/rocketmq/store/ha/HAServerTest.java
@@ -267,7 +267,7 @@ public class HAServerTest {
doReturn(new SystemClock()).when(messageStore).getSystemClock();
doAnswer(invocation -> System.currentTimeMillis()).when(messageStore).now();
doReturn(this.storeConfig).when(messageStore).getMessageStoreConfig();
-// doReturn(new BrokerConfig()).when(messageStore).getBrokerConfig();
+ doReturn(new BrokerConfig()).when(messageStore).getBrokerConfig();
doReturn(true).when(messageStore).isOffsetAligned(anyLong());
// doReturn(new PutMessageResult(PutMessageStatus.PUT_OK, new AppendMessageResult(AppendMessageStatus.PUT_OK))).when(messageStore).sendMsgBack(anyLong());
doReturn(true).when(messageStore).truncateFiles(anyLong());