You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@twill.apache.org by an...@apache.org on 2014/04/14 21:18:44 UTC

[1/2] git commit: (TWILL-72) fix enableDebugging() with empty list of runnables

Repository: incubator-twill
Updated Branches:
  refs/heads/master 6553ed07c -> 15f4a7e5b


(TWILL-72) fix enableDebugging() with empty list of runnables


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

Branch: refs/heads/master
Commit: 1187ebf790bc836e218b19b00854102e15047f73
Parents: 62e51eb
Author: anew <an...@continuuity.com>
Authored: Mon Apr 14 12:12:41 2014 -0700
Committer: anew <an...@continuuity.com>
Committed: Mon Apr 14 12:12:41 2014 -0700

----------------------------------------------------------------------
 pom.xml                                         |  2 +-
 twill-api/pom.xml                               |  2 +-
 twill-common/pom.xml                            |  2 +-
 twill-core/pom.xml                              |  2 +-
 .../org/apache/twill/internal/JvmOptions.java   |  4 ++-
 .../twill/internal/json/JvmOptionsCodec.java    |  9 ++++---
 .../internal/json/JvmOptionsCodecTest.java      | 25 ++++++++++++++++++
 twill-discovery-api/pom.xml                     |  2 +-
 twill-discovery-core/pom.xml                    |  2 +-
 twill-examples/pom.xml                          |  2 +-
 twill-ext/pom.xml                               |  2 +-
 twill-yarn/pom.xml                              |  2 +-
 .../org/apache/twill/yarn/DebugTestRun.java     | 27 +++++++++++++++++++-
 twill-zookeeper/pom.xml                         |  2 +-
 14 files changed, 70 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-twill/blob/1187ebf7/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index b97bac1..1481d54 100644
--- a/pom.xml
+++ b/pom.xml
@@ -29,7 +29,7 @@
 
     <groupId>org.apache.twill</groupId>
     <artifactId>twill-parent</artifactId>
-    <version>0.2.0-incubating-SNAPSHOT</version>
+    <version>0.3.0-incubating-SNAPSHOT</version>
     <packaging>pom</packaging>
     <name>Apache Twill</name>
     <url>http://twill.incubator.apache.org</url>

http://git-wip-us.apache.org/repos/asf/incubator-twill/blob/1187ebf7/twill-api/pom.xml
----------------------------------------------------------------------
diff --git a/twill-api/pom.xml b/twill-api/pom.xml
index 338a716..250289c 100644
--- a/twill-api/pom.xml
+++ b/twill-api/pom.xml
@@ -24,7 +24,7 @@
     <parent>
         <groupId>org.apache.twill</groupId>
         <artifactId>twill-parent</artifactId>
-        <version>0.2.0-incubating-SNAPSHOT</version>
+        <version>0.3.0-incubating-SNAPSHOT</version>
     </parent>
 
     <artifactId>twill-api</artifactId>

http://git-wip-us.apache.org/repos/asf/incubator-twill/blob/1187ebf7/twill-common/pom.xml
----------------------------------------------------------------------
diff --git a/twill-common/pom.xml b/twill-common/pom.xml
index 7506d84..e9e641f 100644
--- a/twill-common/pom.xml
+++ b/twill-common/pom.xml
@@ -22,7 +22,7 @@
     <parent>
         <artifactId>twill-parent</artifactId>
         <groupId>org.apache.twill</groupId>
-        <version>0.2.0-incubating-SNAPSHOT</version>
+        <version>0.3.0-incubating-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 

http://git-wip-us.apache.org/repos/asf/incubator-twill/blob/1187ebf7/twill-core/pom.xml
----------------------------------------------------------------------
diff --git a/twill-core/pom.xml b/twill-core/pom.xml
index 124547c..7b7a085 100644
--- a/twill-core/pom.xml
+++ b/twill-core/pom.xml
@@ -22,7 +22,7 @@
     <parent>
         <artifactId>twill-parent</artifactId>
         <groupId>org.apache.twill</groupId>
-        <version>0.2.0-incubating-SNAPSHOT</version>
+        <version>0.3.0-incubating-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 

