private Iterable<TwillController> lookupFlow(String flowName) throws Exception { Iterable<TwillController> iterable = runnerService.lookup(String.format("flow.%s", flowName)); sleepForZK(iterable); return iterable; }
@Override public void start() { delegate.start(); }
@Override public void stop() { delegate.stop(); }
YarnConfiguration yarnConfiguration = new YarnConfiguration(); final TwillRunnerService twillRunner = new YarnTwillRunnerService(yarnConfiguration, zkStr); twillRunner.start(); List<String> applicationClassPaths = Lists.newArrayList(); Iterables.addAll(applicationClassPaths, Splitter.on(",").split(yarnClasspath)); final TwillController controller = twillRunner.prepare(new HelloWorldRunnable()) .addLogHandler(new PrinterLogHandler(new PrintWriter(System.out, true))) .withApplicationClassPaths(applicationClassPaths)
@Override public TwillPreparer prepare(TwillRunnable runnable, ResourceSpecification resourceSpecification) { // CDAP doesn't use this method, hence not impersonating return delegate.prepare(runnable, resourceSpecification); }
twillRunner.start(); remoteExecutionTwillRunner.start(); secureStoreUpdateCancellable = twillRunner.setSecureStoreRenewer(secureStoreRenewer, 30000L, secureStoreRenewer.getUpdateInterval(), 30000L,
@Override protected void after() { // Stop all runnable applications for (TwillRunner.LiveInfo info : twillRunner.lookupLive()) { for (TwillController controller : info.getControllers()) { try { controller.terminate().get(); } catch (Exception e) { LOG.warn("Exception raised when awaiting termination of {}", info.getApplicationName()); } } } try { twillRunner.stop(); } catch (Exception e) { LOG.warn("Failed to stop TwillRunner", e); } try { cluster.stop(); } catch (Exception e) { LOG.warn("Failed to stop mini Yarn cluster", e); } try { dfsCluster.shutdown(); } catch (Exception e) { LOG.warn("Failed to stop mini dfs cluster", e); } stopQuietly(zkServer); tmpFolder.delete(); }
@Override public Iterable<LiveInfo> lookupLive() { return Iterables.transform(delegate.lookupLive(), new Function<LiveInfo, LiveInfo>() { @Override public LiveInfo apply(final LiveInfo liveInfo) { return new LiveInfo() { @Override public String getApplicationName() { return liveInfo.getApplicationName(); } @Override public Iterable<TwillController> getControllers() { return wrapControllers(liveInfo.getControllers(), liveInfo.getApplicationName()); } }; } }); }
@Override public Cancellable setSecureStoreRenewer(SecureStoreRenewer renewer, long initialDelay, long delay, long retryDelay, TimeUnit unit) { return delegate.setSecureStoreRenewer(wrapSecureStoreRenewer(renewer), initialDelay, delay, retryDelay, unit); }
@Override public TwillPreparer prepare(TwillRunnable runnable) { // CDAP doesn't use this method, hence not impersonating return delegate.prepare(runnable); }
@Override public Iterable<LiveInfo> lookupLive() { return Iterables.transform(delegate.lookupLive(), new Function<LiveInfo, LiveInfo>() { @Override public LiveInfo apply(final LiveInfo liveInfo) { return new LiveInfo() { @Override public String getApplicationName() { return liveInfo.getApplicationName(); } @Override public Iterable<TwillController> getControllers() { return wrapControllers(liveInfo.getControllers(), liveInfo.getApplicationName()); } }; } }); }
@Override public Cancellable setSecureStoreRenewer(SecureStoreRenewer renewer, long initialDelay, long delay, long retryDelay, TimeUnit unit) { return delegate.setSecureStoreRenewer(wrapSecureStoreRenewer(renewer), initialDelay, delay, retryDelay, unit); }
@Override public Iterable<TwillController> lookup(String applicationName) { return wrapControllers(delegate.lookup(applicationName), applicationName); }
@Override public void stop() { delegate.stop(); }
@Override public void start() { delegate.start(); }