You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by ae...@apache.org on 2018/09/07 20:03:07 UTC

[2/3] hadoop git commit: HDDS-190. Improve shell error message for unrecognized option. Contributed by Elek, Marton.

http://git-wip-us.apache.org/repos/asf/hadoop/blob/fd792ce5/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/keys/PutKeyHandler.java
----------------------------------------------------------------------
diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/keys/PutKeyHandler.java b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/keys/PutKeyHandler.java
index c73307d..bea68f2 100644
--- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/keys/PutKeyHandler.java
+++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/keys/PutKeyHandler.java
@@ -18,86 +18,80 @@
 
 package org.apache.hadoop.ozone.web.ozShell.keys;
 
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.codec.digest.DigestUtils;
+import java.io.File;
+import java.io.FileInputStream;
+import java.net.URI;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hdds.client.ReplicationFactor;
+import org.apache.hadoop.hdds.client.ReplicationType;
 import org.apache.hadoop.hdds.conf.OzoneConfiguration;
 import org.apache.hadoop.io.IOUtils;
 import org.apache.hadoop.ozone.client.OzoneBucket;
+import org.apache.hadoop.ozone.client.OzoneClientException;
 import org.apache.hadoop.ozone.client.OzoneVolume;
-import org.apache.hadoop.hdds.client.ReplicationFactor;
-import org.apache.hadoop.hdds.client.ReplicationType;
 import org.apache.hadoop.ozone.client.io.OzoneOutputStream;
-import org.apache.hadoop.ozone.client.OzoneClientException;
-import org.apache.hadoop.ozone.client.rest.OzoneException;
 import org.apache.hadoop.ozone.web.ozShell.Handler;
 import org.apache.hadoop.ozone.web.ozShell.Shell;
 
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-
+import org.apache.commons.codec.digest.DigestUtils;
 import static org.apache.hadoop.hdds.scm.ScmConfigKeys.OZONE_SCM_CHUNK_SIZE_DEFAULT;
 import static org.apache.hadoop.hdds.scm.ScmConfigKeys.OZONE_SCM_CHUNK_SIZE_KEY;
 import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_REPLICATION;
 import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_REPLICATION_DEFAULT;
 import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_REPLICATION_TYPE;
 import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_REPLICATION_TYPE_DEFAULT;
+import picocli.CommandLine.Command;
+import picocli.CommandLine.Option;
+import picocli.CommandLine.Parameters;
 
 /**
  * Puts a file into an ozone bucket.
  */
