sodonnel commented on code in PR #6367:
URL: https://github.com/apache/ozone/pull/6367#discussion_r1534051824
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/NodeDecommissionManager.java:
##########
@@ -368,6 +382,50 @@ public synchronized void startDecommission(DatanodeDetails
dn)
}
}
+ private synchronized boolean
checkIfDecommissionPossible(List<DatanodeDetails> dns, List<DatanodeAdminError>
errors) {
+ // do we require method synchronization?
+ int minInService = -1; // maxRatis = -1, maxEc = -1;
+ 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) ||
+ cif.getState().equals(HddsProtos.LifeCycleState.DELETING)) {
+ continue;
+ }
+ int reqNodes = cif.getReplicationConfig().getRequiredNodes();
+ if (reqNodes > minInService) {
+ minInService = reqNodes;
+ }
+ /* *below code would check the replication type and then get the factor,
+ but as we have a simpler way i.e., getRequiredNodes(), I don't think
we need to care about the replication type
+
+ HddsProtos.ReplicationType replicationType = cif.getReplicationType();
+ if (replicationType.equals(HddsProtos.ReplicationType.RATIS)) {
+ maxRatis = cif.getReplicationFactor().getNumber();
+ } else if (replicationType.equals(HddsProtos.ReplicationType.EC) {
+ //cif.getReplicationConfig();
+ }*/
Review Comment:
Yes, getRequiredNodes is the simplest way. Please remove the commented code
too (I think you left it there just to ask the question which is perfectly
fine).
--
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]