File jarFile = new File(arguments.getJarFileName());
Preconditions.checkArgument(jarFile != null);
Preconditions.checkState(jarFile.exists());
Preconditions.checkState(jarFile.canRead());
final TwillRunnerService twillRunner = new YarnTwillRunnerService(new YarnConfiguration(), zkStr);
twillRunner.startAndWait();
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() {
controller.stopAndWait();
twillRunner.stopAndWait();
}
});
try {
Services.getCompletionFuture(controller).get();