You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by GitBox <gi...@apache.org> on 2019/10/04 02:51:42 UTC

[GitHub] [hadoop] dineshchitlangia commented on a change in pull request #1586: HDDS-2240. Command line tool for OM HA.

dineshchitlangia commented on a change in pull request #1586: HDDS-2240. Command line tool for OM HA.
URL: https://github.com/apache/hadoop/pull/1586#discussion_r331325033
 
 

 ##########
 File path: hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManagerHA.java
 ##########
 @@ -0,0 +1,76 @@
+package org.apache.hadoop.ozone.om;
+
+import org.apache.hadoop.hdds.cli.GenericCli;
+import org.apache.hadoop.hdds.cli.HddsVersionProvider;
+import org.apache.hadoop.hdds.conf.OzoneConfiguration;
+import org.apache.hadoop.hdds.tracing.TracingUtil;
+import org.apache.hadoop.ozone.om.protocol.OzoneManagerProtocol;
+import org.apache.hadoop.ozone.om.protocolPB.OzoneManagerProtocolClientSideTranslatorPB;
+import org.apache.hadoop.security.UserGroupInformation;
+import org.apache.hadoop.security.authentication.client.AuthenticationException;
+import org.apache.ratis.protocol.ClientId;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import picocli.CommandLine;
+import picocli.CommandLine.Command;
+
+import java.io.IOException;
+import java.util.Map;
+
+
+/**
+ * A command line tool for making calls in OM HA protocols.
+ */
+@Command(name = "ozone omha",
+    hidden = true, description = "Command line tool for OM HA.",
+    versionProvider = HddsVersionProvider.class,
+    mixinStandardHelpOptions = true)
+public class OzoneManagerHA extends GenericCli {
+  private OzoneConfiguration conf;
+  private static final Logger LOG =
+      LoggerFactory.getLogger(OzoneManagerHA.class);
+
+  public static void main(String[] args) throws Exception {
+    TracingUtil.initTracing("OzoneManager");
+    new OzoneManagerHA().run(args);
+  }
+
+  private OzoneManagerHA() {
+    super();
+  }
+
+  /**
+   * This function implements a sub-command to allow the OM to be
+   * initialized from the command line.
+   */
+  @CommandLine.Command(name = "--getservicestate",
+      customSynopsis = "ozone om [global options] --getservicestate " +
+          "--serviceId=<OMServiceID>",
+      hidden = false,
+      description = "Get the Ratis server state of all OMs belonging to given" +
+          " OM Service ID",
+      mixinStandardHelpOptions = true,
+      versionProvider = HddsVersionProvider.class)
+  public void getRoleInfoOm(@CommandLine.Option(names = { "--serviceId" },
+      description = "The OM Service ID of the OMs to get the server states for",
+      paramLabel = "id") String serviceId)
+      throws Exception {
+    conf = createOzoneConfiguration();
+    Map<String, String> serviceStates = getServiceStates(conf, serviceId);
+    for (String nodeId : serviceStates.keySet()) {
+      System.out.println(nodeId + " : " + serviceStates.get(nodeId));
+    }
 
 Review comment:
   It will be better to use entrySet() instead of keySet() for performance. Although this method will not be doing extensive amount of work, I believe it is still worth making this change.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org