errose28 commented on code in PR #10011:
URL: https://github.com/apache/ozone/pull/10011#discussion_r3048968988


##########
hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/ozone/admin/upgrade/StatusSubCommand.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.ozone.admin.upgrade;
+
+import java.io.IOException;
+import java.util.UUID;
+import org.apache.hadoop.hdds.cli.HddsVersionProvider;
+import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
+import org.apache.hadoop.hdds.scm.cli.ScmSubcommand;
+import org.apache.hadoop.hdds.scm.client.ScmClient;
+import picocli.CommandLine;
+
+/**
+ * Sub command to query the overall upgrade status of the cluster, returning 
information about the finalization
+ * status of SCM, the datanodes and OM.
+ */
[email protected](
+    name = "status",
+    description = "Show status of the cluster upgrade",
+    mixinStandardHelpOptions = true,
+    versionProvider = HddsVersionProvider.class)
+public class StatusSubCommand extends ScmSubcommand {
+
+  @Override
+  public void execute(ScmClient client) throws IOException {
+    String upgradeClientID = "Upgrade-Client-" + UUID.randomUUID();
+    HddsProtos.UpgradeStatus status = 
client.queryUpgradeStatus(upgradeClientID, true);
+
+    // Temporary output to validate the command is working.
+    out().println("Update status:");
+    out().println("    SCM Finalized: " + status.getScmFinalized());
+    out().println("    Datanodes finalized: " + 
status.getNumDatanodesFinalized());
+    out().println("    Total Datanodes: " + status.getNumDatanodesTotal());
+    out().println("    Should Finalize: " + status.getShouldFinalize());

Review Comment:
   This is fine for now. I'm thinking the final output would have a "human" 
version:
   ```
   OM is not finalized
   SCM is finalized
   3/10 Datanodes are finalized
   ```
   and then a `--json` version for scripting:
   ```json
   {
     "omFinalized": false,
     "scmFinalized": true,
     "finalizedDatanodes": 3,
     "totalDatanodes": 10
   }
   ```
   Note that the final version of this command will also query OM for its 
finalization status.
   
   We also don't need to print the `shouldFinalize` parameter. That is for SCM 
to explicitly tell OM when it should finalize so OM does not need to infer this 
from datanode counts.



##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/scm/client/ScmClient.java:
##########
@@ -450,6 +450,8 @@ StatusAndMessages queryUpgradeFinalizationProgress(
       String upgradeClientID, boolean force, boolean readonly)
       throws IOException;
 
+  HddsProtos.UpgradeStatus queryUpgradeStatus(String upgradeClientID, boolean 
readonly) throws IOException;

Review Comment:
   We don't need client ID and readonly parameters for the new API. 
Finalization will not be tracking message state per client now that is one 
atomic operation per component.



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