@Override public final CompletableFuture<Void> closeAsync() { return FutureUtils.composeAfterwards(closeHandlerAsync(), inFlightRequestTracker::awaitAsync); }
@Override public final CompletableFuture<Void> closeAsync() { return FutureUtils.composeAfterwards(closeHandlerAsync(), inFlightRequestTracker::awaitAsync); }
/** * Deregister the Flink application from the resource management system by signalling * the {@link ResourceManager}. * * @param applicationStatus to terminate the application with * @param diagnostics additional information about the shut down, can be {@code null} * @return Future which is completed once the shut down */ public CompletableFuture<Void> deregisterApplicationAndClose( final ApplicationStatus applicationStatus, final @Nullable String diagnostics) { if (isRunning.compareAndSet(true, false)) { final CompletableFuture<Void> closeWebMonitorAndDeregisterAppFuture = FutureUtils.composeAfterwards(webMonitorEndpoint.closeAsync(), () -> deregisterApplication(applicationStatus, diagnostics)); return FutureUtils.composeAfterwards(closeWebMonitorAndDeregisterAppFuture, this::closeAsyncInternal); } else { return terminationFuture; } }
/** * Deregister the Flink application from the resource management system by signalling * the {@link ResourceManager}. * * @param applicationStatus to terminate the application with * @param diagnostics additional information about the shut down, can be {@code null} * @return Future which is completed once the shut down */ public CompletableFuture<Void> deregisterApplicationAndClose( final ApplicationStatus applicationStatus, final @Nullable String diagnostics) { if (isRunning.compareAndSet(true, false)) { final CompletableFuture<Void> closeWebMonitorAndDeregisterAppFuture = FutureUtils.composeAfterwards(webMonitorEndpoint.closeAsync(), () -> deregisterApplication(applicationStatus, diagnostics)); return FutureUtils.composeAfterwards(closeWebMonitorAndDeregisterAppFuture, this::closeAsyncInternal); } else { return terminationFuture; } }
@Override public CompletableFuture<Void> closeAsync() { synchronized (lock) { log.info("Shutting down rest endpoint."); if (state == State.RUNNING) { final CompletableFuture<Void> shutDownFuture = FutureUtils.composeAfterwards( closeHandlersAsync(), this::shutDownInternal); shutDownFuture.whenComplete( (Void ignored, Throwable throwable) -> { log.info("Shut down complete."); if (throwable != null) { terminationFuture.completeExceptionally(throwable); } else { terminationFuture.complete(null); } }); state = State.SHUTDOWN; } else if (state == State.CREATED) { terminationFuture.complete(null); state = State.SHUTDOWN; } return terminationFuture; } }
@Override public CompletableFuture<Void> closeAsync() { synchronized (lock) { log.info("Shutting down rest endpoint."); if (state == State.RUNNING) { final CompletableFuture<Void> shutDownFuture = FutureUtils.composeAfterwards( closeHandlersAsync(), this::shutDownInternal); shutDownFuture.whenComplete( (Void ignored, Throwable throwable) -> { log.info("Shut down complete."); if (throwable != null) { terminationFuture.completeExceptionally(throwable); } else { terminationFuture.complete(null); } }); state = State.SHUTDOWN; } else if (state == State.CREATED) { terminationFuture.complete(null); state = State.SHUTDOWN; } return terminationFuture; } }
@Override public CompletableFuture<Void> closeAsync() { synchronized (lock) { if (!shutdown) { shutdown = true; taskManager.shutDown(); final CompletableFuture<Void> taskManagerTerminationFuture = taskManager.getTerminationFuture(); final CompletableFuture<Void> serviceTerminationFuture = FutureUtils.composeAfterwards( taskManagerTerminationFuture, this::shutDownServices); serviceTerminationFuture.whenComplete( (Void ignored, Throwable throwable) -> { if (throwable != null) { terminationFuture.completeExceptionally(throwable); } else { terminationFuture.complete(null); } }); } } return terminationFuture; }
@Override public CompletableFuture<Void> closeAsync() { synchronized (lock) { if (!shutdown) { shutdown = true; taskManager.shutDown(); final CompletableFuture<Void> taskManagerTerminationFuture = taskManager.getTerminationFuture(); final CompletableFuture<Void> serviceTerminationFuture = FutureUtils.composeAfterwards( taskManagerTerminationFuture, this::shutDownServices); serviceTerminationFuture.whenComplete( (Void ignored, Throwable throwable) -> { if (throwable != null) { terminationFuture.completeExceptionally(throwable); } else { terminationFuture.complete(null); } }); } } return terminationFuture; }
private CompletableFuture<Void> shutDownAsync( boolean cleanupHaData, ApplicationStatus applicationStatus, @Nullable String diagnostics) { if (isShutDown.compareAndSet(false, true)) { LOG.info("Stopping {}.", getClass().getSimpleName()); final CompletableFuture<Void> shutDownApplicationFuture = deregisterApplication(applicationStatus, diagnostics); final CompletableFuture<Void> componentShutdownFuture = FutureUtils.composeAfterwards( shutDownApplicationFuture, this::stopClusterComponents); final CompletableFuture<Void> serviceShutdownFuture = FutureUtils.composeAfterwards( componentShutdownFuture, () -> stopClusterServices(cleanupHaData)); final CompletableFuture<Void> cleanupDirectoriesFuture = FutureUtils.runAfterwards( serviceShutdownFuture, this::cleanupDirectories); cleanupDirectoriesFuture.whenComplete( (Void ignored2, Throwable serviceThrowable) -> { if (serviceThrowable != null) { terminationFuture.completeExceptionally(serviceThrowable); } else { terminationFuture.complete(null); } }); } return terminationFuture; }
@Override public CompletableFuture<Void> closeAsync() { synchronized (lock) { if (!shutdown) { shutdown = true; taskManager.shutDown(); final CompletableFuture<Void> taskManagerTerminationFuture = taskManager.getTerminationFuture(); final CompletableFuture<Void> serviceTerminationFuture = FutureUtils.composeAfterwards( taskManagerTerminationFuture, this::shutDownServices); serviceTerminationFuture.whenComplete( (Void ignored, Throwable throwable) -> { if (throwable != null) { terminationFuture.completeExceptionally(throwable); } else { terminationFuture.complete(null); } }); } } return terminationFuture; }
private CompletableFuture<ApplicationStatus> shutDownAsync( ApplicationStatus applicationStatus, @Nullable String diagnostics, boolean cleanupHaData) { if (isShutDown.compareAndSet(false, true)) { LOG.info("Shutting {} down with application status {}. Diagnostics {}.", getClass().getSimpleName(), applicationStatus, diagnostics); final CompletableFuture<Void> shutDownApplicationFuture = closeClusterComponent(applicationStatus, diagnostics); final CompletableFuture<Void> serviceShutdownFuture = FutureUtils.composeAfterwards( shutDownApplicationFuture, () -> stopClusterServices(cleanupHaData)); final CompletableFuture<Void> cleanupDirectoriesFuture = FutureUtils.runAfterwards( serviceShutdownFuture, this::cleanupDirectories); cleanupDirectoriesFuture.whenComplete( (Void ignored2, Throwable serviceThrowable) -> { if (serviceThrowable != null) { terminationFuture.completeExceptionally(serviceThrowable); } else { terminationFuture.complete(applicationStatus); } }); } return terminationFuture; }
private CompletableFuture<ApplicationStatus> shutDownAsync( ApplicationStatus applicationStatus, @Nullable String diagnostics, boolean cleanupHaData) { if (isShutDown.compareAndSet(false, true)) { LOG.info("Shutting {} down with application status {}. Diagnostics {}.", getClass().getSimpleName(), applicationStatus, diagnostics); final CompletableFuture<Void> shutDownApplicationFuture = closeClusterComponent(applicationStatus, diagnostics); final CompletableFuture<Void> serviceShutdownFuture = FutureUtils.composeAfterwards( shutDownApplicationFuture, () -> stopClusterServices(cleanupHaData)); final CompletableFuture<Void> cleanupDirectoriesFuture = FutureUtils.runAfterwards( serviceShutdownFuture, this::cleanupDirectories); cleanupDirectoriesFuture.whenComplete( (Void ignored2, Throwable serviceThrowable) -> { if (serviceThrowable != null) { terminationFuture.completeExceptionally(serviceThrowable); } else { terminationFuture.complete(applicationStatus); } }); } return terminationFuture; }
final CompletableFuture<Void> metricSystemTerminationFuture = FutureUtils.composeAfterwards( componentsTerminationFuture, this::closeMetricSystem);
final CompletableFuture<Void> metricSystemTerminationFuture = FutureUtils.composeAfterwards( componentsTerminationFuture, this::closeMetricSystem);