org.apache.flink.runtime.resourcemanager.registration.JobManagerRegistration Java Examples

The following examples show how to use org.apache.flink.runtime.resourcemanager.registration.JobManagerRegistration. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ResourceManager.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * This method should be called by the framework once it detects that a currently registered
 * job manager has failed.
 *
 * @param jobId identifying the job whose leader shall be disconnected.
 * @param cause The exception which cause the JobManager failed.
 */
protected void closeJobManagerConnection(JobID jobId, Exception cause) {
	JobManagerRegistration jobManagerRegistration = jobManagerRegistrations.remove(jobId);

	if (jobManagerRegistration != null) {
		final ResourceID jobManagerResourceId = jobManagerRegistration.getJobManagerResourceID();
		final JobMasterGateway jobMasterGateway = jobManagerRegistration.getJobManagerGateway();
		final JobMasterId jobMasterId = jobManagerRegistration.getJobMasterId();

		log.info("Disconnect job manager {}@{} for job {} from the resource manager.",
			jobMasterId,
			jobMasterGateway.getAddress(),
			jobId);

		jobManagerHeartbeatManager.unmonitorTarget(jobManagerResourceId);

		jmResourceIdRegistrations.remove(jobManagerResourceId);

		// tell the job manager about the disconnect
		jobMasterGateway.disconnectResourceManager(getFencingToken(), cause);
	} else {
		log.debug("There was no registered job manager for job {}.", jobId);
	}
}
 
Example #2
Source File: ResourceManager.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * This method should be called by the framework once it detects that a currently registered
 * job manager has failed.
 *
 * @param jobId identifying the job whose leader shall be disconnected.
 * @param cause The exception which cause the JobManager failed.
 */
protected void closeJobManagerConnection(JobID jobId, Exception cause) {
	JobManagerRegistration jobManagerRegistration = jobManagerRegistrations.remove(jobId);

	if (jobManagerRegistration != null) {
		final ResourceID jobManagerResourceId = jobManagerRegistration.getJobManagerResourceID();
		final JobMasterGateway jobMasterGateway = jobManagerRegistration.getJobManagerGateway();
		final JobMasterId jobMasterId = jobManagerRegistration.getJobMasterId();

		log.info("Disconnect job manager {}@{} for job {} from the resource manager.",
			jobMasterId,
			jobMasterGateway.getAddress(),
			jobId);

		jobManagerHeartbeatManager.unmonitorTarget(jobManagerResourceId);

		jmResourceIdRegistrations.remove(jobManagerResourceId);

		// tell the job manager about the disconnect
		jobMasterGateway.disconnectResourceManager(getFencingToken(), cause);
	} else {
		log.debug("There was no registered job manager for job {}.", jobId);
	}
}
 
Example #3
Source File: ResourceManager.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * This method should be called by the framework once it detects that a currently registered
 * job manager has failed.
 *
 * @param jobId identifying the job whose leader shall be disconnected.
 * @param cause The exception which cause the JobManager failed.
 */
protected void closeJobManagerConnection(JobID jobId, Exception cause) {
	JobManagerRegistration jobManagerRegistration = jobManagerRegistrations.remove(jobId);

	if (jobManagerRegistration != null) {
		final ResourceID jobManagerResourceId = jobManagerRegistration.getJobManagerResourceID();
		final JobMasterGateway jobMasterGateway = jobManagerRegistration.getJobManagerGateway();
		final JobMasterId jobMasterId = jobManagerRegistration.getJobMasterId();

		log.info("Disconnect job manager {}@{} for job {} from the resource manager.",
			jobMasterId,
			jobMasterGateway.getAddress(),
			jobId);

		jobManagerHeartbeatManager.unmonitorTarget(jobManagerResourceId);

		jmResourceIdRegistrations.remove(jobManagerResourceId);

		// tell the job manager about the disconnect
		jobMasterGateway.disconnectResourceManager(getFencingToken(), cause);
	} else {
		log.debug("There was no registered job manager for job {}.", jobId);
	}
}
 
