hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aengin...@apache.org
Subject hadoop git commit: HDFS-12588. Use GenericOptionsParser for scm and ksm daemon. Contributed by Elek, Marton.
Date Fri, 01 Dec 2017 20:21:27 GMT
Repository: hadoop
Updated Branches:
  refs/heads/HDFS-7240 8f7f4aa80 -> 677673f0d


HDFS-12588. Use GenericOptionsParser for scm and ksm daemon. Contributed by Elek, Marton.


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/677673f0
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/677673f0
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/677673f0

Branch: refs/heads/HDFS-7240
Commit: 677673f0df6637616a65bfcbba38278967c6d19e
Parents: 8f7f4aa
Author: Anu Engineer <aengineer@apache.org>
Authored: Fri Dec 1 12:14:08 2017 -0800
Committer: Anu Engineer <aengineer@apache.org>
Committed: Fri Dec 1 12:14:08 2017 -0800

----------------------------------------------------------------------
 .../hadoop-hdfs/src/main/bin/hdfs               |  6 +++++
 .../hadoop/ozone/ksm/KeySpaceManager.java       | 15 ++++++++++-
 .../ozone/scm/StorageContainerManager.java      | 28 +++++++++++++++-----
 .../org/apache/hadoop/ozone/scm/cli/SCMCLI.java |  2 +-
 4 files changed, 42 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/677673f0/hadoop-hdfs-project/hadoop-hdfs/src/main/bin/hdfs
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/bin/hdfs b/hadoop-hdfs-project/hadoop-hdfs/src/main/bin/hdfs
index ffe059b..2dc0713 100755
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/bin/hdfs
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/bin/hdfs
@@ -68,6 +68,7 @@ function hadoop_usage
   hadoop_add_subcommand "oz_debug" client "ozone debug tool, convert ozone metadata into
relational data"
   hadoop_add_subcommand "portmap" daemon "run a portmap service"
   hadoop_add_subcommand "scm" daemon "run the Storage Container Manager service"
+  hadoop_add_subcommand "scmcli" client "run the CLI of the Storage Container Manager "
   hadoop_add_subcommand "secondarynamenode" daemon "run the DFS secondary namenode"
   hadoop_add_subcommand "snapshotDiff" client "diff two snapshots of a directory or diff
the current directory contents with a snapshot"
   hadoop_add_subcommand "storagepolicies" admin "list/get/set block storage policies"
@@ -219,9 +220,14 @@ function hdfscmd_case
       HADOOP_SUBCMD_SUPPORTDAEMONIZATION="true"
       HADOOP_CLASSNAME=org.apache.hadoop.portmap.Portmap
     ;;
+    scmcli)
+       HADOOP_CLASSNAME=org.apache.hadoop.ozone.scm.cli.SCMCLI
+    ;;
     scm)
       HADOOP_SUBCMD_SUPPORTDAEMONIZATION="true"
       HADOOP_CLASSNAME='org.apache.hadoop.ozone.scm.StorageContainerManager'
+      hadoop_debug "Appending HDFS_STORAGECONTAINERMANAGER_OPTS onto HADOOP_OPTS"
+      HADOOP_OPTS="${HADOOP_OPTS} ${HDFS_STORAGECONTAINERMANAGER_OPTS}"
     ;;
     scmcli)
       HADOOP_CLASSNAME=org.apache.hadoop.ozone.scm.cli.SCMCLI

http://git-wip-us.apache.org/repos/asf/hadoop/blob/677673f0/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/KeySpaceManager.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/KeySpaceManager.java
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/KeySpaceManager.java
index dd142f7..385d5f6 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/KeySpaceManager.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/KeySpaceManager.java
@@ -48,6 +48,7 @@ import org.apache.hadoop.scm.protocol.ScmBlockLocationProtocol;
 import org.apache.hadoop.scm.protocolPB.ScmBlockLocationProtocolClientSideTranslatorPB;
 import org.apache.hadoop.scm.protocolPB.ScmBlockLocationProtocolPB;
 import org.apache.hadoop.security.UserGroupInformation;
+import org.apache.hadoop.util.GenericOptionsParser;
 import org.apache.hadoop.util.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -89,6 +90,7 @@ public class KeySpaceManager extends ServiceRuntimeInfoImpl
   private final KSMMetrics metrics;
   private final KeySpaceManagerHttpServer httpServer;
   private ObjectName ksmInfoBeanName;
