@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 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()); } }; } }); }
private Iterable<TwillRunner.LiveInfo> lookupService() throws Exception { Iterable<TwillRunner.LiveInfo> iterable = runnerService.lookupLive(); sleepForZK(iterable); return iterable; }
@Override public Map<RunId, RuntimeInfo> list(ProgramType type) { Map<RunId, RuntimeInfo> result = new HashMap<>(); Lock lock = runtimeInfosLock.readLock(); lock.lock(); try { result.putAll(runtimeInfos.row(type)); } finally { lock.unlock(); } // Add any missing RuntimeInfo from the remote twill runner if (remoteTwillRunnerService == null) { return Collections.unmodifiableMap(result); } for (TwillRunner.LiveInfo liveInfo : remoteTwillRunnerService.lookupLive()) { ProgramId programId = TwillAppNames.fromTwillAppName(liveInfo.getApplicationName(), false); if (programId == null || !programId.getType().equals(type)) { continue; } for (TwillController controller : liveInfo.getControllers()) { // For remote twill runner, the twill run id and cdap run id are the same RunId runId = controller.getRunId(); if (result.computeIfAbsent(runId, rid -> createRuntimeInfo(programId, runId, controller)) == null) { LOG.warn("Unable to create runtime info for program {} with run id {}", programId, runId); } } } return Collections.unmodifiableMap(result); }
@Override public Map<RunId, RuntimeInfo> list(ProgramType type) { Map<RunId, RuntimeInfo> result = new HashMap<>(); Lock lock = runtimeInfosLock.readLock(); lock.lock(); try { result.putAll(runtimeInfos.row(type)); } finally { lock.unlock(); } // Add any missing RuntimeInfo from the remote twill runner if (remoteTwillRunnerService == null) { return Collections.unmodifiableMap(result); } for (TwillRunner.LiveInfo liveInfo : remoteTwillRunnerService.lookupLive()) { ProgramId programId = TwillAppNames.fromTwillAppName(liveInfo.getApplicationName(), false); if (programId == null || !programId.getType().equals(type)) { continue; } for (TwillController controller : liveInfo.getControllers()) { // For remote twill runner, the twill run id and cdap run id are the same RunId runId = controller.getRunId(); if (result.computeIfAbsent(runId, rid -> createRuntimeInfo(programId, runId, controller)) == null) { LOG.warn("Unable to create runtime info for program {} with run id {}", programId, runId); } } } return Collections.unmodifiableMap(result); }
@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(); }