Beyyes commented on code in PR #7108:
URL: https://github.com/apache/iotdb/pull/7108#discussion_r953636211


##########
server/src/main/java/org/apache/iotdb/db/service/thrift/impl/DataNodeInternalRPCServiceImpl.java:
##########
@@ -384,6 +384,7 @@ public TSStatus invalidateSchemaCache(TInvalidateCacheReq 
req) {
   public THeartbeatResp getDataNodeHeartBeat(THeartbeatReq req) throws 
TException {
     THeartbeatResp resp = new THeartbeatResp();
     resp.setHeartbeatTimestamp(req.getHeartbeatTimestamp());
+    
resp.setStatus(IoTDBDescriptor.getInstance().getConfig().getSystemStatus().getStatus());

Review Comment:
   `getNodeStatus` is better?



##########
confignode/src/main/java/org/apache/iotdb/confignode/manager/load/heartbeat/DataNodeHeartbeatCache.java:
##########
@@ -94,15 +84,8 @@ public long getLoadScore() {
       return Long.MAX_VALUE;
     }
 
-    // Return a copy of loadScore
-    switch (status) {
-      case Running:
-        return loadScore;
-      case Unknown:
-      default:
-        // The Unknown Node will get the highest loadScore
-        return Long.MAX_VALUE;
-    }
+    // The DataNode whose status isn't Running will get the highest loadScore
+    return status == NodeStatus.Running ? loadScore : Long.MAX_VALUE;

Review Comment:
   same impl to the `getLoadScore` of `ConfigNodeHeartbeatCache`.



##########
confignode/src/main/java/org/apache/iotdb/confignode/manager/load/heartbeat/DataNodeHeartbeatCache.java:
##########
@@ -112,12 +95,6 @@ public NodeStatus getNodeStatus() {
     }
 
     // Return a copy of status
-    switch (status) {
-      case Running:
-        return NodeStatus.Running;
-      case Unknown:
-      default:
-        return NodeStatus.Unknown;
-    }
+    return NodeStatus.valueOf(status.getStatus());

Review Comment:
   same impl to the `getNodeStatus` of `ConfigNodeHeartbeatCache`.
   
   
![image](https://user-images.githubusercontent.com/6756545/186399558-6d9ea3ff-e7f7-40dc-b553-c07adcee7058.png)
   



##########
confignode/src/main/java/org/apache/iotdb/confignode/manager/load/heartbeat/ConfigNodeHeartbeatCache.java:
##########
@@ -60,23 +60,15 @@ public boolean updateLoadStatistic() {
       }
     }
 
-    NodeStatus originStatus;
-    switch (status) {
-      case Running:
-        originStatus = NodeStatus.Running;
-        break;
-      case Unknown:
-      default:
-        originStatus = NodeStatus.Unknown;
-    }
+    String originStatus = status.getStatus();

Review Comment:
   what's the difference between `Unknown` and `Error`?
   `Unknown` -> `Error` also need to update?



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