in twill-examples/yarn/src/main/java/org/apache/twill/example/yarn/BundledJarExample.java [74:115]
public static void main(String[] args) {
if (args.length < 3) {
System.err.println("Arguments format: <host:port of zookeeper server>"
+ " <bundle jar path> <main class name> <extra args>");
System.exit(1);
}
String zkStr = args[0];
BundledJarRunner.Arguments arguments = new BundledJarRunner.Arguments(
args[1], "/lib", args[2], Arrays.copyOfRange(args, 3, args.length));
File jarFile = new File(arguments.getJarFileName());
Preconditions.checkState(jarFile.exists());
Preconditions.checkState(jarFile.canRead());
final TwillRunnerService twillRunner = new YarnTwillRunnerService(new YarnConfiguration(), zkStr);
twillRunner.start();
final TwillController controller = twillRunner.prepare(
new ExampleBundledJarApp(jarFile.getName(), jarFile.toURI()))
.withArguments("BundledJarRunnable", arguments.toArray())
.addLogHandler(new PrinterLogHandler(new PrintWriter(System.out, true)))
.start();
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
try {
Futures.getUnchecked(controller.terminate());
} finally {
twillRunner.stop();
}
}
});
try {
controller.awaitTerminated();
} catch (ExecutionException e) {
LOG.error("Error", e);
}
}