Search in sources :

Example 51 with SchedulerBase

use of org.apache.flink.runtime.scheduler.SchedulerBase in project flink by apache.

the class DefaultExecutionGraphDeploymentTest method testRegistrationOfExecutionsFinishing.

@Test
public void testRegistrationOfExecutionsFinishing() {
    try {
        final JobVertexID jid1 = new JobVertexID();
        final JobVertexID jid2 = new JobVertexID();
        JobVertex v1 = new JobVertex("v1", jid1);
        JobVertex v2 = new JobVertex("v2", jid2);
        SchedulerBase scheduler = setupScheduler(v1, 7650, v2, 2350);
        Collection<Execution> executions = new ArrayList<>(scheduler.getExecutionGraph().getRegisteredExecutions().values());
        for (Execution e : executions) {
            e.markFinished();
        }
        assertEquals(0, scheduler.getExecutionGraph().getRegisteredExecutions().size());
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : JobVertex(org.apache.flink.runtime.jobgraph.JobVertex) JobVertexID(org.apache.flink.runtime.jobgraph.JobVertexID) ArrayList(java.util.ArrayList) SchedulerBase(org.apache.flink.runtime.scheduler.SchedulerBase) Test(org.junit.Test)

Example 52 with SchedulerBase

use of org.apache.flink.runtime.scheduler.SchedulerBase in project flink by apache.

the class DefaultExecutionGraphDeploymentTest method testAccumulatorsAndMetricsStorage.

/**
 * Verifies that {@link Execution#completeCancelling(Map, IOMetrics, boolean)} and {@link
 * Execution#markFailed(Throwable, boolean, Map, IOMetrics, boolean, boolean)} store the given
 * accumulators and metrics correctly.
 */
@Test
public void testAccumulatorsAndMetricsStorage() throws Exception {
    final JobVertexID jid1 = new JobVertexID();
    final JobVertexID jid2 = new JobVertexID();
    JobVertex v1 = new JobVertex("v1", jid1);
    JobVertex v2 = new JobVertex("v2", jid2);
    SchedulerBase scheduler = setupScheduler(v1, 1, v2, 1);
    Map<ExecutionAttemptID, Execution> executions = scheduler.getExecutionGraph().getRegisteredExecutions();
    IOMetrics ioMetrics = new IOMetrics(0, 0, 0, 0);
    Map<String, Accumulator<?, ?>> accumulators = Collections.emptyMap();
    Execution execution1 = executions.values().iterator().next();
    execution1.cancel();
    execution1.completeCancelling(accumulators, ioMetrics, false);
    assertEquals(ioMetrics, execution1.getIOMetrics());
    assertEquals(accumulators, execution1.getUserAccumulators());
    Execution execution2 = executions.values().iterator().next();
    execution2.markFailed(new Throwable(), false, accumulators, ioMetrics, false, true);
    assertEquals(ioMetrics, execution2.getIOMetrics());
    assertEquals(accumulators, execution2.getUserAccumulators());
}
Also used : Accumulator(org.apache.flink.api.common.accumulators.Accumulator) JobVertex(org.apache.flink.runtime.jobgraph.JobVertex) JobVertexID(org.apache.flink.runtime.jobgraph.JobVertexID) SchedulerBase(org.apache.flink.runtime.scheduler.SchedulerBase) Test(org.junit.Test)

Example 53 with SchedulerBase

use of org.apache.flink.runtime.scheduler.SchedulerBase in project flink by apache.

the class DefaultExecutionGraphDeploymentTest method testAccumulatorsAndMetricsForwarding.

/**
 * Verifies that {@link SchedulerNG#updateTaskExecutionState(TaskExecutionState)} updates the
 * accumulators and metrics for an execution that failed or was canceled.
 */
@Test
public void testAccumulatorsAndMetricsForwarding() throws Exception {
    final JobVertexID jid1 = new JobVertexID();
    final JobVertexID jid2 = new JobVertexID();
    JobVertex v1 = new JobVertex("v1", jid1);
    JobVertex v2 = new JobVertex("v2", jid2);
    SchedulerBase scheduler = setupScheduler(v1, 1, v2, 1);
    ExecutionGraph graph = scheduler.getExecutionGraph();
    Map<ExecutionAttemptID, Execution> executions = graph.getRegisteredExecutions();
    // verify behavior for canceled executions
    Execution execution1 = executions.values().iterator().next();
    IOMetrics ioMetrics = new IOMetrics(0, 0, 0, 0);
    Map<String, Accumulator<?, ?>> accumulators = new HashMap<>();
    accumulators.put("acc", new IntCounter(4));
    AccumulatorSnapshot accumulatorSnapshot = new AccumulatorSnapshot(graph.getJobID(), execution1.getAttemptId(), accumulators);
    TaskExecutionState state = new TaskExecutionState(execution1.getAttemptId(), ExecutionState.CANCELED, null, accumulatorSnapshot, ioMetrics);
    scheduler.updateTaskExecutionState(state);
    assertEquals(ioMetrics, execution1.getIOMetrics());
    assertNotNull(execution1.getUserAccumulators());
    assertEquals(4, execution1.getUserAccumulators().get("acc").getLocalValue());
    // verify behavior for failed executions
    Execution execution2 = executions.values().iterator().next();
    IOMetrics ioMetrics2 = new IOMetrics(0, 0, 0, 0);
    Map<String, Accumulator<?, ?>> accumulators2 = new HashMap<>();
    accumulators2.put("acc", new IntCounter(8));
    AccumulatorSnapshot accumulatorSnapshot2 = new AccumulatorSnapshot(graph.getJobID(), execution2.getAttemptId(), accumulators2);
    TaskExecutionState state2 = new TaskExecutionState(execution2.getAttemptId(), ExecutionState.FAILED, null, accumulatorSnapshot2, ioMetrics2);
    scheduler.updateTaskExecutionState(state2);
    assertEquals(ioMetrics2, execution2.getIOMetrics());
    assertNotNull(execution2.getUserAccumulators());
    assertEquals(8, execution2.getUserAccumulators().get("acc").getLocalValue());
}
Also used : Accumulator(org.apache.flink.api.common.accumulators.Accumulator) HashMap(java.util.HashMap) JobVertexID(org.apache.flink.runtime.jobgraph.JobVertexID) TaskExecutionState(org.apache.flink.runtime.taskmanager.TaskExecutionState) JobVertex(org.apache.flink.runtime.jobgraph.JobVertex) SchedulerBase(org.apache.flink.runtime.scheduler.SchedulerBase) AccumulatorSnapshot(org.apache.flink.runtime.accumulators.AccumulatorSnapshot) IntCounter(org.apache.flink.api.common.accumulators.IntCounter) Test(org.junit.Test)

Example 54 with SchedulerBase

use of org.apache.flink.runtime.scheduler.SchedulerBase in project flink by apache.

the class AdaptiveSchedulerTest method testComputeVertexParallelismStoreForExecutionInReactiveMode.

@Test
public void testComputeVertexParallelismStoreForExecutionInReactiveMode() {
    JobVertex v1 = createNoOpVertex("v1", 1, 50);
    JobVertex v2 = createNoOpVertex("v2", 50, 50);
    JobGraph graph = streamingJobGraph(v1, v2);
    VertexParallelismStore parallelismStore = AdaptiveScheduler.computeVertexParallelismStoreForExecution(graph, SchedulerExecutionMode.REACTIVE, SchedulerBase::getDefaultMaxParallelism);
    for (JobVertex vertex : graph.getVertices()) {
        VertexParallelismInformation info = parallelismStore.getParallelismInfo(vertex.getID());
        assertThat(info.getParallelism()).isEqualTo(vertex.getParallelism());
        assertThat(info.getMaxParallelism()).isEqualTo(vertex.getMaxParallelism());
    }
}
Also used : VertexParallelismInformation(org.apache.flink.runtime.scheduler.VertexParallelismInformation) JobGraph(org.apache.flink.runtime.jobgraph.JobGraph) JobGraphTestUtils.streamingJobGraph(org.apache.flink.runtime.jobgraph.JobGraphTestUtils.streamingJobGraph) ArchivedExecutionJobVertex(org.apache.flink.runtime.executiongraph.ArchivedExecutionJobVertex) JobVertex(org.apache.flink.runtime.jobgraph.JobVertex) VertexParallelismStore(org.apache.flink.runtime.scheduler.VertexParallelismStore) SchedulerBase(org.apache.flink.runtime.scheduler.SchedulerBase) Test(org.junit.Test) ArchivedExecutionGraphTest(org.apache.flink.runtime.executiongraph.ArchivedExecutionGraphTest) DefaultSchedulerTest(org.apache.flink.runtime.scheduler.DefaultSchedulerTest)

Example 55 with SchedulerBase

use of org.apache.flink.runtime.scheduler.SchedulerBase in project flink by apache.

the class AdaptiveSchedulerTest method testComputeVertexParallelismStoreForExecutionInDefaultMode.

@Test
public void testComputeVertexParallelismStoreForExecutionInDefaultMode() {
    JobVertex v1 = createNoOpVertex("v1", 1, 50);
    JobVertex v2 = createNoOpVertex("v2", 50, 50);
    JobGraph graph = streamingJobGraph(v1, v2);
    VertexParallelismStore parallelismStore = AdaptiveScheduler.computeVertexParallelismStoreForExecution(graph, null, SchedulerBase::getDefaultMaxParallelism);
    for (JobVertex vertex : graph.getVertices()) {
        VertexParallelismInformation info = parallelismStore.getParallelismInfo(vertex.getID());
        assertThat(info.getParallelism()).isEqualTo(vertex.getParallelism());
        assertThat(info.getMaxParallelism()).isEqualTo(vertex.getMaxParallelism());
    }
}
Also used : VertexParallelismInformation(org.apache.flink.runtime.scheduler.VertexParallelismInformation) JobGraph(org.apache.flink.runtime.jobgraph.JobGraph) JobGraphTestUtils.streamingJobGraph(org.apache.flink.runtime.jobgraph.JobGraphTestUtils.streamingJobGraph) ArchivedExecutionJobVertex(org.apache.flink.runtime.executiongraph.ArchivedExecutionJobVertex) JobVertex(org.apache.flink.runtime.jobgraph.JobVertex) VertexParallelismStore(org.apache.flink.runtime.scheduler.VertexParallelismStore) SchedulerBase(org.apache.flink.runtime.scheduler.SchedulerBase) Test(org.junit.Test) ArchivedExecutionGraphTest(org.apache.flink.runtime.executiongraph.ArchivedExecutionGraphTest) DefaultSchedulerTest(org.apache.flink.runtime.scheduler.DefaultSchedulerTest)

Aggregations

SchedulerBase (org.apache.flink.runtime.scheduler.SchedulerBase)56 Test (org.junit.Test)49 JobVertex (org.apache.flink.runtime.jobgraph.JobVertex)33 JobGraph (org.apache.flink.runtime.jobgraph.JobGraph)19 JobVertexID (org.apache.flink.runtime.jobgraph.JobVertexID)10 CompletableFuture (java.util.concurrent.CompletableFuture)8 IOException (java.io.IOException)7 TestingPhysicalSlotProvider (org.apache.flink.runtime.scheduler.TestingPhysicalSlotProvider)7 TestRestartBackoffTimeStrategy (org.apache.flink.runtime.executiongraph.failover.flip1.TestRestartBackoffTimeStrategy)6 TaskExecutionState (org.apache.flink.runtime.taskmanager.TaskExecutionState)6 ArrayList (java.util.ArrayList)5 JobStatus (org.apache.flink.api.common.JobStatus)5 IntermediateResultPartitionID (org.apache.flink.runtime.jobgraph.IntermediateResultPartitionID)5 ExecutionGraph (org.apache.flink.runtime.executiongraph.ExecutionGraph)4 ResultPartitionID (org.apache.flink.runtime.io.network.partition.ResultPartitionID)4 SlotPool (org.apache.flink.runtime.jobmaster.slotpool.SlotPool)4 TestingPhysicalSlot (org.apache.flink.runtime.scheduler.TestingPhysicalSlot)4 VertexParallelismInformation (org.apache.flink.runtime.scheduler.VertexParallelismInformation)4 VertexParallelismStore (org.apache.flink.runtime.scheduler.VertexParallelismStore)4 TaskManagerLocation (org.apache.flink.runtime.taskmanager.TaskManagerLocation)4