diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ErasureCodingPolicyManager.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ErasureCodingPolicyManager.java index 3a46c3049a..90699b43a4 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ErasureCodingPolicyManager.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ErasureCodingPolicyManager.java @@ -242,14 +242,15 @@ public synchronized ErasureCodingPolicy addPolicy( policy.getSchema(), policy.getCellSize()); for (ErasureCodingPolicy p : getPolicies()) { if (p.getName().equals(assignedNewName)) { - throw new HadoopIllegalArgumentException("The policy name " + - assignedNewName + " already exists"); + LOG.info("The policy name " + assignedNewName + " already exists"); + return p; } if (p.getSchema().equals(policy.getSchema()) && p.getCellSize() == policy.getCellSize()) { - throw new HadoopIllegalArgumentException("A policy with same schema " + LOG.info("A policy with same schema " + policy.getSchema().toString() + " and cell size " + p.getCellSize() + " already exists"); + return p; } } policy.setName(assignedNewName); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestErasureCodingPolicies.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestErasureCodingPolicies.java index 19277c447b..4f2040b60f 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestErasureCodingPolicies.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestErasureCodingPolicies.java @@ -718,7 +718,7 @@ public void testAddErasureCodingPolicies() throws Exception { policyArray = new ErasureCodingPolicy[]{policy0}; responses = fs.addErasureCodingPolicies(policyArray); assertEquals(1, responses.length); - assertFalse(responses[0].isSucceed()); + assertTrue(responses[0].isSucceed()); // Test add policy successfully newPolicy = diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNamenodeRetryCache.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNamenodeRetryCache.java index d217813bd5..42ff6989e1 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNamenodeRetryCache.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNamenodeRetryCache.java @@ -436,7 +436,7 @@ public void testRetryCacheRebuild() throws Exception { LightWeightCache cacheSet = (LightWeightCache) namesystem.getRetryCache().getCacheSet(); - assertEquals("Retry cache size is wrong", 26, cacheSet.size()); + assertEquals("Retry cache size is wrong", 34, cacheSet.size()); Map oldEntries = new HashMap(); @@ -455,7 +455,7 @@ public void testRetryCacheRebuild() throws Exception { assertTrue(namesystem.hasRetryCache()); cacheSet = (LightWeightCache) namesystem .getRetryCache().getCacheSet(); - assertEquals("Retry cache size is wrong", 26, cacheSet.size()); + assertEquals("Retry cache size is wrong", 34, cacheSet.size()); iter = cacheSet.iterator(); while (iter.hasNext()) { CacheEntry entry = iter.next(); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestRetryCacheWithHA.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestRetryCacheWithHA.java index b40006be73..1d114d62e4 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestRetryCacheWithHA.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestRetryCacheWithHA.java @@ -166,7 +166,7 @@ public void testRetryCacheOnStandbyNN() throws Exception { FSNamesystem fsn0 = cluster.getNamesystem(0); LightWeightCache cacheSet = (LightWeightCache) fsn0.getRetryCache().getCacheSet(); - assertEquals("Retry cache size is wrong", 26, cacheSet.size()); + assertEquals("Retry cache size is wrong", 34, cacheSet.size()); Map oldEntries = new HashMap(); @@ -187,7 +187,7 @@ public void testRetryCacheOnStandbyNN() throws Exception { FSNamesystem fsn1 = cluster.getNamesystem(1); cacheSet = (LightWeightCache) fsn1 .getRetryCache().getCacheSet(); - assertEquals("Retry cache size is wrong", 26, cacheSet.size()); + assertEquals("Retry cache size is wrong", 34, cacheSet.size()); iter = cacheSet.iterator(); while (iter.hasNext()) { CacheEntry entry = iter.next();