YARN-3077. Fixed RM to create zk root path recursively. Contributed by Chun Chen

This commit is contained in:
Jian He 2015-01-30 17:34:49 -08:00
parent 09ad9a868a
commit 054a947989
3 changed files with 20 additions and 3 deletions

View File

@ -449,6 +449,8 @@ Release 2.7.0 - UNRELEASED
YARN-3099. Capacity Scheduler LeafQueue/ParentQueue should use ResourceUsage
to track used-resources-by-label.(Wangda Tan via jianhe)
YARN-3077. Fixed RM to create zk root path recursively. (Chun Chen via jianhe)
Release 2.6.0 - 2014-11-18
INCOMPATIBLE CHANGES

View File

@ -30,6 +30,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import com.google.common.base.Preconditions;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.classification.InterfaceAudience.Private;
@ -275,7 +276,7 @@ public class ZKRMStateStore extends RMStateStore {
createConnection();
// ensure root dirs exist
createRootDir(znodeWorkingPath);
createRootDirRecursively(znodeWorkingPath);
createRootDir(zkRootNodePath);
if (HAUtil.isHAEnabled(getConfig())){
fence();
@ -1143,4 +1144,18 @@ public class ZKRMStateStore extends RMStateStore {
setDataWithRetries(amrmTokenSecretManagerRoot, stateData, -1);
}
/**
* Utility function to ensure that the configured base znode exists.
* This recursively creates the znode as well as all of its parents.
*/
private void createRootDirRecursively(String path) throws Exception {
String pathParts[] = path.split("/");
Preconditions.checkArgument(pathParts.length >= 1 && pathParts[0].isEmpty(),
"Invalid path: %s", path);
StringBuilder sb = new StringBuilder();
for (int i = 1; i < pathParts.length; i++) {
sb.append("/").append(pathParts[i]);
createRootDir(sb.toString());
}
}
}

View File

@ -103,7 +103,7 @@ public class TestZKRMStateStore extends RMStateStoreTestBase {
public RMStateStore getRMStateStore() throws Exception {
YarnConfiguration conf = new YarnConfiguration();
workingZnode = "/Test";
workingZnode = "/jira/issue/3077/rmstore";
conf.set(YarnConfiguration.RM_ZK_ADDRESS, hostPort);
conf.set(YarnConfiguration.ZK_RM_STATE_STORE_PARENT_PATH, workingZnode);
this.client = createClient();
@ -161,7 +161,7 @@ public class TestZKRMStateStore extends RMStateStoreTestBase {
@Override
public RMStateStore getRMStateStore() throws Exception {
YarnConfiguration conf = new YarnConfiguration();
workingZnode = "/Test";
workingZnode = "/jira/issue/3077/rmstore";
conf.set(YarnConfiguration.RM_ZK_ADDRESS, hostPort);
conf.set(YarnConfiguration.ZK_RM_STATE_STORE_PARENT_PATH, workingZnode);
this.client = createClient();