docs: 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
  				disconnectJobManager(
  					oldJobManagerRegistration.getJobID(),
  					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 HeartbeatTarget<Void>() {
  			@Override
  			public void receiveHeartbeat(ResourceID resourceID, Void payload) {
  				// the ResourceManager will always send heartbeat requests to the JobManager
  			}
  
  			@Override
  			public void requestHeartbeat(ResourceID resourceID, Void payload) {
  				jobMasterGateway.heartbeatFromResourceManager(resourceID);
  			}
  		});
  
  		return new JobMasterRegistrationSuccess(
  			getFencingToken(),
  			resourceId);
  	}