Example #4
Source File: ResourceManager.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public CompletableFuture<Acknowledge> requestSlot(
		JobMasterId jobMasterId,
		SlotRequest slotRequest,
		final Time timeout) {

	JobID jobId = slotRequest.getJobId();
	JobManagerRegistration jobManagerRegistration = jobManagerRegistrations.get(jobId);

	if (null != jobManagerRegistration) {
		if (Objects.equals(jobMasterId, jobManagerRegistration.getJobMasterId())) {
			log.info("Request slot with profile {} for job {} with allocation id {}.",
				slotRequest.getResourceProfile(),
				slotRequest.getJobId(),
				slotRequest.getAllocationId());

			try {
				slotManager.registerSlotRequest(slotRequest);
			} catch (SlotManagerException e) {
				return FutureUtils.completedExceptionally(e);
			}

			return CompletableFuture.completedFuture(Acknowledge.get());
		} else {
			return FutureUtils.completedExceptionally(new ResourceManagerException("The job leader's id " +
				jobManagerRegistration.getJobMasterId() + " does not match the received id " + jobMasterId + '.'));
		}

	} else {
		return FutureUtils.completedExceptionally(new ResourceManagerException("Could not find registered job manager for job " + jobId + '.'));
	}
}
 
Example #5
Source File: ResourceManager.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
protected void jobLeaderLostLeadership(JobID jobId, JobMasterId oldJobMasterId) {
	if (jobManagerRegistrations.containsKey(jobId)) {
		JobManagerRegistration jobManagerRegistration = jobManagerRegistrations.get(jobId);

		if (Objects.equals(jobManagerRegistration.getJobMasterId(), oldJobMasterId)) {
			disconnectJobManager(jobId, new Exception("Job leader lost leadership."));
		} else {
			log.debug("Discarding job leader lost leadership, because a new job leader was found for job {}. ", jobId);
		}
	} else {
		log.debug("Discard job leader lost leadership for outdated leader {} for job {}.", oldJobMasterId, jobId);
	}
}
 
Example #6
Source File: ResourceManager.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public void notifyAllocationFailure(JobID jobId, AllocationID allocationId, Exception cause) {
	validateRunsInMainThread();

	JobManagerRegistration jobManagerRegistration = jobManagerRegistrations.get(jobId);
	if (jobManagerRegistration != null) {
		jobManagerRegistration.getJobManagerGateway().notifyAllocationFailure(allocationId, cause);
	}
}
 
Example #7
Source File: ResourceManager.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public void notifyHeartbeatTimeout(final ResourceID resourceID) {
	validateRunsInMainThread();
	log.info("The heartbeat of JobManager with id {} timed out.", resourceID);

	if (jmResourceIdRegistrations.containsKey(resourceID)) {
		JobManagerRegistration jobManagerRegistration = jmResourceIdRegistrations.get(resourceID);

		if (jobManagerRegistration != null) {
			closeJobManagerConnection(
				jobManagerRegistration.getJobID(),
				new TimeoutException("The heartbeat of JobManager with id " + resourceID + " timed out."));
		}
	}
}
 
Example #8
Source File: ResourceManager.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public CompletableFuture<Acknowledge> requestSlot(
		JobMasterId jobMasterId,
		SlotRequest slotRequest,
		final Time timeout) {

	JobID jobId = slotRequest.getJobId();
	JobManagerRegistration jobManagerRegistration = jobManagerRegistrations.get(jobId);

	if (null != jobManagerRegistration) {
		if (Objects.equals(jobMasterId, jobManagerRegistration.getJobMasterId())) {
			log.info("Request slot with profile {} for job {} with allocation id {}.",
				slotRequest.getResourceProfile(),
				slotRequest.getJobId(),
				slotRequest.getAllocationId());

			try {
				slotManager.registerSlotRequest(slotRequest);
			} catch (ResourceManagerException e) {
				return FutureUtils.completedExceptionally(e);
			}

			return CompletableFuture.completedFuture(Acknowledge.get());
		} else {
			return FutureUtils.completedExceptionally(new ResourceManagerException("The job leader's id " +
				jobManagerRegistration.getJobMasterId() + " does not match the received id " + jobMasterId + '.'));
		}

	} else {
		return FutureUtils.completedExceptionally(new ResourceManagerException("Could not find registered job manager for job " + jobId + '.'));
	}
}
 
Example #9
Source File: ResourceManager.java    From flink with Apache License 2.0 5 votes vote down vote up
protected void jobLeaderLostLeadership(JobID jobId, JobMasterId oldJobMasterId) {
	if (jobManagerRegistrations.containsKey(jobId)) {
		JobManagerRegistration jobManagerRegistration = jobManagerRegistrations.get(jobId);

		if (Objects.equals(jobManagerRegistration.getJobMasterId(), oldJobMasterId)) {
			disconnectJobManager(jobId, new Exception("Job leader lost leadership."));
		} else {
			log.debug("Discarding job leader lost leadership, because a new job leader was found for job {}. ", jobId);
		}
	} else {
		log.debug("Discard job leader lost leadership for outdated leader {} for job {}.", oldJobMasterId, jobId);
	}
}
 