http://git-wip-us.apache.org/repos/asf/incubator-twill/blob/1187ebf7/twill-core/src/main/java/org/apache/twill/internal/JvmOptions.java
----------------------------------------------------------------------
diff --git a/twill-core/src/main/java/org/apache/twill/internal/JvmOptions.java b/twill-core/src/main/java/org/apache/twill/internal/JvmOptions.java
index a260f5b..f827433 100644
--- a/twill-core/src/main/java/org/apache/twill/internal/JvmOptions.java
+++ b/twill-core/src/main/java/org/apache/twill/internal/JvmOptions.java
@@ -18,6 +18,7 @@
 package org.apache.twill.internal;
 
 import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
 
 import java.util.Set;
 
@@ -60,7 +61,8 @@ public final class JvmOptions {
     public DebugOptions(boolean doDebug, boolean doSuspend, Iterable<String> runnables) {
       this.doDebug = doDebug;
       this.doSuspend = doDebug && doSuspend;
-      this.runnables = doDebug && runnables != null ? ImmutableSet.copyOf(runnables) : null;
+      this.runnables =
+        doDebug && runnables != null && Iterables.size(runnables) > 0 ? ImmutableSet.copyOf(runnables) : null;
     }
 
     public boolean doDebug() {

http://git-wip-us.apache.org/repos/asf/incubator-twill/blob/1187ebf7/twill-core/src/main/java/org/apache/twill/internal/json/JvmOptionsCodec.java
----------------------------------------------------------------------
diff --git a/twill-core/src/main/java/org/apache/twill/internal/json/JvmOptionsCodec.java b/twill-core/src/main/java/org/apache/twill/internal/json/JvmOptionsCodec.java
index a1b7eb9..09fc91b 100644
--- a/twill-core/src/main/java/org/apache/twill/internal/json/JvmOptionsCodec.java
+++ b/twill-core/src/main/java/org/apache/twill/internal/json/JvmOptionsCodec.java
@@ -96,8 +96,9 @@ public class JvmOptionsCodec implements JsonSerializer<JvmOptions>, JsonDeserial
         return JvmOptions.DebugOptions.NO_DEBUG;
       }
       Boolean doSuspend = context.deserialize(jsonObj.get("doSuspend"), Boolean.class);
-      Set<String> runnables = context.deserialize(jsonObj.get("runnables"), new TypeToken<Set<String>>() { }.getType());
-      return new JvmOptions.DebugOptions(true, doSuspend, ImmutableSet.copyOf(runnables));
+      Set<String> runnables = context.deserialize(jsonObj.get("runnables"),
+                                                  new TypeToken<Set<String>>() { }.getType());
+      return new JvmOptions.DebugOptions(true, doSuspend, runnables == null ? null : ImmutableSet.copyOf(runnables));
     }
 
     @Override
@@ -105,7 +106,9 @@ public class JvmOptionsCodec implements JsonSerializer<JvmOptions>, JsonDeserial
       JsonObject json = new JsonObject();
       json.add("doDebug", context.serialize(src.doDebug()));
       json.add("doSuspend", context.serialize(src.doSuspend()));
-      json.add("runnables", context.serialize(src.getRunnables()));
+      if (src.getRunnables() != null) {
+        json.add("runnables", context.serialize(src.getRunnables()));
+      }
       return json;
     }
   }

http://git-wip-us.apache.org/repos/asf/incubator-twill/blob/1187ebf7/twill-core/src/test/java/org/apache/twill/internal/json/JvmOptionsCodecTest.java
----------------------------------------------------------------------
diff --git a/twill-core/src/test/java/org/apache/twill/internal/json/JvmOptionsCodecTest.java b/twill-core/src/test/java/org/apache/twill/internal/json/JvmOptionsCodecTest.java
index 66187f2..2791e72 100644
--- a/twill-core/src/test/java/org/apache/twill/internal/json/JvmOptionsCodecTest.java
+++ b/twill-core/src/test/java/org/apache/twill/internal/json/JvmOptionsCodecTest.java
@@ -29,6 +29,8 @@ import java.io.Reader;
 import java.io.StringReader;
 import java.io.StringWriter;
 import java.io.Writer;
