hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From viraj...@apache.org
Subject [09/50] [abbrv] hadoop git commit: HADOOP-15215 s3guard set-capacity command to fail on read/write of 0 (Gabor Bota)
Date Mon, 09 Jul 2018 18:26:01 GMT
HADOOP-15215 s3guard set-capacity command to fail on read/write of 0 (Gabor Bota)


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

Branch: refs/heads/HDFS-12090
Commit: 93ac01cb59b99b84b4f1ff26c089dcb5ce1b7c89
Parents: c0ef7e7
Author: Aaron Fabbri <fabbri@apache.org>
Authored: Tue Jul 3 13:50:11 2018 -0700
Committer: Aaron Fabbri <fabbri@apache.org>
Committed: Tue Jul 3 13:50:11 2018 -0700

----------------------------------------------------------------------
 .../apache/hadoop/fs/s3a/s3guard/S3GuardTool.java | 10 ++++++++++
 .../s3a/s3guard/AbstractS3GuardToolTestBase.java  | 18 ++++++++++++++++++
 2 files changed, 28 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/93ac01cb/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/s3guard/S3GuardTool.java
----------------------------------------------------------------------
diff --git a/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/s3guard/S3GuardTool.java
b/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/s3guard/S3GuardTool.java
index 527697f..19dc32a 100644
--- a/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/s3guard/S3GuardTool.java
+++ b/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/s3guard/S3GuardTool.java
@@ -439,6 +439,10 @@ public abstract class S3GuardTool extends Configured implements Tool
{
   static class SetCapacity extends S3GuardTool {
     public static final String NAME = "set-capacity";
     public static final String PURPOSE = "Alter metadata store IO capacity";
+    public static final String READ_CAP_INVALID = "Read capacity must have "
+        + "value greater than or equal to 1.";
+    public static final String WRITE_CAP_INVALID = "Write capacity must have "
+        + "value greater than or equal to 1.";
     private static final String USAGE = NAME + " [OPTIONS] [s3a://BUCKET]\n" +
         "\t" + PURPOSE + "\n\n" +
         "Common options:\n" +
@@ -478,11 +482,17 @@ public abstract class S3GuardTool extends Configured implements Tool
{
 
       String readCap = getCommandFormat().getOptValue(READ_FLAG);
       if (StringUtils.isNotEmpty(readCap)) {
+        Preconditions.checkArgument(Integer.parseInt(readCap) > 0,
+            READ_CAP_INVALID);
+
         S3GuardTool.println(out, "Read capacity set to %s", readCap);
         options.put(S3GUARD_DDB_TABLE_CAPACITY_READ_KEY, readCap);
       }
       String writeCap = getCommandFormat().getOptValue(WRITE_FLAG);
       if (StringUtils.isNotEmpty(writeCap)) {
+        Preconditions.checkArgument(Integer.parseInt(writeCap) > 0,
+            WRITE_CAP_INVALID);
+
         S3GuardTool.println(out, "Write capacity set to %s", writeCap);
         options.put(S3GUARD_DDB_TABLE_CAPACITY_WRITE_KEY, writeCap);
       }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/93ac01cb/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/s3guard/AbstractS3GuardToolTestBase.java
----------------------------------------------------------------------
diff --git a/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/s3guard/AbstractS3GuardToolTestBase.java
b/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/s3guard/AbstractS3GuardToolTestBase.java
index 7d75f52..f591e32 100644
--- a/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/s3guard/AbstractS3GuardToolTestBase.java
+++ b/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/s3guard/AbstractS3GuardToolTestBase.java
@@ -51,6 +51,7 @@ import org.apache.hadoop.io.IOUtils;
 import org.apache.hadoop.util.ExitUtil;
 import org.apache.hadoop.util.StringUtils;
 
+import static org.apache.hadoop.fs.s3a.Constants.S3GUARD_DDB_TABLE_NAME_KEY;
 import static org.apache.hadoop.fs.s3a.Constants.S3GUARD_METASTORE_NULL;
 import static org.apache.hadoop.fs.s3a.Constants.S3_METADATA_STORE_IMPL;
 import static org.apache.hadoop.fs.s3a.s3guard.S3GuardTool.E_BAD_STATE;
@@ -287,6 +288,23 @@ public abstract class AbstractS3GuardToolTestBase extends AbstractS3ATestBase
{
   }
 
   @Test
+  public void testSetCapacityFailFast() throws Exception{
+    Configuration conf = getConfiguration();
+    conf.set(S3GUARD_DDB_TABLE_NAME_KEY, getFileSystem().getBucket());
+
+    S3GuardTool.SetCapacity cmdR = new S3GuardTool.SetCapacity(conf);
+    String[] argsR = new String[]{cmdR.getName(), "-read", "0", "s3a://bucket"};
+    intercept(IllegalArgumentException.class,
+        S3GuardTool.SetCapacity.READ_CAP_INVALID, () -> cmdR.run(argsR));
+
+    S3GuardTool.SetCapacity cmdW = new S3GuardTool.SetCapacity(conf);
+    String[] argsW = new String[]{cmdW.getName(), "-write", "0",
+        "s3a://bucket"};
+    intercept(IllegalArgumentException.class,
+        S3GuardTool.SetCapacity.WRITE_CAP_INVALID, () -> cmdW.run(argsW));
+  }
+
+  @Test
   public void testDestroyNoBucket() throws Throwable {
     intercept(FileNotFoundException.class,
         new Callable<Integer>() {


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