cserwen commented on code in PR #4100:
URL: https://github.com/apache/rocketmq/pull/4100#discussion_r845704893


##########
container/src/main/java/org/apache/rocketmq/container/BrokerContainer.java:
##########
@@ -258,16 +263,51 @@ public void registerBrokerBootHook(BrokerBootHook 
brokerBootHook) {
     @Override
     public InnerBrokerController addBroker(final BrokerConfig brokerConfig,
         final MessageStoreConfig storeConfig) throws Exception {
-        if (brokerConfig.getBrokerId() == MixAll.MASTER_ID && 
storeConfig.getBrokerRole() != BrokerRole.SLAVE) {
-            return this.addMasterBroker(brokerConfig, storeConfig);
-        }
-        if (brokerConfig.getBrokerId() != MixAll.MASTER_ID && 
storeConfig.getBrokerRole() == BrokerRole.SLAVE) {
-            return this.addSlaveBroker(brokerConfig, storeConfig);
+        if (storeConfig.isEnableDLegerCommitLog()) {
+            return this.addDLedgerBroker(brokerConfig, storeConfig);
+        } else {
+            if (brokerConfig.getBrokerId() == MixAll.MASTER_ID && 
storeConfig.getBrokerRole() != BrokerRole.SLAVE) {
+                return this.addMasterBroker(brokerConfig, storeConfig);
+            }
+            if (brokerConfig.getBrokerId() != MixAll.MASTER_ID && 
storeConfig.getBrokerRole() == BrokerRole.SLAVE) {
+                return this.addSlaveBroker(brokerConfig, storeConfig);
+            }
         }
 
         return null;
     }
 
+    public InnerBrokerController addDLedgerBroker(final BrokerConfig 
brokerConfig, final MessageStoreConfig storeConfig) throws Exception {
+        brokerConfig.setInBrokerContainer(true);
+        if (storeConfig.isDuplicationEnable()) {
+            LOG.error("Can not add broker to container when duplicationEnable 
is true currently");
+            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)));
+        final BrokerController previousBroker = 
dLedgerBrokerControllers.putIfAbsent(brokerIdentity, brokerController);
+        if (previousBroker == null) {
+            // New master broker added, start it
+            try {
+                BrokerLogbackConfigurator.doConfigure(brokerConfig);

Review Comment:
   > The log will be separated by BrokerClusterName_ BrokerName_BrokerId, but 
the brokerId will change in the dledger mode. There may be a problem here.
   
   @RongtongJin  Yes, you are right! I think that we can use `BrokerIdentity` 
to replace it in `doConfigure`, so that we can use dLedgerId to replace 
brokerId.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to