@Override public ListenableFuture<?> apply(ProgramController input) { return input.stop(); } })).get();
@Override public ListenableFuture<?> apply(ProgramController controller) { return controller.stop(); } })).get();
@Override public ListenableFuture<?> apply(ProgramController controller) { return controller.stop(); } })).get();
@Override public ListenableFuture<ProgramController> apply(ProgramController input) { return input.stop(); } })).get();
@Override public ListenableFuture<?> apply(ProgramController controller) { return controller.stop(); } })).get();
@Override public ListenableFuture<?> apply(ProgramController input) { return input.stop(); } })).get();
@Override public void stop() { try { // If the program is not completed, get the controller and call stop CompletableFuture<ProgramController.State> programCompletion = this.programCompletion; // If there is no program completion future or it is already done, simply return as there is nothing to stop. if (programCompletion == null || programCompletion.isDone()) { return; } // Don't block forever to get the controller. The controller future might be empty if there is // systematic failure such that program runner is not reacting correctly ProgramController controller = controllerFuture.get(5, TimeUnit.SECONDS); LOG.info("Stopping runnable: {}.", name); // Give some time for the program to stop controller.stop().get(maxStopSeconds == 0L ? Constants.APPLICATION_MAX_STOP_SECONDS : maxStopSeconds, TimeUnit.SECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { throw Throwables.propagate(e); } }
@Override public void stop() { try { // If the program is not completed, get the controller and call stop CompletableFuture<ProgramController.State> programCompletion = this.programCompletion; // If there is no program completion future or it is already done, simply return as there is nothing to stop. if (programCompletion == null || programCompletion.isDone()) { return; } // Don't block forever to get the controller. The controller future might be empty if there is // systematic failure such that program runner is not reacting correctly ProgramController controller = controllerFuture.get(5, TimeUnit.SECONDS); LOG.info("Stopping runnable: {}.", name); // Give some time for the program to stop controller.stop().get(maxStopSeconds == 0L ? Constants.APPLICATION_MAX_STOP_SECONDS : maxStopSeconds, TimeUnit.SECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { throw Throwables.propagate(e); } }
private void stopProgramIfRunning(ProgramId programId) throws InterruptedException, ExecutionException { ProgramRuntimeService.RuntimeInfo programRunInfo = findRuntimeInfo(programId, runtimeService); if (programRunInfo != null) { ProgramController controller = programRunInfo.getController(); controller.stop().get(); } }
private void stopProgramIfRunning(ProgramId programId) throws InterruptedException, ExecutionException { ProgramRuntimeService.RuntimeInfo programRunInfo = findRuntimeInfo(programId, runtimeService); if (programRunInfo != null) { ProgramController controller = programRunInfo.getController(); controller.stop().get(); } }
private void stopAllPrograms() { LOG.info("Stopping all running programs."); List<ListenableFuture<ProgramController>> futures = Lists.newLinkedList(); for (ProgramType type : ProgramType.values()) { for (Map.Entry<RunId, RuntimeInfo> entry : list(type).entrySet()) { RuntimeInfo runtimeInfo = entry.getValue(); if (isRunning(runtimeInfo.getProgramId())) { futures.add(runtimeInfo.getController().stop()); } } } // unchecked because we cannot do much if it fails. We will still shutdown the standalone CDAP instance. try { Futures.successfulAsList(futures).get(60, TimeUnit.SECONDS); LOG.info("All programs have been stopped."); } catch (ExecutionException e) { // note this should not happen because we wait on a successfulAsList LOG.warn("Got exception while waiting for all programs to stop", e.getCause()); } catch (InterruptedException e) { LOG.warn("Got interrupted exception while waiting for all programs to stop", e); Thread.currentThread().interrupt(); } catch (TimeoutException e) { // can't do much more than log it. We still want to exit. LOG.warn("Timeout while waiting for all programs to stop."); } } }
private void stopAllPrograms() { LOG.info("Stopping all running programs."); List<ListenableFuture<ProgramController>> futures = Lists.newLinkedList(); for (ProgramType type : ProgramType.values()) { for (Map.Entry<RunId, RuntimeInfo> entry : list(type).entrySet()) { RuntimeInfo runtimeInfo = entry.getValue(); if (isRunning(runtimeInfo.getProgramId())) { futures.add(runtimeInfo.getController().stop()); } } } // unchecked because we cannot do much if it fails. We will still shutdown the standalone CDAP instance. try { Futures.successfulAsList(futures).get(60, TimeUnit.SECONDS); LOG.info("All programs have been stopped."); } catch (ExecutionException e) { // note this should not happen because we wait on a successfulAsList LOG.warn("Got exception while waiting for all programs to stop", e.getCause()); } catch (InterruptedException e) { LOG.warn("Got interrupted exception while waiting for all programs to stop", e); Thread.currentThread().interrupt(); } catch (TimeoutException e) { // can't do much more than log it. We still want to exit. LOG.warn("Timeout while waiting for all programs to stop."); } } }
} catch (InterruptedException e) { try { Futures.getUnchecked(controller.stop()); } catch (Throwable t) {
futures.add(flowlets.remove(flowletName, instanceId).stop());
} catch (InterruptedException e) { try { Futures.getUnchecked(controller.stop()); } catch (Throwable t) {
List<ListenableFuture<ProgramController>> futures = Lists.newArrayListWithCapacity(liveCount - newCount); for (int instanceId = liveCount - 1; instanceId >= newCount; instanceId--) { futures.add(components.remove(runnableName, instanceId).stop());
List<ListenableFuture<ProgramController>> futures = Lists.newArrayListWithCapacity(liveCount - newCount); for (int instanceId = liveCount - 1; instanceId >= newCount; instanceId--) { futures.add(components.remove(runnableName, instanceId).stop());
private void stopProgram(ProgramController controller) throws Throwable { final AtomicReference<Throwable> errorCause = new AtomicReference<>(); final CountDownLatch complete = new CountDownLatch(1); controller.addListener(new AbstractListener() { @Override public void error(Throwable cause) { complete.countDown(); errorCause.set(cause); } @Override public void completed() { complete.countDown(); } @Override public void killed() { complete.countDown(); } }, Threads.SAME_THREAD_EXECUTOR); controller.stop(); complete.await(30, TimeUnit.SECONDS); runningPrograms.remove(controller); Throwable t = errorCause.get(); if (t != null) { throw t; } } }
ListenableFuture<ProgramController> future = runtimeInfo.getController().stop(); futures.add(Futures.transform(future, ProgramController::getProgramRunId)); iterator.remove();
controller.stop().get();