diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/ZKConfigurationStore.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/ZKConfigurationStore.java index 7276d3d0143..f25b3cd6af6 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/ZKConfigurationStore.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/ZKConfigurationStore.java @@ -19,6 +19,7 @@ package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.conf; import org.apache.hadoop.thirdparty.com.google.common.annotations.VisibleForTesting; +import org.apache.zookeeper.KeeperException.NodeExistsException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.apache.hadoop.conf.Configuration; @@ -92,7 +93,11 @@ public void initialize(Configuration config, Configuration schedConf, this.fencingNodePath = getNodePath(znodeParentPath, FENCING_PATH); this.confVersionPath = getNodePath(znodeParentPath, CONF_VERSION_PATH); - zkManager.createRootDirRecursively(znodeParentPath, zkAcl); + try { + zkManager.createRootDirRecursively(znodeParentPath, zkAcl); + } catch(NodeExistsException e) { + // We can get node exists if another RM is initing store in parallel + } zkManager.delete(fencingNodePath); if (createNewZkPath(logsPath)) { @@ -244,7 +249,13 @@ public long getConfigVersion() throws Exception { */ private boolean createNewZkPath(String path) throws Exception { if (!zkManager.exists(path)) { - zkManager.create(path); + try { + zkManager.create(path); + } catch(NodeExistsException e) { + // We can get node exists if another RM is initing store in parallel + // No need to create now as the other RM will do that + return false; + } return true; } else { return false; @@ -279,8 +290,12 @@ private void safeSetZkData(String path, Object data) throws Exception { @VisibleForTesting protected void safeCreateZkData(String path, byte[] data) throws Exception { - zkManager.safeCreate(path, data, zkAcl, CreateMode.PERSISTENT, - zkAcl, fencingNodePath); + try { + zkManager.safeCreate(path, data, zkAcl, CreateMode.PERSISTENT, + zkAcl, fencingNodePath); + } catch(NodeExistsException e) { + // We can get node exists if another RM is initing store in parallel + } } private static String getNodePath(String root, String nodeName) {