Repository: twill
Updated Branches:
  refs/heads/feature/TWILL-242-fix-extra-jvm-opts [created] 7187ed966


(TWILL-242) Fixed the dropping of extra jvm opts

Project: http://git-wip-us.apache.org/repos/asf/twill/repo
Commit: http://git-wip-us.apache.org/repos/asf/twill/commit/7187ed96
Tree: http://git-wip-us.apache.org/repos/asf/twill/tree/7187ed96
Diff: http://git-wip-us.apache.org/repos/asf/twill/diff/7187ed96

Branch: refs/heads/feature/TWILL-242-fix-extra-jvm-opts
Commit: 7187ed966139fd05ce4a6a8d79b65feac34545ae
Parents: 4356c28
Author: Terence Yim <cht...@apache.org>
Authored: Wed Aug 9 14:56:33 2017 -0700
Committer: Terence Yim <cht...@apache.org>
Committed: Wed Aug 9 14:56:33 2017 -0700

----------------------------------------------------------------------
 .../main/java/org/apache/twill/yarn/YarnTwillPreparer.java  | 9 ++++-----
 .../org/apache/twill/yarn/CustomClassLoaderRunnable.java    | 3 ++-
 .../org/apache/twill/yarn/CustomClassLoaderTestRun.java     | 1 +
 3 files changed, 7 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/twill/blob/7187ed96/twill-yarn/src/main/java/org/apache/twill/yarn/YarnTwillPreparer.java
----------------------------------------------------------------------
diff --git 
a/twill-yarn/src/main/java/org/apache/twill/yarn/YarnTwillPreparer.java 
b/twill-yarn/src/main/java/org/apache/twill/yarn/YarnTwillPreparer.java
index 0eba62b..1ea2ab3 100644
--- a/twill-yarn/src/main/java/org/apache/twill/yarn/YarnTwillPreparer.java
+++ b/twill-yarn/src/main/java/org/apache/twill/yarn/YarnTwillPreparer.java
@@ -473,7 +473,7 @@ final class YarnTwillPreparer implements TwillPreparer {
       return extraOptions;
     }
     String classLoaderProperty = "-D" + Constants.TWILL_CONTAINER_CLASSLOADER 
+ "=" + classLoaderClassName;
-    return extraOptions.isEmpty() ? classLoaderProperty : " " + 
classLoaderProperty;
+    return extraOptions.isEmpty() ? classLoaderProperty : extraOptions + " " + 
classLoaderProperty;
   }
 
   private void setEnv(String runnableName, Map<String, String> env, boolean 
overwrite) {
@@ -774,17 +774,16 @@ final class YarnTwillPreparer implements TwillPreparer {
   }
 
   private JvmOptions saveJvmOptions(final Path targetPath) throws IOException {
-    // Updates the extra options with the classloader name if necessary
-    final String globalOptions = addClassLoaderClassName(extraOptions);
     // Append runnable specific extra options.
     Map<String, String> runnableExtraOptions = Maps.newHashMap(
       Maps.transformValues(this.runnableExtraOptions, new Function<String, 
String>() {
         @Override
-        public String apply(String extraOptions) {
-          return globalOptions.isEmpty() ? extraOptions : globalOptions + " " 
+ extraOptions;
+        public String apply(String options) {
+          return addClassLoaderClassName(extraOptions.isEmpty() ? options : 
extraOptions + " " + options);
         }
       }));
 
+    String globalOptions = addClassLoaderClassName(extraOptions);
     JvmOptions jvmOptions = new JvmOptions(globalOptions, 
runnableExtraOptions, debugOptions);
     if (globalOptions.isEmpty() && runnableExtraOptions.isEmpty()
       && JvmOptions.DebugOptions.NO_DEBUG.equals(debugOptions)) {

http://git-wip-us.apache.org/repos/asf/twill/blob/7187ed96/twill-yarn/src/test/java/org/apache/twill/yarn/CustomClassLoaderRunnable.java
----------------------------------------------------------------------
diff --git 
a/twill-yarn/src/test/java/org/apache/twill/yarn/CustomClassLoaderRunnable.java 
b/twill-yarn/src/test/java/org/apache/twill/yarn/CustomClassLoaderRunnable.java
index 591f931..d088b07 100644
--- 
a/twill-yarn/src/test/java/org/apache/twill/yarn/CustomClassLoaderRunnable.java
+++ 
b/twill-yarn/src/test/java/org/apache/twill/yarn/CustomClassLoaderRunnable.java
@@ -41,7 +41,8 @@ public final class CustomClassLoaderRunnable extends 
AbstractTwillRunnable {
     try {
       Class<?> cls = Class.forName(GENERATED_CLASS_NAME);
       java.lang.reflect.Method announce = cls.getMethod("announce", 
ServiceAnnouncer.class, String.class, int.class);
-      announce.invoke(cls.newInstance(), getContext(), 
System.getProperty("service.name"), 54321);
+      announce.invoke(cls.newInstance(), getContext(), 
System.getProperty("service.name"),
+                      Integer.getInteger("service.port"));
       Uninterruptibles.awaitUninterruptibly(stopLatch);
     } catch (Exception e) {
       LOG.error("Failed to call announce on " + GENERATED_CLASS_NAME, e);

http://git-wip-us.apache.org/repos/asf/twill/blob/7187ed96/twill-yarn/src/test/java/org/apache/twill/yarn/CustomClassLoaderTestRun.java
----------------------------------------------------------------------
diff --git 
a/twill-yarn/src/test/java/org/apache/twill/yarn/CustomClassLoaderTestRun.java 
b/twill-yarn/src/test/java/org/apache/twill/yarn/CustomClassLoaderTestRun.java
index f0a75b2..ba12e0f 100644
--- 
a/twill-yarn/src/test/java/org/apache/twill/yarn/CustomClassLoaderTestRun.java
+++ 
b/twill-yarn/src/test/java/org/apache/twill/yarn/CustomClassLoaderTestRun.java
@@ -34,6 +34,7 @@ public class CustomClassLoaderTestRun extends BaseYarnTest {
     TwillController controller = getTwillRunner().prepare(new 
CustomClassLoaderRunnable())
       .setClassLoader(CustomClassLoader.class.getName())
       .addLogHandler(new PrinterLogHandler(new PrintWriter(System.out, true)))
+      .setJVMOptions("-Dservice.port=54321")
       .setJVMOptions(CustomClassLoaderRunnable.class.getSimpleName(), 
"-Dservice.name=custom")
       .start();
 

Reply via email to