You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ozone.apache.org by av...@apache.org on 2020/11/24 21:40:36 UTC

[ozone] branch master updated: HDDS-4492. CLI flag --quota should default to 'spaceQuota' to preserve backward compatibility. (#1609)

This is an automated email from the ASF dual-hosted git repository.

avijayan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new a9ff68a  HDDS-4492. CLI flag --quota should default to 'spaceQuota' to preserve backward compatibility. (#1609)
a9ff68a is described below

commit a9ff68ab7133c63f5076533669d46d0ba6921d12
Author: Ayush Saxena <ay...@apache.org>
AuthorDate: Wed Nov 25 03:10:16 2020 +0530

    HDDS-4492. CLI flag --quota should default to 'spaceQuota' to preserve backward compatibility. (#1609)
---
 .../hadoop/ozone/shell/TestOzoneShellHA.java       | 42 ++++++++++++++++++++++
 .../hadoop/ozone/shell/SetSpaceQuotaOptions.java   |  3 +-
 2 files changed, 44 insertions(+), 1 deletion(-)

diff --git a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneShellHA.java b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneShellHA.java
index 513049d..830a3d6 100644
--- a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneShellHA.java
+++ b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneShellHA.java
@@ -20,6 +20,7 @@ package org.apache.hadoop.ozone.shell;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileNotFoundException;
+import java.io.IOException;
 import java.io.PrintStream;
 import java.util.Arrays;
 import java.util.List;
@@ -36,6 +37,7 @@ import org.apache.hadoop.ozone.MiniOzoneCluster;
 import org.apache.hadoop.ozone.MiniOzoneHAClusterImpl;
 import org.apache.hadoop.ozone.OmUtils;
 import org.apache.hadoop.ozone.OzoneConsts;
+import org.apache.hadoop.ozone.client.ObjectStore;
 import org.apache.hadoop.ozone.om.OMConfigKeys;
 import org.apache.hadoop.ozone.om.OzoneManager;
 import org.apache.hadoop.test.GenericTestUtils;
@@ -48,6 +50,8 @@ import static org.apache.hadoop.ozone.OzoneConsts.OZONE_OFS_URI_SCHEME;
 import org.junit.After;
 import org.junit.AfterClass;
 import org.junit.Assert;
+
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
 import org.junit.Before;
 import org.junit.BeforeClass;
@@ -525,4 +529,42 @@ public class TestOzoneShellHA {
     }
   }
 
+  @Test
+  public void testShQuota() throws IOException {
+    ObjectStore objectStore = cluster.getClient().getObjectStore();
+    try {
+      // Test --quota option.
+
+      String[] args =
+          new String[] {"volume", "create", "vol1", "--quota", "100BYTES"};
+      execute(ozoneShell, args);
+      assertEquals(100, objectStore.getVolume("vol1").getQuotaInBytes());
+      out.reset();
+
+      args =
+          new String[] {"bucket", "create", "vol1/buck1", "--quota", "10BYTES"};
+      execute(ozoneShell, args);
+      assertEquals(10,
+          objectStore.getVolume("vol1").getBucket("buck1").getQuotaInBytes());
+
+      // Test --space-quota option.
+
+      args = new String[] {"volume", "create", "vol2", "--space-quota",
+          "100BYTES"};
+      execute(ozoneShell, args);
+      assertEquals(100, objectStore.getVolume("vol2").getQuotaInBytes());
+      out.reset();
+
+      args = new String[] {"bucket", "create", "vol2/buck2", "--space-quota",
+          "10BYTES"};
+      execute(ozoneShell, args);
+      assertEquals(10,
+          objectStore.getVolume("vol2").getBucket("buck2").getQuotaInBytes());
+    } finally {
+      objectStore.getVolume("vol1").deleteBucket("buck1");
+      objectStore.deleteVolume("vol1");
+      objectStore.getVolume("vol2").deleteBucket("buck2");
+      objectStore.deleteVolume("vol2");
+    }
+  }
 }
diff --git a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/SetSpaceQuotaOptions.java b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/SetSpaceQuotaOptions.java
index 364efc5..8dea3a9 100644
--- a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/SetSpaceQuotaOptions.java
+++ b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/SetSpaceQuotaOptions.java
@@ -24,7 +24,8 @@ import picocli.CommandLine;
  */
 public class SetSpaceQuotaOptions {
 
-  @CommandLine.Option(names = {"--space-quota"},
+  // Added --quota for backward compatibility.
+  @CommandLine.Option(names = {"--space-quota", "--quota"},
       description = "The maximum space quota can be used (eg. 1GB)")
   private String quotaInBytes;
 


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