You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@slider.apache.org by st...@apache.org on 2014/10/21 15:57:41 UTC
[7/9] git commit: SLIDER-509 Add/extend funtests to use registry (and
resolve command)
SLIDER-509 Add/extend funtests to use registry (and resolve command)
Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/94c6060b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/94c6060b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/94c6060b
Branch: refs/heads/develop
Commit: 94c6060b1764f0b8f4c776b26f3af8cc7a34fe76
Parents: ee1c244
Author: Steve Loughran <st...@apache.org>
Authored: Tue Oct 21 14:24:30 2014 +0100
Committer: Steve Loughran <st...@apache.org>
Committed: Tue Oct 21 14:24:30 2014 +0100
----------------------------------------------------------------------
.../org/apache/slider/client/SliderClient.java | 35 +++++++++++++++-----
.../funtest/framework/CommandTestBase.groovy | 7 ++++
.../lifecycle/AgentClusterLifecycleIT.groovy | 15 +--------
3 files changed, 34 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/94c6060b/slider-core/src/main/java/org/apache/slider/client/SliderClient.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/client/SliderClient.java b/slider-core/src/main/java/org/apache/slider/client/SliderClient.java
index d503637..e89ca65 100644
--- a/slider-core/src/main/java/org/apache/slider/client/SliderClient.java
+++ b/slider-core/src/main/java/org/apache/slider/client/SliderClient.java
@@ -30,7 +30,9 @@ import org.apache.hadoop.fs.permission.FsPermission;
import org.apache.hadoop.hdfs.DFSConfigKeys;
import org.apache.hadoop.hdfs.HdfsConfiguration;
import org.apache.hadoop.net.NetUtils;
+import org.apache.hadoop.registry.client.api.RegistryConstants;
import org.apache.hadoop.registry.client.binding.RegistryPathUtils;
+import org.apache.hadoop.registry.client.types.RegistryPathStatus;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.security.alias.CredentialProvider;
import org.apache.hadoop.security.alias.CredentialProviderFactory;
@@ -1315,12 +1317,14 @@ public class SliderClient extends AbstractSliderLaunchedService implements RunSe
if (serviceArgs.getFilesystemBinding() != null) {
commandLine.add(Arguments.ARG_FILESYSTEM, serviceArgs.getFilesystemBinding());
}
-/*
+
+ /**
+ * pass the registry binding
+ */
addConfOptionToCLI(commandLine, config, REGISTRY_PATH,
DEFAULT_REGISTRY_PATH);
addMandatoryConfOptionToCLI(commandLine, config,
RegistryConstants.KEY_REGISTRY_ZK_QUORUM);
-*/
if (clusterSecure) {
// if the cluster is secure, make sure that
@@ -2299,7 +2303,6 @@ public class SliderClient extends AbstractSliderLaunchedService implements RunSe
public ApplicationReport getApplicationReport(ApplicationId appId)
throws YarnException, IOException {
return new LaunchedApplication(appId, yarnClient).getApplicationReport();
-
}
/**
@@ -2329,30 +2332,44 @@ public class SliderClient extends AbstractSliderLaunchedService implements RunSe
}
Map<String, ServiceRecord> recordMap;
+ Map<String, RegistryPathStatus> znodes;
try {
- recordMap = listServiceRecords(operations, path);
+ znodes = statChildren(registryOperations, path);
+ recordMap = extractServiceRecords(registryOperations,
+ path,
+ znodes.values());
} catch (PathNotFoundException e) {
// treat the root directory as if if is always there
if ("/".equals(path)) {
+ znodes = new HashMap<String, RegistryPathStatus>(0);
recordMap = new HashMap<String, ServiceRecord>(0);
} else {
throw e;
}
}
-
+ // subtract all records from the znodes map to get pure directories
+ log.info("Entries: {}", znodes.size());
+
+ for (String name : znodes.keySet()) {
+ println(" " + name);
+ }
+ println("");
+
+ log.info("Service records: {}", recordMap.size());
for (Entry<String, ServiceRecord> recordEntry : recordMap.entrySet()) {
String name = recordEntry.getKey();
ServiceRecord instance = recordEntry.getValue();
String json = serviceRecordMarshal.toJson(instance);
if (destDir == null) {
- print(name);
- print(json);
+ println(name);
+ println(json);
} else {
String filename = RegistryPathUtils.lastPathEntry(name) + ".json";
File jsonFile = new File(destDir, filename);
SliderUtils.write(jsonFile,
- serviceRecordMarshal.toBytes(instance), true);
+ serviceRecordMarshal.toBytes(instance),
+ true);
}
}
} else {
@@ -2365,7 +2382,7 @@ public class SliderClient extends AbstractSliderLaunchedService implements RunSe
if (outFile != null) {
SliderUtils.write(outFile, serviceRecordMarshal.toBytes(instance), true);
} else {
- print(serviceRecordMarshal.toJson(instance));
+ println(serviceRecordMarshal.toJson(instance));
}
}
// TODO JDK7
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/94c6060b/slider-funtest/src/main/groovy/org/apache/slider/funtest/framework/CommandTestBase.groovy
----------------------------------------------------------------------
diff --git a/slider-funtest/src/main/groovy/org/apache/slider/funtest/framework/CommandTestBase.groovy b/slider-funtest/src/main/groovy/org/apache/slider/funtest/framework/CommandTestBase.groovy
index 1878f63..58c61ea 100644
--- a/slider-funtest/src/main/groovy/org/apache/slider/funtest/framework/CommandTestBase.groovy
+++ b/slider-funtest/src/main/groovy/org/apache/slider/funtest/framework/CommandTestBase.groovy
@@ -83,6 +83,12 @@ abstract class CommandTestBase extends SliderTestUtils {
public static final String TEST_AM_KEYTAB
static File keytabFile
+ /**
+ * shell-escaped ~ symbol. On windows this does
+ * not need to be escaped
+ */
+ static final String TILDE
+
/*
Static initializer for test configurations. If this code throws exceptions
(which it may) the class will not be instantiable.
@@ -108,6 +114,7 @@ abstract class CommandTestBase extends SliderTestUtils {
TEST_AM_KEYTAB = SLIDER_CONFIG.getTrimmed(
KEY_TEST_AM_KEYTAB)
+ TILDE = Shell.WINDOWS? "~" : "\\~"
}
@Rule
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/94c6060b/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AgentClusterLifecycleIT.groovy
----------------------------------------------------------------------
diff --git a/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AgentClusterLifecycleIT.groovy b/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AgentClusterLifecycleIT.groovy
index 8fbe6b2..3ab7897 100644
--- a/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AgentClusterLifecycleIT.groovy
+++ b/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AgentClusterLifecycleIT.groovy
@@ -99,26 +99,13 @@ public class AgentClusterLifecycleIT extends AgentCommandTestBase
//simple status
status(0, CLUSTER)
-
- // resolve the ~ path
-
- resolve(0, [ARG_LIST, ARG_PATH, "~"])
- // running app
- resolve(0, [ARG_LIST, ARG_PATH, SliderKeys.APP_TYPE, CLUSTER])
- // and the service record
- File serviceRecordFile = File.createTempFile("tempfile", ".json")
- resolve(0, [ARG_PATH, SliderKeys.APP_TYPE, CLUSTER,
- ARG_OUTPUT, serviceRecordFile.absolutePath])
- RegistryUtils.ServiceRecordMarshal marshal = new RegistryUtils.ServiceRecordMarshal()
-
- ServiceRecord serviceRecord = marshal.fromFile(serviceRecordFile)
//now status to a temp file
File jsonStatus = File.createTempFile("tempfile", ".json")
try {
slider(0,
[
- SliderActions.ACTION_STATUS, CLUSTER,
+ ACTION_STATUS, CLUSTER,
ARG_OUTPUT, jsonStatus.canonicalPath
])