private void releaseTaskManagerInternal(final ResourceID resourceId, final Exception cause) { final Set<AllocatedSlot> removedSlots = new HashSet<>(allocatedSlots.removeSlotsForTaskManager(resourceId)); for (AllocatedSlot allocatedSlot : removedSlots) { allocatedSlot.releasePayload(cause); } removedSlots.addAll(availableSlots.removeAllForTaskManager(resourceId)); for (AllocatedSlot removedSlot : removedSlots) { TaskManagerGateway taskManagerGateway = removedSlot.getTaskManagerGateway(); taskManagerGateway.freeSlot(removedSlot.getAllocationId(), cause, rpcTimeout); } }
private void releaseTaskManagerInternal(final ResourceID resourceId, final Exception cause) { final Set<AllocatedSlot> removedSlots = new HashSet<>(allocatedSlots.removeSlotsForTaskManager(resourceId)); for (AllocatedSlot allocatedSlot : removedSlots) { allocatedSlot.releasePayload(cause); } removedSlots.addAll(availableSlots.removeAllForTaskManager(resourceId)); for (AllocatedSlot removedSlot : removedSlots) { TaskManagerGateway taskManagerGateway = removedSlot.getTaskManagerGateway(); taskManagerGateway.freeSlot(removedSlot.getAllocationId(), cause, rpcTimeout); } }
private void releaseTaskManagerInternal(final ResourceID resourceId, final Exception cause) { final Set<AllocatedSlot> removedSlots = new HashSet<>(allocatedSlots.removeSlotsForTaskManager(resourceId)); for (AllocatedSlot allocatedSlot : removedSlots) { allocatedSlot.releasePayload(cause); } removedSlots.addAll(availableSlots.removeAllForTaskManager(resourceId)); for (AllocatedSlot removedSlot : removedSlots) { TaskManagerGateway taskManagerGateway = removedSlot.getTaskManagerGateway(); taskManagerGateway.freeSlot(removedSlot.getAllocationId(), cause, rpcTimeout); } }
private void releaseSlotToTaskManager(AllocatedSlot expiredSlot, Throwable cause) { final AllocationID allocationID = expiredSlot.getAllocationId(); final CompletableFuture<Acknowledge> freeSlotFuture = expiredSlot.getTaskManagerGateway().freeSlot( allocationID, cause, rpcTimeout); freeSlotFuture.whenCompleteAsync( (Acknowledge ignored, Throwable throwable) -> { if (throwable != null) { if (throwable instanceof SlotNotFoundException) { log.debug("The slot {} is dropped as the task executor has released it.", allocationID, throwable); } else if (registeredTaskManagers.contains(expiredSlot.getTaskManagerId())) { log.debug("Releasing slot {} of registered TaskExecutor {} failed. Will retry.", allocationID, expiredSlot.getTaskManagerId(), throwable); releaseSlotToTaskManager(expiredSlot, cause); } else { log.debug("Releasing slot {} failed and owning TaskExecutor {} is no " + "longer registered. Discarding slot.", allocationID, expiredSlot.getTaskManagerId()); } } }, getMainThreadExecutor()); }
private CompletableFuture<SerializableOptional<ResourceID>> tryFailingAllocatedSlot(AllocationID allocationID, Exception cause) { AllocatedSlot allocatedSlot = availableSlots.tryRemove(allocationID); if (allocatedSlot == null) { allocatedSlot = allocatedSlots.remove(allocationID); } if (allocatedSlot != null) { log.debug("Failed allocated slot [{}]: {}", allocationID, cause.getMessage()); // notify TaskExecutor about the failure allocatedSlot.getTaskManagerGateway().freeSlot(allocationID, cause, rpcTimeout); // release the slot. // since it is not in 'allocatedSlots' any more, it will be dropped o return' allocatedSlot.releasePayload(cause); final ResourceID taskManagerId = allocatedSlot.getTaskManagerId(); if (!availableSlots.containsTaskManager(taskManagerId) && !allocatedSlots.containResource(taskManagerId)) { return CompletableFuture.completedFuture(SerializableOptional.of(taskManagerId)); } } return CompletableFuture.completedFuture(SerializableOptional.empty()); }
private CompletableFuture<SerializableOptional<ResourceID>> tryFailingAllocatedSlot(AllocationID allocationID, Exception cause) { AllocatedSlot allocatedSlot = availableSlots.tryRemove(allocationID); if (allocatedSlot == null) { allocatedSlot = allocatedSlots.remove(allocationID); } if (allocatedSlot != null) { log.debug("Failed allocated slot [{}]: {}", allocationID, cause.getMessage()); // notify TaskExecutor about the failure allocatedSlot.getTaskManagerGateway().freeSlot(allocationID, cause, rpcTimeout); // release the slot. // since it is not in 'allocatedSlots' any more, it will be dropped o return' allocatedSlot.releasePayload(cause); final ResourceID taskManagerId = allocatedSlot.getTaskManagerId(); if (!availableSlots.containsTaskManager(taskManagerId) && !allocatedSlots.containResource(taskManagerId)) { return CompletableFuture.completedFuture(SerializableOptional.of(taskManagerId)); } } return CompletableFuture.completedFuture(SerializableOptional.empty()); }
final CompletableFuture<Acknowledge> freeSlotFuture = expiredSlot.getTaskManagerGateway().freeSlot( allocationID, cause,
final CompletableFuture<Acknowledge> freeSlotFuture = expiredSlot.getTaskManagerGateway().freeSlot( allocationID, cause,