johnyangk closed pull request #147: [NEMO-202] Make job launcher handle empty
user_args
URL: https://github.com/apache/incubator-nemo/pull/147
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/client/src/main/java/org/apache/nemo/client/JobLauncher.java
b/client/src/main/java/org/apache/nemo/client/JobLauncher.java
index 00d1ba171..7ec5fddc6 100644
--- a/client/src/main/java/org/apache/nemo/client/JobLauncher.java
+++ b/client/src/main/java/org/apache/nemo/client/JobLauncher.java
@@ -86,6 +86,7 @@
private static CountDownLatch jobDoneLatch;
private static String serializedDAG;
private static final List<?> COLLECTED_DATA = new ArrayList<>();
+ private static final String[] EMPTY_USER_ARGS = new String[0];
/**
* private constructor.
@@ -239,7 +240,8 @@ public static void launchDAG(final DAG dag, final
Map<Serializable, Object> broa
private static void runUserProgramMain(final Configuration jobConf) throws
Exception {
final Injector injector = TANG.newInjector(jobConf);
final String className =
injector.getNamedInstance(JobConf.UserMainClass.class);
- final String[] args =
injector.getNamedInstance(JobConf.UserMainArguments.class).split(" ");
+ final String userArgsString =
injector.getNamedInstance(JobConf.UserMainArguments.class);
+ final String[] args = userArgsString.isEmpty() ? EMPTY_USER_ARGS :
userArgsString.split(" ");
final Class userCode = Class.forName(className);
final Method method = userCode.getMethod("main", String[].class);
if (!Modifier.isStatic(method.getModifiers())) {
diff --git
a/examples/spark/src/test/java/org/apache/nemo/examples/spark/SparkScala.java
b/examples/spark/src/test/java/org/apache/nemo/examples/spark/SparkScala.java
index 108fa2920..3dcf490ad 100644
---
a/examples/spark/src/test/java/org/apache/nemo/examples/spark/SparkScala.java
+++
b/examples/spark/src/test/java/org/apache/nemo/examples/spark/SparkScala.java
@@ -113,7 +113,17 @@ public void testALS() throws Exception {
JobLauncher.main(builder
.addJobId(SparkALS.class.getSimpleName() + "_test")
.addUserMain(SparkALS.class.getCanonicalName())
- .addUserArgs("100") // TODO #202: Bug with empty string user_args
+ .addUserArgs("100")
+ .addOptimizationPolicy(DefaultPolicy.class.getCanonicalName())
+ .build());
+ }
+
+ @Test(timeout = TIMEOUT)
+ public void testALSEmptyUserArgs() throws Exception {
+ JobLauncher.main(builder
+ .addJobId(SparkALS.class.getSimpleName() + "_test")
+ .addUserMain(SparkALS.class.getCanonicalName())
+ .addUserArgs("")
.addOptimizationPolicy(DefaultPolicy.class.getCanonicalName())
.build());
}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services