org.apache.flink.runtime.taskexecutor.slot.SlotNotFoundException Java Examples

The following examples show how to use org.apache.flink.runtime.taskexecutor.slot.SlotNotFoundException. 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: TaskExecutorTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public boolean markSlotActive(AllocationID allocationId) throws SlotNotFoundException {
	final boolean result = super.markSlotActive(allocationId);

	if (result) {
		slotsToActivate.countDown();
	}

	return result;
}
 
Example #2
Source File: TaskExecutor.java    From flink with Apache License 2.0 5 votes vote down vote up
private void freeSlotInternal(AllocationID allocationId, Throwable cause) {
	checkNotNull(allocationId);

	log.debug("Free slot with allocation id {} because: {}", allocationId, cause.getMessage());

	try {
		final JobID jobId = taskSlotTable.getOwningJob(allocationId);

		final int slotIndex = taskSlotTable.freeSlot(allocationId, cause);

		if (slotIndex != -1) {

			if (isConnectedToResourceManager()) {
				// the slot was freed. Tell the RM about it
				ResourceManagerGateway resourceManagerGateway = establishedResourceManagerConnection.getResourceManagerGateway();

				resourceManagerGateway.notifySlotAvailable(
					establishedResourceManagerConnection.getTaskExecutorRegistrationId(),
					new SlotID(getResourceID(), slotIndex),
					allocationId);
			}

			if (jobId != null) {
				closeJobManagerConnectionIfNoAllocatedResources(jobId);
			}
		}
	} catch (SlotNotFoundException e) {
		log.debug("Could not free slot for allocation id {}.", allocationId, e);
	}

	localStateStoresManager.releaseLocalStateForAllocationId(allocationId);
}
 
Example #3
Source File: TaskExecutorTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public boolean markSlotActive(AllocationID allocationId) throws SlotNotFoundException {
	final boolean result = super.markSlotActive(allocationId);

	if (result) {
		slotsToActivate.countDown();
	}

	return result;
}
 
Example #4
Source File: TaskExecutor.java    From flink with Apache License 2.0 5 votes vote down vote up
private void freeSlotInternal(AllocationID allocationId, Throwable cause) {
	checkNotNull(allocationId);

	log.debug("Free slot with allocation id {} because: {}", allocationId, cause.getMessage());

	try {
		final JobID jobId = taskSlotTable.getOwningJob(allocationId);

		final int slotIndex = taskSlotTable.freeSlot(allocationId, cause);

		if (slotIndex != -1) {

			if (isConnectedToResourceManager()) {
				// the slot was freed. Tell the RM about it
				ResourceManagerGateway resourceManagerGateway = establishedResourceManagerConnection.getResourceManagerGateway();

				resourceManagerGateway.notifySlotAvailable(
					establishedResourceManagerConnection.getTaskExecutorRegistrationId(),
					new SlotID(getResourceID(), slotIndex),
					allocationId);
			}

			if (jobId != null) {
				closeJobManagerConnectionIfNoAllocatedResources(jobId);
			}
		}
	} catch (SlotNotFoundException e) {
		log.debug("Could not free slot for allocation id {}.", allocationId, e);
	}

	localStateStoresManager.releaseLocalStateForAllocationId(allocationId);
}
 
Example #5
Source File: TaskExecutorTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public boolean markSlotActive(AllocationID allocationId) throws SlotNotFoundException {
	final boolean result = super.markSlotActive(allocationId);

	if (result) {
		slotsToActivate.countDown();
	}

	return result;
}
 
Example #6
Source File: TaskExecutor.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public CompletableFuture<Acknowledge> requestSlot(
	final SlotID slotId,
	final JobID jobId,
	final AllocationID allocationId,
	final ResourceProfile resourceProfile,
	final String targetAddress,
	final ResourceManagerId resourceManagerId,
	final Time timeout) {
	// TODO: Filter invalid requests from the resource manager by using the instance/registration Id

	log.info("Receive slot request {} for job {} from resource manager with leader id {}.",
		allocationId, jobId, resourceManagerId);

	if (!isConnectedToResourceManager(resourceManagerId)) {
		final String message = String.format("TaskManager is not connected to the resource manager %s.", resourceManagerId);
		log.debug(message);
		return FutureUtils.completedExceptionally(new TaskManagerException(message));
	}

	try {
		allocateSlot(
			slotId,
			jobId,
			allocationId,
			resourceProfile);
	} catch (SlotAllocationException sae) {
		return FutureUtils.completedExceptionally(sae);
	}

	final JobTable.Job job;

	try {
		job = jobTable.getOrCreateJob(jobId, () -> registerNewJobAndCreateServices(jobId, targetAddress));
	} catch (Exception e) {
		// free the allocated slot
		try {
			taskSlotTable.freeSlot(allocationId);
		} catch (SlotNotFoundException slotNotFoundException) {
			// slot no longer existent, this should actually never happen, because we've
			// just allocated the slot. So let's fail hard in this case!
			onFatalError(slotNotFoundException);
		}

		// release local state under the allocation id.
		localStateStoresManager.releaseLocalStateForAllocationId(allocationId);

		// sanity check
		if (!taskSlotTable.isSlotFree(slotId.getSlotNumber())) {
			onFatalError(new Exception("Could not free slot " + slotId));
		}

		return FutureUtils.completedExceptionally(new SlotAllocationException("Could not create new job.", e));
	}

	if (job.isConnected()) {
		offerSlotsToJobManager(jobId);
	}

	return CompletableFuture.completedFuture(Acknowledge.get());
}