use of org.apache.flink.runtime.executiongraph.Execution in project flink by apache.
the class InputChannelDeploymentDescriptorTest method mockExecutionVertex.
private static ExecutionVertex mockExecutionVertex(ExecutionState state, ResourceID resourceId) {
ExecutionVertex vertex = mock(ExecutionVertex.class);
Execution exec = mock(Execution.class);
when(exec.getState()).thenReturn(state);
when(exec.getAttemptId()).thenReturn(new ExecutionAttemptID());
if (resourceId != null) {
SimpleSlot slot = mockSlot(resourceId);
when(exec.getAssignedResource()).thenReturn(slot);
when(vertex.getCurrentAssignedResource()).thenReturn(slot);
} else {
// no resource
when(exec.getAssignedResource()).thenReturn(null);
when(vertex.getCurrentAssignedResource()).thenReturn(null);
}
when(vertex.getCurrentExecutionAttempt()).thenReturn(exec);
return vertex;
}
use of org.apache.flink.runtime.executiongraph.Execution in project flink by apache.
the class BackPressureStatsTrackerTest method mockExecutionVertex.
private ExecutionVertex mockExecutionVertex(ExecutionJobVertex jobVertex, int subTaskIndex) {
Execution exec = mock(Execution.class);
when(exec.getAttemptId()).thenReturn(new ExecutionAttemptID());
JobVertexID id = jobVertex.getJobVertexId();
ExecutionVertex vertex = mock(ExecutionVertex.class);
when(vertex.getJobvertexId()).thenReturn(id);
when(vertex.getCurrentExecutionAttempt()).thenReturn(exec);
when(vertex.getParallelSubtaskIndex()).thenReturn(subTaskIndex);
return vertex;
}
use of org.apache.flink.runtime.executiongraph.Execution in project flink by apache.
the class SchedulerTestUtils method getDummyTask.
public static Execution getDummyTask() {
ExecutionVertex vertex = mock(ExecutionVertex.class);
when(vertex.getJobId()).thenReturn(new JobID());
when(vertex.toString()).thenReturn("TEST-VERTEX");
Execution execution = mock(Execution.class);
when(execution.getVertex()).thenReturn(vertex);
return execution;
}
use of org.apache.flink.runtime.executiongraph.Execution in project flink by apache.
the class SchedulerTestUtils method getTestVertexWithLocation.
public static Execution getTestVertexWithLocation(JobVertexID jid, int taskIndex, int numTasks, TaskManagerLocation... locations) {
ExecutionVertex vertex = mock(ExecutionVertex.class);
when(vertex.getPreferredLocationsBasedOnInputs()).thenReturn(Arrays.asList(locations));
when(vertex.getJobId()).thenReturn(new JobID());
when(vertex.getJobvertexId()).thenReturn(jid);
when(vertex.getParallelSubtaskIndex()).thenReturn(taskIndex);
when(vertex.getTotalNumberOfParallelSubtasks()).thenReturn(numTasks);
when(vertex.getMaxParallelism()).thenReturn(numTasks);
when(vertex.toString()).thenReturn("TEST-VERTEX");
Execution execution = mock(Execution.class);
when(execution.getVertex()).thenReturn(vertex);
return execution;
}
use of org.apache.flink.runtime.executiongraph.Execution in project flink by apache.
the class CheckpointCoordinatorTest method testMinTimeBetweenCheckpointsInterval.
/**
* This test verified that after a completed checkpoint a certain time has passed before
* another is triggered.
*/
@Test
public void testMinTimeBetweenCheckpointsInterval() throws Exception {
final JobID jid = new JobID();
// create some mock execution vertices and trigger some checkpoint
final ExecutionAttemptID attemptID = new ExecutionAttemptID();
final ExecutionVertex vertex = mockExecutionVertex(attemptID);
final Execution executionAttempt = vertex.getCurrentExecutionAttempt();
final BlockingQueue<Long> triggerCalls = new LinkedBlockingQueue<>();
doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
triggerCalls.add((Long) invocation.getArguments()[0]);
return null;
}
}).when(executionAttempt).triggerCheckpoint(anyLong(), anyLong(), any(CheckpointOptions.class));
final long delay = 50;
final CheckpointCoordinator coord = new CheckpointCoordinator(jid, // periodic interval is 2 ms
2, // timeout is very long (200 s)
200_000, // 50 ms delay between checkpoints
delay, 1, ExternalizedCheckpointSettings.none(), new ExecutionVertex[] { vertex }, new ExecutionVertex[] { vertex }, new ExecutionVertex[] { vertex }, new StandaloneCheckpointIDCounter(), new StandaloneCompletedCheckpointStore(2), "dummy-path", Executors.directExecutor());
try {
coord.startCheckpointScheduler();
// wait until the first checkpoint was triggered
Long firstCallId = triggerCalls.take();
assertEquals(1L, firstCallId.longValue());
AcknowledgeCheckpoint ackMsg = new AcknowledgeCheckpoint(jid, attemptID, 1L);
// tell the coordinator that the checkpoint is done
final long ackTime = System.nanoTime();
coord.receiveAcknowledgeMessage(ackMsg);
// wait until the next checkpoint is triggered
Long nextCallId = triggerCalls.take();
final long nextCheckpointTime = System.nanoTime();
assertEquals(2L, nextCallId.longValue());
final long delayMillis = (nextCheckpointTime - ackTime) / 1_000_000;
// we need to add one ms here to account for rounding errors
if (delayMillis + 1 < delay) {
fail("checkpoint came too early: delay was " + delayMillis + " but should have been at least " + delay);
}
} finally {
coord.stopCheckpointScheduler();
coord.shutdown(JobStatus.FINISHED);
}
}
Aggregations