@Override public LeaderRetrievalService getDispatcherLeaderRetriever() { enter(); try { return new StandaloneLeaderRetrievalService(dispatcherRpcUrl, DEFAULT_LEADER_ID); } finally { exit(); } }
@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); } }
@Test public void testClosingReportsToLeader() throws Exception { final Configuration flinkConfig = new Configuration(); try (YarnHighAvailabilityServices services = new YarnIntraNonHaMasterServices(flinkConfig, hadoopConfig)) { final LeaderElectionService elector = services.getResourceManagerLeaderElectionService(); final LeaderRetrievalService retrieval = services.getResourceManagerLeaderRetriever(); final LeaderContender contender = mockContender(elector); final LeaderRetrievalListener listener = mock(LeaderRetrievalListener.class); elector.start(contender); retrieval.start(listener); // wait until the contender has become the leader verify(listener, timeout(1000L).times(1)).notifyLeaderAddress(anyString(), any(UUID.class)); // now we can close the election service services.close(); verify(contender, timeout(1000L).times(1)).handleError(any(Exception.class)); } }
@Override public void stateChanged(CuratorFramework client, ConnectionState newState) { handleStateChange(newState); } };
public void shutdown(Exception cause) { if (running) { running = false; listener.handleError(cause); listener = null; } } }
SettableLeaderRetrievalService leaderRetrievalService = new SettableLeaderRetrievalService( null, null); )); leaderRetrievalService.notifyListener(leader1.path().toString(), leaderSessionID); leaderRetrievalService.notifyListener(null, null); leaderRetrievalService.notifyListener(leader1.path().toString(), leaderSessionID);
final SettableLeaderRetrievalService settableLeaderRetrievalService = new SettableLeaderRetrievalService(expectedAddress, leaderId);
@Override public void start() throws Exception { synchronized (startupShutdownLock) { leaderRetrievalService.start(retriever); long delay = backPressureStatsTrackerImpl.getCleanUpInterval(); // Scheduled back pressure stats tracker cache cleanup. We schedule // this here repeatedly, because cache clean up only happens on // interactions with the cache. We need it to make sure that we // don't leak memory after completed jobs or long ago accessed stats. netty.getBootstrap().childGroup().scheduleWithFixedDelay(new Runnable() { @Override public void run() { try { backPressureStatsTrackerImpl.cleanUpOperatorStatsCache(); } catch (Throwable t) { LOG.error("Error during back pressure stats cache cleanup.", t); } } }, delay, delay, TimeUnit.MILLISECONDS); } }
@Override public void stop() throws Exception { synchronized (startupShutdownLock) { executionGraphCleanupTask.cancel(false); executionGraphCache.close(); leaderRetrievalService.stop(); netty.shutdown(); stackTraceSamples.shutDown(); backPressureStatsTrackerImpl.shutDown(); cleanup(); } }
@Override public LeaderRetrievalService getResourceManagerLeaderRetriever() { enter(); try { return new StandaloneLeaderRetrievalService(resourceManagerRpcUrl, DEFAULT_LEADER_ID); } finally { exit(); } }
@Override public void stateChanged(CuratorFramework client, ConnectionState newState) { handleStateChange(newState); } };
void shutdown(Exception cause) { if (running) { final LeaderRetrievalListener lst = listener; running = false; listener = null; try { lst.handleError(cause); } catch (Throwable ignored) {} } } }
@Override public LeaderRetrievalService getJobManagerLeaderRetriever(JobID jobID, String defaultJobManagerAddress) { enter(); try { return new StandaloneLeaderRetrievalService(defaultJobManagerAddress, DEFAULT_LEADER_ID); } finally { exit(); } }
@Override public void stateChanged(CuratorFramework client, ConnectionState newState) { handleStateChange(newState); } };
void shutdown(Exception cause) { if (running) { final LeaderRetrievalListener lst = listener; running = false; listener = null; try { lst.handleError(cause); } catch (Throwable ignored) {} } } }
@Override public void stateChanged(CuratorFramework client, ConnectionState newState) { handleStateChange(newState); } };
void shutdown(Exception cause) { if (running) { final LeaderRetrievalListener lst = listener; running = false; listener = null; try { lst.handleError(cause); } catch (Throwable ignored) {} } } }