@@ -123,4 +123,69 @@ You can also stop the application through the `TwillController`:
123
123
controller. stop(). get();
124
124
```
125
125
126
- This will shut down the application master and all the containers.
126
+ This will shut down the application master and all the containers.
127
+
128
+ ### Hello World
129
+
130
+ To see Twill in action, you can run the " hello world" example applications located in the twill- examples module.
131
+
132
+ #### Prerequisites
133
+
134
+ * Single Node or Cluster installation of Hadoop with YARN (Hadoop >= 2.2 . 0 ) set- up and running.
135
+ * Single Node or Cluster installation of ZooKeeper set- up and running.
136
+ * Build of Twill Library Code (minimum, build of twill- examples module)
137
+
138
+ #### Running the Examples
139
+
140
+ There are two example applications you can run: HelloWorld and BundledJarExample .
141
+
142
+ ##### HelloWorld Application
143
+
144
+ The HelloWorld application creates a simple YARN application that prints a line to the log.
145
+
146
+ You can run the HelloWorld application from any node of the Hadoop cluster using the below command
147
+ (be sure to add your ZooKeeper Host and Port ):
148
+
149
+ ```sh
150
+ $ CP = twill- examples- yarn- 0.5 . 0 - incubating- SNAPSHOT . jar: `hadoop classpath`; java - cp $CP org.apache.twill.example.yarn. HelloWorld {zookeeper_host: port}
151
+ ```
152
+
153
+ If successful, you should see logs output to the terminal with details of the running application. Once the application
154
+ is finished running, check the YARN logs and you should see output like the following:
155
+
156
+ ```
157
+ 14 : 49 : 45.944 [TwillContainerService ] INFO o.a.twill.example.yarn. HelloWorld - Hello World . My first distributed application.
158
+ ```
159
+
160
+ ##### BundledJarExample Application
161
+
162
+ The BundledJarExample application demonstrates the Twill functionality that allows you to run any Java application
163
+ in Twill without worrying about library version conflicts between your application and Hadoop . The example
164
+ calls the main class in a sample application `Echo`, which simply logs the command line argument(s) passed to it.
165
+ The `Echo` application uses a different version of Guava from Twill and Hadoop distributions. BundledJarExample
166
+ looks for the dependency in a `lib` folder packaged at the root of the `Echo` jar.
167
+
168
+ You can run the BundleJarExample application from any node of the Hadoop cluster using the below command
169
+ (be sure to add your ZooKeeper Host and Port):
170
+
171
+ ```sh
172
+ $ CP=twill-examples-yarn-0.5.0-incubating-SNAPSHOT.jar:`hadoop classpath`;
173
+ java -cp $CP org.apache.twill.example.yarn.BundledJarExample {zookeeper_host: port} twill- examples- echo- 0.5 . 0 - incubating- SNAPSHOT . jar echo. EchoMain arg1
174
+ ```
175
+
176
+ Like with the HelloWorld example, you should see logs output to the terminal. Once the application is complete, check
177
+ the YARN logs as before and you should see output like the following:
178
+
179
+ ```
180
+ [TwillContainerService ] INFO echo. EchoMain - Hello from EchoMain : 6
181
+ err HELLO from scatch
182
+ [TwillContainerService ] INFO echo. EchoMain - Got args: [arg1]
183
+
184
+ ...
185
+
186
+ out HELLO from scatch
187
+ Got args: [arg1]
188
+
189
+ ```
190
+
191
+ Congratulations ! You have run your first Twill applications.
0 commit comments