hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aengin...@apache.org
Subject [1/2] hadoop git commit: HDDS-18. Ozone Shell should use RestClient and RpcClient. Contributed by Lokesh Jain.
Date Thu, 10 May 2018 06:00:30 GMT
Repository: hadoop
Updated Branches:
  refs/heads/trunk 3c95ca4f2 -> 46e0f2786


http://git-wip-us.apache.org/repos/asf/hadoop/blob/46e0f278/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/bucket/DeleteBucketHandler.java
----------------------------------------------------------------------
diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/bucket/DeleteBucketHandler.java b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/bucket/DeleteBucketHandler.java
index 181f6cc..5fc443e 100644
--- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/bucket/DeleteBucketHandler.java
+++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/bucket/DeleteBucketHandler.java
@@ -19,8 +19,8 @@
 package org.apache.hadoop.ozone.web.ozShell.bucket;
 
 import org.apache.commons.cli.CommandLine;
-import org.apache.hadoop.ozone.web.client.OzoneRestClientException;
-import org.apache.hadoop.ozone.web.client.OzoneVolume;
+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;
@@ -37,7 +37,6 @@ import java.nio.file.Paths;
 public class DeleteBucketHandler extends Handler {
   private String volumeName;
   private String bucketName;
-  private String rootName;
 
   /**
    * Executes the Client Calls.
@@ -52,7 +51,7 @@ public class DeleteBucketHandler extends Handler {
   protected void execute(CommandLine cmd)
       throws IOException, OzoneException, URISyntaxException {
     if (!cmd.hasOption(Shell.DELETE_BUCKET)) {
-      throw new OzoneRestClientException(
+      throw new OzoneClientException(
           "Incorrect call : deleteBucket is missing");
     }
 
@@ -60,7 +59,7 @@ public class DeleteBucketHandler extends Handler {
     URI ozoneURI = verifyURI(ozoneURIString);
     Path path = Paths.get(ozoneURI.getPath());
     if (path.getNameCount() < 2) {
-      throw new OzoneRestClientException(
+      throw new OzoneClientException(
           "volume and bucket name required in delete Bucket");
     }
 
@@ -72,16 +71,7 @@ public class DeleteBucketHandler extends Handler {
       System.out.printf("Bucket Name : %s%n", bucketName);
     }
 
-    if (cmd.hasOption(Shell.RUNAS)) {
-      rootName = "hdfs";
-    } else {
-      rootName = System.getProperty("user.name");
-    }
-
-    client.setEndPointURI(ozoneURI);
-    client.setUserAuth(rootName);
-
-    OzoneVolume vol = client.getVolume(volumeName);
+    OzoneVolume vol = client.getObjectStore().getVolume(volumeName);
     vol.deleteBucket(bucketName);
   }
 }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/46e0f278/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/bucket/InfoBucketHandler.java
----------------------------------------------------------------------
diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/bucket/InfoBucketHandler.java b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/bucket/InfoBucketHandler.java
index 321c4c2..b3ca4e5 100644
--- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/bucket/InfoBucketHandler.java
+++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/bucket/InfoBucketHandler.java
@@ -19,9 +19,10 @@ package org.apache.hadoop.ozone.web.ozShell.bucket;
 
 
 import org.apache.commons.cli.CommandLine;
-import org.apache.hadoop.ozone.web.client.OzoneBucket;
-import org.apache.hadoop.ozone.web.client.OzoneRestClientException;
-import org.apache.hadoop.ozone.web.client.OzoneVolume;
+import org.apache.hadoop.ozone.client.OzoneBucket;
+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;
@@ -39,7 +40,6 @@ import java.nio.file.Paths;
 public class InfoBucketHandler extends Handler {
   private String volumeName;
   private String bucketName;
-  private String rootName;
 
   /**
    * Executes the Client Calls.
@@ -54,7 +54,7 @@ public class InfoBucketHandler extends Handler {
   protected void execute(CommandLine cmd)
       throws IOException, OzoneException, URISyntaxException {
     if (!cmd.hasOption(Shell.INFO_BUCKET)) {
-      throw new OzoneRestClientException(
+      throw new OzoneClientException(
           "Incorrect call : infoBucket is missing");
     }
 
@@ -63,7 +63,7 @@ public class InfoBucketHandler extends Handler {
     Path path = Paths.get(ozoneURI.getPath());
 
     if (path.getNameCount() < 2) {
-      throw new OzoneRestClientException(
+      throw new OzoneClientException(
           "volume and bucket name required in info Bucket");
     }
 
@@ -75,20 +75,11 @@ public class InfoBucketHandler extends Handler {
       System.out.printf("Bucket Name : %s%n", bucketName);
     }
 
-    if (cmd.hasOption(Shell.RUNAS)) {
-      rootName = "hdfs";
-    } else {
-      rootName = System.getProperty("user.name");
-    }
-
-    client.setEndPointURI(ozoneURI);
-    client.setUserAuth(rootName);
-
-    OzoneVolume vol = client.getVolume(volumeName);
+    OzoneVolume vol = client.getObjectStore().getVolume(volumeName);
     OzoneBucket bucket = vol.getBucket(bucketName);
 
     System.out.printf("%s%n", JsonUtils.toJsonStringWithDefaultPrettyPrinter(
-        bucket.getBucketInfo().toJsonString()));
+        JsonUtils.toJsonString(OzoneClientUtils.asBucketInfo(bucket))));
   }
 
 }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/46e0f278/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/bucket/ListBucketHandler.java
----------------------------------------------------------------------
diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/bucket/ListBucketHandler.java b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/bucket/ListBucketHandler.java
index ea77cae..655022a 100644
--- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/bucket/ListBucketHandler.java
+++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/bucket/ListBucketHandler.java
@@ -19,13 +19,14 @@
 package org.apache.hadoop.ozone.web.ozShell.bucket;
 
 import org.apache.commons.cli.CommandLine;
-import org.apache.hadoop.ozone.web.client.OzoneBucket;
-import org.apache.hadoop.ozone.web.client.OzoneRestClientException;
-import org.apache.hadoop.ozone.web.client.OzoneVolume;
+import org.apache.hadoop.ozone.client.OzoneBucket;
+import org.apache.hadoop.ozone.client.OzoneClientUtils;
+import org.apache.hadoop.ozone.client.OzoneVolume;
+import org.apache.hadoop.ozone.client.rest.response.BucketInfo;
+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.response.BucketInfo;
 import org.apache.hadoop.ozone.web.utils.JsonUtils;
 import org.apache.hadoop.ozone.web.utils.OzoneUtils;
 
@@ -34,15 +35,15 @@ import java.net.URI;
 import java.net.URISyntaxException;
 import java.nio.file.Path;
 import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Iterator;
 import java.util.List;
-import java.util.stream.Collectors;
 
 /**
  * Executes List Bucket.
  */
 public class ListBucketHandler extends Handler {
   private String volumeName;
-  private String rootName;
 
   /**
    * Executes the Client Calls.
@@ -57,7 +58,7 @@ public class ListBucketHandler extends Handler {
   protected void execute(CommandLine cmd)
       throws IOException, OzoneException, URISyntaxException {
     if (!cmd.hasOption(Shell.LIST_BUCKET)) {
-      throw new OzoneRestClientException(
+      throw new OzoneClientException(
           "Incorrect call : listBucket is missing");
     }
 
@@ -65,30 +66,20 @@ public class ListBucketHandler extends Handler {
     URI ozoneURI = verifyURI(ozoneURIString);
     Path path = Paths.get(ozoneURI.getPath());
     if (path.getNameCount() < 1) {
-      throw new OzoneRestClientException("volume is required in listBucket");
+      throw new OzoneClientException("volume is required in listBucket");
     }
 
     volumeName = path.getName(0).toString();
 
-
     if (cmd.hasOption(Shell.VERBOSE)) {
       System.out.printf("Volume Name : %s%n", volumeName);
     }
 
-    if (cmd.hasOption(Shell.RUNAS)) {
-      rootName = "hdfs";
-    } else {
-      rootName = System.getProperty("user.name");
-    }
-
-
-    client.setEndPointURI(ozoneURI);
-    client.setUserAuth(rootName);
-
-    String length = null;
+    int maxBuckets = Integer.MAX_VALUE;
     if (cmd.hasOption(Shell.LIST_LENGTH)) {
-      length = cmd.getOptionValue(Shell.LIST_LENGTH);
+      String length = cmd.getOptionValue(Shell.LIST_LENGTH);
       OzoneUtils.verifyMaxKeyLength(length);
+      maxBuckets = Integer.parseInt(length);
     }
 
     String startBucket = null;
@@ -101,13 +92,21 @@ public class ListBucketHandler extends Handler {
       prefix = cmd.getOptionValue(Shell.PREFIX);
     }
 
-    OzoneVolume vol = client.getVolume(volumeName);
-    List<OzoneBucket> bucketList = vol.listBuckets(length, startBucket, prefix);
+    OzoneVolume vol = client.getObjectStore().getVolume(volumeName);
+    Iterator<OzoneBucket> bucketIterator = vol.listBuckets(prefix, startBucket);
+    List<BucketInfo> bucketList = new ArrayList<>();
+    while (maxBuckets > 0 && bucketIterator.hasNext()) {
+      BucketInfo bucketInfo = OzoneClientUtils.asBucketInfo(bucketIterator.next());
+      bucketList.add(bucketInfo);
+      maxBuckets -= 1;
+    }
 
-    List<BucketInfo> jsonData = bucketList.stream()
-        .map(OzoneBucket::getBucketInfo).collect(Collectors.toList());
+    if (cmd.hasOption(Shell.VERBOSE)) {
+      System.out.printf("Found : %d buckets for volume : %s ",
+          bucketList.size(), volumeName);
+    }
     System.out.println(JsonUtils.toJsonStringWithDefaultPrettyPrinter(
-        JsonUtils.toJsonString(jsonData)));
+        JsonUtils.toJsonString(bucketList)));
   }
 }
 

http://git-wip-us.apache.org/repos/asf/hadoop/blob/46e0f278/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/bucket/UpdateBucketHandler.java
----------------------------------------------------------------------
diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/bucket/UpdateBucketHandler.java b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/bucket/UpdateBucketHandler.java
index 781a00c..aff0e19 100644
--- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/bucket/UpdateBucketHandler.java
+++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/bucket/UpdateBucketHandler.java
@@ -18,9 +18,11 @@
 package org.apache.hadoop.ozone.web.ozShell.bucket;
 
 import org.apache.commons.cli.CommandLine;
-import org.apache.hadoop.ozone.web.client.OzoneBucket;
-import org.apache.hadoop.ozone.web.client.OzoneRestClientException;
-import org.apache.hadoop.ozone.web.client.OzoneVolume;
+import org.apache.hadoop.ozone.OzoneAcl;
+import org.apache.hadoop.ozone.client.OzoneBucket;
+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;
@@ -31,6 +33,9 @@ import java.net.URI;
 import java.net.URISyntaxException;
 import java.nio.file.Path;
 import java.nio.file.Paths;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * Allows users to add and remove acls and from a bucket.
@@ -38,13 +43,12 @@ import java.nio.file.Paths;
 public class UpdateBucketHandler extends Handler {
   private String volumeName;
   private String bucketName;
-  private String rootName;
 
   @Override
   protected void execute(CommandLine cmd)
       throws IOException, OzoneException, URISyntaxException {
     if (!cmd.hasOption(Shell.UPDATE_BUCKET)) {
-      throw new OzoneRestClientException(
+      throw new OzoneClientException(
           "Incorrect call : updateBucket is missing");
     }
 
@@ -53,7 +57,7 @@ public class UpdateBucketHandler extends Handler {
     Path path = Paths.get(ozoneURI.getPath());
 
     if (path.getNameCount() < 2) {
-      throw new OzoneRestClientException(
+      throw new OzoneClientException(
           "volume and bucket name required in update bucket");
     }
 
@@ -65,30 +69,27 @@ public class UpdateBucketHandler extends Handler {
       System.out.printf("Bucket Name : %s%n", bucketName);
     }
 
-    if (cmd.hasOption(Shell.RUNAS)) {
-      rootName = "hdfs";
-    } else {
-      rootName = System.getProperty("user.name");
-    }
-
-    client.setEndPointURI(ozoneURI);
-    client.setUserAuth(rootName);
-
-    OzoneVolume vol = client.getVolume(volumeName);
+    OzoneVolume vol = client.getObjectStore().getVolume(volumeName);
+    OzoneBucket bucket = vol.getBucket(bucketName);
     if (cmd.hasOption(Shell.ADD_ACLS)) {
       String aclString = cmd.getOptionValue(Shell.ADD_ACLS);
       String[] aclArray = aclString.split(",");
-      vol.addAcls(bucketName, aclArray);
+      List<OzoneAcl> aclList =
+          Arrays.stream(aclArray).map(acl -> OzoneAcl.parseAcl(acl))
+              .collect(Collectors.toList());
+      bucket.addAcls(aclList);
     }
 
     if (cmd.hasOption(Shell.REMOVE_ACLS)) {
       String aclString = cmd.getOptionValue(Shell.REMOVE_ACLS);
       String[] aclArray = aclString.split(",");
-      vol.removeAcls(bucketName, aclArray);
+      List<OzoneAcl> aclList =
+          Arrays.stream(aclArray).map(acl -> OzoneAcl.parseAcl(acl))
+              .collect(Collectors.toList());
+      bucket.removeAcls(aclList);
     }
 
-    OzoneBucket bucket = vol.getBucket(bucketName);
     System.out.printf("%s%n", JsonUtils.toJsonStringWithDefaultPrettyPrinter(
-        bucket.getBucketInfo().toJsonString()));
+        JsonUtils.toJsonString(OzoneClientUtils.asBucketInfo(bucket))));
   }
 }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/46e0f278/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/keys/DeleteKeyHandler.java
----------------------------------------------------------------------
diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/keys/DeleteKeyHandler.java b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/keys/DeleteKeyHandler.java
index 1ad2588..fccabe7 100644
--- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/keys/DeleteKeyHandler.java
+++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/keys/DeleteKeyHandler.java
@@ -19,9 +19,9 @@
 package org.apache.hadoop.ozone.web.ozShell.keys;
 
 import org.apache.commons.cli.CommandLine;
-import org.apache.hadoop.ozone.web.client.OzoneBucket;
-import org.apache.hadoop.ozone.web.client.OzoneRestClientException;
-import org.apache.hadoop.ozone.web.client.OzoneVolume;
+import org.apache.hadoop.ozone.client.OzoneBucket;
+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;
@@ -36,7 +36,6 @@ import java.nio.file.Paths;
  * Executes Delete Key.
  */
 public class DeleteKeyHandler extends Handler {
-  private String userName;
   private String volumeName;
   private String bucketName;
   private String keyName;
@@ -53,23 +52,15 @@ public class DeleteKeyHandler extends Handler {
   protected void execute(CommandLine cmd)
       throws IOException, OzoneException, URISyntaxException {
     if (!cmd.hasOption(Shell.DELETE_KEY)) {
-      throw new OzoneRestClientException(
+      throw new OzoneClientException(
           "Incorrect call : deleteKey is missing");
     }
 
-
-    if (cmd.hasOption(Shell.USER)) {
-      userName = cmd.getOptionValue(Shell.USER);
-    } else {
-      userName = System.getProperty("user.name");
-    }
-
-
     String ozoneURIString = cmd.getOptionValue(Shell.DELETE_KEY);
     URI ozoneURI = verifyURI(ozoneURIString);
     Path path = Paths.get(ozoneURI.getPath());
     if (path.getNameCount() < 3) {
-      throw new OzoneRestClientException(
+      throw new OzoneClientException(
           "volume/bucket/key name required in deleteKey");
     }
 
@@ -84,13 +75,8 @@ public class DeleteKeyHandler extends Handler {
       System.out.printf("Key Name : %s%n", keyName);
     }
 
-    client.setEndPointURI(ozoneURI);
-    client.setUserAuth(userName);
-
-
-    OzoneVolume vol = client.getVolume(volumeName);
+    OzoneVolume vol = client.getObjectStore().getVolume(volumeName);
     OzoneBucket bucket = vol.getBucket(bucketName);
     bucket.deleteKey(keyName);
-
   }
 }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/46e0f278/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/keys/GetKeyHandler.java
----------------------------------------------------------------------
diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/keys/GetKeyHandler.java b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/keys/GetKeyHandler.java
index a56bbc0..34620b4 100644
--- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/keys/GetKeyHandler.java
+++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/keys/GetKeyHandler.java
@@ -20,24 +20,34 @@ package org.apache.hadoop.ozone.web.ozShell.keys;
 
 import org.apache.commons.cli.CommandLine;
 import org.apache.commons.codec.digest.DigestUtils;
-import org.apache.hadoop.ozone.web.client.OzoneRestClientException;
+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.OzoneVolume;
+import org.apache.hadoop.ozone.client.io.OzoneInputStream;
+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.FileOutputStream;
 import java.io.IOException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 
+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;
+
 /**
  * Gets an existing key.
  */
 public class GetKeyHandler extends Handler {
-  private String userName;
   private String volumeName;
   private String bucketName;
   private String keyName;
@@ -56,26 +66,19 @@ public class GetKeyHandler extends Handler {
   protected void execute(CommandLine cmd)
       throws IOException, OzoneException, URISyntaxException {
     if (!cmd.hasOption(Shell.GET_KEY)) {
-      throw new OzoneRestClientException("Incorrect call : getKey is missing");
+      throw new OzoneClientException("Incorrect call : getKey is missing");
     }
 
     if (!cmd.hasOption(Shell.FILE)) {
-      throw new OzoneRestClientException(
+      throw new OzoneClientException(
           "get key needs a file path to download to");
     }
 
-    if (cmd.hasOption(Shell.USER)) {
-      userName = cmd.getOptionValue(Shell.USER);
-    } else {
-      userName = System.getProperty("user.name");
-    }
-
-
     String ozoneURIString = cmd.getOptionValue(Shell.GET_KEY);
     URI ozoneURI = verifyURI(ozoneURIString);
     Path path = Paths.get(ozoneURI.getPath());
     if (path.getNameCount() < 3) {
-      throw new OzoneRestClientException(
+      throw new OzoneClientException(
           "volume/bucket/key name required in putKey");
     }
 
@@ -97,19 +100,28 @@ public class GetKeyHandler extends Handler {
 
 
     if (dataFile.exists()) {
-      throw new OzoneRestClientException(fileName +
+      throw new OzoneClientException(fileName +
                                          "exists. Download will overwrite an " +
                                          "existing file. Aborting.");
     }
 
-    client.setEndPointURI(ozoneURI);
-    client.setUserAuth(userName);
-
-    client.getKey(volumeName, bucketName, keyName, dataFilePath);
+    OzoneVolume vol = client.getObjectStore().getVolume(volumeName);
+    OzoneBucket bucket = vol.getBucket(bucketName);
+    OzoneInputStream keyInputStream = bucket.readKey(keyName);
+    if (dataFilePath != null) {
+      FileOutputStream outputStream = new FileOutputStream(dataFile);
+      IOUtils.copyBytes(keyInputStream, outputStream, new OzoneConfiguration()
+          .getInt(OZONE_SCM_CHUNK_SIZE_KEY, OZONE_SCM_CHUNK_SIZE_DEFAULT));
+      outputStream.close();
+    } else {
+      throw new OzoneClientException(
+          "Can not access the file \"" + fileName + "\"");
+    }
     if(cmd.hasOption(Shell.VERBOSE)) {
       FileInputStream stream = new FileInputStream(dataFile);
       String hash = DigestUtils.md5Hex(stream);
       System.out.printf("Downloaded file hash : %s%n", hash);
+      stream.close();
     }
 
   }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/46e0f278/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/keys/InfoKeyHandler.java
----------------------------------------------------------------------
diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/keys/InfoKeyHandler.java b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/keys/InfoKeyHandler.java
index 3e9b2da..3fcdda9 100644
--- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/keys/InfoKeyHandler.java
+++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/keys/InfoKeyHandler.java
@@ -25,10 +25,11 @@ import java.nio.file.Path;
 import java.nio.file.Paths;
 
 import org.apache.commons.cli.CommandLine;
-import org.apache.hadoop.ozone.web.client.OzoneBucket;
-import org.apache.hadoop.ozone.web.client.OzoneKey;
-import org.apache.hadoop.ozone.web.client.OzoneRestClientException;
-import org.apache.hadoop.ozone.web.client.OzoneVolume;
+import org.apache.hadoop.ozone.client.OzoneClientException;
+import org.apache.hadoop.ozone.client.OzoneClientUtils;
+import org.apache.hadoop.ozone.client.OzoneBucket;
+import org.apache.hadoop.ozone.client.OzoneKey;
+import org.apache.hadoop.ozone.client.OzoneVolume;
 import org.apache.hadoop.ozone.client.rest.OzoneException;
 import org.apache.hadoop.ozone.web.ozShell.Handler;
 import org.apache.hadoop.ozone.web.ozShell.Shell;
@@ -38,7 +39,6 @@ import org.apache.hadoop.ozone.web.utils.JsonUtils;
  * Executes Info Object.
  */
 public class InfoKeyHandler extends Handler {
-  private String userName;
   private String volumeName;
   private String bucketName;
   private String keyName;
@@ -55,22 +55,14 @@ public class InfoKeyHandler extends Handler {
   protected void execute(CommandLine cmd)
       throws IOException, OzoneException, URISyntaxException {
     if (!cmd.hasOption(Shell.INFO_KEY)) {
-      throw new OzoneRestClientException("Incorrect call : infoKey is missing");
+      throw new OzoneClientException("Incorrect call : infoKey is missing");
     }
 
-
-    if (cmd.hasOption(Shell.USER)) {
-      userName = cmd.getOptionValue(Shell.USER);
-    } else {
-      userName = System.getProperty("user.name");
-    }
-
-
     String ozoneURIString = cmd.getOptionValue(Shell.INFO_KEY);
     URI ozoneURI = verifyURI(ozoneURIString);
     Path path = Paths.get(ozoneURI.getPath());
     if (path.getNameCount() < 3) {
-      throw new OzoneRestClientException(
+      throw new OzoneClientException(
           "volume/bucket/key name required in infoKey");
     }
 
@@ -85,14 +77,11 @@ public class InfoKeyHandler extends Handler {
       System.out.printf("Key Name : %s%n", keyName);
     }
 
-    client.setEndPointURI(ozoneURI);
-    client.setUserAuth(userName);
-
-    OzoneVolume vol = client.getVolume(volumeName);
+    OzoneVolume vol = client.getObjectStore().getVolume(volumeName);
     OzoneBucket bucket = vol.getBucket(bucketName);
-    OzoneKey key = bucket.getKeyInfo(keyName);
+    OzoneKey key = bucket.getKey(keyName);
 
     System.out.printf("%s%n", JsonUtils.toJsonStringWithDefaultPrettyPrinter(
-        key.getObjectInfo().toJsonString()));
+        JsonUtils.toJsonString(OzoneClientUtils.asKeyInfo(key))));
   }
 }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/46e0f278/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/keys/ListKeyHandler.java
----------------------------------------------------------------------
diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/keys/ListKeyHandler.java b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/keys/ListKeyHandler.java
index ea563ad..6e266fd 100644
--- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/keys/ListKeyHandler.java
+++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/keys/ListKeyHandler.java
@@ -19,12 +19,11 @@
 package org.apache.hadoop.ozone.web.ozShell.keys;
 
 import org.apache.commons.cli.CommandLine;
-import org.apache.hadoop.ozone.web.client.OzoneRestClientException;
-import org.apache.hadoop.ozone.web.client.OzoneKey;
+import org.apache.hadoop.ozone.client.*;
+import org.apache.hadoop.ozone.client.rest.response.KeyInfo;
 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.response.KeyInfo;
 import org.apache.hadoop.ozone.web.utils.JsonUtils;
 import org.apache.hadoop.ozone.web.utils.OzoneUtils;
 
@@ -33,14 +32,14 @@ import java.net.URI;
 import java.net.URISyntaxException;
 import java.nio.file.Path;
 import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Iterator;
 import java.util.List;
-import java.util.stream.Collectors;
 
 /**
  * Executes List Keys.
  */
 public class ListKeyHandler extends Handler {
-  private String userName;
   private String volumeName;
   private String bucketName;
 
@@ -57,14 +56,15 @@ public class ListKeyHandler extends Handler {
       throws IOException, OzoneException, URISyntaxException {
 
     if (!cmd.hasOption(Shell.LIST_KEY)) {
-      throw new OzoneRestClientException(
+      throw new OzoneClientException(
           "Incorrect call : listKey is missing");
     }
 
-    String length = null;
+    int maxKeys = Integer.MAX_VALUE;
     if (cmd.hasOption(Shell.LIST_LENGTH)) {
-      length = cmd.getOptionValue(Shell.LIST_LENGTH);
+      String length = cmd.getOptionValue(Shell.LIST_LENGTH);
       OzoneUtils.verifyMaxKeyLength(length);
+      maxKeys = Integer.parseInt(length);
     }
 
     String startKey = null;
@@ -81,7 +81,7 @@ public class ListKeyHandler extends Handler {
     URI ozoneURI = verifyURI(ozoneURIString);
     Path path = Paths.get(ozoneURI.getPath());
     if (path.getNameCount() < 2) {
-      throw new OzoneRestClientException(
+      throw new OzoneClientException(
           "volume/bucket is required in listKey");
     }
 
@@ -94,23 +94,23 @@ public class ListKeyHandler extends Handler {
       System.out.printf("bucket Name : %s%n", bucketName);
     }
 
-    if (cmd.hasOption(Shell.USER)) {
-      userName = cmd.getOptionValue(Shell.USER);
-    } else {
-      userName = System.getProperty("user.name");
-    }
-
-
-    client.setEndPointURI(ozoneURI);
-    client.setUserAuth(userName);
+    OzoneVolume vol = client.getObjectStore().getVolume(volumeName);
+    OzoneBucket bucket = vol.getBucket(bucketName);
+    Iterator<OzoneKey> keyIterator = bucket.listKeys(prefix, startKey);
+    List<KeyInfo> keyInfos = new ArrayList<>();
 
-    List<OzoneKey> keys = client.listKeys(volumeName, bucketName, length,
-        startKey, prefix);
+    while (maxKeys > 0 && keyIterator.hasNext()) {
+      KeyInfo key = OzoneClientUtils.asKeyInfo(keyIterator.next());
+      keyInfos.add(key);
+      maxKeys -= 1;
+    }
 
-    List<KeyInfo> jsonData = keys.stream()
-        .map(OzoneKey::getObjectInfo).collect(Collectors.toList());
-    System.out.printf(JsonUtils.toJsonStringWithDefaultPrettyPrinter(
-        JsonUtils.toJsonString(jsonData)));
+    if (cmd.hasOption(Shell.VERBOSE)) {
+      System.out.printf("Found : %d keys for bucket %s in volume : %s ",
+          keyInfos.size(), bucketName, volumeName);
+    }
+    System.out.println(JsonUtils.toJsonStringWithDefaultPrettyPrinter(
+        JsonUtils.toJsonString(keyInfos)));
   }
 
 }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/46e0f278/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 1f2c692..ed8cc88 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
@@ -20,7 +20,15 @@ package org.apache.hadoop.ozone.web.ozShell.keys;
 
 import org.apache.commons.cli.CommandLine;
 import org.apache.commons.codec.digest.DigestUtils;
-import org.apache.hadoop.ozone.web.client.OzoneRestClientException;
+import org.apache.hadoop.conf.Configuration;
+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.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;
@@ -33,11 +41,15 @@ import java.net.URISyntaxException;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 
+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_TYPE;
+
 /**
  * Puts a file into an ozone bucket.
  */
 public class PutKeyHandler extends Handler {
-  private String userName;
   private String volumeName;
   private String bucketName;
   private String keyName;
@@ -54,24 +66,18 @@ public class PutKeyHandler extends Handler {
   protected void execute(CommandLine cmd)
       throws IOException, OzoneException, URISyntaxException {
     if (!cmd.hasOption(Shell.PUT_KEY)) {
-      throw new OzoneRestClientException("Incorrect call : putKey is missing");
+      throw new OzoneClientException("Incorrect call : putKey is missing");
     }
 
     if (!cmd.hasOption(Shell.FILE)) {
-      throw new OzoneRestClientException("put key needs a file to put");
-    }
-
-    if (cmd.hasOption(Shell.USER)) {
-      userName = cmd.getOptionValue(Shell.USER);
-    } else {
-      userName = System.getProperty("user.name");
+      throw new OzoneClientException("put key needs a file to put");
     }
 
     String ozoneURIString = cmd.getOptionValue(Shell.PUT_KEY);
     URI ozoneURI = verifyURI(ozoneURIString);
     Path path = Paths.get(ozoneURI.getPath());
     if (path.getNameCount() < 3) {
-      throw new OzoneRestClientException(
+      throw new OzoneClientException(
           "volume/bucket/key name required in putKey");
     }
 
@@ -86,7 +92,6 @@ public class PutKeyHandler extends Handler {
       System.out.printf("Key Name : %s%n", keyName);
     }
 
-
     String fileName = cmd.getOptionValue(Shell.FILE);
     File dataFile = new File(fileName);
 
@@ -97,10 +102,22 @@ public class PutKeyHandler extends Handler {
       stream.close();
     }
 
-    client.setEndPointURI(ozoneURI);
-    client.setUserAuth(userName);
-
-    client.putKey(volumeName, bucketName, keyName, dataFile);
+    Configuration conf = new OzoneConfiguration();
+    ReplicationFactor replicationFactor = ReplicationFactor.valueOf(
+        conf.getInt(OZONE_REPLICATION, ReplicationFactor.THREE.getValue()));
+    ReplicationType replicationType = ReplicationType.valueOf(
+        conf.get(OZONE_REPLICATION_TYPE, ReplicationType.RATIS.toString()));
+
+    OzoneVolume vol = client.getObjectStore().getVolume(volumeName);
+    OzoneBucket bucket = vol.getBucket(bucketName);
+    OzoneOutputStream outputStream = bucket
+        .createKey(keyName, dataFile.length(), replicationType,
+            replicationFactor);
+    FileInputStream fileInputStream = new FileInputStream(dataFile);
+    IOUtils.copyBytes(fileInputStream, outputStream,
+        conf.getInt(OZONE_SCM_CHUNK_SIZE_KEY, OZONE_SCM_CHUNK_SIZE_DEFAULT));
+    outputStream.close();
+    fileInputStream.close();
   }
 
 }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/46e0f278/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 c0b0bb9..74fdbb0 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
@@ -19,8 +19,10 @@
 package org.apache.hadoop.ozone.web.ozShell.volume;
 
 import org.apache.commons.cli.CommandLine;
-import org.apache.hadoop.ozone.web.client.OzoneRestClientException;
-import org.apache.hadoop.ozone.web.client.OzoneVolume;
+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;
@@ -52,14 +54,14 @@ public class CreateVolumeHandler extends Handler {
   protected void execute(CommandLine cmd)
       throws IOException, OzoneException, URISyntaxException {
     if (!cmd.hasOption(Shell.CREATE_VOLUME)) {
-      throw new OzoneRestClientException(
+      throw new OzoneClientException(
           "Incorrect call : createVolume is missing");
     }
 
     String ozoneURIString = cmd.getOptionValue(Shell.CREATE_VOLUME);
     URI ozoneURI = verifyURI(ozoneURIString);
     if (ozoneURI.getPath().isEmpty()) {
-      throw new OzoneRestClientException(
+      throw new OzoneClientException(
           "Volume name is required to create a volume");
     }
 
@@ -77,7 +79,7 @@ public class CreateVolumeHandler extends Handler {
     }
 
     if (!cmd.hasOption(Shell.USER)) {
-      throw new OzoneRestClientException(
+      throw new OzoneClientException(
           "User name is needed in createVolume call.");
     }
 
@@ -86,13 +88,19 @@ public class CreateVolumeHandler extends Handler {
     }
 
     userName = cmd.getOptionValue(Shell.USER);
-    client.setEndPointURI(ozoneURI);
-    client.setUserAuth(rootName);
 
-    OzoneVolume vol = client.createVolume(volumeName, userName, quota);
+    VolumeArgs.Builder volumeArgsBuilder = VolumeArgs.newBuilder()
+        .setAdmin(rootName)
+        .setOwner(userName);
+    if (quota != null) {
+      volumeArgsBuilder.setQuota(quota);
+    }
+    client.getObjectStore().createVolume(volumeName, volumeArgsBuilder.build());
+
     if (cmd.hasOption(Shell.VERBOSE)) {
-      System.out.printf("%s%n",
-          JsonUtils.toJsonStringWithDefaultPrettyPrinter(vol.getJsonString()));
+      OzoneVolume vol = client.getObjectStore().getVolume(volumeName);
+      System.out.printf("%s%n", JsonUtils.toJsonStringWithDefaultPrettyPrinter(
+          JsonUtils.toJsonString(OzoneClientUtils.asVolumeInfo(vol))));
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/46e0f278/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 bed7db3..d6facf6 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
@@ -19,7 +19,7 @@
 package org.apache.hadoop.ozone.web.ozShell.volume;
 
 import org.apache.commons.cli.CommandLine;
-import org.apache.hadoop.ozone.web.client.OzoneRestClientException;
+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;
@@ -34,7 +34,6 @@ import java.net.URISyntaxException;
 public class DeleteVolumeHandler extends Handler {
 
   private String volumeName;
-  private String rootName;
 
   /**
    * Executes the delete volume call.
@@ -49,14 +48,14 @@ public class DeleteVolumeHandler extends Handler {
       throws IOException, OzoneException, URISyntaxException {
 
     if (!cmd.hasOption(Shell.DELETE_VOLUME)) {
-      throw new OzoneRestClientException(
+      throw new OzoneClientException(
           "Incorrect call : deleteVolume call is missing");
     }
 
     String ozoneURIString = cmd.getOptionValue(Shell.DELETE_VOLUME);
     URI ozoneURI = verifyURI(ozoneURIString);
     if (ozoneURI.getPath().isEmpty()) {
-      throw new OzoneRestClientException(
+      throw new OzoneClientException(
           "Volume name is required to delete a volume");
     }
 
@@ -67,15 +66,6 @@ public class DeleteVolumeHandler extends Handler {
       System.out.printf("Volume name : %s%n", volumeName);
     }
 
-    if (cmd.hasOption(Shell.RUNAS)) {
-      rootName = "hdfs";
-    } else {
-      rootName = System.getProperty("user.name");
-    }
-
-    client.setEndPointURI(ozoneURI);
-    client.setUserAuth(rootName);
-    client.deleteVolume(volumeName);
-
+    client.getObjectStore().deleteVolume(volumeName);
   }
 }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/46e0f278/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 16de3d4..b5be2c6 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
@@ -19,8 +19,9 @@
 package org.apache.hadoop.ozone.web.ozShell.volume;
 
 import org.apache.commons.cli.CommandLine;
-import org.apache.hadoop.ozone.web.client.OzoneRestClientException;
-import org.apache.hadoop.ozone.web.client.OzoneVolume;
+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;
@@ -35,9 +36,7 @@ import java.net.URISyntaxException;
  */
 public class InfoVolumeHandler extends Handler{
 
-  private String rootName;
   private String volumeName;
-  private String userName;
 
   /**
    * Executes volume Info.
@@ -53,43 +52,22 @@ public class InfoVolumeHandler extends Handler{
       throws IOException, OzoneException, URISyntaxException {
 
     if (!cmd.hasOption(Shell.INFO_VOLUME)) {
-      throw new OzoneRestClientException(
+      throw new OzoneClientException(
           "Incorrect call : infoVolume is missing");
     }
 
     String ozoneURIString = cmd.getOptionValue(Shell.INFO_VOLUME);
     URI ozoneURI = verifyURI(ozoneURIString);
     if (ozoneURI.getPath().isEmpty()) {
-      throw new OzoneRestClientException(
+      throw new OzoneClientException(
           "Volume name is required to get info of a volume");
     }
 
-    if (cmd.hasOption(Shell.RUNAS)) {
-      rootName = "hdfs";
-    }
-
     // we need to skip the slash in the URI path
     volumeName = ozoneURI.getPath().substring(1);
 
-    if (cmd.hasOption(Shell.USER)) {
-      userName = cmd.getOptionValue(Shell.USER);
-    } else {
-      userName = System.getProperty("user.name");
-    }
-
-    client.setEndPointURI(ozoneURI);
-
-    if (rootName != null) {
-      client.setUserAuth(rootName);
-    } else {
-      client.setUserAuth(userName);
-    }
-
-    client.setEndPointURI(ozoneURI);
-    client.setUserAuth(rootName);
-
-    OzoneVolume vol = client.getVolume(volumeName);
-    System.out.printf("%s%n",
-        JsonUtils.toJsonStringWithDefaultPrettyPrinter(vol.getJsonString()));
+    OzoneVolume vol = client.getObjectStore().getVolume(volumeName);
+    System.out.printf("%s%n", JsonUtils.toJsonStringWithDefaultPrettyPrinter(
+        JsonUtils.toJsonString(OzoneClientUtils.asVolumeInfo(vol))));
   }
 }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/46e0f278/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 189c891..3749df4 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,26 +19,26 @@
 package org.apache.hadoop.ozone.web.ozShell.volume;
 
 import org.apache.commons.cli.CommandLine;
-import org.apache.hadoop.ozone.web.client.OzoneRestClientException;
-import org.apache.hadoop.ozone.web.client.OzoneVolume;
+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.response.VolumeInfo;
 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;
-import java.util.stream.Collectors;
 
 /**
  * Executes List Volume call.
  */
 public class ListVolumeHandler extends Handler {
-  private String rootName;
   private String userName;
 
   /**
@@ -54,16 +54,16 @@ public class ListVolumeHandler extends Handler {
       throws IOException, OzoneException, URISyntaxException {
 
     if (!cmd.hasOption(Shell.LIST_VOLUME)) {
-      throw new OzoneRestClientException(
+      throw new OzoneClientException(
           "Incorrect call : listVolume is missing");
     }
 
-    int maxKeys = 0;
+    int maxVolumes = Integer.MAX_VALUE;
     if (cmd.hasOption(Shell.LIST_LENGTH)) {
       String length = cmd.getOptionValue(Shell.LIST_LENGTH);
       OzoneUtils.verifyMaxKeyLength(length);
 
-      maxKeys = Integer.parseInt(length);
+      maxVolumes = Integer.parseInt(length);
     }
 
     String startVolume = null;
@@ -77,11 +77,7 @@ public class ListVolumeHandler extends Handler {
     }
 
     String ozoneURIString = cmd.getOptionValue(Shell.LIST_VOLUME);
-    URI ozoneURI = verifyURI(ozoneURIString);
-
-    if (cmd.hasOption(Shell.RUNAS)) {
-      rootName = "hdfs";
-    }
+    verifyURI(ozoneURIString);
 
     if (cmd.hasOption(Shell.USER)) {
       userName = cmd.getOptionValue(Shell.USER);
@@ -89,26 +85,28 @@ public class ListVolumeHandler extends Handler {
       userName = System.getProperty("user.name");
     }
 
-    client.setEndPointURI(ozoneURI);
-    if (rootName != null) {
-      client.setUserAuth(rootName);
+    Iterator<OzoneVolume> volumeIterator;
+    if(userName != null) {
+      volumeIterator = client.getObjectStore()
+          .listVolumesByUser(userName, prefix, startVolume);
     } else {
-      client.setUserAuth(userName);
+      volumeIterator = client.getObjectStore().listVolumes(prefix);
+    }
+
+    List<VolumeInfo> volumeInfos = new ArrayList<>();
+
+    while (maxVolumes > 0 && volumeIterator.hasNext()) {
+      VolumeInfo volume = OzoneClientUtils.asVolumeInfo(volumeIterator.next());
+      volumeInfos.add(volume);
+      maxVolumes -= 1;
     }
 
-    List<OzoneVolume> volumes = client.listVolumes(userName, prefix, maxKeys,
-        startVolume);
-    if (volumes != null) {
-      if (cmd.hasOption(Shell.VERBOSE)) {
-        System.out.printf("Found : %d volumes for user : %s %n", volumes.size(),
-            userName);
-      }
-
-      List<VolumeInfo> jsonData = volumes.stream()
-          .map(OzoneVolume::getVolumeInfo).collect(Collectors.toList());
-      System.out.println(JsonUtils.toJsonStringWithDefaultPrettyPrinter(
-          JsonUtils.toJsonString(jsonData)));
+    if (cmd.hasOption(Shell.VERBOSE)) {
+      System.out.printf("Found : %d volumes for user : %s ", volumeInfos.size(),
+          userName);
     }
+    System.out.println(JsonUtils.toJsonStringWithDefaultPrettyPrinter(
+        JsonUtils.toJsonString(volumeInfos)));
   }
 }
 

http://git-wip-us.apache.org/repos/asf/hadoop/blob/46e0f278/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 164fe34..1e3fbb5 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
@@ -19,7 +19,9 @@
 package org.apache.hadoop.ozone.web.ozShell.volume;
 
 import org.apache.commons.cli.CommandLine;
-import org.apache.hadoop.ozone.web.client.OzoneRestClientException;
+import org.apache.hadoop.hdds.client.OzoneQuota;
+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;
@@ -32,7 +34,6 @@ import java.net.URISyntaxException;
  * Executes update volume calls.
  */
 public class UpdateVolumeHandler extends Handler {
-  private String rootName;
   private String ownerName;
   private String volumeName;
   private String quota;
@@ -49,26 +50,20 @@ public class UpdateVolumeHandler extends Handler {
   protected void execute(CommandLine cmd)
       throws IOException, OzoneException, URISyntaxException {
     if (!cmd.hasOption(Shell.UPDATE_VOLUME)) {
-      throw new OzoneRestClientException(
+      throw new OzoneClientException(
           "Incorrect call : updateVolume is missing");
     }
 
     String ozoneURIString = cmd.getOptionValue(Shell.UPDATE_VOLUME);
     URI ozoneURI = verifyURI(ozoneURIString);
     if (ozoneURI.getPath().isEmpty()) {
-      throw new OzoneRestClientException(
+      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.RUNAS)) {
-      rootName = "hdfs";
-    } else {
-      rootName = System.getProperty("user.name");
-    }
-
     if (cmd.hasOption(Shell.QUOTA)) {
       quota = cmd.getOptionValue(Shell.QUOTA);
     }
@@ -77,16 +72,13 @@ public class UpdateVolumeHandler extends Handler {
       ownerName = cmd.getOptionValue(Shell.USER);
     }
 
-    client.setEndPointURI(ozoneURI);
-    client.setUserAuth(rootName);
-
+    OzoneVolume volume = client.getObjectStore().getVolume(volumeName);
     if (quota != null && !quota.isEmpty()) {
-      client.setVolumeQuota(volumeName, quota);
+      volume.setQuota(OzoneQuota.parseQuota(quota));
     }
 
     if (ownerName != null && !ownerName.isEmpty()) {
-      client.setVolumeOwner(volumeName, ownerName);
+      volume.setOwner(ownerName);
     }
-
   }
 }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/46e0f278/hadoop-tools/hadoop-ozone/src/main/java/org/apache/hadoop/fs/ozone/Constants.java
----------------------------------------------------------------------
diff --git a/hadoop-tools/hadoop-ozone/src/main/java/org/apache/hadoop/fs/ozone/Constants.java b/hadoop-tools/hadoop-ozone/src/main/java/org/apache/hadoop/fs/ozone/Constants.java
index 992d43a..832a0cb 100644
--- a/hadoop-tools/hadoop-ozone/src/main/java/org/apache/hadoop/fs/ozone/Constants.java
+++ b/hadoop-tools/hadoop-ozone/src/main/java/org/apache/hadoop/fs/ozone/Constants.java
@@ -23,12 +23,8 @@ package org.apache.hadoop.fs.ozone;
  */
 public final class Constants {
 
-  public static final String OZONE_URI_SCHEME = "o3";
-
   public static final String OZONE_DEFAULT_USER = "hdfs";
 
-  public static final String OZONE_HTTP_SCHEME = "http://";
-
   public static final String OZONE_USER_DIR = "/user";
 
   /** Local buffer directory. */
@@ -37,8 +33,6 @@ public final class Constants {
   /** Temporary directory. */
   public static final String BUFFER_TMP_KEY = "hadoop.tmp.dir";
 
-  public static final String OZONE_URI_DELIMITER = "/";
-
   /** Page size for Ozone listing operation. */
   public static final int LISTING_PAGE_SIZE = 1024;
 

http://git-wip-us.apache.org/repos/asf/hadoop/blob/46e0f278/hadoop-tools/hadoop-ozone/src/main/java/org/apache/hadoop/fs/ozone/OzFs.java
----------------------------------------------------------------------
diff --git a/hadoop-tools/hadoop-ozone/src/main/java/org/apache/hadoop/fs/ozone/OzFs.java b/hadoop-tools/hadoop-ozone/src/main/java/org/apache/hadoop/fs/ozone/OzFs.java
index 46dd645..4163c13 100644
--- a/hadoop-tools/hadoop-ozone/src/main/java/org/apache/hadoop/fs/ozone/OzFs.java
+++ b/hadoop-tools/hadoop-ozone/src/main/java/org/apache/hadoop/fs/ozone/OzFs.java
@@ -22,6 +22,7 @@ import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.classification.InterfaceStability;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.DelegateToFileSystem;
+import org.apache.hadoop.ozone.OzoneConsts;
 
 import java.io.IOException;
 import java.net.URI;
@@ -38,6 +39,6 @@ public class OzFs extends DelegateToFileSystem {
   public OzFs(URI theUri, Configuration conf)
       throws IOException, URISyntaxException {
     super(theUri, new OzoneFileSystem(), conf,
-        Constants.OZONE_URI_SCHEME, false);
+        OzoneConsts.OZONE_URI_SCHEME, false);
   }
 }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/46e0f278/hadoop-tools/hadoop-ozone/src/main/java/org/apache/hadoop/fs/ozone/OzoneFileSystem.java
----------------------------------------------------------------------
diff --git a/hadoop-tools/hadoop-ozone/src/main/java/org/apache/hadoop/fs/ozone/OzoneFileSystem.java b/hadoop-tools/hadoop-ozone/src/main/java/org/apache/hadoop/fs/ozone/OzoneFileSystem.java
index ef0d3ab..0ff1d50 100644
--- a/hadoop-tools/hadoop-ozone/src/main/java/org/apache/hadoop/fs/ozone/OzoneFileSystem.java
+++ b/hadoop-tools/hadoop-ozone/src/main/java/org/apache/hadoop/fs/ozone/OzoneFileSystem.java
@@ -64,9 +64,9 @@ import org.apache.hadoop.ozone.client.io.OzoneInputStream;
 import org.apache.hadoop.ozone.client.io.OzoneOutputStream;
 
 import static org.apache.hadoop.fs.ozone.Constants.OZONE_DEFAULT_USER;
-import static org.apache.hadoop.fs.ozone.Constants.OZONE_URI_SCHEME;
+import static org.apache.hadoop.ozone.OzoneConsts.OZONE_URI_SCHEME;
 import static org.apache.hadoop.fs.ozone.Constants.OZONE_USER_DIR;
-import static org.apache.hadoop.fs.ozone.Constants.OZONE_URI_DELIMITER;
+import static org.apache.hadoop.ozone.OzoneConsts.OZONE_URI_DELIMITER;
 import static org.apache.hadoop.fs.ozone.Constants.LISTING_PAGE_SIZE;
 
 /**

http://git-wip-us.apache.org/repos/asf/hadoop/blob/46e0f278/hadoop-tools/hadoop-ozone/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFSInputStream.java
----------------------------------------------------------------------
diff --git a/hadoop-tools/hadoop-ozone/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFSInputStream.java b/hadoop-tools/hadoop-ozone/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFSInputStream.java
index a7a53dc..4d8c9d6 100644
--- a/hadoop-tools/hadoop-ozone/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFSInputStream.java
+++ b/hadoop-tools/hadoop-ozone/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFSInputStream.java
@@ -30,6 +30,7 @@ import org.apache.hadoop.hdfs.server.datanode.ObjectStoreHandler;
 import org.apache.hadoop.hdds.conf.OzoneConfiguration;
 import org.apache.hadoop.ozone.MiniOzoneCluster;
 import org.apache.hadoop.ozone.OzoneConfigKeys;
+import org.apache.hadoop.ozone.OzoneConsts;
 import org.apache.hadoop.ozone.web.handlers.BucketArgs;
 import org.apache.hadoop.ozone.web.handlers.UserArgs;
 import org.apache.hadoop.ozone.web.interfaces.StorageHandler;
@@ -94,7 +95,7 @@ public class TestOzoneFSInputStream {
 
     // Set the fs.defaultFS and start the filesystem
     String uri = String.format("%s://%s.%s/",
-        Constants.OZONE_URI_SCHEME, bucketName, volumeName);
+        OzoneConsts.OZONE_URI_SCHEME, bucketName, volumeName);
     conf.set(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY, uri);
     fs =  FileSystem.get(conf);
     int fileLen = 100 * 1024 * 1024;

http://git-wip-us.apache.org/repos/asf/hadoop/blob/46e0f278/hadoop-tools/hadoop-ozone/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFileInterfaces.java
----------------------------------------------------------------------
diff --git a/hadoop-tools/hadoop-ozone/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFileInterfaces.java b/hadoop-tools/hadoop-ozone/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFileInterfaces.java
index 9f94e37..5a7cb4f 100644
--- a/hadoop-tools/hadoop-ozone/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFileInterfaces.java
+++ b/hadoop-tools/hadoop-ozone/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFileInterfaces.java
@@ -24,6 +24,7 @@ import java.util.Arrays;
 import java.util.Collection;
 
 import org.apache.hadoop.ozone.MiniOzoneCluster;
+import org.apache.hadoop.ozone.OzoneConsts;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -118,7 +119,7 @@ public class TestOzoneFileInterfaces {
     storageHandler.createBucket(bucketArgs);
 
     rootPath = String
-        .format("%s://%s.%s/", Constants.OZONE_URI_SCHEME, bucketName,
+        .format("%s://%s.%s/", OzoneConsts.OZONE_URI_SCHEME, bucketName,
             volumeName);
     if (setDefaultFs) {
       // Set the fs.defaultFS and start the filesystem
@@ -145,7 +146,7 @@ public class TestOzoneFileInterfaces {
           "The initialized file system is not OzoneFileSystem but " +
               fs.getClass(),
           fs instanceof OzoneFileSystem);
-      assertEquals(Constants.OZONE_URI_SCHEME, fs.getUri().getScheme());
+      assertEquals(OzoneConsts.OZONE_URI_SCHEME, fs.getUri().getScheme());
     }
   }
 

http://git-wip-us.apache.org/repos/asf/hadoop/blob/46e0f278/hadoop-tools/hadoop-ozone/src/test/java/org/apache/hadoop/fs/ozone/contract/OzoneContract.java
----------------------------------------------------------------------
diff --git a/hadoop-tools/hadoop-ozone/src/test/java/org/apache/hadoop/fs/ozone/contract/OzoneContract.java b/hadoop-tools/hadoop-ozone/src/test/java/org/apache/hadoop/fs/ozone/contract/OzoneContract.java
index 3848bc8..176b614 100644
--- a/hadoop-tools/hadoop-ozone/src/test/java/org/apache/hadoop/fs/ozone/contract/OzoneContract.java
+++ b/hadoop-tools/hadoop-ozone/src/test/java/org/apache/hadoop/fs/ozone/contract/OzoneContract.java
@@ -24,9 +24,9 @@ import org.apache.hadoop.hdds.conf.OzoneConfiguration;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.contract.AbstractFSContract;
-import org.apache.hadoop.fs.ozone.Constants;
 import org.apache.hadoop.hdfs.server.datanode.ObjectStoreHandler;
 import org.apache.hadoop.ozone.MiniOzoneCluster;
+import org.apache.hadoop.ozone.OzoneConsts;
 import org.apache.hadoop.ozone.client.rest.OzoneException;
 import org.apache.hadoop.ozone.web.handlers.BucketArgs;
 import org.apache.hadoop.ozone.web.handlers.UserArgs;
@@ -56,7 +56,7 @@ class OzoneContract extends AbstractFSContract {
 
   @Override
   public String getScheme() {
-    return Constants.OZONE_URI_SCHEME;
+    return OzoneConsts.OZONE_URI_SCHEME;
   }
 
   @Override
@@ -107,7 +107,7 @@ class OzoneContract extends AbstractFSContract {
     }
 
     String uri = String.format("%s://%s.%s/",
-        Constants.OZONE_URI_SCHEME, bucketName, volumeName);
+        OzoneConsts.OZONE_URI_SCHEME, bucketName, volumeName);
     getConf().set("fs.defaultFS", uri);
     copyClusterConfigs(KSMConfigKeys.OZONE_KSM_ADDRESS_KEY);
     copyClusterConfigs(ScmConfigKeys.OZONE_SCM_CLIENT_ADDRESS_KEY);


---------------------------------------------------------------------
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