From common-commits-return-80156-archive-asf-public=cust-asf.ponee.io@hadoop.apache.org Wed Mar 21 03:53:41 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 1A24A18064A for ; Wed, 21 Mar 2018 03:53:40 +0100 (CET) Received: (qmail 33327 invoked by uid 500); 21 Mar 2018 02:53:39 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 33317 invoked by uid 99); 21 Mar 2018 02:53:39 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 21 Mar 2018 02:53:39 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id B7213E96D5; Wed, 21 Mar 2018 02:53:39 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: yqlin@apache.org To: common-commits@hadoop.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: hadoop git commit: HDFS-13307. RBF: Improve the use of setQuota command. Contributed by liuhongtong. Date: Wed, 21 Mar 2018 02:53:39 +0000 (UTC) Repository: hadoop Updated Branches: refs/heads/branch-3.1 9b96e7522 -> 131546002 HDFS-13307. RBF: Improve the use of setQuota command. Contributed by liuhongtong. (cherry picked from commit 69fe4407ebd885fed69d9cf7f4dd17d3ba1acb60) Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/13154600 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/13154600 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/13154600 Branch: refs/heads/branch-3.1 Commit: 131546002da0dc6d8d511a62599df071279ef347 Parents: 9b96e75 Author: Yiqun Lin Authored: Wed Mar 21 10:51:35 2018 +0800 Committer: Yiqun Lin Committed: Wed Mar 21 10:53:24 2018 +0800 ---------------------------------------------------------------------- .../hdfs/tools/federation/RouterAdmin.java | 35 ++++++++++++++------ .../federation/router/TestRouterAdminCLI.java | 2 ++ 2 files changed, 26 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/13154600/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/tools/federation/RouterAdmin.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/tools/federation/RouterAdmin.java b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/tools/federation/RouterAdmin.java index f4adbad..927b073 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/tools/federation/RouterAdmin.java +++ b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/tools/federation/RouterAdmin.java @@ -453,7 +453,8 @@ public class RouterAdmin extends Configured implements Tool { try { nsQuota = Long.parseLong(parameters[i]); } catch (Exception e) { - System.err.println("Cannot parse nsQuota: " + parameters[i]); + throw new IllegalArgumentException( + "Cannot parse nsQuota: " + parameters[i]); } } else if (parameters[i].equals("-ssQuota")) { i++; @@ -461,7 +462,8 @@ public class RouterAdmin extends Configured implements Tool { ssQuota = StringUtils.TraditionalBinaryPrefix .string2long(parameters[i]); } catch (Exception e) { - System.err.println("Cannot parse ssQuota: " + parameters[i]); + throw new IllegalArgumentException( + "Cannot parse ssQuota: " + parameters[i]); } } @@ -469,8 +471,14 @@ public class RouterAdmin extends Configured implements Tool { } if (nsQuota <= 0 || ssQuota <= 0) { - System.err.println("Input quota value should be a positive number."); - return false; + throw new IllegalArgumentException( + "Input quota value should be a positive number."); + } + + if (nsQuota == HdfsConstants.QUOTA_DONT_SET && + ssQuota == HdfsConstants.QUOTA_DONT_SET) { + throw new IllegalArgumentException( + "Must specify at least one of -nsQuota and -ssQuota."); } return updateQuota(mount, nsQuota, ssQuota); @@ -515,18 +523,23 @@ public class RouterAdmin extends Configured implements Tool { } if (existingEntry == null) { - return false; + throw new IOException(mount + " doesn't exist in mount table."); } else { long nsCount = existingEntry.getQuota().getFileAndDirectoryCount(); long ssCount = existingEntry.getQuota().getSpaceConsumed(); - // If nsQuota or ssQuota was unset, reset corresponding usage - // value to zero. - if (nsQuota == HdfsConstants.QUOTA_DONT_SET) { + // If nsQuota and ssQuota were unset, clear nsQuota and ssQuota. + if (nsQuota == HdfsConstants.QUOTA_DONT_SET && + ssQuota == HdfsConstants.QUOTA_DONT_SET) { nsCount = RouterQuotaUsage.QUOTA_USAGE_COUNT_DEFAULT; - } - - if (nsQuota == HdfsConstants.QUOTA_DONT_SET) { ssCount = RouterQuotaUsage.QUOTA_USAGE_COUNT_DEFAULT; + } else { + // If nsQuota or ssQuota was unset, use the value in mount table. + if (nsQuota == HdfsConstants.QUOTA_DONT_SET) { + nsQuota = existingEntry.getQuota().getQuota(); + } + if (ssQuota == HdfsConstants.QUOTA_DONT_SET) { + ssQuota = existingEntry.getQuota().getSpaceQuota(); + } } RouterQuotaUsage updatedQuota = new RouterQuotaUsage.Builder() http://git-wip-us.apache.org/repos/asf/hadoop/blob/13154600/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterAdminCLI.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterAdminCLI.java b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterAdminCLI.java index 6111c6b..d59e25f 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterAdminCLI.java +++ b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterAdminCLI.java @@ -381,6 +381,8 @@ public class TestRouterAdminCLI { .getMountTableEntries(getRequest); mountTable = getResponse.getEntries().get(0); quotaUsage = mountTable.getQuota(); + // verify if ns quota keeps quondam value + assertEquals(nsQuota, quotaUsage.getQuota()); // verify if ss quota is correctly set assertEquals(2 * 1024 * 1024, quotaUsage.getSpaceQuota()); --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org For additional commands, e-mail: common-commits-help@hadoop.apache.org