You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@twill.apache.org by ch...@apache.org on 2013/12/13 09:14:40 UTC

git commit: Added more documentation for getting started. Also removed enable source code line number.

Updated Branches:
  refs/heads/site b30956ec7 -> 899986226


Added more documentation for getting started.
Also removed enable source code line number.

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

Branch: refs/heads/site
Commit: 899986226d83825019f1eb50c2b23ea0c682060f
Parents: b30956e
Author: Terence Yim <te...@continuuity.com>
Authored: Fri Dec 13 00:14:30 2013 -0800
Committer: Terence Yim <te...@continuuity.com>
Committed: Fri Dec 13 00:14:30 2013 -0800

----------------------------------------------------------------------
 src/site/markdown/GettingStarted.md | 74 +++++++++++++++++++++++++++++++-
 src/site/site.xml                   |  1 -
 2 files changed, 73 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-twill/blob/89998622/src/site/markdown/GettingStarted.md
----------------------------------------------------------------------
diff --git a/src/site/markdown/GettingStarted.md b/src/site/markdown/GettingStarted.md
index d06099d..c8384a3 100644
--- a/src/site/markdown/GettingStarted.md
+++ b/src/site/markdown/GettingStarted.md
@@ -51,4 +51,76 @@ public class EchoServer implements Runnable {
     }
   }
 }
-```
\ No newline at end of file
+```
+
+Our example defines an implementation of `Runnable` that implements the `run()` method.
+The `EchoServer` is now a `Runnable` that can be executed by an `ExecutorService`:
+
+```java
+ExecutorService service = Executors.newFixedThreadPool(2);
+service.submit(new EchoServer());
+```
+
+The above model is familiar, but now assume you want to run your `EchoServer` on a YARN cluster.
+To do this, all you need to do is implement the `TwillRunnable` interface similarly to how you
+normally implement `Runnable`:
+
+```java
+public class EchoServer implements TwillRunnable {
+
+  private static Logger LOG = LoggerFactory.getLogger(EchoServer.class);
+  private final ServerSocket serverSocket;
+  private final int port;
+
+  public EchoServer() {
+    ...
+  }
+
+  @Override
+  public void run() {
+    while ( isRunning() ) {
+      Socket socket = serverSocket.accept();
+      ...
+    }
+  }
+}
+```
+
+To run `EchoServer` on the YARN cluster, you need a `TwillRunnerService`, which is similar to `ExecutorService`.
+You can specify the YARN cluster configuration and connection string to a running instance of a Zookeeper service
+to create an instance of `TwillRunnerService`:
+
+```java
+TwillRunnerService runnerService = new YarnTwillRunnerService(
+  new YarnConfiguration(), zkConnectStr);
+runnerService.startAndWait();
+```
+
+Now you are read to run the EchoServer on YARN, by simply preparing and starting through the `TwillRunnerService`. You
+can also attach log handler to receives logs generated by EchoService running on some nodes in the cluster:
+
+```java
+TwillController controller = runnerService.prepare(new EchoServer())
+  .addLogHandler(new PrinterLogHandler(new PrintWriter(System.out)))
+  .start();
+```
+
+Now that the `EchoServer` is started and you can inspect or control the application through the `TwillController`.
+For example, you can attach listeners for state changes:
+
+```java
+controller.addListener(new ListenerAdapter() {
+  @Override
+  public void running() {
+    LOG.info('Echo Server Started');
+  }
+}
+```
+
+You can also stop the application through the `TwillController`:
+
+```java
+controller.stop().get();
+```
+
+This will shut down the application master and all the containers.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-twill/blob/89998622/src/site/site.xml
----------------------------------------------------------------------
diff --git a/src/site/site.xml b/src/site/site.xml
index 1690c67..c400c01 100644
--- a/src/site/site.xml
+++ b/src/site/site.xml
@@ -76,7 +76,6 @@
             <sideBarEnabled>true</sideBarEnabled>
             <leftColumnClass>span2</leftColumnClass>
             <bodyColumnClass>span10</bodyColumnClass>
-            <sourceLineNumbersEnabled>true</sourceLineNumbersEnabled>
         </fluidoSkin>
     </custom>