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/08/25 01:42:31 UTC

[GitHub] [iotdb] CRZbulabula commented on a diff in pull request #7115: [IOTDB-4185] Prevent RatisConsensus Start Race

CRZbulabula commented on code in PR #7115:
URL: https://github.com/apache/iotdb/pull/7115#discussion_r954427284


##########
confignode/src/main/java/org/apache/iotdb/confignode/manager/PartitionManager.java:
##########
@@ -496,19 +497,23 @@ public String getRegionStorageGroup(TConsensusGroupId regionId) {
 
   /** Called by {@link PartitionManager#regionCleaner} Delete RegionGroups periodically. */
   public void clearDeletedRegions() {
-    if (getConsensusManager().isLeader()) {
-      final Set<TRegionReplicaSet> deletedRegionSet = partitionInfo.getDeletedRegionSet();
-      if (!deletedRegionSet.isEmpty()) {
-        LOGGER.info(
-            "DELETE REGIONS {} START",
-            deletedRegionSet.stream()
-                .map(TRegionReplicaSet::getRegionId)
-                .collect(Collectors.toList()));
-        deletedRegionSet.forEach(
-            regionReplicaSet -> removeRegionGroupCache(regionReplicaSet.regionId));
-        SyncDataNodeClientPool.getInstance().deleteRegions(deletedRegionSet);
-      }
-    }
+    Optional.ofNullable(getConsensusManager())
+        .ifPresent(

Review Comment:
   We'd better add annotation about why should we must use Optional.ofNullable.ifPresent here.



##########
confignode/src/main/java/org/apache/iotdb/confignode/manager/NodeManager.java:
##########
@@ -432,14 +433,18 @@ public void startHeartbeatService() {
 
   /** loop body of the heartbeat thread */
   private void heartbeatLoopBody() {
-    if (getConsensusManager().isLeader()) {
-      // Generate HeartbeatReq
-      THeartbeatReq heartbeatReq = genHeartbeatReq();
-      // Send heartbeat requests to all the registered DataNodes
-      pingRegisteredDataNodes(heartbeatReq, getRegisteredDataNodes());
-      // Send heartbeat requests to all the registered ConfigNodes
-      pingRegisteredConfigNodes(heartbeatReq, getRegisteredConfigNodes());
-    }
+    Optional.ofNullable(getConsensusManager())
+        .ifPresent(

Review Comment:
   We'd better add annotation about why should we must use Optional.ofNullable.ifPresent here.



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