use of org.apache.flink.runtime.jobmaster.LogicalSlot in project flink by apache.
the class DefaultScheduler method assignResource.
private BiFunction<LogicalSlot, Throwable, LogicalSlot> assignResource(final DeploymentHandle deploymentHandle) {
final ExecutionVertexVersion requiredVertexVersion = deploymentHandle.getRequiredVertexVersion();
final ExecutionVertexID executionVertexId = deploymentHandle.getExecutionVertexId();
return (logicalSlot, throwable) -> {
if (executionVertexVersioner.isModified(requiredVertexVersion)) {
if (throwable == null) {
log.debug("Refusing to assign slot to execution vertex {} because this deployment was " + "superseded by another deployment", executionVertexId);
releaseSlotIfPresent(logicalSlot);
}
return null;
}
// a task which is about to cancel in #restartTasksWithDelay(...)
if (throwable != null) {
throw new CompletionException(maybeWrapWithNoResourceAvailableException(throwable));
}
final ExecutionVertex executionVertex = getExecutionVertex(executionVertexId);
executionVertex.tryAssignResource(logicalSlot);
startReserveAllocation(executionVertexId, logicalSlot.getAllocationId());
return logicalSlot;
};
}
use of org.apache.flink.runtime.jobmaster.LogicalSlot in project flink by apache.
the class SlotSharingExecutionSlotAllocator method allocateLogicalSlotsFromSharedSlots.
private static Map<ExecutionVertexID, SlotExecutionVertexAssignment> allocateLogicalSlotsFromSharedSlots(Map<ExecutionSlotSharingGroup, SharedSlot> slots, Map<ExecutionSlotSharingGroup, List<ExecutionVertexID>> executionsByGroup) {
Map<ExecutionVertexID, SlotExecutionVertexAssignment> assignments = new HashMap<>();
for (Map.Entry<ExecutionSlotSharingGroup, List<ExecutionVertexID>> entry : executionsByGroup.entrySet()) {
ExecutionSlotSharingGroup group = entry.getKey();
List<ExecutionVertexID> executionIds = entry.getValue();
for (ExecutionVertexID executionId : executionIds) {
CompletableFuture<LogicalSlot> logicalSlotFuture = slots.get(group).allocateLogicalSlot(executionId);
SlotExecutionVertexAssignment assignment = new SlotExecutionVertexAssignment(executionId, logicalSlotFuture);
assignments.put(executionId, assignment);
}
}
return assignments;
}
use of org.apache.flink.runtime.jobmaster.LogicalSlot in project flink by apache.
the class SingleLogicalSlotTest method testAllocatedSlotRelease.
/**
* Tests that the {@link PhysicalSlot.Payload#release(Throwable)} does not wait for the payload
* to reach a terminal state.
*/
@Test
public void testAllocatedSlotRelease() {
final CompletableFuture<LogicalSlot> returnSlotFuture = new CompletableFuture<>();
final WaitingSlotOwner waitingSlotOwner = new WaitingSlotOwner(returnSlotFuture, new CompletableFuture<>());
final SingleLogicalSlot singleLogicalSlot = createSingleLogicalSlot(waitingSlotOwner);
final CompletableFuture<?> terminalStateFuture = new CompletableFuture<>();
final CompletableFuture<?> failFuture = new CompletableFuture<>();
final ManualTestingPayload dummyPayload = new ManualTestingPayload(failFuture, terminalStateFuture);
assertThat(singleLogicalSlot.tryAssignPayload(dummyPayload), is(true));
singleLogicalSlot.release(new FlinkException("Test exception"));
assertThat(failFuture.isDone(), is(true));
// we don't require the logical slot to return to the owner because
// the release call should only come from the owner
assertThat(returnSlotFuture.isDone(), is(false));
}
use of org.apache.flink.runtime.jobmaster.LogicalSlot in project flink by apache.
the class DefaultSchedulerTest method restartVerticesOnAssignedSlotReleased.
@Test
public void restartVerticesOnAssignedSlotReleased() throws Exception {
testExecutionSlotAllocator.disableAutoCompletePendingRequests();
testRestartVerticesOnFailuresInScheduling(vid -> {
final LogicalSlot slot = testExecutionSlotAllocator.completePendingRequest(vid);
slot.releaseSlot(new Exception("Release slot for test"));
});
}
use of org.apache.flink.runtime.jobmaster.LogicalSlot in project flink by apache.
the class Execution method triggerCheckpointHelper.
private CompletableFuture<Acknowledge> triggerCheckpointHelper(long checkpointId, long timestamp, CheckpointOptions checkpointOptions) {
final LogicalSlot slot = assignedResource;
if (slot != null) {
final TaskManagerGateway taskManagerGateway = slot.getTaskManagerGateway();
return taskManagerGateway.triggerCheckpoint(attemptId, getVertex().getJobId(), checkpointId, timestamp, checkpointOptions);
}
LOG.debug("The execution has no slot assigned. This indicates that the execution is no longer running.");
return CompletableFuture.completedFuture(Acknowledge.get());
}
Aggregations