@Override public CompletableFuture<Boolean> returnAllocatedSlot(LogicalSlot slot) { return gateway .releaseSlot( slot.getSlotRequestId(), slot.getSlotSharingGroupId(), slot.getCoLocationConstraint(), new FlinkException("Slot is being returned to the SlotPool.")) .thenApply( (Acknowledge acknowledge) -> true); }
private void sendFailIntermediateResultPartitionsRpcCall() { final LogicalSlot slot = assignedResource; if (slot != null) { final TaskManagerGateway taskManagerGateway = slot.getTaskManagerGateway(); // TODO For some tests this could be a problem when querying too early if all resources were released taskManagerGateway.failPartition(attemptId); } }
/** * Update the partition infos on the assigned resource. * * @param partitionInfos for the remote task */ private void sendUpdatePartitionInfoRpcCall( final Iterable<PartitionInfo> partitionInfos) { final LogicalSlot slot = assignedResource; if (slot != null) { final TaskManagerGateway taskManagerGateway = slot.getTaskManagerGateway(); final TaskManagerLocation taskManagerLocation = slot.getTaskManagerLocation(); CompletableFuture<Acknowledge> updatePartitionsResultFuture = taskManagerGateway.updatePartitions(attemptId, partitionInfos, rpcTimeout); updatePartitionsResultFuture.whenCompleteAsync( (ack, failure) -> { // fail if there was a failure if (failure != null) { fail(new IllegalStateException("Update task on TaskManager " + taskManagerLocation + " failed due to:", failure)); } }, executor); } }
@Override public CompletableFuture<Boolean> returnAllocatedSlot(LogicalSlot slot) { return gateway .releaseSlot( slot.getSlotRequestId(), slot.getSlotSharingGroupId(), new FlinkException("Slot is being returned to the SlotPool.")) .thenApply( (Acknowledge acknowledge) -> true); }
if (!slot.isAlive()) { throw new JobException("Target slot (TaskManager) for deployment is no longer alive."); if (this != slot.getPayload()) { throw new IllegalStateException( String.format("The execution %s has not been assigned to the assigned slot.", this)); slot.releaseSlot(new FlinkException("Actual state of execution " + this + " (" + state + ") does not match expected state DEPLOYING.")); return; attemptNumber, slot.getTaskManagerLocation().getResourceID(), slot.getPhysicalSlotNumber(), getAssignedResourceLocation().getHostname())); final TaskManagerGateway taskManagerGateway = slot.getTaskManagerGateway();
if (!slot.isAlive()) { throw new JobException("Target slot (TaskManager) for deployment is no longer alive."); if (this != slot.getPayload()) { throw new IllegalStateException( String.format("The execution %s has not been assigned to the assigned slot.", this)); slot.releaseSlot(new FlinkException("Actual state of execution " + this + " (" + state + ") does not match expected state DEPLOYING.")); return; final TaskManagerGateway taskManagerGateway = slot.getTaskManagerGateway();
if (ASSIGNED_SLOT_UPDATER.compareAndSet(this, null, logicalSlot) && logicalSlot.tryAssignPayload(this)) { taskManagerLocationFuture.complete(logicalSlot.getTaskManagerLocation()); assignedAllocationID = logicalSlot.getAllocationId(); LOG.info("{} is assigned resource {}_{} with {}", getVertexWithAttempt(), logicalSlot.getTaskManagerLocation().getResourceID(), logicalSlot.getPhysicalSlotNumber(), assignedAllocationID); return true;
if (logicalSlot.tryAssignPayload(this)) { taskManagerLocationFuture.complete(logicalSlot.getTaskManagerLocation()); assignedAllocationID = logicalSlot.getAllocationId(); return true; } else {
InputChannelDeploymentDescriptor[] partitions = InputChannelDeploymentDescriptor.fromEdges( edges, targetSlot.getTaskManagerLocation().getResourceID(), lazyScheduling); serializedTaskInformation, executionId, targetSlot.getAllocationId(), subTaskIndex, attemptNumber, targetSlot.getPhysicalSlotNumber(), taskRestore, producedPartitions,
@Override public String toString() { String logicalSlotString = "(pending)"; try { LogicalSlot slot = singleLogicalSlotFuture.getNow(null); if (slot != null) { logicalSlotString = "(requestId=" + slot.getSlotRequestId() + ", allocationId=" + slot.getAllocationId() + ')'; } } catch (Exception e) { logicalSlotString = '(' + ExceptionUtils.stripCompletionException(e).getMessage() + ')'; } return "SingleTaskSlot{" + "logicalSlot=" + logicalSlotString + ", request=" + getSlotRequestId() + ", group=" + getGroupId() + '}'; } }
@Override public TaskManagerLocation getAssignedResourceLocation() { // returns non-null only when a location is already assigned final LogicalSlot currentAssignedResource = assignedResource; return currentAssignedResource != null ? currentAssignedResource.getTaskManagerLocation() : null; }
/** * Releases this slot. * * @return Future which is completed once the slot has been released, * in case of a failure it is completed exceptionally * @deprecated Added because extended the actual releaseSlot method with cause parameter. */ default CompletableFuture<?> releaseSlot() { return releaseSlot(null); }
if (!slot.isAlive()) { throw new JobException("Target slot (TaskManager) for deployment is no longer alive."); if (this != slot.getPayload()) { throw new IllegalStateException( String.format("The execution %s has not been assigned to the assigned slot.", this)); slot.releaseSlot(new FlinkException("Actual state of execution " + this + " (" + state + ") does not match expected state DEPLOYING.")); return; final TaskManagerGateway taskManagerGateway = slot.getTaskManagerGateway();
if (logicalSlot.tryAssignPayload(this)) { taskManagerLocationFuture.complete(logicalSlot.getTaskManagerLocation()); assignedAllocationID = logicalSlot.getAllocationId(); return true; } else {
InputChannelDeploymentDescriptor[] partitions = InputChannelDeploymentDescriptor.fromEdges( edges, targetSlot.getTaskManagerLocation().getResourceID(), lazyScheduling); serializedTaskInformation, executionId, targetSlot.getAllocationId(), subTaskIndex, attemptNumber, targetSlot.getPhysicalSlotNumber(), taskRestore, producedPartitions,
@Override public String toString() { String logicalSlotString = "(pending)"; try { LogicalSlot slot = singleLogicalSlotFuture.getNow(null); if (slot != null) { logicalSlotString = "(requestId=" + slot.getSlotRequestId() + ", allocationId=" + slot.getAllocationId() + ')'; } } catch (Exception e) { logicalSlotString = '(' + ExceptionUtils.stripCompletionException(e).getMessage() + ')'; } return "SingleTaskSlot{" + "logicalSlot=" + logicalSlotString + ", request=" + getSlotRequestId() + ", group=" + getGroupId() + '}'; } }
@Override public TaskManagerLocation getAssignedResourceLocation() { // returns non-null only when a location is already assigned final LogicalSlot currentAssignedResource = assignedResource; return currentAssignedResource != null ? currentAssignedResource.getTaskManagerLocation() : null; }
/** * Releases this slot. * * @return Future which is completed once the slot has been released, * in case of a failure it is completed exceptionally * @deprecated Added because extended the actual releaseSlot method with cause parameter. */ default CompletableFuture<?> releaseSlot() { return releaseSlot(null); }
@Override public CompletableFuture<Boolean> returnAllocatedSlot(LogicalSlot slot) { return gateway .releaseSlot( slot.getSlotRequestId(), slot.getSlotSharingGroupId(), new FlinkException("Slot is being returned to the SlotPool.")) .thenApply( (Acknowledge acknowledge) -> true); }
if (ASSIGNED_SLOT_UPDATER.compareAndSet(this, null, slot) && slot.tryAssignPayload(this)) { if (taskManagerLocationFuture.isDone() && !slot.getTaskManagerLocation().equals(taskManagerLocationFuture.getNow(null))) { ASSIGNED_SLOT_UPDATER.compareAndSet(this, slot, null); reconcileFuture.complete(attemptId); LOG.info("Reconcile {} fail as has already has a different location.", vertex.getTaskNameWithSubtaskIndex()); return false; } else if (!taskManagerLocationFuture.isDone() && !taskManagerLocationFuture.complete(slot.getTaskManagerLocation())) { ASSIGNED_SLOT_UPDATER.compareAndSet(this, slot, null); reconcileFuture.complete(attemptId); } else { if (reconcileFuture.complete(null)) { assignedAllocationID = slot.getAllocationId(); this.attemptId = executionId; this.attemptNumber = attemptNumber;