You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by GitBox <gi...@apache.org> on 2022/12/04 15:25:00 UTC

[GitHub] [rocketmq] mxsm commented on a diff in pull request #5057: [ISSUE #5009] Refactor scan broker active.

mxsm commented on code in PR #5057:
URL: https://github.com/apache/rocketmq/pull/5057#discussion_r1038988385


##########
controller/src/main/java/org/apache/rocketmq/controller/impl/DefaultBrokerHeartbeatManager.java:
##########
@@ -119,18 +113,14 @@ public void registerBroker(String clusterName, String brokerName, String brokerA
     }
 
     @Override
-    public void changeBrokerMetadata(String clusterName, String brokerAddr, Long brokerId) {
-        BrokerAddrInfo addrInfo = new BrokerAddrInfo(clusterName, brokerAddr);
-        BrokerLiveInfo prev = this.brokerLiveTable.get(addrInfo);
-        if (prev != null) {
-            prev.setBrokerId(brokerId);
-            log.info("Change broker {}'s brokerId to {}", brokerAddr, brokerId);
-        }
-    }
+    public void onBrokerHeartbeat(final String clusterName, final String brokerName, final Long brokerId, final String brokerAddr,
+        final Integer epoch, final Long maxOffset, final Long confirmOffset) {
+
+        BrokerData brokerData = brokerAddrTable.computeIfAbsent(brokerName, name -> new BrokerData(clusterName, brokerName, new HashMap<>()));
+        //Switch slave to master: first remove <1, IP:PORT>, then add <0, IP:PORT>

Review Comment:
   replace with
   ```java
            BrokerData brokerData = ConcurrentHashMapUtils.computeIfAbsent((ConcurrentHashMap<String/* brokerName */, BrokerData>)brokerAddrTable, brokerName, name -> new BrokerData(clusterName, brokerName, new HashMap<>()));
   ```



-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org