org.apache.flink.runtime.clusterframework.ApplicationStatus Java Examples
The following examples show how to use
org.apache.flink.runtime.clusterframework.ApplicationStatus.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ApplicationDispatcherBootstrapTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testClusterShutdownWhenApplicationFails() throws Exception { // we're "listening" on this to be completed to verify that the cluster // is being shut down from the ApplicationDispatcherBootstrap final CompletableFuture<ApplicationStatus> externalShutdownFuture = new CompletableFuture<>(); final TestingDispatcherGateway.Builder dispatcherBuilder = new TestingDispatcherGateway.Builder() .setSubmitFunction(jobGraph -> CompletableFuture.completedFuture(Acknowledge.get())) .setRequestJobStatusFunction(jobId -> CompletableFuture.completedFuture(JobStatus.FAILED)) .setRequestJobResultFunction(jobId -> CompletableFuture.completedFuture(createFailedJobResult(jobId))) .setClusterShutdownFunction((status) -> { externalShutdownFuture.complete(status); return CompletableFuture.completedFuture(Acknowledge.get()); }); ApplicationDispatcherBootstrap bootstrap = createApplicationDispatcherBootstrap(3); final CompletableFuture<Acknowledge> shutdownFuture = bootstrap.runApplicationAndShutdownClusterAsync(dispatcherBuilder.build(), scheduledExecutor); // wait until the bootstrap "thinks" it's done shutdownFuture.get(TIMEOUT_SECONDS, TimeUnit.SECONDS); // verify that the dispatcher is actually being shut down assertThat(externalShutdownFuture.get(TIMEOUT_SECONDS, TimeUnit.SECONDS), is(ApplicationStatus.FAILED)); }
Example #2
Source File: DispatcherResourceManagerComponent.java From flink with Apache License 2.0 | 6 votes |
private void registerShutDownFuture() { terminationFuture.whenComplete( (aVoid, throwable) -> { if (throwable != null) { shutDownFuture.completeExceptionally(throwable); } else { shutDownFuture.complete(ApplicationStatus.SUCCEEDED); } }); dispatcher .getTerminationFuture() .whenComplete( (aVoid, throwable) -> { if (throwable != null) { shutDownFuture.completeExceptionally(throwable); } else { shutDownFuture.complete(ApplicationStatus.SUCCEEDED); } }); }
Example #3
Source File: MiniDispatcher.java From flink with Apache License 2.0 | 6 votes |
@Override public CompletableFuture<JobResult> requestJobResult(JobID jobId, Time timeout) { final CompletableFuture<JobResult> jobResultFuture = super.requestJobResult(jobId, timeout); if (executionMode == ClusterEntrypoint.ExecutionMode.NORMAL) { // terminate the MiniDispatcher once we served the first JobResult successfully jobResultFuture.thenAccept((JobResult result) -> { ApplicationStatus status = result.getSerializedThrowable().isPresent() ? ApplicationStatus.FAILED : ApplicationStatus.SUCCEEDED; jobTerminationFuture.complete(status); }); } return jobResultFuture; }
Example #4
Source File: YarnResourceManager.java From flink with Apache License 2.0 | 6 votes |
/** * Converts a Flink application status enum to a YARN application status enum. * @param status The Flink application status. * @return The corresponding YARN application status. */ private FinalApplicationStatus getYarnStatus(ApplicationStatus status) { if (status == null) { return FinalApplicationStatus.UNDEFINED; } else { switch (status) { case SUCCEEDED: return FinalApplicationStatus.SUCCEEDED; case FAILED: return FinalApplicationStatus.FAILED; case CANCELED: return FinalApplicationStatus.KILLED; default: return FinalApplicationStatus.UNDEFINED; } } }
Example #5
Source File: DispatcherResourceManagerComponent.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
private void registerShutDownFuture() { terminationFuture.whenComplete( (aVoid, throwable) -> { if (throwable != null) { shutDownFuture.completeExceptionally(throwable); } else { shutDownFuture.complete(ApplicationStatus.SUCCEEDED); } }); dispatcher .getTerminationFuture() .whenComplete( (aVoid, throwable) -> { if (throwable != null) { shutDownFuture.completeExceptionally(throwable); } else { shutDownFuture.complete(ApplicationStatus.SUCCEEDED); } }); }
Example #6
Source File: JobDispatcherResourceManagerComponent.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
JobDispatcherResourceManagerComponent( MiniDispatcher dispatcher, ResourceManager<?> resourceManager, LeaderRetrievalService dispatcherLeaderRetrievalService, LeaderRetrievalService resourceManagerRetrievalService, WebMonitorEndpoint<?> webMonitorEndpoint, JobManagerMetricGroup jobManagerMetricGroup) { super(dispatcher, resourceManager, dispatcherLeaderRetrievalService, resourceManagerRetrievalService, webMonitorEndpoint, jobManagerMetricGroup); final CompletableFuture<ApplicationStatus> shutDownFuture = getShutDownFuture(); dispatcher.getJobTerminationFuture().whenComplete((applicationStatus, throwable) -> { if (throwable != null) { shutDownFuture.completeExceptionally(throwable); } else { shutDownFuture.complete(applicationStatus); } }); }
Example #7
Source File: MiniDispatcher.java From flink with Apache License 2.0 | 6 votes |
@Override public CompletableFuture<JobResult> requestJobResult(JobID jobId, Time timeout) { final CompletableFuture<JobResult> jobResultFuture = super.requestJobResult(jobId, timeout); if (executionMode == ClusterEntrypoint.ExecutionMode.NORMAL) { // terminate the MiniDispatcher once we served the first JobResult successfully jobResultFuture.thenAccept((JobResult result) -> { ApplicationStatus status = result.getSerializedThrowable().isPresent() ? ApplicationStatus.FAILED : ApplicationStatus.SUCCEEDED; LOG.debug("Shutting down per-job cluster because someone retrieved the job result."); shutDownFuture.complete(status); }); } else { LOG.debug("Not shutting down per-job cluster after someone retrieved the job result."); } return jobResultFuture; }
Example #8
Source File: ApplicationDispatcherBootstrapTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testDispatcherIsCancelledWhenOneJobIsCancelled() throws Exception { final CompletableFuture<ApplicationStatus> clusterShutdownStatus = new CompletableFuture<>(); final TestingDispatcherGateway.Builder dispatcherBuilder = new TestingDispatcherGateway.Builder() .setSubmitFunction(jobGraph -> CompletableFuture.completedFuture(Acknowledge.get())) .setRequestJobStatusFunction(jobId -> CompletableFuture.completedFuture(JobStatus.CANCELED)) .setClusterShutdownFunction((status) -> { clusterShutdownStatus.complete(status); return CompletableFuture.completedFuture(Acknowledge.get()); }) .setRequestJobResultFunction(jobId -> CompletableFuture.completedFuture(createCancelledJobResult(jobId))); ApplicationDispatcherBootstrap bootstrap = createApplicationDispatcherBootstrap(3); final CompletableFuture<Acknowledge> shutdownFuture = bootstrap.runApplicationAndShutdownClusterAsync(dispatcherBuilder.build(), scheduledExecutor); // wait until the bootstrap "thinks" it's done, also makes sure that we don't // fail the future exceptionally with a JobCancelledException shutdownFuture.get(TIMEOUT_SECONDS, TimeUnit.SECONDS); assertThat(clusterShutdownStatus.get(TIMEOUT_SECONDS, TimeUnit.SECONDS), is(ApplicationStatus.CANCELED)); }
Example #9
Source File: YarnResourceManager.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** * Converts a Flink application status enum to a YARN application status enum. * @param status The Flink application status. * @return The corresponding YARN application status. */ private FinalApplicationStatus getYarnStatus(ApplicationStatus status) { if (status == null) { return FinalApplicationStatus.UNDEFINED; } else { switch (status) { case SUCCEEDED: return FinalApplicationStatus.SUCCEEDED; case FAILED: return FinalApplicationStatus.FAILED; case CANCELED: return FinalApplicationStatus.KILLED; default: return FinalApplicationStatus.UNDEFINED; } } }
Example #10
Source File: MiniCluster.java From flink with Apache License 2.0 | 6 votes |
@GuardedBy("lock") private void setupDispatcherResourceManagerComponents(Configuration configuration, RpcServiceFactory dispatcherResourceManagreComponentRpcServiceFactory, MetricQueryServiceRetriever metricQueryServiceRetriever) throws Exception { dispatcherResourceManagerComponents.addAll(createDispatcherResourceManagerComponents( configuration, dispatcherResourceManagreComponentRpcServiceFactory, haServices, blobServer, heartbeatServices, metricRegistry, metricQueryServiceRetriever, new ShutDownFatalErrorHandler() )); final Collection<CompletableFuture<ApplicationStatus>> shutDownFutures = new ArrayList<>(dispatcherResourceManagerComponents.size()); for (DispatcherResourceManagerComponent dispatcherResourceManagerComponent : dispatcherResourceManagerComponents) { final CompletableFuture<ApplicationStatus> shutDownFuture = dispatcherResourceManagerComponent.getShutDownFuture(); FutureUtils.assertNoException(shutDownFuture.thenRun(dispatcherResourceManagerComponent::closeAsync)); shutDownFutures.add(shutDownFuture); } FutureUtils.assertNoException(FutureUtils.completeAll(shutDownFutures).thenRun(this::closeAsync)); }
Example #11
Source File: YarnApplicationStatusMonitor.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
private void updateApplicationStatus() { if (yarnClient.isInState(Service.STATE.STARTED)) { final ApplicationReport applicationReport; try { applicationReport = yarnClient.getApplicationReport(yarnApplicationId); } catch (Exception e) { LOG.info("Could not retrieve the Yarn application report for {}.", yarnApplicationId); applicationStatus = ApplicationStatus.UNKNOWN; return; } YarnApplicationState yarnApplicationState = applicationReport.getYarnApplicationState(); if (yarnApplicationState == YarnApplicationState.FAILED || yarnApplicationState == YarnApplicationState.KILLED) { applicationStatus = ApplicationStatus.FAILED; } else { applicationStatus = ApplicationStatus.SUCCEEDED; } } else { LOG.info("Yarn client is no longer in state STARTED. Stopping the Yarn application status monitor."); applicationStatusUpdateFuture.cancel(false); } }
Example #12
Source File: YarnApplicationStatusMonitor.java From flink with Apache License 2.0 | 6 votes |
private void updateApplicationStatus() { if (yarnClient.isInState(Service.STATE.STARTED)) { final ApplicationReport applicationReport; try { applicationReport = yarnClient.getApplicationReport(yarnApplicationId); } catch (Exception e) { LOG.info("Could not retrieve the Yarn application report for {}.", yarnApplicationId); applicationStatus = ApplicationStatus.UNKNOWN; return; } YarnApplicationState yarnApplicationState = applicationReport.getYarnApplicationState(); if (yarnApplicationState == YarnApplicationState.FAILED || yarnApplicationState == YarnApplicationState.KILLED) { applicationStatus = ApplicationStatus.FAILED; } else { applicationStatus = ApplicationStatus.SUCCEEDED; } } else { LOG.info("Yarn client is no longer in state STARTED. Stopping the Yarn application status monitor."); applicationStatusUpdateFuture.cancel(false); } }
Example #13
Source File: ClusterEntrypoint.java From flink with Apache License 2.0 | 5 votes |
public void startCluster() throws ClusterEntrypointException { LOG.info("Starting {}.", getClass().getSimpleName()); try { configureFileSystems(configuration); SecurityContext securityContext = installSecurityContext(configuration); securityContext.runSecured((Callable<Void>) () -> { runCluster(configuration); return null; }); } catch (Throwable t) { final Throwable strippedThrowable = ExceptionUtils.stripException(t, UndeclaredThrowableException.class); try { // clean up any partial state shutDownAsync( ApplicationStatus.FAILED, ExceptionUtils.stringifyException(strippedThrowable), false).get(INITIALIZATION_SHUTDOWN_TIMEOUT.toMilliseconds(), TimeUnit.MILLISECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { strippedThrowable.addSuppressed(e); } throw new ClusterEntrypointException( String.format("Failed to initialize the cluster entrypoint %s.", getClass().getSimpleName()), strippedThrowable); } }
Example #14
Source File: YarnResourceManagerTest.java From flink with Apache License 2.0 | 5 votes |
/** * Tests that application files are deleted when the YARN application master is de-registered. */ @Test public void testDeleteApplicationFiles() throws Exception { new Context() {{ final File applicationDir = folder.newFolder(".flink"); env.put(FLINK_YARN_FILES, applicationDir.getCanonicalPath()); runTest(() -> { resourceManager.deregisterApplication(ApplicationStatus.SUCCEEDED, null); assertFalse("YARN application directory was not removed", Files.exists(applicationDir.toPath())); }); }}; }
Example #15
Source File: ClusterEntrypoint.java From flink with Apache License 2.0 | 5 votes |
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; }
Example #16
Source File: YarnApplicationStatusMonitor.java From flink with Apache License 2.0 | 5 votes |
public YarnApplicationStatusMonitor( YarnClient yarnClient, ApplicationId yarnApplicationId, ScheduledExecutor scheduledExecutor) { this.yarnClient = Preconditions.checkNotNull(yarnClient); this.yarnApplicationId = Preconditions.checkNotNull(yarnApplicationId); applicationStatusUpdateFuture = scheduledExecutor.scheduleWithFixedDelay( this::updateApplicationStatus, 0L, UPDATE_INTERVAL, TimeUnit.MILLISECONDS); applicationStatus = ApplicationStatus.UNKNOWN; }
Example #17
Source File: ApplicationDispatcherBootstrap.java From flink with Apache License 2.0 | 5 votes |
/** * If the given {@link JobResult} indicates success, this passes through the {@link JobResult}. * Otherwise, this returns a future that is finished exceptionally (potentially with an * exception from the {@link JobResult}. */ private CompletableFuture<JobResult> unwrapJobResultException( CompletableFuture<JobResult> jobResult) { return jobResult.thenApply(result -> { if (result.isSuccess()) { return result; } Optional<SerializedThrowable> serializedThrowable = result.getSerializedThrowable(); if (result.getApplicationStatus() == ApplicationStatus.CANCELED) { throw new CompletionException( new JobCancellationException( result.getJobId(), "Job was cancelled.", serializedThrowable.orElse(null))); } if (serializedThrowable.isPresent()) { Throwable throwable = serializedThrowable .get() .deserializeError(application.getUserCodeClassLoader()); throw new CompletionException(throwable); } throw new RuntimeException("Job execution failed for unknown reason."); }); }
Example #18
Source File: MesosResourceManagerTest.java From flink with Apache License 2.0 | 5 votes |
/** * Test application shutdown handling. */ @Test public void testShutdownApplication() throws Exception { new Context() {{ startResourceManager(); resourceManager.deregisterApplication(ApplicationStatus.SUCCEEDED, ""); // verify that the Mesos framework is shutdown verify(rmServices.schedulerDriver).stop(false); verify(rmServices.workerStore).stop(true); }}; }
Example #19
Source File: ClusterEntrypoint.java From flink with Apache License 2.0 | 5 votes |
/** * 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 */ private CompletableFuture<Void> closeClusterComponent(ApplicationStatus applicationStatus, @Nullable String diagnostics) { synchronized (lock) { if (clusterComponent != null) { return clusterComponent.deregisterApplicationAndClose(applicationStatus, diagnostics); } else { return CompletableFuture.completedFuture(null); } } }
Example #20
Source File: RestClusterClientTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testJobSubmitCancel() throws Exception { TestJobSubmitHandler submitHandler = new TestJobSubmitHandler(); TestJobCancellationHandler terminationHandler = new TestJobCancellationHandler(); TestJobExecutionResultHandler testJobExecutionResultHandler = new TestJobExecutionResultHandler( JobExecutionResultResponseBody.created(new JobResult.Builder() .applicationStatus(ApplicationStatus.SUCCEEDED) .jobId(jobId) .netRuntime(Long.MAX_VALUE) .build())); try (TestRestServerEndpoint restServerEndpoint = createRestServerEndpoint( submitHandler, terminationHandler, testJobExecutionResultHandler)) { RestClusterClient<?> restClusterClient = createRestClusterClient(restServerEndpoint.getServerAddress().getPort()); try { Assert.assertFalse(submitHandler.jobSubmitted); restClusterClient.submitJob(jobGraph, ClassLoader.getSystemClassLoader()); Assert.assertTrue(submitHandler.jobSubmitted); Assert.assertFalse(terminationHandler.jobCanceled); restClusterClient.cancel(jobId); Assert.assertTrue(terminationHandler.jobCanceled); } finally { restClusterClient.shutdown(); } } }
Example #21
Source File: DispatcherResourceManagerComponent.java From flink with Apache License 2.0 | 5 votes |
private CompletableFuture<Void> deregisterApplication( final ApplicationStatus applicationStatus, final @Nullable String diagnostics) { final ResourceManagerGateway selfGateway = resourceManager.getSelfGateway(ResourceManagerGateway.class); return selfGateway.deregisterApplication(applicationStatus, diagnostics).thenApply(ack -> null); }
Example #22
Source File: ResourceManager.java From flink with Apache License 2.0 | 5 votes |
/** * Cleanup application and shut down cluster. * * @param finalStatus of the Flink application * @param diagnostics diagnostics message for the Flink application or {@code null} */ @Override public CompletableFuture<Acknowledge> deregisterApplication( final ApplicationStatus finalStatus, @Nullable final String diagnostics) { log.info("Shut down cluster because application is in {}, diagnostics {}.", finalStatus, diagnostics); try { internalDeregisterApplication(finalStatus, diagnostics); } catch (ResourceManagerException e) { log.warn("Could not properly shutdown the application.", e); } return CompletableFuture.completedFuture(Acknowledge.get()); }
Example #23
Source File: JobResult.java From flink with Apache License 2.0 | 5 votes |
/** * Creates the {@link JobResult} from the given {@link AccessExecutionGraph} which * must be in a globally terminal state. * * @param accessExecutionGraph to create the JobResult from * @return JobResult of the given AccessExecutionGraph */ public static JobResult createFrom(AccessExecutionGraph accessExecutionGraph) { final JobID jobId = accessExecutionGraph.getJobID(); final JobStatus jobStatus = accessExecutionGraph.getState(); checkArgument( jobStatus.isGloballyTerminalState(), "The job " + accessExecutionGraph.getJobName() + '(' + jobId + ") is not in a globally " + "terminal state. It is in state " + jobStatus + '.'); final JobResult.Builder builder = new JobResult.Builder(); builder.jobId(jobId); builder.applicationStatus(ApplicationStatus.fromJobStatus(accessExecutionGraph.getState())); final long netRuntime = accessExecutionGraph.getStatusTimestamp(jobStatus) - accessExecutionGraph.getStatusTimestamp(JobStatus.CREATED); // guard against clock changes final long guardedNetRuntime = Math.max(netRuntime, 0L); builder.netRuntime(guardedNetRuntime); builder.accumulatorResults(accessExecutionGraph.getAccumulatorsSerialized()); if (jobStatus != JobStatus.FINISHED) { final ErrorInfo errorInfo = accessExecutionGraph.getFailureInfo(); if (errorInfo != null) { builder.serializedThrowable(errorInfo.getException()); } } return builder.build(); }
Example #24
Source File: MiniDispatcher.java From flink with Apache License 2.0 | 5 votes |
@Override protected void jobNotFinished(JobID jobId) { super.jobNotFinished(jobId); // shut down since we have done our job jobTerminationFuture.complete(ApplicationStatus.UNKNOWN); }
Example #25
Source File: YarnApplicationStatusMonitor.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
public YarnApplicationStatusMonitor( YarnClient yarnClient, ApplicationId yarnApplicationId, ScheduledExecutor scheduledExecutor) { this.yarnClient = Preconditions.checkNotNull(yarnClient); this.yarnApplicationId = Preconditions.checkNotNull(yarnApplicationId); applicationStatusUpdateFuture = scheduledExecutor.scheduleWithFixedDelay( this::updateApplicationStatus, 0L, UPDATE_INTERVAL, TimeUnit.MILLISECONDS); applicationStatus = ApplicationStatus.UNKNOWN; }
Example #26
Source File: DispatcherResourceManagerComponent.java From flink with Apache License 2.0 | 5 votes |
private CompletableFuture<Void> deregisterApplication( final ApplicationStatus applicationStatus, final @Nullable String diagnostics) { final ResourceManagerGateway selfGateway = resourceManager.getSelfGateway(ResourceManagerGateway.class); return selfGateway.deregisterApplication(applicationStatus, diagnostics).thenApply(ack -> null); }
Example #27
Source File: YarnResourceManagerTest.java From flink with Apache License 2.0 | 5 votes |
/** * Tests that application files are deleted when the YARN application master is de-registered. */ @Test public void testDeleteApplicationFiles() throws Exception { new Context() {{ final File applicationDir = folder.newFolder(".flink"); env.put(FLINK_YARN_FILES, applicationDir.getCanonicalPath()); runTest(() -> { resourceManager.deregisterApplication(ApplicationStatus.SUCCEEDED, null); assertFalse("YARN application directory was not removed", Files.exists(applicationDir.toPath())); }); }}; }
Example #28
Source File: RestClusterClientTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testJobSubmitCancelStop() throws Exception { TestJobSubmitHandler submitHandler = new TestJobSubmitHandler(); TestJobTerminationHandler terminationHandler = new TestJobTerminationHandler(); TestJobExecutionResultHandler testJobExecutionResultHandler = new TestJobExecutionResultHandler( JobExecutionResultResponseBody.created(new JobResult.Builder() .applicationStatus(ApplicationStatus.SUCCEEDED) .jobId(jobId) .netRuntime(Long.MAX_VALUE) .build())); try (TestRestServerEndpoint restServerEndpoint = createRestServerEndpoint( submitHandler, terminationHandler, testJobExecutionResultHandler)) { RestClusterClient<?> restClusterClient = createRestClusterClient(restServerEndpoint.getServerAddress().getPort()); try { Assert.assertFalse(submitHandler.jobSubmitted); restClusterClient.submitJob(jobGraph, ClassLoader.getSystemClassLoader()); Assert.assertTrue(submitHandler.jobSubmitted); Assert.assertFalse(terminationHandler.jobCanceled); restClusterClient.cancel(jobId); Assert.assertTrue(terminationHandler.jobCanceled); Assert.assertFalse(terminationHandler.jobStopped); restClusterClient.stop(jobId); Assert.assertTrue(terminationHandler.jobStopped); } finally { restClusterClient.shutdown(); } } }
Example #29
Source File: DispatcherResourceManagerComponent.java From flink with Apache License 2.0 | 5 votes |
/** * 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; } }
Example #30
Source File: ClusterEntrypoint.java From flink with Apache License 2.0 | 5 votes |
/** * 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 */ private CompletableFuture<Void> closeClusterComponent(ApplicationStatus applicationStatus, @Nullable String diagnostics) { synchronized (lock) { if (clusterComponent != null) { return clusterComponent.deregisterApplicationAndClose(applicationStatus, diagnostics); } else { return CompletableFuture.completedFuture(null); } } }