flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mxm <...@git.apache.org>
Subject [GitHub] flink pull request #2657: [FLINK-4853] [rm] Harden job manager registration ...
Date Fri, 21 Oct 2016 15:35:54 GMT
Github user mxm commented on a diff in the pull request:

    https://github.com/apache/flink/pull/2657#discussion_r84501742
  
    --- Diff: flink-runtime/src/main/java/org/apache/flink/runtime/resourcemanager/ResourceManager.java
---
    @@ -471,6 +498,149 @@ public void shutDownCluster(final ApplicationStatus finalStatus,
final String op
     	}
     
     	// ------------------------------------------------------------------------
    +	//  Testing methods
    +	// ------------------------------------------------------------------------
    +
    +	/**
    +	 * Gets the leader session id of current resourceManager.
    +	 *
    +	 * @return return the leaderSessionId of current resourceManager, this returns null
until the current resourceManager is granted leadership.
    +	 */
    +	@VisibleForTesting
    +	UUID getLeaderSessionId() {
    +		return leaderSessionId;
    +	}
    +
    +	// ------------------------------------------------------------------------
    +	//  Internal methods
    +	// ------------------------------------------------------------------------
    +
    +	private void clearState() {
    +		jobManagerRegistrations.clear();
    +		taskExecutors.clear();
    +		slotManager.clearState();
    +
    +		try {
    +			jobLeaderIdService.clear();
    +		} catch (Exception e) {
    +			onFatalError(new ResourceManagerException("Could not properly clear the job leader
id service.", e));
    +		}
    +
    +		leaderSessionId = new UUID(0, 0);
    +	}
    +
    +	/**
    +	 * Disconnects the job manager which is connected for the given job from the resource
manager.
    +	 *
    +	 * @param jobId identifying the job whose leader shall be disconnected
    +	 */
    +	protected void disconnectJobManager(JobID jobId, Exception cause) {
    +		JobManagerRegistration jobManagerRegistration = jobManagerRegistrations.remove(jobId);
    +
    +		if (jobManagerRegistration != null) {
    +			log.info("Disconnect job manager {}@{} for job {} from the resource manager.",
    +				jobManagerRegistration.getLeaderID(),
    +				jobManagerRegistration.getJobManagerGateway().getAddress(),
    +				jobId);
    +
    +			JobMasterGateway jobMasterGateway = jobManagerRegistration.getJobManagerGateway();
    +
    +			// tell the job manager about the disconnect
    +			jobMasterGateway.disconnectResourceManager(jobManagerRegistration.getLeaderID(), getLeaderSessionId(),
cause);
    +		} else {
    +			log.debug("There was no registered job manager for job {}.", jobId);
    +		}
    +	}
    +
    +	/**
    +	 * Checks whether the given resource manager leader id is matching the current leader
id.
    +	 *
    +	 * @param resourceManagerLeaderId to check
    +	 * @return True if the given leader id matches the actual leader id; otherwise false
    +	 */
    +	protected boolean isValid(UUID resourceManagerLeaderId) {
    +		if (resourceManagerLeaderId == null) {
    +			return leaderSessionId == null;
    --- End diff --
    
    Should `null` always return `false` if we assume that we use a default UUID in non high
availability mode?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message