Bläddra i källkod

YARN-2725. Added test cases of retrying creating znode in ZKRMStateStore. Contributed by Tsuyoshi Ozawa
(cherry picked from commit d701acc9c67adc578ba18035edde1166eedaae98)

Jian He 10 år sedan
förälder
incheckning
f71c49c5e3

+ 3 - 0
hadoop-yarn-project/CHANGES.txt

@@ -257,6 +257,9 @@ Release 2.8.0 - UNRELEASED
     YARN-3375. NodeHealthScriptRunner.shouldRun() check is performing 3 times for 
     starting NodeHealthScriptRunner. (Devaraj K via wangda)
 
+    YARN-2725. Added test cases of retrying creating znode in ZKRMStateStore.
+    (Tsuyoshi Ozawa via jianhe)
+
 Release 2.7.1 - UNRELEASED
 
   INCOMPATIBLE CHANGES

+ 1 - 1
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/ZKRMStateStore.java

@@ -297,7 +297,7 @@ public class ZKRMStateStore extends RMStateStore {
     createRootDir(amrmTokenSecretManagerRoot);
   }
 
-  private void createRootDir(final String rootPath) throws Exception {
+  protected void createRootDir(final String rootPath) throws Exception {
     // For root dirs, we shouldn't use the doMulti helper methods
     new ZKAction<String>() {
       @Override

+ 11 - 0
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/TestZKRMStateStore.java

@@ -100,6 +100,15 @@ public class TestZKRMStateStore extends RMStateStoreTestBase {
         return workingZnode + "/" + ROOT_ZNODE_NAME + "/" + RM_APP_ROOT + "/"
             + appId;
       }
+
+      /**
+       * Emulating retrying createRootDir not to raise NodeExist exception
+       * @throws Exception
+       */
+      public void testRetryingCreateRootDir() throws Exception {
+        createRootDir(znodeWorkingPath);
+      }
+
     }
 
     public RMStateStore getRMStateStore() throws Exception {
@@ -148,6 +157,8 @@ public class TestZKRMStateStore extends RMStateStoreTestBase {
     testDeleteStore(zkTester);
     testRemoveApplication(zkTester);
     testAMRMTokenSecretManagerStateStore(zkTester);
+    ((TestZKRMStateStoreTester.TestZKRMStateStoreInternal)
+        zkTester.getRMStateStore()).testRetryingCreateRootDir();
   }
 
   @Test (timeout = 60000)