diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index fcc02d27c5..47f931f221 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -350,6 +350,9 @@ Release 2.4.0 - UNRELEASED HDFS-5882. TestAuditLogs is flaky (jxiang via cmccabe) + HDFS-5900. Cannot set cache pool limit of "unlimited" via CacheAdmin. + (wang) + Release 2.3.0 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/CacheAdmin.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/CacheAdmin.java index 290e60087f..b674d09d50 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/CacheAdmin.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/CacheAdmin.java @@ -140,6 +140,18 @@ private static Long parseTtlString(String maxTtlString) throws IOException { return maxTtl; } + private static Long parseLimitString(String limitString) { + Long limit = null; + if (limitString != null) { + if (limitString.equalsIgnoreCase("unlimited")) { + limit = CachePoolInfo.LIMIT_UNLIMITED; + } else { + limit = Long.parseLong(limitString); + } + } + return limit; + } + private static Expiration parseExpirationString(String ttlString) throws IOException { Expiration ex = null; @@ -650,8 +662,8 @@ public int run(Configuration conf, List args) throws IOException { info.setMode(new FsPermission(mode)); } String limitString = StringUtils.popOptionWithArgument("-limit", args); - if (limitString != null) { - long limit = Long.parseLong(limitString); + Long limit = parseLimitString(limitString); + if (limit != null) { info.setLimit(limit); } String maxTtlString = StringUtils.popOptionWithArgument("-maxTtl", args); @@ -726,8 +738,7 @@ public int run(Configuration conf, List args) throws IOException { Integer mode = (modeString == null) ? null : Integer.parseInt(modeString, 8); String limitString = StringUtils.popOptionWithArgument("-limit", args); - Long limit = (limitString == null) ? - null : Long.parseLong(limitString); + Long limit = parseLimitString(limitString); String maxTtlString = StringUtils.popOptionWithArgument("-maxTtl", args); Long maxTtl = null; try { diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testCacheAdminConf.xml b/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testCacheAdminConf.xml index 64de6bf87c..13f1b9ae14 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testCacheAdminConf.xml +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testCacheAdminConf.xml @@ -469,6 +469,8 @@ -removePool pool1 + -removePool pool2 + -removePool pool3 @@ -489,5 +491,33 @@ + + + Testing setting pool unlimited limits + + -addPool pool1 -limit unlimited -owner andrew -group andrew + -addPool pool2 -limit 10 -owner andrew -group andrew + -modifyPool pool2 -limit unlimited + -listPools + + + -removePool pool1 + -removePool pool2 + + + + SubstringComparator + Found 2 results + + + SubstringComparator + pool1 andrew andrew rwxr-xr-x unlimited never + + + SubstringComparator + pool2 andrew andrew rwxr-xr-x unlimited never + + +