Tejaskriya commented on code in PR #6367:
URL: https://github.com/apache/ozone/pull/6367#discussion_r1540693012


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/NodeDecommissionManager.java:
##########
@@ -368,6 +384,57 @@ public synchronized void startDecommission(DatanodeDetails 
dn)
     }
   }
 
+  private synchronized boolean 
checkIfDecommissionPossible(List<DatanodeDetails> dns, List<DatanodeAdminError> 
errors) {
+    int minInService = -1, numDecom = dns.size();
+    int inServiceTotal = 
nodeManager.getNodeCount(NodeStatus.inServiceHealthy());
+    for (DatanodeDetails dn : dns) {
+      try {
+        NodeStatus nodeStatus = getNodeStatus(dn);
+        NodeOperationalState opState = nodeStatus.getOperationalState();
+        if (opState != NodeOperationalState.IN_SERVICE) {
+          numDecom--;
+        }
+      } catch (NodeNotFoundException ex) {
+        numDecom--;
+      }
+    }
+
+    for (DatanodeDetails dn : dns) {
+      Set<ContainerID> containers;
+      try {
+        containers = nodeManager.getContainers(dn);
+      } catch (NodeNotFoundException ex) {
+        LOG.warn("The host {} was not found in SCM. Ignoring the request to " +
+            "decommission it", dn.getHostName());
+        errors.add(new DatanodeAdminError(dn.getHostName(),
+            "The host was not found in SCM"));
+        continue; // ignore the DN and continue to next one
+      }
+
+      for (ContainerID cid : containers) {
+        ContainerInfo cif;
+        try {
+          cif = containerManager.getContainer(cid);
+        } catch (ContainerNotFoundException ex) {
+          continue; // ignore the container and continue to next one
+        }
+        if (cif.getState().equals(HddsProtos.LifeCycleState.DELETED) ||

Review Comment:
   I have moved the container related code under a synchronized block. Could 
you please take a look now?



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to