nemo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From johnya...@apache.org
Subject [incubator-nemo] branch master updated: [NEMO-202] Make job launcher handle empty user_args #147
Date Mon, 05 Nov 2018 00:20:14 GMT
This is an automated email from the ASF dual-hosted git repository.

johnyangk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nemo.git


The following commit(s) were added to refs/heads/master by this push:
     new f34324e  [NEMO-202] Make job launcher handle empty user_args #147
f34324e is described below

commit f34324e9aa22e78b0cb00e745f5c9e031f61417e
Author: Yunseong Lee <yunseong.lee@me.com>
AuthorDate: Mon Nov 5 09:20:09 2018 +0900

    [NEMO-202] Make job launcher handle empty user_args #147
    
    JIRA: [NEMO-202: Bug with empty string user_args](https://issues.apache.org/jira/projects/NEMO/issues/NEMO-202)
    
    **Major changes:**
    - Make JobLauncher handle an empty string ("") for user_args
    - When an empty string is given, JobLauncher passes an empty array (String[0]) to the
application.
    
    **Minor changes to note:**
    - N/A
    
    **Tests for the changes:**
    - Added SparkScala#testALSEmptyUserArgs.
    
    **Other comments:**
    - N/A
    
    Closes #147
---
 client/src/main/java/org/apache/nemo/client/JobLauncher.java |  4 +++-
 .../test/java/org/apache/nemo/examples/spark/SparkScala.java | 12 +++++++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)

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 00d1ba1..7ec5fdd 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 @@ public final class JobLauncher {
   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 final class JobLauncher {
   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 108fa29..3dcf490 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 final class SparkScala {
     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());
   }


Mime
View raw message