+  private static final String USAGE = "hdfs ksm [genericOptions]";
 
   public KeySpaceManager(OzoneConfiguration conf) throws IOException {
     final int handlerCount = conf.getInt(OZONE_KSM_HANDLER_COUNT_KEY,
@@ -191,14 +193,25 @@ public class KeySpaceManager extends ServiceRuntimeInfoImpl
    * @throws IOException if startup fails due to I/O error
    */
   public static void main(String[] argv) throws IOException {
-    StringUtils.startupShutdownMessage(KeySpaceManager.class, argv, LOG);
+    if (DFSUtil.parseHelpArgument(argv, USAGE,
+        System.out, true)) {
+      System.exit(0);
+    }
     try {
       OzoneConfiguration conf = new OzoneConfiguration();
+      GenericOptionsParser hParser = new GenericOptionsParser(conf, argv);
+      if (!hParser.isParseSuccessful()
+          || hParser.getRemainingArgs().length > 0) {
+        System.err.println("USAGE: " + USAGE + " \n");
+        hParser.printGenericCommandUsage(System.err);
+        System.exit(1);
+      }
       if (!DFSUtil.isOzoneEnabled(conf)) {
         System.out.println("KSM cannot be started in secure mode or when " +
             OZONE_ENABLED + " is set to false");
         System.exit(1);
       }
+      StringUtils.startupShutdownMessage(KeySpaceManager.class, argv, LOG);
       KeySpaceManager ksm = new KeySpaceManager(conf);
       ksm.start();
       ksm.join();

http://git-wip-us.apache.org/repos/asf/hadoop/blob/677673f0/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/scm/StorageContainerManager.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/scm/StorageContainerManager.java
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/scm/StorageContainerManager.java
index b351c84..bae4cff 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/scm/StorageContainerManager.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/scm/StorageContainerManager.java
@@ -91,6 +91,7 @@ import org.apache.hadoop.scm.protocolPB.StorageContainerLocationProtocolPB;
 import org.apache.hadoop.ozone.common.Storage.StorageState;
 import org.apache.hadoop.ozone.scm.exceptions.SCMException.ResultCodes;
 import org.apache.hadoop.security.UserGroupInformation;
+import org.apache.hadoop.util.GenericOptionsParser;
 import org.apache.hadoop.util.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -216,9 +217,12 @@ public class StorageContainerManager extends ServiceRuntimeInfoImpl
 
 
   private static final String USAGE =
-      "Usage: \n hdfs scm [ " + StartupOption.INIT.getName() + " [ "
-          + StartupOption.CLUSTERID.getName() + " <cid> ] ]\n " + "hdfs scm [ "
-          + StartupOption.GENCLUSTERID.getName() + " ]\n " + "hdfs scm [ "
+      "Usage: \n hdfs scm [genericOptions] "
+          + "[ " + StartupOption.INIT.getName() + " [ "
+          + StartupOption.CLUSTERID.getName() + " <cid> ] ]\n "
+          + "hdfs scm [genericOptions] [ "
+          + StartupOption.GENCLUSTERID.getName() + " ]\n " +
+          "hdfs scm [ "
           + StartupOption.HELP.getName() + " ]\n";
   /**
    * Creates a new StorageContainerManager.  Configuration will be updated with
@@ -401,11 +405,21 @@ public class StorageContainerManager extends ServiceRuntimeInfoImpl
    * @throws IOException if startup fails due to I/O error
    */
   public static void main(String[] argv) throws IOException {
-    StringUtils.startupShutdownMessage(StorageContainerManager.class,
-        argv, LOG);
-    OzoneConfiguration conf = new OzoneConfiguration();
+    if (DFSUtil.parseHelpArgument(argv, USAGE,
+        System.out, true)) {
+      System.exit(0);
+    }
     try {
-      StorageContainerManager scm = createSCM(argv, conf);
+      OzoneConfiguration conf = new OzoneConfiguration();
+      GenericOptionsParser hParser = new GenericOptionsParser(conf, argv);
+      if (!hParser.isParseSuccessful()) {
+        System.err.println("USAGE: " + USAGE + "\n");
+        hParser.printGenericCommandUsage(System.err);
+        System.exit(1);
+      }
+      StringUtils.startupShutdownMessage(StorageContainerManager.class,
+          argv, LOG);
+      StorageContainerManager scm = createSCM(hParser.getRemainingArgs(), conf);
       if (scm != null) {
         scm.start();
         scm.join();

http://git-wip-us.apache.org/repos/asf/hadoop/blob/677673f0/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/scm/cli/SCMCLI.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/scm/cli/SCMCLI.java
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/scm/cli/SCMCLI.java
index b9bd89f..fb22d05 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/scm/cli/SCMCLI.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/scm/cli/SCMCLI.java
@@ -162,7 +162,7 @@ public class SCMCLI extends OzoneBaseCLI {
     HelpFormatter helpFormatter = new HelpFormatter();
     Options topLevelOptions = new Options();
     addTopLevelOptions(topLevelOptions);
-    helpFormatter.printHelp(CMD_WIDTH, "hdfs scm <commands> [<options>]",
+    helpFormatter.printHelp(CMD_WIDTH, "hdfs scmcli <commands> [<options>]",
         "where <commands> can be one of the following",
         topLevelOptions, "");
   }


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


Mime
View raw message