+@Command(name = "-putKey",
+    description = "creates or overwrites an existing key")
 public class PutKeyHandler extends Handler {
-  private String volumeName;
-  private String bucketName;
-  private String keyName;
 
+  @Parameters(arity = "1..1", description = Shell.OZONE_KEY_URI_DESCRIPTION)
+  private String uri;
+
+  @Option(names = {"-f", "--file", "-file"},
+      description = "File to upload",
+      required = true)
+  private String fileName;
+
+  @Option(names = {"-r", "--replication", "-replicationFactor"},
+      description = "Replication factor of the new key. (use ONE or THREE) "
+          + "Default is specified in the cluster-wide config.")
+  private ReplicationFactor replicationFactor;
   /**
    * Executes the Client Calls.
-   *
-   * @param cmd - CommandLine
-   * @throws IOException
-   * @throws OzoneException
-   * @throws URISyntaxException
    */
   @Override
-  protected void execute(CommandLine cmd)
-      throws IOException, OzoneException, URISyntaxException {
-    if (!cmd.hasOption(Shell.PUT_KEY)) {
-      throw new OzoneClientException("Incorrect call : putKey is missing");
-    }
+  public Void call() throws Exception {
 
-    if (!cmd.hasOption(Shell.FILE)) {
-      throw new OzoneClientException("put key needs a file to put");
-    }
-
-    String ozoneURIString = cmd.getOptionValue(Shell.PUT_KEY);
-    URI ozoneURI = verifyURI(ozoneURIString);
+    URI ozoneURI = verifyURI(uri);
     Path path = Paths.get(ozoneURI.getPath());
     if (path.getNameCount() < 3) {
       throw new OzoneClientException(
           "volume/bucket/key name required in putKey");
     }
 
-    volumeName = path.getName(0).toString();
-    bucketName = path.getName(1).toString();
-    keyName = path.getName(2).toString();
-
+    String volumeName = path.getName(0).toString();
+    String bucketName = path.getName(1).toString();
+    String keyName = path.getName(2).toString();
 
-    if (cmd.hasOption(Shell.VERBOSE)) {
+    if (isVerbose()) {
       System.out.printf("Volume Name : %s%n", volumeName);
       System.out.printf("Bucket Name : %s%n", bucketName);
       System.out.printf("Key Name : %s%n", keyName);
     }
 
-    String fileName = cmd.getOptionValue(Shell.FILE);
     File dataFile = new File(fileName);
 
-    if (cmd.hasOption(Shell.VERBOSE)) {
+    if (isVerbose()) {
       FileInputStream stream = new FileInputStream(dataFile);
       String hash = DigestUtils.md5Hex(stream);
       System.out.printf("File Hash : %s%n", hash);
@@ -105,11 +99,7 @@ public class PutKeyHandler extends Handler {
     }
 
     Configuration conf = new OzoneConfiguration();
-    ReplicationFactor replicationFactor;
-    if (cmd.hasOption(Shell.REPLICATION_FACTOR)) {
-      replicationFactor = ReplicationFactor.valueOf(Integer.parseInt(cmd
-          .getOptionValue(Shell.REPLICATION_FACTOR)));
-    } else {
+    if (replicationFactor == null) {
       replicationFactor = ReplicationFactor.valueOf(
           conf.getInt(OZONE_REPLICATION, OZONE_REPLICATION_DEFAULT));
     }
@@ -126,6 +116,7 @@ public class PutKeyHandler extends Handler {
         conf.getInt(OZONE_SCM_CHUNK_SIZE_KEY, OZONE_SCM_CHUNK_SIZE_DEFAULT));
     outputStream.close();
     fileInputStream.close();
+    return null;
   }
 
 }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/fd792ce5/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/volume/CreateVolumeHandler.java
----------------------------------------------------------------------
diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/volume/CreateVolumeHandler.java b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/volume/CreateVolumeHandler.java
index 0057282..25e207a 100644
--- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/volume/CreateVolumeHandler.java
+++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/volume/CreateVolumeHandler.java
@@ -18,77 +18,72 @@
 
 package org.apache.hadoop.ozone.web.ozShell.volume;
 
-import org.apache.commons.cli.CommandLine;
+import picocli.CommandLine.Command;
+import picocli.CommandLine.Option;
+import picocli.CommandLine.Parameters;
+
 import org.apache.hadoop.ozone.client.OzoneClientUtils;
 import org.apache.hadoop.ozone.client.OzoneVolume;
 import org.apache.hadoop.ozone.client.VolumeArgs;
 import org.apache.hadoop.ozone.client.OzoneClientException;
-import org.apache.hadoop.ozone.client.rest.OzoneException;
 import org.apache.hadoop.ozone.web.ozShell.Handler;
 import org.apache.hadoop.ozone.web.ozShell.Shell;
 import org.apache.hadoop.ozone.web.utils.JsonUtils;
 
-import java.io.IOException;
 import java.net.URI;
-import java.net.URISyntaxException;
 
 /**
  * Executes the create volume call for the shell.
  */
+@Command(name = "-createVolume",
+    description = "Creates a volume for the specified user")
 public class CreateVolumeHandler extends Handler {
 
-  private String rootName;
+  @Parameters(arity = "1..1", description = Shell.OZONE_VOLUME_URI_DESCRIPTION)
+  private String uri;
+
+  @Option(names = {"--user", "-user"},
+      description = "Owner of of the volume", required =
+      true)
   private String userName;
-  private String volumeName;
+
+  @Option(names = {"--quota", "-quota"},
+      description =
+          "Quota of the newly created volume (eg. 1G)")
   private String quota;
 
+  @Option(names = {"--root", "-root"},
+      description = "Development flag to execute the "
+          + "command as the admin (hdfs) user.")
+  private boolean root;
+
   /**
    * Executes the Create Volume.
-   *
-   * @param cmd - CommandLine
-   * @throws IOException
-   * @throws OzoneException
-   * @throws URISyntaxException
    */
   @Override
-  protected void execute(CommandLine cmd)
-      throws IOException, OzoneException, URISyntaxException {
-    if (!cmd.hasOption(Shell.CREATE_VOLUME)) {
-      throw new OzoneClientException(
-          "Incorrect call : createVolume is missing");
-    }
+  public Void call() throws Exception {
 
-    String ozoneURIString = cmd.getOptionValue(Shell.CREATE_VOLUME);
-    URI ozoneURI = verifyURI(ozoneURIString);
+    URI ozoneURI = verifyURI(uri);
 
     // we need to skip the slash in the URI path
     // getPath returns /volumeName needs to remove the initial slash.
-    volumeName = ozoneURI.getPath().replaceAll("^/+", "");
+    String volumeName = ozoneURI.getPath().replaceAll("^/+", "");
     if (volumeName.isEmpty()) {
       throw new OzoneClientException(
           "Volume name is required to create a volume");
     }
 
-    if (cmd.hasOption(Shell.VERBOSE)) {
+    if (isVerbose()) {
       System.out.printf("Volume name : %s%n", volumeName);
     }
-    if (cmd.hasOption(Shell.RUNAS)) {
+
+    String rootName;
+    if (root) {
       rootName = "hdfs";
     } else {
       rootName = System.getProperty("user.name");
     }
 
-    if (!cmd.hasOption(Shell.USER)) {
-      throw new OzoneClientException(
-          "User name is needed in createVolume call.");
-    }
-
-    if (cmd.hasOption(Shell.QUOTA)) {
-      quota = cmd.getOptionValue(Shell.QUOTA);
-    }
-
-    userName = cmd.getOptionValue(Shell.USER);
-
     VolumeArgs.Builder volumeArgsBuilder = VolumeArgs.newBuilder()
         .setAdmin(rootName)
         .setOwner(userName);
@@ -97,11 +92,13 @@ public class CreateVolumeHandler extends Handler {
     }
     client.getObjectStore().createVolume(volumeName, volumeArgsBuilder.build());
 
-    if (cmd.hasOption(Shell.VERBOSE)) {
+    if (isVerbose()) {
       OzoneVolume vol = client.getObjectStore().getVolume(volumeName);
       System.out.printf("%s%n", JsonUtils.toJsonStringWithDefaultPrettyPrinter(
           JsonUtils.toJsonString(OzoneClientUtils.asVolumeInfo(vol))));
     }
+    return null;
   }
+
 }
 

http://git-wip-us.apache.org/repos/asf/hadoop/blob/fd792ce5/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/volume/DeleteVolumeHandler.java
----------------------------------------------------------------------
diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/volume/DeleteVolumeHandler.java b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/volume/DeleteVolumeHandler.java
index 2df788a..e6444e7 100644
--- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/volume/DeleteVolumeHandler.java
+++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/volume/DeleteVolumeHandler.java
@@ -18,55 +18,46 @@
 
 package org.apache.hadoop.ozone.web.ozShell.volume;
 
-import org.apache.commons.cli.CommandLine;
+import java.net.URI;
+
 import org.apache.hadoop.ozone.client.OzoneClientException;
-import org.apache.hadoop.ozone.client.rest.OzoneException;
 import org.apache.hadoop.ozone.web.ozShell.Handler;
 import org.apache.hadoop.ozone.web.ozShell.Shell;
 
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
+import picocli.CommandLine.Command;
+import picocli.CommandLine.Parameters;
 
 /**
  * Executes deleteVolume call for the shell.
  */
+@Command(name = "-deleteVolume",
+    description = "deletes a volume if it is empty")
 public class DeleteVolumeHandler extends Handler {
 
-  private String volumeName;
+  @Parameters(arity = "1..1", description = Shell.OZONE_VOLUME_URI_DESCRIPTION)
+  private String uri;
 
   /**
    * Executes the delete volume call.
-   *
-   * @param cmd - CommandLine
-   * @throws IOException
-   * @throws OzoneException
-   * @throws URISyntaxException
    */
   @Override
-  protected void execute(CommandLine cmd)
-      throws IOException, OzoneException, URISyntaxException {
-
-    if (!cmd.hasOption(Shell.DELETE_VOLUME)) {
-      throw new OzoneClientException(
-          "Incorrect call : deleteVolume call is missing");
-    }
+  public Void call() throws Exception {
 
-    String ozoneURIString = cmd.getOptionValue(Shell.DELETE_VOLUME);
-    URI ozoneURI = verifyURI(ozoneURIString);
+    URI ozoneURI = verifyURI(uri);
     if (ozoneURI.getPath().isEmpty()) {
       throw new OzoneClientException(
           "Volume name is required to delete a volume");
     }
 
     // we need to skip the slash in the URI path
-    volumeName = ozoneURI.getPath().substring(1);
+    String volumeName = ozoneURI.getPath().substring(1);
 
-    if (cmd.hasOption(Shell.VERBOSE)) {
+    if (isVerbose()) {
       System.out.printf("Volume name : %s%n", volumeName);
     }
 
     client.getObjectStore().deleteVolume(volumeName);
     System.out.printf("Volume %s is deleted%n", volumeName);
+    return null;
   }
 }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/fd792ce5/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/volume/InfoVolumeHandler.java
----------------------------------------------------------------------
diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/volume/InfoVolumeHandler.java b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/volume/InfoVolumeHandler.java
index b5be2c6..9ee3dce 100644
--- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/volume/InfoVolumeHandler.java
+++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/volume/InfoVolumeHandler.java
@@ -18,56 +18,47 @@
 
 package org.apache.hadoop.ozone.web.ozShell.volume;
 
-import org.apache.commons.cli.CommandLine;
+import java.net.URI;
+
+import org.apache.hadoop.ozone.client.OzoneClientException;
 import org.apache.hadoop.ozone.client.OzoneClientUtils;
 import org.apache.hadoop.ozone.client.OzoneVolume;
-import org.apache.hadoop.ozone.client.OzoneClientException;
-import org.apache.hadoop.ozone.client.rest.OzoneException;
 import org.apache.hadoop.ozone.web.ozShell.Handler;
 import org.apache.hadoop.ozone.web.ozShell.Shell;
 import org.apache.hadoop.ozone.web.utils.JsonUtils;
 
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
+import picocli.CommandLine.Command;
+import picocli.CommandLine.Parameters;
 
 /**
  * Executes volume Info calls.
  */
+@Command(name = "-infoVolume",
+    description = "returns information about a specific volume")
 public class InfoVolumeHandler extends Handler{
 
-  private String volumeName;
+  @Parameters(arity = "1..1", description = Shell.OZONE_VOLUME_URI_DESCRIPTION)
+  private String uri;
 
   /**
    * Executes volume Info.
-   *
-   * @param cmd - CommandLine
-   *
-   * @throws IOException
-   * @throws OzoneException
-   * @throws URISyntaxException
    */
   @Override
-  protected void execute(CommandLine cmd)
-      throws IOException, OzoneException, URISyntaxException {
+  public Void call() throws Exception {
 
-    if (!cmd.hasOption(Shell.INFO_VOLUME)) {
-      throw new OzoneClientException(
-          "Incorrect call : infoVolume is missing");
-    }
-
-    String ozoneURIString = cmd.getOptionValue(Shell.INFO_VOLUME);
-    URI ozoneURI = verifyURI(ozoneURIString);
+    URI ozoneURI = verifyURI(uri);
     if (ozoneURI.getPath().isEmpty()) {
       throw new OzoneClientException(
           "Volume name is required to get info of a volume");
     }
 
     // we need to skip the slash in the URI path
-    volumeName = ozoneURI.getPath().substring(1);
+    String volumeName = ozoneURI.getPath().substring(1);
 
     OzoneVolume vol = client.getObjectStore().getVolume(volumeName);
     System.out.printf("%s%n", JsonUtils.toJsonStringWithDefaultPrettyPrinter(
         JsonUtils.toJsonString(OzoneClientUtils.asVolumeInfo(vol))));
+    return null;
   }
+
 }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/fd792ce5/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/volume/ListVolumeHandler.java
----------------------------------------------------------------------
diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/volume/ListVolumeHandler.java b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/volume/ListVolumeHandler.java
index 85b7b2b..058ef2e 100644
--- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/volume/ListVolumeHandler.java
+++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/volume/ListVolumeHandler.java
@@ -19,20 +19,19 @@
 package org.apache.hadoop.ozone.web.ozShell.volume;
 
 import com.google.common.base.Strings;
-import org.apache.commons.cli.CommandLine;
+import picocli.CommandLine.Command;
+import picocli.CommandLine.Option;
+import picocli.CommandLine.Parameters;
+
 import org.apache.hadoop.ozone.client.OzoneClientUtils;
 import org.apache.hadoop.ozone.client.OzoneVolume;
 import org.apache.hadoop.ozone.client.rest.response.VolumeInfo;
 import org.apache.hadoop.ozone.client.OzoneClientException;
-import org.apache.hadoop.ozone.client.rest.OzoneException;
 import org.apache.hadoop.ozone.web.ozShell.Handler;
 import org.apache.hadoop.ozone.web.ozShell.Shell;
 import org.apache.hadoop.ozone.web.utils.JsonUtils;
-import org.apache.hadoop.ozone.web.utils.OzoneUtils;
 
-import java.io.IOException;
 import java.net.URI;
-import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -40,49 +39,39 @@ import java.util.List;
 /**
  * Executes List Volume call.
  */
+@Command(name = "-listVolume",
+    description = "List the volumes of a given user")
 public class ListVolumeHandler extends Handler {
-  private String userName;
 
-  /**
-   * Executes the Client Calls.
-   *
-   * @param cmd - CommandLine
-   * @throws IOException
-   * @throws OzoneException
-   * @throws URISyntaxException
-   */
-  @Override
-  protected void execute(CommandLine cmd)
-      throws IOException, OzoneException, URISyntaxException {
+  @Parameters(arity = "1..1",
+      description = Shell.OZONE_VOLUME_URI_DESCRIPTION,
+      defaultValue = "/")
+  private String uri;
 
-    if (!cmd.hasOption(Shell.LIST_VOLUME)) {
-      throw new OzoneClientException(
-          "Incorrect call : listVolume is missing");
-    }
+  @Option(names = {"--length", "-length", "-l"},
+      description = "Limit of the max results",
+      defaultValue = "100")
+  private int maxVolumes;
 
-    int maxVolumes = Integer.MAX_VALUE;
-    if (cmd.hasOption(Shell.LIST_LENGTH)) {
-      String length = cmd.getOptionValue(Shell.LIST_LENGTH);
-      OzoneUtils.verifyMaxKeyLength(length);
+  @Option(names = {"--start", "-start", "-s"},
+      description = "The first volume to start the listing")
+  private String startVolume;
 
-      maxVolumes = Integer.parseInt(length);
-    }
+  @Option(names = {"--prefix", "-prefix", "-p"},
+      description = "Prefix to filter the volumes")
+  private String prefix;
 
-    String startVolume = null;
-    if (cmd.hasOption(Shell.START)) {
-      startVolume = cmd.getOptionValue(Shell.START);
-    }
+  @Option(names = {"--user", "-user", "-u"},
+      description = "Owner of the volumes to list.")
+  private String userName;
 
-    String prefix = null;
-    if (cmd.hasOption(Shell.PREFIX)) {
-      prefix = cmd.getOptionValue(Shell.PREFIX);
-    }
+  /**
+   * Executes the Client Calls.
+   */
+  @Override
+  public Void call() throws Exception {
 
-    String ozoneURIString = cmd.getOptionValue(Shell.LIST_VOLUME);
-    if (Strings.isNullOrEmpty(ozoneURIString)) {
-      ozoneURIString = "/";
-    }
-    URI ozoneURI = verifyURI(ozoneURIString);
+    URI ozoneURI = verifyURI(uri);
     if (!Strings.isNullOrEmpty(ozoneURI.getPath()) && !ozoneURI.getPath()
         .equals("/")) {
       throw new OzoneClientException(
@@ -90,12 +79,15 @@ public class ListVolumeHandler extends Handler {
               .getPath());
     }
 
-    if (cmd.hasOption(Shell.USER)) {
-      userName = cmd.getOptionValue(Shell.USER);
-    } else {
+    if (userName == null) {
       userName = System.getProperty("user.name");
     }
 
+    if (maxVolumes < 1) {
+      throw new IllegalArgumentException(
+          "the length should be a positive number");
+    }
+
     Iterator<OzoneVolume> volumeIterator;
     if(userName != null) {
       volumeIterator = client.getObjectStore()
@@ -112,12 +104,13 @@ public class ListVolumeHandler extends Handler {
       maxVolumes -= 1;
     }
 
-    if (cmd.hasOption(Shell.VERBOSE)) {
+    if (isVerbose()) {
       System.out.printf("Found : %d volumes for user : %s ", volumeInfos.size(),
           userName);
     }
     System.out.println(JsonUtils.toJsonStringWithDefaultPrettyPrinter(
         JsonUtils.toJsonString(volumeInfos)));
+    return null;
   }
 }
 

http://git-wip-us.apache.org/repos/asf/hadoop/blob/fd792ce5/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/volume/UpdateVolumeHandler.java
----------------------------------------------------------------------
diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/volume/UpdateVolumeHandler.java b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/volume/UpdateVolumeHandler.java
index 3738cb4..aa692bd 100644
--- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/volume/UpdateVolumeHandler.java
+++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/volume/UpdateVolumeHandler.java
@@ -18,61 +18,53 @@
 
 package org.apache.hadoop.ozone.web.ozShell.volume;
 
-import org.apache.commons.cli.CommandLine;
+import picocli.CommandLine.Command;
+import picocli.CommandLine.Option;
+import picocli.CommandLine.Parameters;
+
 import org.apache.hadoop.hdds.client.OzoneQuota;
 import org.apache.hadoop.ozone.client.OzoneVolume;
 import org.apache.hadoop.ozone.client.OzoneClientUtils;
 import org.apache.hadoop.ozone.client.OzoneClientException;
-import org.apache.hadoop.ozone.client.rest.OzoneException;
 import org.apache.hadoop.ozone.web.ozShell.Handler;
 import org.apache.hadoop.ozone.web.ozShell.Shell;
 import org.apache.hadoop.ozone.web.utils.JsonUtils;
 
-import java.io.IOException;
 import java.net.URI;
-import java.net.URISyntaxException;
 
 /**
  * Executes update volume calls.
  */
+@Command(name = "-updateVolume",
+    description = "Updates parameter of the volumes")
 public class UpdateVolumeHandler extends Handler {
+
+  @Parameters(arity = "1..1", description = Shell.OZONE_VOLUME_URI_DESCRIPTION)
+  private String uri;
+
+  @Option(names = {"--user", "-user"},
+      description = "Owner of the volume to set")
   private String ownerName;
-  private String volumeName;
+
+  @Option(names = {"--quota", "-quota"},
+      description = "Quota of the volume to set"
+          + "(eg. 1G)")
   private String quota;
 
   /**
-   * Executes update volume calls.
-   *
-   * @param cmd - CommandLine
-   * @throws IOException
-   * @throws OzoneException
-   * @throws URISyntaxException
+   * Executes the Client Calls.
    */
   @Override
-  protected void execute(CommandLine cmd)
-      throws IOException, OzoneException, URISyntaxException {
-    if (!cmd.hasOption(Shell.UPDATE_VOLUME)) {
-      throw new OzoneClientException(
-          "Incorrect call : updateVolume is missing");
-    }
+  public Void call() throws Exception {
 
-    String ozoneURIString = cmd.getOptionValue(Shell.UPDATE_VOLUME);
-    URI ozoneURI = verifyURI(ozoneURIString);
+    URI ozoneURI = verifyURI(uri);
     if (ozoneURI.getPath().isEmpty()) {
       throw new OzoneClientException(
           "Volume name is required to update a volume");
     }
 
     // we need to skip the slash in the URI path
-    volumeName = ozoneURI.getPath().substring(1);
-
-    if (cmd.hasOption(Shell.QUOTA)) {
-      quota = cmd.getOptionValue(Shell.QUOTA);
-    }
-
-    if (cmd.hasOption(Shell.USER)) {
-      ownerName = cmd.getOptionValue(Shell.USER);
-    }
+    String volumeName = ozoneURI.getPath().substring(1);
 
     OzoneVolume volume = client.getObjectStore().getVolume(volumeName);
     if (quota != null && !quota.isEmpty()) {
@@ -85,5 +77,6 @@ public class UpdateVolumeHandler extends Handler {
 
     System.out.printf("%s%n", JsonUtils.toJsonStringWithDefaultPrettyPrinter(
         JsonUtils.toJsonString(OzoneClientUtils.asVolumeInfo(volume))));
+    return null;
   }
 }


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