diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/scm/cli/container/CreateContainerHandler.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/scm/cli/container/CreateContainerHandler.java index 9e5cc1a49a3..b68d872054b 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/scm/cli/container/CreateContainerHandler.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/scm/cli/container/CreateContainerHandler.java @@ -35,7 +35,9 @@ import static org.apache.hadoop.ozone.scm.cli.SCMCLI.HELP_OP; public class CreateContainerHandler extends OzoneCommandHandler { public static final String CONTAINER_CREATE = "create"; - public static final String PIPELINE_ID = "p"; + public static final String OPT_CONTAINER_NAME = "c"; + // TODO Support an optional -p option to create + // container on given datanodes. public CreateContainerHandler(ScmClient scmClient) { super(scmClient); @@ -46,25 +48,23 @@ public class CreateContainerHandler extends OzoneCommandHandler { if (!cmd.hasOption(CONTAINER_CREATE)) { throw new IOException("Expecting container create"); } - // TODO requires pipeline id (instead of optional as in the design) for now - if (!cmd.hasOption(PIPELINE_ID)) { + if (!cmd.hasOption(OPT_CONTAINER_NAME)) { displayHelp(); if (!cmd.hasOption(HELP_OP)) { - throw new IOException("Expecting container ID"); + throw new IOException("Expecting container name"); } else { return; } } - String pipelineID = cmd.getOptionValue(PIPELINE_ID); + String containerName = cmd.getOptionValue(OPT_CONTAINER_NAME); - logOut("Creating container : %s.", pipelineID); - getScmClient().createContainer(pipelineID); + logOut("Creating container : %s.", containerName); + getScmClient().createContainer(containerName); logOut("Container created."); } @Override public void displayHelp() { - // TODO : may need to change this if we decide to make -p optional later Options options = new Options(); addOptions(options); HelpFormatter helpFormatter = new HelpFormatter(); @@ -73,7 +73,8 @@ public class CreateContainerHandler extends OzoneCommandHandler { } public static void addOptions(Options options) { - Option pipelineID = new Option(PIPELINE_ID, true, "Specify pipeline ID"); - options.addOption(pipelineID); + Option containerNameOpt = new Option(OPT_CONTAINER_NAME, + true, "Specify container name"); + options.addOption(containerNameOpt); } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/scm/TestSCMCli.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/scm/TestSCMCli.java index b8ebec11964..ec586773c82 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/scm/TestSCMCli.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/scm/TestSCMCli.java @@ -113,9 +113,8 @@ public class TestSCMCli { assertTrue(ioe.getMessage().contains( "Specified key does not exist. key : " + containerName)); } - String[] args = {"-container", "-create", "-p", containerName}; + String[] args = {"-container", "-create", "-c", containerName}; assertEquals(ResultCode.SUCCESS, cli.run(args)); - Thread.sleep(3000); Pipeline container = scm.getContainer(containerName); assertNotNull(container); assertEquals(containerName, container.getContainerName()); @@ -226,7 +225,7 @@ public class TestSCMCli { String expected2 = "usage: hdfs scm -container -create