adoroszlai commented on code in PR #6304:
URL: https://github.com/apache/ozone/pull/6304#discussion_r1555690295


##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestGetClusterTreeInformation.java:
##########
@@ -62,6 +87,11 @@ public static void init() throws IOException, 
TimeoutException,
         .build();
     cluster.waitForClusterToBeReady();
     scm = cluster.getStorageContainerManager();
+    om = cluster.getOzoneManager();
+    nodeManager = (SCMNodeManager) scm.getScmNodeManager();
+    client = cluster.newClient();

Review Comment:
   `client` needs to be closed in `shutdown()`.



##########
hadoop-ozone/interface-client/src/main/proto/OmClientProtocol.proto:
##########
@@ -147,6 +147,7 @@ enum Type {
   ListStatusLight = 129;
   GetSnapshotInfo = 130;
   RenameSnapshot = 131;
+  RefetchNetworkTopologyTree = 132;

Review Comment:
   Let's omit `Tree` to make it a bit shorter.  (Also in request/response, 
method and command names.)



##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/om/FetchNetworkTopologyTreeSubCommand.java:
##########
@@ -0,0 +1,65 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.om;
+
+import java.io.IOException;
+import java.util.concurrent.Callable;
+import org.apache.hadoop.hdds.cli.HddsVersionProvider;
+import org.apache.hadoop.ozone.om.protocol.OzoneManagerProtocol;
+import picocli.CommandLine;
+
+/**
+ * Handler of ozone admin om fetch-topology-tree command.
+ */
[email protected](
+    name = "fetch-topology-tree",
+    description = "CLI command for OM to force fetch the latest network " +
+        "topology tree information from SCM.",
+    mixinStandardHelpOptions = true,
+    versionProvider = HddsVersionProvider.class
+)
+public class FetchNetworkTopologyTreeSubCommand implements Callable<Void> {
+  @CommandLine.ParentCommand
+  private OMAdmin parent;
+
+  @CommandLine.Option(
+      names = {"-id", "--service-id"},

Review Comment:
   Please avoid adding `-id` as an option for new commands (see HDDS-6736).
   
   ```suggestion
         names = {"--service-id"},
   ```



##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/om/FetchNetworkTopologyTreeSubCommand.java:
##########
@@ -0,0 +1,65 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.om;
+
+import java.io.IOException;
+import java.util.concurrent.Callable;
+import org.apache.hadoop.hdds.cli.HddsVersionProvider;
+import org.apache.hadoop.ozone.om.protocol.OzoneManagerProtocol;
+import picocli.CommandLine;
+
+/**
+ * Handler of ozone admin om fetch-topology-tree command.
+ */
[email protected](
+    name = "fetch-topology-tree",
+    description = "CLI command for OM to force fetch the latest network " +
+        "topology tree information from SCM.",
+    mixinStandardHelpOptions = true,
+    versionProvider = HddsVersionProvider.class
+)
+public class FetchNetworkTopologyTreeSubCommand implements Callable<Void> {
+  @CommandLine.ParentCommand
+  private OMAdmin parent;
+
+  @CommandLine.Option(
+      names = {"-id", "--service-id"},
+      description = "Ozone Manager Service ID",
+      required = false
+  )
+  private String omServiceId;
+
+  @Override
+  public Void call() throws Exception {
+    try (OzoneManagerProtocol client = parent.createOmClient(omServiceId)) {
+      boolean status = false;
+      try {
+        status = client.refetchNetworkTopologyTree();
+      } catch (IOException e) {
+        System.err.println("Force fetching network topology tree information " 
+
+            "has failed: " + e.getMessage());
+      }
+      if (status) {
+        System.out.println(
+            "Force fetching network topology tree information " +
+                "is complete.");
+      }

Review Comment:
   I find this output a bit too verbose.



##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java:
##########
@@ -1094,11 +1094,17 @@ private void stopSecretManager() {
     }
   }
 
+  @Override
   public UUID refetchSecretKey() {
     secretKeyClient.refetchSecretKey();
     return secretKeyClient.getCurrentSecretKey().getId();
   }
 
+  @Override
+  public boolean refetchNetworkTopologyTree() {
+    return scmTopologyClient.refetchClusterTree(configuration);

Review Comment:
   I think admin privilege should be required to make the request.



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