Search in sources :

Example 1 with DefaultScheduler

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

the class RemoveCachedShuffleDescriptorTest method createSchedulerAndDeploy.

private DefaultScheduler createSchedulerAndDeploy(JobID jobId, JobVertex v1, JobVertex v2, DistributionPattern distributionPattern, BlobWriter blobWriter) throws Exception {
    v2.connectNewDataSetAsInput(v1, distributionPattern, ResultPartitionType.BLOCKING);
    final List<JobVertex> ordered = new ArrayList<>(Arrays.asList(v1, v2));
    final DefaultScheduler scheduler = createScheduler(jobId, ordered, blobWriter, mainThreadExecutor, ioExecutor);
    final ExecutionGraph executionGraph = scheduler.getExecutionGraph();
    final TestingLogicalSlotBuilder slotBuilder = new TestingLogicalSlotBuilder();
    CompletableFuture.runAsync(() -> {
        try {
            // Deploy upstream source vertices
            deployTasks(executionGraph, v1.getID(), slotBuilder);
            // Transition upstream vertices into FINISHED
            transitionTasksToFinished(executionGraph, v1.getID());
            // Deploy downstream sink vertices
            deployTasks(executionGraph, v2.getID(), slotBuilder);
        } catch (Exception e) {
            throw new RuntimeException("Exceptions shouldn't happen here.", e);
        }
    }, mainThreadExecutor).join();
    return scheduler;
}
Also used : JobVertex(org.apache.flink.runtime.jobgraph.JobVertex) ArrayList(java.util.ArrayList) TestingLogicalSlotBuilder(org.apache.flink.runtime.jobmaster.TestingLogicalSlotBuilder) DefaultScheduler(org.apache.flink.runtime.scheduler.DefaultScheduler) TimeoutException(java.util.concurrent.TimeoutException) JobException(org.apache.flink.runtime.JobException) PartitionNotFoundException(org.apache.flink.runtime.io.network.partition.PartitionNotFoundException) ExecutionException(java.util.concurrent.ExecutionException)

Example 2 with DefaultScheduler

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

the class RemoveCachedShuffleDescriptorTest method testRemoveCacheForAllToAllEdgeAfterFinished.

private void testRemoveCacheForAllToAllEdgeAfterFinished(TestingBlobWriter blobWriter, int expectedBefore, int expectedAfter) throws Exception {
    final JobID jobId = new JobID();
    final JobVertex v1 = ExecutionGraphTestUtils.createNoOpVertex("v1", PARALLELISM);
    final JobVertex v2 = ExecutionGraphTestUtils.createNoOpVertex("v2", PARALLELISM);
    final DefaultScheduler scheduler = createSchedulerAndDeploy(jobId, v1, v2, DistributionPattern.ALL_TO_ALL, blobWriter);
    final ExecutionGraph executionGraph = scheduler.getExecutionGraph();
    // ShuffleDescriptors should be cached during the deployment
    final ShuffleDescriptor[] shuffleDescriptors = deserializeShuffleDescriptors(getConsumedCachedShuffleDescriptor(executionGraph, v2), jobId, blobWriter);
    assertEquals(PARALLELISM, shuffleDescriptors.length);
    assertEquals(expectedBefore, blobWriter.numberOfBlobs());
    // For the all-to-all edge, we transition all downstream tasks to finished
    CompletableFuture.runAsync(() -> transitionTasksToFinished(executionGraph, v2.getID()), mainThreadExecutor).join();
    ioExecutor.triggerAll();
    // Cache should be removed since partitions are released
    assertNull(getConsumedCachedShuffleDescriptor(executionGraph, v2));
    assertEquals(expectedAfter, blobWriter.numberOfBlobs());
}
Also used : JobVertex(org.apache.flink.runtime.jobgraph.JobVertex) ShuffleDescriptor(org.apache.flink.runtime.shuffle.ShuffleDescriptor) JobID(org.apache.flink.api.common.JobID) DefaultScheduler(org.apache.flink.runtime.scheduler.DefaultScheduler)

Example 3 with DefaultScheduler

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

the class SchedulerBenchmarkUtils method createAndInitExecutionGraph.

