You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2022/12/19 09:54:20 UTC

[GitHub] [iotdb] MiniSho commented on a diff in pull request #8483: [IOTDB-4630] Implement observer pattern in LoadBalancing framework

MiniSho commented on code in PR #8483:
URL: https://github.com/apache/iotdb/pull/8483#discussion_r1052006518


##########
confignode/src/main/java/org/apache/iotdb/confignode/manager/load/LoadManager.java:
##########
@@ -185,20 +197,26 @@ private void updateLoadStatistics() {
     // Broadcast the RegionRouteMap if some LoadStatistics has changed
     boolean isNeedBroadcast = false;
 
-    // Update NodeStatistics
-    Map<Integer, NodeStatistics> differentNodeStatisticsMap = new ConcurrentHashMap<>();
+    // Update NodeStatistics:
+    // NodeStatistics[]:index 0 means the current NodeStatistics, index 1 means the previous
+    // NodeStatistics
+    Map<Integer, NodeStatistics[]> differentNodeStatisticsMap = new ConcurrentHashMap<>();
     getNodeManager()
         .getNodeCacheMap()
         .forEach(
             (nodeId, nodeCache) -> {
+              NodeStatistics preNodeStatistics = nodeCache.getPreviousStatistics().deepCopy();
               if (nodeCache.periodicUpdate()) {
                 // Update and record the changed NodeStatistics
-                differentNodeStatisticsMap.put(nodeId, nodeCache.getStatistics());
+                differentNodeStatisticsMap.put(
+                    nodeId, new NodeStatistics[] {nodeCache.getStatistics(), preNodeStatistics});
+                LOGGER.info("previous NodeStatistics: {}", preNodeStatistics);

Review Comment:
   fixed



##########
confignode/src/main/java/org/apache/iotdb/confignode/manager/load/LoadManager.java:
##########
@@ -185,20 +197,26 @@ private void updateLoadStatistics() {
     // Broadcast the RegionRouteMap if some LoadStatistics has changed
     boolean isNeedBroadcast = false;
 
-    // Update NodeStatistics
-    Map<Integer, NodeStatistics> differentNodeStatisticsMap = new ConcurrentHashMap<>();
+    // Update NodeStatistics:
+    // NodeStatistics[]:index 0 means the current NodeStatistics, index 1 means the previous
+    // NodeStatistics
+    Map<Integer, NodeStatistics[]> differentNodeStatisticsMap = new ConcurrentHashMap<>();

Review Comment:
   done.



-- 
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: reviews-unsubscribe@iotdb.apache.org

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