@Override public void stop() throws Exception { synchronized (lock) { if (client != null) { client.shutdown(); client = null; } } }
@Override public void shutdown() throws Exception { super.shutdown(); }
@Override public void after() { TestStreamEnvironment.unsetAsContext(); TestEnvironment.unsetAsContext(); Exception exception = null; if (clusterClient != null) { try { clusterClient.shutdown(); } catch (Exception e) { exception = e; } } clusterClient = null; super.after(); if (exception != null) { log.warn("Could not properly shut down the MiniClusterWithClientResource.", exception); } }
private void shutdownCluster( ClusterClient clusterClient, ScheduledExecutorService scheduledExecutorService, YarnApplicationStatusMonitor yarnApplicationStatusMonitor) { try { yarnApplicationStatusMonitor.close(); } catch (Exception e) { LOG.info("Could not properly close the Yarn application status monitor.", e); } clusterClient.shutDownCluster(); try { clusterClient.shutdown(); } catch (Exception e) { LOG.info("Could not properly shutdown cluster client.", e); } // shut down the scheduled executor service ExecutorUtils.gracefulShutdown( 1000L, TimeUnit.MILLISECONDS, scheduledExecutorService); deleteYarnPropertiesFile(); }
@Override public void shutdown() { ExecutorUtils.gracefulShutdown(restClusterClientConfiguration.getRetryDelay(), TimeUnit.MILLISECONDS, retryExecutorService); this.restClient.shutdown(Time.seconds(5)); ExecutorUtils.gracefulShutdown(5, TimeUnit.SECONDS, this.executorService); try { webMonitorRetrievalService.stop(); } catch (Exception e) { log.error("An error occurred during stopping the webMonitorRetrievalService", e); } try { dispatcherRetrievalService.stop(); } catch (Exception e) { log.error("An error occurred during stopping the dispatcherLeaderRetriever", e); } try { // we only call this for legacy reasons to shutdown components that are started in the ClusterClient constructor super.shutdown(); } catch (Exception e) { log.error("An error occurred during the client shutdown.", e); } }
} finally { try { clusterClient.shutdown(); } catch (Exception e) { LOG.info("Could not properly shut down the cluster client.", e);
private <T> void deployJobOnNewCluster( ClusterDescriptor<T> clusterDescriptor, JobGraph jobGraph, Result<T> result, ClassLoader classLoader) throws Exception { ClusterClient<T> clusterClient = null; try { // deploy job cluster with job attached clusterClient = clusterDescriptor.deployJobCluster(context.getClusterSpec(), jobGraph, false); // save information about the new cluster result.setClusterInformation(clusterClient.getClusterId(), clusterClient.getWebInterfaceURL()); // get result if (awaitJobResult) { // we need to hard cast for now final JobExecutionResult jobResult = ((RestClusterClient<T>) clusterClient) .requestJobResult(jobGraph.getJobID()) .get() .toJobExecutionResult(context.getClassLoader()); // throws exception if job fails executionResultBucket.add(jobResult); } } finally { try { if (clusterClient != null) { clusterClient.shutdown(); } } catch (Exception e) { // ignore } } }
} catch (Exception e) { try { clusterClient.shutdown(); } catch (Exception ex) { LOG.info("Could not properly shutdown cluster client.", ex);
/** * Tests that a CLI call with a custom savepoint directory target is * forwarded correctly to the cluster client. */ @Test public void testTriggerSavepointCustomTarget() throws Exception { replaceStdOutAndStdErr(); JobID jobId = new JobID(); String savepointDirectory = "customTargetDirectory"; final ClusterClient<String> clusterClient = createClusterClient(savepointDirectory); try { MockedCliFrontend frontend = new MockedCliFrontend(clusterClient); String[] parameters = { jobId.toString(), savepointDirectory }; frontend.savepoint(parameters); verify(clusterClient, times(1)) .triggerSavepoint(eq(jobId), eq(savepointDirectory)); assertTrue(buffer.toString().contains(savepointDirectory)); } finally { clusterClient.shutdown(); restoreStdOutAndStdErr(); } }
@Test public void testTriggerSavepointSuccess() throws Exception { replaceStdOutAndStdErr(); JobID jobId = new JobID(); String savepointPath = "expectedSavepointPath"; final ClusterClient<String> clusterClient = createClusterClient(savepointPath); try { MockedCliFrontend frontend = new MockedCliFrontend(clusterClient); String[] parameters = { jobId.toString() }; frontend.savepoint(parameters); verify(clusterClient, times(1)) .triggerSavepoint(eq(jobId), isNull(String.class)); assertTrue(buffer.toString().contains(savepointPath)); } finally { clusterClient.shutdown(); restoreStdOutAndStdErr(); } }
@Test public void testDisposeSavepointSuccess() throws Exception { replaceStdOutAndStdErr(); String savepointPath = "expectedSavepointPath"; ClusterClient clusterClient = new DisposeSavepointClusterClient( (String path) -> CompletableFuture.completedFuture(Acknowledge.get()), getConfiguration()); try { CliFrontend frontend = new MockedCliFrontend(clusterClient); String[] parameters = { "-d", savepointPath }; frontend.savepoint(parameters); String outMsg = buffer.toString(); assertTrue(outMsg.contains(savepointPath)); assertTrue(outMsg.contains("disposed")); } finally { clusterClient.shutdown(); restoreStdOutAndStdErr(); } }
try { if (clusterClient != null) { clusterClient.shutdown();
try { if (clusterClient != null) { clusterClient.shutdown();
client.shutdown(); } catch (Exception e) { LOG.warn("Could not properly shut down the cluster client.", e);
@Test public void testTriggerSavepointFailure() throws Exception { replaceStdOutAndStdErr(); JobID jobId = new JobID(); String expectedTestException = "expectedTestException"; Exception testException = new Exception(expectedTestException); final ClusterClient<String> clusterClient = createFailingClusterClient(testException); try { MockedCliFrontend frontend = new MockedCliFrontend(clusterClient); String[] parameters = { jobId.toString() }; try { frontend.savepoint(parameters); fail("Savepoint should have failed."); } catch (FlinkException e) { assertTrue(ExceptionUtils.findThrowableWithMessage(e, expectedTestException).isPresent()); } } finally { clusterClient.shutdown(); restoreStdOutAndStdErr(); } }
} finally { if (clusterClient != null) { clusterClient.shutdown();
} finally { restClient.shutdown(TIMEOUT); clusterClient.shutdown();
@VisibleForTesting void start(AthenaXYarnClusterDescriptor descriptor, JobGraph job) throws Exception { ClusterClient<ApplicationId> client = descriptor.deploy(); try { client.runDetached(job, null); stopAfterJob(client, job.getJobID()); } finally { client.shutdown(); } }
@Override public void stop() throws Exception { synchronized (lock) { if (client != null) { client.shutdown(); System.out.println("shutdown client"); client = null; } } }