diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/scm/cli/container/ContainerCommandHandler.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/scm/cli/container/ContainerCommandHandler.java index f4e428ea83..822c8b51d9 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/scm/cli/container/ContainerCommandHandler.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/scm/cli/container/ContainerCommandHandler.java @@ -92,9 +92,9 @@ private static void addCommandsOption(Options options) { Option createContainer = new Option(CONTAINER_CREATE, false, "Create container"); Option infoContainer = - new Option(CONTAINER_INFO, true, "Info container"); + new Option(CONTAINER_INFO, false, "Info container"); Option deleteContainer = - new Option(CONTAINER_DELETE, true, "Delete container"); + new Option(CONTAINER_DELETE, false, "Delete container"); options.addOption(createContainer); options.addOption(deleteContainer); @@ -107,6 +107,7 @@ public static void addOptions(Options options) { // for create container options. CreateContainerHandler.addOptions(options); DeleteContainerHandler.addOptions(options); + InfoContainerHandler.addOptions(options); // TODO : add other options such as delete, close etc. } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/scm/cli/container/DeleteContainerHandler.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/scm/cli/container/DeleteContainerHandler.java index fc83e05001..0782af3b04 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/scm/cli/container/DeleteContainerHandler.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/scm/cli/container/DeleteContainerHandler.java @@ -30,14 +30,16 @@ import java.io.IOException; import static org.apache.hadoop.ozone.scm.cli.SCMCLI.CMD_WIDTH; +import static org.apache.hadoop.ozone.scm.cli.SCMCLI.HELP_OP; /** * This is the handler that process delete container command. */ public class DeleteContainerHandler extends OzoneCommandHandler { - protected static final String CONTAINER_DELETE = "del"; + protected static final String CONTAINER_DELETE = "delete"; protected static final String OPT_FORCE = "f"; + protected static final String OPT_CONTAINER_NAME = "c"; public DeleteContainerHandler(ScmClient scmClient) { super(scmClient); @@ -46,9 +48,17 @@ public DeleteContainerHandler(ScmClient scmClient) { @Override public void execute(CommandLine cmd) throws IOException { Preconditions.checkArgument(cmd.hasOption(CONTAINER_DELETE), - "Expecting command del"); + "Expecting command delete"); + if (!cmd.hasOption(OPT_CONTAINER_NAME)) { + displayHelp(); + if (!cmd.hasOption(HELP_OP)) { + throw new IOException("Expecting container name"); + } else { + return; + } + } - String containerName = cmd.getOptionValue(CONTAINER_DELETE); + String containerName = cmd.getOptionValue(OPT_CONTAINER_NAME); Pipeline pipeline = getScmClient().getContainer(containerName); if (pipeline == null) { @@ -61,11 +71,12 @@ public void execute(CommandLine cmd) throws IOException { logOut("Container %s deleted.", containerName); } - @Override public void displayHelp() { + @Override + public void displayHelp() { Options options = new Options(); addOptions(options); HelpFormatter helpFormatter = new HelpFormatter(); - helpFormatter.printHelp(CMD_WIDTH, "hdfs scm -container -del