use of org.apache.flink.runtime.jobmaster.LogicalSlot in project flink by apache.
the class Execution method getNextInputSplit.
public InputSplit getNextInputSplit() {
final LogicalSlot slot = this.getAssignedResource();
final String host = slot != null ? slot.getTaskManagerLocation().getHostname() : null;
return this.vertex.getNextInputSplit(host);
}
use of org.apache.flink.runtime.jobmaster.LogicalSlot in project flink by apache.
the class CheckpointCoordinatorTest method testReportLatestCompletedCheckpointIdWithAbort.
@Test
public void testReportLatestCompletedCheckpointIdWithAbort() throws Exception {
JobVertexID jobVertexID = new JobVertexID();
ExecutionGraph graph = new CheckpointCoordinatorTestingUtils.CheckpointExecutionGraphBuilder().addJobVertex(jobVertexID).setTransitToRunning(false).build();
ExecutionVertex task = graph.getJobVertex(jobVertexID).getTaskVertices()[0];
AtomicLong reportedCheckpointId = new AtomicLong(-1);
LogicalSlot slot = new TestingLogicalSlotBuilder().setTaskManagerGateway(new SimpleAckingTaskManagerGateway() {
@Override
public void notifyCheckpointAborted(ExecutionAttemptID executionAttemptID, JobID jobId, long checkpointId, long latestCompletedCheckpointId, long timestamp) {
reportedCheckpointId.set(latestCompletedCheckpointId);
}
}).createTestingLogicalSlot();
ExecutionGraphTestUtils.setVertexResource(task, slot);
task.getCurrentExecutionAttempt().transitionState(ExecutionState.RUNNING);
CheckpointCoordinator checkpointCoordinator = new CheckpointCoordinatorBuilder().setExecutionGraph(graph).setTimer(manuallyTriggeredScheduledExecutor).setAllowCheckpointsAfterTasksFinished(true).build();
// Trigger a successful checkpoint
CompletableFuture<CompletedCheckpoint> result = checkpointCoordinator.triggerCheckpoint(false);
manuallyTriggeredScheduledExecutor.triggerAll();
long completedCheckpointId = checkpointCoordinator.getPendingCheckpoints().entrySet().iterator().next().getKey();
checkpointCoordinator.receiveAcknowledgeMessage(new AcknowledgeCheckpoint(graph.getJobID(), task.getCurrentExecutionAttempt().getAttemptId(), completedCheckpointId, new CheckpointMetrics(), new TaskStateSnapshot()), "localhost");
assertTrue(result.isDone());
assertFalse(result.isCompletedExceptionally());
result = checkpointCoordinator.triggerCheckpoint(false);
manuallyTriggeredScheduledExecutor.triggerAll();
long abortedCheckpointId = checkpointCoordinator.getPendingCheckpoints().entrySet().iterator().next().getKey();
checkpointCoordinator.receiveDeclineMessage(new DeclineCheckpoint(graph.getJobID(), task.getCurrentExecutionAttempt().getAttemptId(), abortedCheckpointId, new CheckpointException(CHECKPOINT_EXPIRED)), "localhost");
assertTrue(result.isCompletedExceptionally());
assertEquals(completedCheckpointId, reportedCheckpointId.get());
}
use of org.apache.flink.runtime.jobmaster.LogicalSlot in project flink by apache.
the class SharedSlotTest method testCannotAllocateLogicalSlotDuringRelease.
@Test(expected = IllegalStateException.class)
public void testCannotAllocateLogicalSlotDuringRelease() {
final TestingPhysicalSlot physicalSlot = TestingPhysicalSlot.builder().build();
final SharedSlot sharedSlot = new SharedSlot(new SlotRequestId(), physicalSlot, false, () -> {
});
final LogicalSlot logicalSlot = sharedSlot.allocateLogicalSlot();
logicalSlot.tryAssignPayload(new TestLogicalSlotPayload(ignored -> sharedSlot.allocateLogicalSlot()));
sharedSlot.release(new Exception("test"));
}
use of org.apache.flink.runtime.jobmaster.LogicalSlot in project flink by apache.
the class SharedSlotTest method testAllocateLogicalSlot.
@Test
public void testAllocateLogicalSlot() {
final TestingPhysicalSlot physicalSlot = TestingPhysicalSlot.builder().build();
final SharedSlot sharedSlot = new SharedSlot(new SlotRequestId(), physicalSlot, false, () -> {
});
final LogicalSlot logicalSlot = sharedSlot.allocateLogicalSlot();
assertThat(logicalSlot.getAllocationId(), equalTo(physicalSlot.getAllocationId()));
assertThat(logicalSlot.getLocality(), is(Locality.UNKNOWN));
assertThat(logicalSlot.getPayload(), nullValue());
assertThat(logicalSlot.getTaskManagerLocation(), equalTo(physicalSlot.getTaskManagerLocation()));
assertThat(logicalSlot.getTaskManagerGateway(), equalTo(physicalSlot.getTaskManagerGateway()));
}
use of org.apache.flink.runtime.jobmaster.LogicalSlot in project flink by apache.
the class SharedSlotTest method testReturnLogicalSlotTriggersExternalReleaseOnLastSlot.
@Test
public void testReturnLogicalSlotTriggersExternalReleaseOnLastSlot() {
final TestingPhysicalSlot physicalSlot = TestingPhysicalSlot.builder().build();
final AtomicBoolean externalReleaseInitiated = new AtomicBoolean(false);
final SharedSlot sharedSlot = new SharedSlot(new SlotRequestId(), physicalSlot, false, () -> externalReleaseInitiated.set(true));
final LogicalSlot logicalSlot1 = sharedSlot.allocateLogicalSlot();
final LogicalSlot logicalSlot2 = sharedSlot.allocateLogicalSlot();
// this implicitly returns the slot
logicalSlot1.releaseSlot(new Exception("test"));
assertThat(externalReleaseInitiated.get(), is(false));
logicalSlot2.releaseSlot(new Exception("test"));
assertThat(externalReleaseInitiated.get(), is(true));
}
Aggregations