Ziy1-Tan commented on code in PR #7325:
URL: https://github.com/apache/rocketmq/pull/7325#discussion_r1320554154


##########
common/src/main/java/org/apache/rocketmq/common/BrokerConfig.java:
##########
@@ -396,6 +396,10 @@ public class BrokerConfig extends BrokerIdentity {
 
     private boolean enableMixedMessageType = false;
 
+    private boolean enableSplitRegistration = false;

Review Comment:
   Fixed.



##########
broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java:
##########
@@ -1766,36 +1767,63 @@ public synchronized void 
registerIncrementBrokerData(List<TopicConfig> topicConf
     }
 
     public synchronized void registerBrokerAll(final boolean checkOrderConfig, 
boolean oneway, boolean forceRegister) {
+        ConcurrentMap<String, TopicConfig> topicConfigMap = 
this.getTopicConfigManager().getTopicConfigTable();
+        ConcurrentHashMap<String, TopicConfig> topicConfigTable = new 
ConcurrentHashMap<>();
 
-        TopicConfigAndMappingSerializeWrapper topicConfigWrapper = new 
TopicConfigAndMappingSerializeWrapper();
+        for (TopicConfig topicConfig : topicConfigMap.values()) {
+            if 
(!PermName.isWriteable(this.getBrokerConfig().getBrokerPermission())
+                || 
!PermName.isReadable(this.getBrokerConfig().getBrokerPermission())) {
+                topicConfigTable.put(topicConfig.getTopicName(),
+                    new TopicConfig(topicConfig.getTopicName(), 
topicConfig.getReadQueueNums(), topicConfig.getWriteQueueNums(),
+                        topicConfig.getPerm() & 
getBrokerConfig().getBrokerPermission()));
+            } else {
+                topicConfigTable.put(topicConfig.getTopicName(), topicConfig);
+            }
 
-        
topicConfigWrapper.setDataVersion(this.getTopicConfigManager().getDataVersion());
-        
topicConfigWrapper.setTopicConfigTable(this.getTopicConfigManager().getTopicConfigTable());
+            if (this.brokerConfig.isEnableSplitRegistration()
+                && topicConfigTable.size() >= 
this.brokerConfig.getSplitRegistrationSize()
+                && needRegister(forceRegister)) {
+                TopicConfigAndMappingSerializeWrapper topicConfigWrapper = 
buildSerializeWrapper(topicConfigTable);
+                doRegisterBrokerAll(checkOrderConfig, oneway, 
topicConfigWrapper);
+                topicConfigTable.clear();
+            }
+        }
 
-        
topicConfigWrapper.setTopicQueueMappingInfoMap(this.getTopicQueueMappingManager().getTopicQueueMappingTable().entrySet().stream().map(
-            entry -> new AbstractMap.SimpleImmutableEntry<>(entry.getKey(), 
TopicQueueMappingDetail.cloneAsMappingInfo(entry.getValue()))
-        ).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)));
+        Map<String, TopicQueueMappingInfo> topicQueueMappingInfoMap = 
this.getTopicQueueMappingManager().getTopicQueueMappingTable().entrySet().stream()
+            .map(entry -> new 
AbstractMap.SimpleImmutableEntry<>(entry.getKey(), 
TopicQueueMappingDetail.cloneAsMappingInfo(entry.getValue())))
+            .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
 
-        if (!PermName.isWriteable(this.getBrokerConfig().getBrokerPermission())
-            || 
!PermName.isReadable(this.getBrokerConfig().getBrokerPermission())) {
-            ConcurrentHashMap<String, TopicConfig> topicConfigTable = new 
ConcurrentHashMap<>();
-            for (TopicConfig topicConfig : 
topicConfigWrapper.getTopicConfigTable().values()) {
-                TopicConfig tmp =
-                    new TopicConfig(topicConfig.getTopicName(), 
topicConfig.getReadQueueNums(), topicConfig.getWriteQueueNums(),
-                        topicConfig.getPerm() & 
this.brokerConfig.getBrokerPermission(), topicConfig.getTopicSysFlag());
-                topicConfigTable.put(topicConfig.getTopicName(), tmp);
-            }
-            topicConfigWrapper.setTopicConfigTable(topicConfigTable);
+        TopicConfigAndMappingSerializeWrapper topicConfigWrapper = 
buildSerializeWrapper(topicConfigTable, topicQueueMappingInfoMap);
+        if (this.brokerConfig.isEnableSplitRegistration() || 
needRegister(forceRegister)) {
+            doRegisterBrokerAll(checkOrderConfig, oneway, topicConfigWrapper);
         }
+    }
 
-        if (forceRegister || 
needRegister(this.brokerConfig.getBrokerClusterName(),
+    private boolean needRegister(final boolean forceRegister) {
+        return forceRegister || 
needRegister(this.brokerConfig.getBrokerClusterName(),
             this.getBrokerAddr(),
             this.brokerConfig.getBrokerName(),
             this.brokerConfig.getBrokerId(),
             this.brokerConfig.getRegisterBrokerTimeoutMills(),
-            this.brokerConfig.isInBrokerContainer())) {
-            doRegisterBrokerAll(checkOrderConfig, oneway, topicConfigWrapper);
+            this.brokerConfig.isInBrokerContainer());
+    }
+
+    private TopicConfigAndMappingSerializeWrapper buildSerializeWrapper(final 
ConcurrentMap<String, TopicConfig> topicConfigTable) {
+        return buildSerializeWrapper(topicConfigTable, Maps.newHashMap());
+    }
+
+    private TopicConfigAndMappingSerializeWrapper buildSerializeWrapper(

Review Comment:
   Fixed.



-- 
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