flink-instrumentation/workspace/flink-1.4.1-instrumented/flink-1.4.1/flink-runtime/src/main/java/org/apache/flink/runtime/util/LeaderRetrievalUtils.java
/**
	 * Retrieves the current leader gateway using the given {@link LeaderRetrievalService}. If the
	 * current leader could not be retrieved after the given timeout, then a
	 * {@link LeaderRetrievalException} is thrown.
	 *
	 * @param leaderRetrievalService {@link LeaderRetrievalService} which is used for the leader retrieval
	 * @param actorSystem ActorSystem which is used for the {@link LeaderRetrievalListener} implementation
	 * @param timeout Timeout value for the retrieval call
	 * @return The current leader gateway
	 * @throws LeaderRetrievalException If the actor gateway could not be retrieved or the timeout has been exceeded
	 */
Retrieves the current leader gateway using the given  LeaderRetrievalService. If the
current leader could not be retrieved after the given timeout, then a
LeaderRetrievalException is thrown.


Retrieves the current leader gateway using the given LeaderRetrievalService . If the current leader could not be retrieved after the given timeout then a LeaderRetrievalException is thrown .
public static ActorGateway retrieveLeaderGateway(
			LeaderRetrievalService leaderRetrievalService,
			ActorSystem actorSystem,
			FiniteDuration timeout)
		throws LeaderRetrievalException {
		LeaderGatewayListener listener = new LeaderGatewayListener(actorSystem, timeout);
		try {
			leaderRetrievalService.start(listener);
			Future<ActorGateway> actorGatewayFuture = listener.getActorGatewayFuture();
			return Await.result(actorGatewayFuture, timeout);
		} catch (Exception e) {
			throw new LeaderRetrievalException("Could not retrieve the leader gateway.", e);
		} finally {
			try {
				leaderRetrievalService.stop();
			} catch (Exception fe) {
				LOG.warn("Could not stop the leader retrieval service.", fe);
			}
		}
	}
public static ActorGateway retrieveLeaderGateway ( LeaderRetrievalService leaderRetrievalService , ActorSystem actorSystem , FiniteDuration timeout ) throws LeaderRetrievalException { LeaderGatewayListener listener = new LeaderGatewayListener ( actorSystem , timeout ) ; try { leaderRetrievalService . start ( listener ) ; Future < ActorGateway > actorGatewayFuture = listener . getActorGatewayFuture ( ) ; return Await . result ( actorGatewayFuture , timeout ) ; } catch ( Exception e ) { throw new LeaderRetrievalException ( "Could not retrieve the leader gateway." , e ) ; } finally { try { leaderRetrievalService . stop ( ) ; } catch ( Exception fe ) { LOG . warn ( "Could not stop the leader retrieval service." , fe ) ; } } }
Retrieves the current leader gateway using the given {@link LeaderRetrievalService}.
Retrieves the current leader gateway using the given { @link LeaderRetrievalService } .