dombizita commented on code in PR #10084:
URL: https://github.com/apache/ozone/pull/10084#discussion_r3137691232
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/upgrade/SCMUpgradeFinalizer.java:
##########
@@ -177,4 +146,76 @@ private void
waitForDatanodesToFinalize(SCMUpgradeFinalizationContext context)
}
}
}
+
+ public static DatanodeFinalizationCounts getNumFinalizedDatanodes(
+ NodeManager nodeManager) {
+ int finalizedNodes = 0;
+ int totalHealthyNodes = 0;
+ int unfinalizedNodes = 0;
+
+ for (DatanodeDetails dn : nodeManager.getAllNodes()) {
+ try {
+ // Only check HEALTHY nodes. STALE/DEAD nodes will be told to
+ // finalize when they recover.
+ if (!nodeManager.getNodeStatus(dn).isHealthy()) {
+ continue;
+ }
+ totalHealthyNodes++;
+ DatanodeInfo datanodeInfo = nodeManager.getDatanodeInfo(dn);
+ if (datanodeInfo == null) {
+ LOG.warn("Could not get DatanodeInfo for {}, skipping in " +
+ "finalization wait.", dn.getHostName());
+ continue;
+ }
+
+ LayoutVersionProto dnLayout = datanodeInfo.getLastKnownLayoutVersion();
+ int dnMlv = dnLayout.getMetadataLayoutVersion();
+ int dnSlv = dnLayout.getSoftwareLayoutVersion();
+
+ if (dnMlv < dnSlv) {
+ // Datanode has not yet finalized
+ unfinalizedNodes++;
+ LOG.debug("Datanode {} has not yet finalized: MLV={}, SLV={}",
+ dn.getHostName(), dnMlv, dnSlv);
+ } else {
+ finalizedNodes++;
+ }
+ } catch (NodeNotFoundException e) {
+ // Node was removed while we were iterating. This is OK, skip it.
+ LOG.debug("Node {} not found while waiting for finalization, " +
+ "skipping.", dn);
+ }
+ }
+
+ return new DatanodeFinalizationCounts(finalizedNodes, totalHealthyNodes,
unfinalizedNodes);
+ }
+
+ /**
+ * Class to store the number finalized, unfinalized and healthy datanodes.
+ */
+ public static final class DatanodeFinalizationCounts {
+ private final int numFinalizedDatanodes;
+ private final int totalHealthyDatanodes;
+ private final int numUnfinalizedDatanodes;
Review Comment:
You are right, the `numUnfinalizedDatanodes` was only used in a debug
message in `waitForDatanodesToFinalize`. I was just not sure at first if I'm
losing any nodes with a derivation, but thinking it through this looks good.
--
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]