use of org.apache.flink.runtime.jobmaster.TestingLogicalSlotBuilder in project flink by apache.
the class ExecutionVertexCancelTest method testCancelFromRunning.
@Test
public void testCancelFromRunning() {
try {
final ExecutionVertex vertex = getExecutionVertex();
LogicalSlot slot = new TestingLogicalSlotBuilder().setTaskManagerGateway(new CancelSequenceSimpleAckingTaskManagerGateway(1)).createTestingLogicalSlot();
setVertexResource(vertex, slot);
setVertexState(vertex, ExecutionState.RUNNING);
assertEquals(ExecutionState.RUNNING, vertex.getExecutionState());
vertex.cancel();
vertex.getCurrentExecutionAttempt().completeCancelling();
assertEquals(ExecutionState.CANCELED, vertex.getExecutionState());
assertFalse(slot.isAlive());
assertFalse(vertex.getFailureInfo().isPresent());
assertTrue(vertex.getStateTimestamp(ExecutionState.CREATED) > 0);
assertTrue(vertex.getStateTimestamp(ExecutionState.CANCELING) > 0);
assertTrue(vertex.getStateTimestamp(ExecutionState.CANCELED) > 0);
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.apache.flink.runtime.jobmaster.TestingLogicalSlotBuilder in project flink by apache.
the class DefaultSchedulerTest method testExceptionHistoryWithRestartableFailure.
@Test
public void testExceptionHistoryWithRestartableFailure() {
final JobGraph jobGraph = singleNonParallelJobVertexJobGraph();
final TaskManagerLocation taskManagerLocation = new LocalTaskManagerLocation();
final TestingLogicalSlotBuilder logicalSlotBuilder = new TestingLogicalSlotBuilder();
logicalSlotBuilder.setTaskManagerLocation(taskManagerLocation);
executionSlotAllocatorFactory = new TestExecutionSlotAllocatorFactory(logicalSlotBuilder);
final DefaultScheduler scheduler = createSchedulerAndStartScheduling(jobGraph);
// initiate restartable failure
final ArchivedExecutionVertex taskFailureExecutionVertex = Iterables.getOnlyElement(scheduler.requestJob().getArchivedExecutionGraph().getAllExecutionVertices());
final RuntimeException restartableException = new RuntimeException("restartable exception");
final long updateStateTriggeringRestartTimestamp = initiateFailure(scheduler, taskFailureExecutionVertex.getCurrentExecutionAttempt().getAttemptId(), restartableException);
taskRestartExecutor.triggerNonPeriodicScheduledTask();
// initiate job failure
testRestartBackoffTimeStrategy.setCanRestart(false);
final ExecutionAttemptID failingAttemptId = Iterables.getOnlyElement(scheduler.requestJob().getArchivedExecutionGraph().getAllExecutionVertices()).getCurrentExecutionAttempt().getAttemptId();
final RuntimeException failingException = new RuntimeException("failing exception");
final long updateStateTriggeringJobFailureTimestamp = initiateFailure(scheduler, failingAttemptId, failingException);
final Iterable<RootExceptionHistoryEntry> actualExceptionHistory = scheduler.getExceptionHistory();
// assert restarted attempt
assertThat(actualExceptionHistory, IsIterableContainingInOrder.contains(ExceptionHistoryEntryMatcher.matchesFailure(restartableException, updateStateTriggeringRestartTimestamp, taskFailureExecutionVertex.getTaskNameWithSubtaskIndex(), taskFailureExecutionVertex.getCurrentAssignedResourceLocation()), ExceptionHistoryEntryMatcher.matchesGlobalFailure(failingException, updateStateTriggeringJobFailureTimestamp)));
}
use of org.apache.flink.runtime.jobmaster.TestingLogicalSlotBuilder in project flink by apache.
the class FailureHandlingResultSnapshotTest method extractExecutionVertex.
private ExecutionVertex extractExecutionVertex(int pos) {
final ExecutionVertex executionVertex = Iterables.get(executionGraph.getAllExecutionVertices(), pos);
executionVertex.tryAssignResource(new TestingLogicalSlotBuilder().createTestingLogicalSlot());
return executionVertex;
}
use of org.apache.flink.runtime.jobmaster.TestingLogicalSlotBuilder 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.TestingLogicalSlotBuilder in project flink by apache.
the class PartitionReleaseInBatchJobBenchmark method setup.
public void setup(JobConfiguration jobConfiguration) throws Exception {
super.setup();
final List<JobVertex> jobVertices = createDefaultJobVertices(jobConfiguration);
executionGraph = createAndInitExecutionGraph(jobVertices, jobConfiguration, scheduledExecutorService);
final JobVertex source = jobVertices.get(0);
sink = jobVertices.get(1);
final TestingLogicalSlotBuilder slotBuilder = new TestingLogicalSlotBuilder();
deployTasks(executionGraph, source.getID(), slotBuilder, true);
transitionTaskStatus(executionGraph, source.getID(), ExecutionState.FINISHED);
deployTasks(executionGraph, sink.getID(), slotBuilder, true);
}
Aggregations