+import java.util.Collections;
+import java.util.List;
 
 /**
  * Tests the JvmOptions Codec.
@@ -79,4 +81,27 @@ public class JvmOptionsCodecTest {
     Assert.assertEquals(options.getDebugOptions().doSuspend(), options1.getDebugOptions().doSuspend());
     Assert.assertEquals(options.getDebugOptions().getRunnables(), options1.getDebugOptions().getRunnables());
   }
+
+  @Test
+  public void testNoRunnables() throws Exception {
+    List<String> noRunnables = Collections.emptyList();
+    JvmOptions options = new JvmOptions(null, new JvmOptions.DebugOptions(true, false, noRunnables));
+    final StringWriter writer = new StringWriter();
+    JvmOptionsCodec.encode(options, new OutputSupplier<Writer>() {
+      @Override
+      public Writer getOutput() throws IOException {
+        return writer;
+      }
+    });
+    JvmOptions options1 = JvmOptionsCodec.decode(new InputSupplier<Reader>() {
+      @Override
+      public Reader getInput() throws IOException {
+        return new StringReader(writer.toString());
+      }
+    });
+    Assert.assertEquals(options.getExtraOptions(), options1.getExtraOptions());
+    Assert.assertEquals(options.getDebugOptions().doDebug(), options1.getDebugOptions().doDebug());
+    Assert.assertEquals(options.getDebugOptions().doSuspend(), options1.getDebugOptions().doSuspend());
+    Assert.assertEquals(options.getDebugOptions().getRunnables(), options1.getDebugOptions().getRunnables());
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-twill/blob/1187ebf7/twill-discovery-api/pom.xml
----------------------------------------------------------------------
diff --git a/twill-discovery-api/pom.xml b/twill-discovery-api/pom.xml
index 2a12f39..0ce6c38 100644
--- a/twill-discovery-api/pom.xml
+++ b/twill-discovery-api/pom.xml
@@ -22,7 +22,7 @@
     <parent>
         <artifactId>twill-parent</artifactId>
         <groupId>org.apache.twill</groupId>
-        <version>0.2.0-incubating-SNAPSHOT</version>
+        <version>0.3.0-incubating-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 

http://git-wip-us.apache.org/repos/asf/incubator-twill/blob/1187ebf7/twill-discovery-core/pom.xml
----------------------------------------------------------------------
diff --git a/twill-discovery-core/pom.xml b/twill-discovery-core/pom.xml
index 5570986..2bdad6b 100644
--- a/twill-discovery-core/pom.xml
+++ b/twill-discovery-core/pom.xml
@@ -22,7 +22,7 @@
     <parent>
         <artifactId>twill-parent</artifactId>
         <groupId>org.apache.twill</groupId>
-        <version>0.2.0-incubating-SNAPSHOT</version>
+        <version>0.3.0-incubating-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 

http://git-wip-us.apache.org/repos/asf/incubator-twill/blob/1187ebf7/twill-examples/pom.xml
----------------------------------------------------------------------
diff --git a/twill-examples/pom.xml b/twill-examples/pom.xml
index 60f48fc..79a9581 100644
--- a/twill-examples/pom.xml
+++ b/twill-examples/pom.xml
@@ -23,7 +23,7 @@ limitations under the License.
     <modelVersion>4.0.0</modelVersion>
     <groupId>org.apache.twill.example</groupId>
     <artifactId>twill-examples</artifactId>
-    <version>0.2.0-incubating-SNAPSHOT</version>
+    <version>0.3.0-incubating-SNAPSHOT</version>
     <name>Twill examples</name>
     <packaging>pom</packaging>
 

http://git-wip-us.apache.org/repos/asf/incubator-twill/blob/1187ebf7/twill-ext/pom.xml
----------------------------------------------------------------------
diff --git a/twill-ext/pom.xml b/twill-ext/pom.xml
index d6245bf..3d835bf 100644
--- a/twill-ext/pom.xml
+++ b/twill-ext/pom.xml
@@ -22,7 +22,7 @@ limitations under the License.
     <parent>
         <artifactId>twill-parent</artifactId>
         <groupId>org.apache.twill</groupId>
-        <version>0.2.0-incubating-SNAPSHOT</version>
+        <version>0.3.0-incubating-SNAPSHOT</version>
     </parent>
 
     <modelVersion>4.0.0</modelVersion>

http://git-wip-us.apache.org/repos/asf/incubator-twill/blob/1187ebf7/twill-yarn/pom.xml
----------------------------------------------------------------------
diff --git a/twill-yarn/pom.xml b/twill-yarn/pom.xml
index de45335..014489c 100644
--- a/twill-yarn/pom.xml
+++ b/twill-yarn/pom.xml
@@ -22,7 +22,7 @@
     <parent>
         <artifactId>twill-parent</artifactId>
         <groupId>org.apache.twill</groupId>
-        <version>0.2.0-incubating-SNAPSHOT</version>
+        <version>0.3.0-incubating-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 

http://git-wip-us.apache.org/repos/asf/incubator-twill/blob/1187ebf7/twill-yarn/src/test/java/org/apache/twill/yarn/DebugTestRun.java
----------------------------------------------------------------------
diff --git a/twill-yarn/src/test/java/org/apache/twill/yarn/DebugTestRun.java b/twill-yarn/src/test/java/org/apache/twill/yarn/DebugTestRun.java
index daf0bc1..0cb6fc8 100644
--- a/twill-yarn/src/test/java/org/apache/twill/yarn/DebugTestRun.java
+++ b/twill-yarn/src/test/java/org/apache/twill/yarn/DebugTestRun.java
@@ -102,7 +102,7 @@ public class DebugTestRun extends BaseYarnTest {
   }
 
   @Test
-  public void testDebugPort() throws Exception {
+  public void testDebugPortOneRunnable() throws Exception {
     YarnTwillRunnerService runner = (YarnTwillRunnerService) YarnTestUtils.getTwillRunner();
     runner.startAndWait();
 
@@ -124,4 +124,29 @@ public class DebugTestRun extends BaseYarnTest {
     // Sleep a bit before exiting.
     TimeUnit.SECONDS.sleep(2);
   }
+
+  @Test
+  public void testDebugPortAllRunnables() throws Exception {
+    YarnTwillRunnerService runner = (YarnTwillRunnerService) YarnTestUtils.getTwillRunner();
+    runner.startAndWait();
+
+    TwillController controller = runner.prepare(new DummyApplication())
+                                       .enableDebugging()
+                                       .addLogHandler(new PrinterLogHandler(new PrintWriter(System.out)))
+                                       .start();
+    final CountDownLatch running = new CountDownLatch(1);
+    controller.addListener(new ServiceListenerAdapter() {
+      @Override
+      public void running() {
+        running.countDown();
+      }
+    }, Threads.SAME_THREAD_EXECUTOR);
+
+    Assert.assertTrue(running.await(30, TimeUnit.SECONDS));
+    Assert.assertTrue(waitForDebugPort(controller, "r1", 30));
+    Assert.assertTrue(waitForDebugPort(controller, "r2", 30));
+    controller.stop().get(30, TimeUnit.SECONDS);
+    // Sleep a bit before exiting.
+    TimeUnit.SECONDS.sleep(2);
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-twill/blob/1187ebf7/twill-zookeeper/pom.xml
----------------------------------------------------------------------
diff --git a/twill-zookeeper/pom.xml b/twill-zookeeper/pom.xml
index 70de6bf..8b1f4fe 100644
--- a/twill-zookeeper/pom.xml
+++ b/twill-zookeeper/pom.xml
@@ -22,7 +22,7 @@
     <parent>
         <artifactId>twill-parent</artifactId>
         <groupId>org.apache.twill</groupId>
-        <version>0.2.0-incubating-SNAPSHOT</version>
+        <version>0.3.0-incubating-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 


[2/2] git commit: Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/incubator-twill

Posted by an...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/incubator-twill


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

Branch: refs/heads/master
Commit: 15f4a7e5b7fb4242ad57e002212d6ca66240779d
Parents: 1187ebf 6553ed0
Author: anew <an...@continuuity.com>
Authored: Mon Apr 14 12:17:56 2014 -0700
Committer: anew <an...@continuuity.com>
Committed: Mon Apr 14 12:17:56 2014 -0700

----------------------------------------------------------------------

----------------------------------------------------------------------