flink-instrumentation/workspace/flink-1.4.1-instrumented/flink-1.4.1/flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/Dispatcher.java
/**
	 * Callback method when current resourceManager is granted leadership.
	 *
	 * @param newLeaderSessionID unique leadershipID
	 */
Callback method when current resourceManager is granted leadership.
@param newLeaderSessionID unique leadershipID
Callback method when current resourceManager is granted leadership . @param newLeaderSessionID unique leadershipID
@Override
	public void grantLeadership(final UUID newLeaderSessionID) {
		runAsyncWithoutFencing(
			() -> {
				final DispatcherId dispatcherId = new DispatcherId(newLeaderSessionID);
				log.info("Dispatcher {} was granted leadership with fencing token {}", getAddress(), dispatcherId);
				if (getFencingToken() != null) {
					try {
						clearState();
					} catch (Exception e) {
						log.warn("Could not properly clear the Dispatcher state while granting leadership.", e);
					}
				}
				setFencingToken(dispatcherId);
				getRpcService().execute(
					() -> leaderElectionService.confirmLeaderSessionID(newLeaderSessionID));
				recoverJobs();
			});
	}
@ Override public void grantLeadership ( final UUID newLeaderSessionID ) { runAsyncWithoutFencing ( ( ) -> { final DispatcherId dispatcherId = new DispatcherId ( newLeaderSessionID ) ; log . info ( "Dispatcher {} was granted leadership with fencing token {}" , getAddress ( ) , dispatcherId ) ; if ( getFencingToken ( ) != null ) { try { clearState ( ) ; } catch ( Exception e ) { log . warn ( "Could not properly clear the Dispatcher state while granting leadership." , e ) ; } } setFencingToken ( dispatcherId ) ; getRpcService ( ) . execute ( ( ) -> leaderElectionService . confirmLeaderSessionID ( newLeaderSessionID ) ) ; recoverJobs ( ) ; } ) ; }
Callback method when current resourceManager is granted leadership.
Callback method when current resourceManager is granted leadership .
// clear the state if we've been the leader before // confirming the leader session ID might be blocking,