Search in sources :

Example 6 with JobManagerRegistration

use of org.apache.flink.runtime.resourcemanager.registration.JobManagerRegistration in project flink by apache.

the class ResourceManager method registerJobMasterInternal.

// ------------------------------------------------------------------------
// Internal methods
// ------------------------------------------------------------------------
/**
 * Registers a new JobMaster.
 *
 * @param jobMasterGateway to communicate with the registering JobMaster
 * @param jobId of the job for which the JobMaster is responsible
 * @param jobManagerAddress address of the JobMaster
 * @param jobManagerResourceId ResourceID of the JobMaster
 * @return RegistrationResponse
 */
private RegistrationResponse registerJobMasterInternal(final JobMasterGateway jobMasterGateway, JobID jobId, String jobManagerAddress, ResourceID jobManagerResourceId) {
    if (jobManagerRegistrations.containsKey(jobId)) {
        JobManagerRegistration oldJobManagerRegistration = jobManagerRegistrations.get(jobId);
        if (Objects.equals(oldJobManagerRegistration.getJobMasterId(), jobMasterGateway.getFencingToken())) {
            // same registration
            log.debug("Job manager {}@{} was already registered.", jobMasterGateway.getFencingToken(), jobManagerAddress);
        } else {
            // tell old job manager that he is no longer the job leader
            closeJobManagerConnection(oldJobManagerRegistration.getJobID(), ResourceRequirementHandling.RETAIN, new Exception("New job leader for job " + jobId + " found."));
            JobManagerRegistration jobManagerRegistration = new JobManagerRegistration(jobId, jobManagerResourceId, jobMasterGateway);
            jobManagerRegistrations.put(jobId, jobManagerRegistration);
            jmResourceIdRegistrations.put(jobManagerResourceId, jobManagerRegistration);
        }
    } else {
        // new registration for the job
        JobManagerRegistration jobManagerRegistration = new JobManagerRegistration(jobId, jobManagerResourceId, jobMasterGateway);
        jobManagerRegistrations.put(jobId, jobManagerRegistration);
        jmResourceIdRegistrations.put(jobManagerResourceId, jobManagerRegistration);
    }
    log.info("Registered job manager {}@{} for job {}.", jobMasterGateway.getFencingToken(), jobManagerAddress, jobId);
    jobManagerHeartbeatManager.monitorTarget(jobManagerResourceId, new JobMasterHeartbeatSender(jobMasterGateway));
    return new JobMasterRegistrationSuccess(getFencingToken(), resourceId);
}
Also used : JobMasterRegistrationSuccess(org.apache.flink.runtime.jobmaster.JobMasterRegistrationSuccess) JobManagerRegistration(org.apache.flink.runtime.resourcemanager.registration.JobManagerRegistration) TimeoutException(java.util.concurrent.TimeoutException) CompletionException(java.util.concurrent.CompletionException) FlinkException(org.apache.flink.util.FlinkException) ResourceManagerException(org.apache.flink.runtime.resourcemanager.exceptions.ResourceManagerException) UnknownTaskExecutorException(org.apache.flink.runtime.resourcemanager.exceptions.UnknownTaskExecutorException)

Aggregations

JobManagerRegistration (org.apache.flink.runtime.resourcemanager.registration.JobManagerRegistration)6 JobMasterGateway (org.apache.flink.runtime.jobmaster.JobMasterGateway)3 ResourceManagerException (org.apache.flink.runtime.resourcemanager.exceptions.ResourceManagerException)3 JobID (org.apache.flink.api.common.JobID)2 JobMasterRegistrationSuccess (org.apache.flink.runtime.jobmaster.JobMasterRegistrationSuccess)2 RpcMethod (org.apache.flink.runtime.rpc.RpcMethod)2 UUID (java.util.UUID)1 CompletionException (java.util.concurrent.CompletionException)1 TimeoutException (java.util.concurrent.TimeoutException)1 ResourceID (org.apache.flink.runtime.clusterframework.types.ResourceID)1 LeaderIdMismatchException (org.apache.flink.runtime.highavailability.LeaderIdMismatchException)1 JobMasterId (org.apache.flink.runtime.jobmaster.JobMasterId)1 RegistrationResponse (org.apache.flink.runtime.registration.RegistrationResponse)1 UnknownTaskExecutorException (org.apache.flink.runtime.resourcemanager.exceptions.UnknownTaskExecutorException)1 RMSlotRequestRejected (org.apache.flink.runtime.resourcemanager.messages.jobmanager.RMSlotRequestRejected)1 FlinkException (org.apache.flink.util.FlinkException)1