public static ExecutionGraph createAndInitExecutionGraph(List<JobVertex> jobVertices, JobConfiguration jobConfiguration, ScheduledExecutorService scheduledExecutorService) throws Exception {
    final JobGraph jobGraph = createJobGraph(jobVertices, jobConfiguration);
    final ComponentMainThreadExecutor mainThreadExecutor = ComponentMainThreadExecutorServiceAdapter.forMainThread();
    final DefaultScheduler scheduler = SchedulerTestingUtils.createSchedulerBuilder(jobGraph, mainThreadExecutor).setIoExecutor(scheduledExecutorService).setFutureExecutor(scheduledExecutorService).setDelayExecutor(new ScheduledExecutorServiceAdapter(scheduledExecutorService)).build();
    return scheduler.getExecutionGraph();
}
Also used : JobGraph(org.apache.flink.runtime.jobgraph.JobGraph) ComponentMainThreadExecutor(org.apache.flink.runtime.concurrent.ComponentMainThreadExecutor) ScheduledExecutorServiceAdapter(org.apache.flink.util.concurrent.ScheduledExecutorServiceAdapter) DefaultScheduler(org.apache.flink.runtime.scheduler.DefaultScheduler)

Example 4 with DefaultScheduler

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

the class OperatorCoordinatorSchedulerTest method testFailureToStartPropagatesExceptions.

@Test
public void testFailureToStartPropagatesExceptions() throws Exception {
    final OperatorCoordinator.Provider failingCoordinatorProvider = new TestingOperatorCoordinator.Provider(testOperatorId, CoordinatorThatFailsInStart::new);
    final DefaultScheduler scheduler = createScheduler(failingCoordinatorProvider);
    try {
        scheduler.startScheduling();
        fail("expected an exception");
    } catch (Exception ignored) {
    // expected
    }
}
Also used : DefaultScheduler(org.apache.flink.runtime.scheduler.DefaultScheduler) FlinkException(org.apache.flink.util.FlinkException) IOException(java.io.IOException) TtlTimeProvider(org.apache.flink.runtime.state.ttl.TtlTimeProvider) Test(org.junit.Test)

Example 5 with DefaultScheduler

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

the class OperatorCoordinatorSchedulerTest method testBatchGlobalFailureResetsToEmptyState.

// ------------------------------------------------------------------------
// tests for failover notifications in a batch setup (no checkpoints)
// ------------------------------------------------------------------------
@Test
public void testBatchGlobalFailureResetsToEmptyState() throws Exception {
    final DefaultScheduler scheduler = createSchedulerWithoutCheckpointingAndDeployTasks();
    final TestingOperatorCoordinator coordinator = getCoordinator(scheduler);
    failGlobalAndRestart(scheduler, new TestException());
    assertSame("coordinator should have null restored state", TestingOperatorCoordinator.NULL_RESTORE_VALUE, coordinator.getLastRestoredCheckpointState());
    assertEquals(OperatorCoordinator.NO_CHECKPOINT, coordinator.getLastRestoredCheckpointId());
}
Also used : DefaultScheduler(org.apache.flink.runtime.scheduler.DefaultScheduler) Test(org.junit.Test)

Aggregations

DefaultScheduler (org.apache.flink.runtime.scheduler.DefaultScheduler)45 Test (org.junit.Test)34 JobVertex (org.apache.flink.runtime.jobgraph.JobVertex)9 TtlTimeProvider (org.apache.flink.runtime.state.ttl.TtlTimeProvider)9 JobID (org.apache.flink.api.common.JobID)7 IOException (java.io.IOException)5 Random (java.util.Random)5 ComponentMainThreadExecutor (org.apache.flink.runtime.concurrent.ComponentMainThreadExecutor)5 JobGraph (org.apache.flink.runtime.jobgraph.JobGraph)5 OperatorID (org.apache.flink.runtime.jobgraph.OperatorID)5 Ignore (org.junit.Ignore)5 OperatorIDPair (org.apache.flink.runtime.OperatorIDPair)4 CompletedCheckpoint (org.apache.flink.runtime.checkpoint.CompletedCheckpoint)4 OperatorState (org.apache.flink.runtime.checkpoint.OperatorState)4 ComponentMainThreadExecutorServiceAdapter (org.apache.flink.runtime.concurrent.ComponentMainThreadExecutorServiceAdapter)4 ExecutionJobVertex (org.apache.flink.runtime.executiongraph.ExecutionJobVertex)4 RestartAllFailoverStrategy (org.apache.flink.runtime.executiongraph.failover.flip1.RestartAllFailoverStrategy)4 SchedulerTestingUtils (org.apache.flink.runtime.scheduler.SchedulerTestingUtils)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 Duration (java.time.Duration)3