Example #10
Source File: ResourceManager.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void notifyAllocationFailure(JobID jobId, AllocationID allocationId, Exception cause) {
	validateRunsInMainThread();

	JobManagerRegistration jobManagerRegistration = jobManagerRegistrations.get(jobId);
	if (jobManagerRegistration != null) {
		jobManagerRegistration.getJobManagerGateway().notifyAllocationFailure(allocationId, cause);
	}
}
 
Example #11
Source File: ResourceManager.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void notifyHeartbeatTimeout(final ResourceID resourceID) {
	validateRunsInMainThread();
	log.info("The heartbeat of JobManager with id {} timed out.", resourceID);

	if (jmResourceIdRegistrations.containsKey(resourceID)) {
		JobManagerRegistration jobManagerRegistration = jmResourceIdRegistrations.get(resourceID);

		if (jobManagerRegistration != null) {
			closeJobManagerConnection(
				jobManagerRegistration.getJobID(),
				new TimeoutException("The heartbeat of JobManager with id " + resourceID + " timed out."));
		}
	}
}
 
Example #12
Source File: ResourceManager.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public CompletableFuture<Acknowledge> requestSlot(
		JobMasterId jobMasterId,
		SlotRequest slotRequest,
		final Time timeout) {

	JobID jobId = slotRequest.getJobId();
	JobManagerRegistration jobManagerRegistration = jobManagerRegistrations.get(jobId);

	if (null != jobManagerRegistration) {
		if (Objects.equals(jobMasterId, jobManagerRegistration.getJobMasterId())) {
			log.info("Request slot with profile {} for job {} with allocation id {}.",
				slotRequest.getResourceProfile(),
				slotRequest.getJobId(),
				slotRequest.getAllocationId());

			try {
				slotManager.registerSlotRequest(slotRequest);
			} catch (ResourceManagerException e) {
				return FutureUtils.completedExceptionally(e);
			}

			return CompletableFuture.completedFuture(Acknowledge.get());
		} else {
			return FutureUtils.completedExceptionally(new ResourceManagerException("The job leader's id " +
				jobManagerRegistration.getJobMasterId() + " does not match the received id " + jobMasterId + '.'));
		}

	} else {
		return FutureUtils.completedExceptionally(new ResourceManagerException("Could not find registered job manager for job " + jobId + '.'));
	}
}
 
Example #13
Source File: ResourceManager.java    From flink with Apache License 2.0 5 votes vote down vote up
protected void jobLeaderLostLeadership(JobID jobId, JobMasterId oldJobMasterId) {
	if (jobManagerRegistrations.containsKey(jobId)) {
		JobManagerRegistration jobManagerRegistration = jobManagerRegistrations.get(jobId);

		if (Objects.equals(jobManagerRegistration.getJobMasterId(), oldJobMasterId)) {
			disconnectJobManager(jobId, new Exception("Job leader lost leadership."));
		} else {
			log.debug("Discarding job leader lost leadership, because a new job leader was found for job {}. ", jobId);
		}
	} else {
		log.debug("Discard job leader lost leadership for outdated leader {} for job {}.", oldJobMasterId, jobId);
	}
}
 
Example #14
Source File: ResourceManager.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void notifyAllocationFailure(JobID jobId, AllocationID allocationId, Exception cause) {
	validateRunsInMainThread();

	JobManagerRegistration jobManagerRegistration = jobManagerRegistrations.get(jobId);
	if (jobManagerRegistration != null) {
		jobManagerRegistration.getJobManagerGateway().notifyAllocationFailure(allocationId, cause);
	}
}
 
Example #15
Source File: ResourceManager.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void notifyHeartbeatTimeout(final ResourceID resourceID) {
	validateRunsInMainThread();
	log.info("The heartbeat of JobManager with id {} timed out.", resourceID);

	if (jmResourceIdRegistrations.containsKey(resourceID)) {
		JobManagerRegistration jobManagerRegistration = jmResourceIdRegistrations.get(resourceID);

		if (jobManagerRegistration != null) {
			closeJobManagerConnection(
				jobManagerRegistration.getJobID(),
				new TimeoutException("The heartbeat of JobManager with id " + resourceID + " timed out."));
		}
	}
}