Repository: incubator-twill Updated Branches: refs/heads/site a61ef0c49 -> 81a5e462b
Removing files that are for generating Twill sites - Those files are maintained in the âsiteâ branch and are not part of the source distribution. Project: http://git-wip-us.apache.org/repos/asf/incubator-twill/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-twill/commit/a303e3bb Tree: http://git-wip-us.apache.org/repos/asf/incubator-twill/tree/a303e3bb Diff: http://git-wip-us.apache.org/repos/asf/incubator-twill/diff/a303e3bb Branch: refs/heads/site Commit: a303e3bbd25fed4fa14177fc955bd58310768789 Parents: bb0212d Author: Terence Yim <[email protected]> Authored: Mon Aug 3 11:40:18 2015 -0700 Committer: Terence Yim <[email protected]> Committed: Mon Aug 3 11:40:18 2015 -0700 ---------------------------------------------------------------------- src/site/markdown/GettingStarted.md | 191 ------------------------------- src/site/markdown/index.md | 35 ------ src/site/site.xml | 84 -------------- 3 files changed, 310 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-twill/blob/a303e3bb/src/site/markdown/GettingStarted.md ---------------------------------------------------------------------- diff --git a/src/site/markdown/GettingStarted.md b/src/site/markdown/GettingStarted.md deleted file mode 100644 index 85345ab..0000000 --- a/src/site/markdown/GettingStarted.md +++ /dev/null @@ -1,191 +0,0 @@ -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> - - -<head> - <title>Getting started</title> -</head> - -### Clone and build the Twill library - -```sh -$ git clone https://git-wip-us.apache.org/repos/asf/incubator-twill.git twill -$ cd twill -$ mvn clean install -``` - -### Quick example - -Let's begin by building a basic `EchoServer` in Twill. Traditionally, when you build a server as simple as this, -you add logic within a `Runnable` implementation to run it in a `Thread` using an appropriate `ExecutorService`: - -```java -public class EchoServer implements Runnable { - private static Logger LOG = LoggerFactory.getLogger(EchoServer.class); - private final ServerSocket serverSocket; - - public EchoServer() { - ... - } - - @Override - public void run() { - while ( isRunning() ) { - Socket socket = serverSocket.accept(); - ... - } - } -} -``` - -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. - -### Hello World - -To see Twill in action, you can run the "hello world" example applications located in the twill-examples module. - -#### Prerequisites - -* Single Node or Cluster installation of Hadoop with YARN (Hadoop >= 2.2.0) set-up and running. -* Single Node or Cluster installation of ZooKeeper set-up and running. -* Build of Twill Library Code (minimum, build of twill-examples module) - -#### Running the Examples - -There are two example applications you can run: HelloWorld and BundledJarExample. - -##### HelloWorld Application - -The HelloWorld application creates a simple YARN application that prints a line to the log. - -You can run the HelloWorld application from any node of the Hadoop cluster using the below command -(be sure to add your ZooKeeper Host and Port): - -```sh -$ CP=twill-examples-yarn-0.5.0-incubating-SNAPSHOT.jar:`hadoop classpath`; java -cp $CP org.apache.twill.example.yarn.HelloWorld {zookeeper_host:port} -``` - -If successful, you should see logs output to the terminal with details of the running application. Once the application -is finished running, check the YARN logs and you should see output like the following: - -``` -14:49:45.944 [TwillContainerService] INFO o.a.twill.example.yarn.HelloWorld - Hello World. My first distributed application. -``` - -##### BundledJarExample Application - -The BundledJarExample application demonstrates the Twill functionality that allows you to run any Java application -in Twill without worrying about library version conflicts between your application and Hadoop. The example -calls the main class in a sample application `Echo`, which simply logs the command line argument(s) passed to it. -The `Echo` application uses a different version of Guava from Twill and Hadoop distributions. BundledJarExample -looks for the dependency in a `lib` folder packaged at the root of the `Echo` jar. - -You can run the BundleJarExample application from any node of the Hadoop cluster using the below command -(be sure to add your ZooKeeper Host and Port): - -```sh -$ CP=twill-examples-yarn-0.5.0-incubating-SNAPSHOT.jar:`hadoop classpath`; - java -cp $CP org.apache.twill.example.yarn.BundledJarExample {zookeeper_host:port} twill-examples-echo-0.5.0-incubating-SNAPSHOT.jar echo.EchoMain arg1 -``` - -Like with the HelloWorld example, you should see logs output to the terminal. Once the application is complete, check -the YARN logs as before and you should see output like the following: - -``` -[TwillContainerService] INFO echo.EchoMain - Hello from EchoMain: 6 -err HELLO from scatch -[TwillContainerService] INFO echo.EchoMain - Got args: [arg1] - -... - -out HELLO from scatch -Got args: [arg1] - -``` - -Congratulations! You have run your first Twill applications. \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-twill/blob/a303e3bb/src/site/markdown/index.md ---------------------------------------------------------------------- diff --git a/src/site/markdown/index.md b/src/site/markdown/index.md deleted file mode 100644 index 56ce3bf..0000000 --- a/src/site/markdown/index.md +++ /dev/null @@ -1,35 +0,0 @@ -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> - -<head> - <title>Home</title> -</head> - -### What is Twill? - -Twill is an abstraction over Apache Hadoop® YARN that reduces the complexity of developing distributed applications, -allowing developers to focus more on their business logic. Twill allows you to use YARNâs distributed capabilities -with a programming model that is similar to running threads. - -### Disclaimer - -Apache Twill is an effort undergoing incubation at The Apache Software Foundation (ASF), sponsored by Incubator. -Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, -communications, and decision making process have stabilized in a manner consistent with other successful ASF projects. -While incubation status is not necessarily a reflection of the completeness or stability of the code, -it does indicate that the project has yet to be fully endorsed by the ASF. \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-twill/blob/a303e3bb/src/site/site.xml ---------------------------------------------------------------------- diff --git a/src/site/site.xml b/src/site/site.xml deleted file mode 100644 index d5e1735..0000000 --- a/src/site/site.xml +++ /dev/null @@ -1,84 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> -<project name="Apache Twill"> - <bannerRight> - <src>http://incubator.apache.org/images/egg-logo.png</src> - <href>http://incubator.apache.org/</href> - </bannerRight> - - <publishDate position="none"/> - <version position="none"/> - - <skin> - <groupId>org.apache.maven.skins</groupId> - <artifactId>maven-fluido-skin</artifactId> - <version>1.3.0</version> - </skin> - - <body> - - <breadcrumbs position="left"> - <item name="Apache Twill" href="http://twill.incubator.apache.org/"/> - </breadcrumbs> - - <menu name="Apache Twill"> - <item name="Introduction" href="./index.html"/> - <item name="Getting Started" href="./GettingStarted.html"/> - <item name="API documentations" href="./apidocs/index.html"/> - </menu> - - <menu name="Get Involved"> - <item name="Mailing Lists" href="mail-lists.html"/> - <item name="Sources" href="source-repository.html"/> - <item name="Issues" href="issue-tracking.html"/> - <item name="Team" href="team-list.html"/> - </menu> - - <menu name="ASF"> - <item name="Apache Incubator" href="http://incubator.apache.org/"/> - <item name="Apache Foundation" href="http://www.apache.org/foundation/"/> - <item name="How Apache Works" href="http://www.apache.org/foundation/how-it-works.html"/> - <item name="The Apache License" href="http://www.apache.org/licenses/LICENSE-2.0.html"/> - <item name="Sponsoring Apache" href="http://www.apache.org/foundation/sponsorship.html"/> - <item name="Thanks" href="http://www.apache.org/foundation/thanks.html"/> - </menu> - - <footer> - <div class="row span16"> - <div> - Apache Twill, Apache, the Apache feather logo, - and the Apache Twill project logos are trademarks of The Apache Software Foundation. - All other marks mentioned may be trademarks or registered trademarks of their respective owners. - </div> - <a href="${project.url}/privacy-policy.html">Privacy Policy</a> - </div> - </footer> - </body> - - <custom> - <fluidoSkin> - <topBarEnabled>true</topBarEnabled> - <navBarStyle>navbar-inverse</navBarStyle> - <sideBarEnabled>true</sideBarEnabled> - <leftColumnClass>span2</leftColumnClass> - <bodyColumnClass>span10</bodyColumnClass> - </fluidoSkin> - </custom> - -</project>
