use of org.apache.flink.runtime.taskexecutor.slot.SlotNotFoundException in project flink by splunk.
the class MetricUtils method getUsedManagedMemory.
private static long getUsedManagedMemory(TaskSlotTable<?> taskSlotTable) {
Set<AllocationID> activeTaskAllocationIds = taskSlotTable.getActiveTaskSlotAllocationIds();
long usedMemory = 0L;
for (AllocationID allocationID : activeTaskAllocationIds) {
try {
MemoryManager taskSlotMemoryManager = taskSlotTable.getTaskMemoryManager(allocationID);
usedMemory += taskSlotMemoryManager.getMemorySize() - taskSlotMemoryManager.availableMemory();
} catch (SlotNotFoundException e) {
LOG.debug("The task slot {} is not present anymore and will be ignored in calculating the amount of used memory.", allocationID);
}
}
return usedMemory;
}
use of org.apache.flink.runtime.taskexecutor.slot.SlotNotFoundException in project flink by splunk.
the class TaskExecutor method allocateSlotForJob.
private boolean allocateSlotForJob(JobID jobId, SlotID slotId, AllocationID allocationId, ResourceProfile resourceProfile, String targetAddress) throws SlotAllocationException {
allocateSlot(slotId, jobId, allocationId, resourceProfile);
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));
}
throw new SlotAllocationException("Could not create new job.", e);
}
return job.isConnected();
}
use of org.apache.flink.runtime.taskexecutor.slot.SlotNotFoundException in project flink by splunk.
the class TaskExecutor method freeSlotInternal.
private void freeSlotInternal(AllocationID allocationId, Throwable cause) {
checkNotNull(allocationId);
// information
if (isRunning()) {
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);
slotAllocationSnapshotPersistenceService.deleteAllocationSnapshot(slotIndex);
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);
} else {
log.debug("Ignoring the freeing of slot {} because the TaskExecutor is shutting down.", allocationId);
}
}
Aggregations