Search in sources :

Example 16 with DefaultScheduler

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

the class OperatorCoordinatorSchedulerTest method testFailureToStartClosesCoordinator.

@Test
public void testFailureToStartClosesCoordinator() throws Exception {
    final OperatorCoordinator.Provider failingCoordinatorProvider = new TestingOperatorCoordinator.Provider(testOperatorId, CoordinatorThatFailsInStart::new);
    final DefaultScheduler scheduler = createScheduler(failingCoordinatorProvider);
    final TestingOperatorCoordinator coordinator = getCoordinator(scheduler);
    try {
        scheduler.startScheduling();
    } catch (Exception ignored) {
    }
    assertTrue(coordinator.isClosed());
}
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 17 with DefaultScheduler

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

the class OperatorCoordinatorSchedulerTest method testLocalFailoverDoesNotResetToCheckpoint.

@Test
public void testLocalFailoverDoesNotResetToCheckpoint() throws Exception {
    final DefaultScheduler scheduler = createSchedulerAndDeployTasks();
    final TestingOperatorCoordinator coordinator = getCoordinator(scheduler);
    takeCompleteCheckpoint(scheduler, coordinator, new byte[] { 37, 11, 83, 4 });
    failAndRestartTask(scheduler, 0);
    assertNull("coordinator should not have a restored checkpoint", coordinator.getLastRestoredCheckpointState());
}
Also used : DefaultScheduler(org.apache.flink.runtime.scheduler.DefaultScheduler) Test(org.junit.Test)

Example 18 with DefaultScheduler

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

the class RemoveCachedShuffleDescriptorTest method testRemoveCacheForPointwiseEdgeAfterFailover.

private void testRemoveCacheForPointwiseEdgeAfterFailover(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.POINTWISE, blobWriter);
    final ExecutionGraph executionGraph = scheduler.getExecutionGraph();
    // ShuffleDescriptors should be cached during the deployment
    final ShuffleDescriptor[] shuffleDescriptors = deserializeShuffleDescriptors(getConsumedCachedShuffleDescriptor(executionGraph, v2), jobId, blobWriter);
    assertEquals(1, shuffleDescriptors.length);
    assertEquals(expectedBefore, blobWriter.numberOfBlobs());
    triggerExceptionAndComplete(executionGraph, v1, v2);
    ioExecutor.triggerAll();
    // The cache of the first upstream task should be removed during
    // ExecutionVertex#resetForNewExecution
    assertNull(getConsumedCachedShuffleDescriptor(executionGraph, v2, 0));
    // The cache of the other upstream tasks should stay
    final ShuffleDescriptor[] shuffleDescriptorsForOtherVertex = deserializeShuffleDescriptors(getConsumedCachedShuffleDescriptor(executionGraph, v2, 1), jobId, blobWriter);
    assertEquals(1, shuffleDescriptorsForOtherVertex.length);
    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 19 with DefaultScheduler

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

the class RemoveCachedShuffleDescriptorTest method testRemoveCacheForPointwiseEdgeAfterFinished.

private void testRemoveCacheForPointwiseEdgeAfterFinished(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.POINTWISE, blobWriter);
    final ExecutionGraph executionGraph = scheduler.getExecutionGraph();
    // ShuffleDescriptors should be cached during the deployment
    final ShuffleDescriptor[] shuffleDescriptors = deserializeShuffleDescriptors(getConsumedCachedShuffleDescriptor(executionGraph, v2), jobId, blobWriter);
    assertEquals(1, shuffleDescriptors.length);
    assertEquals(expectedBefore, blobWriter.numberOfBlobs());
    // For the pointwise edge, we just transition the first downstream task to FINISHED
    ExecutionVertex ev21 = Objects.requireNonNull(executionGraph.getJobVertex(v2.getID())).getTaskVertices()[0];
    CompletableFuture.runAsync(() -> transitionTaskToFinished(executionGraph, ev21), mainThreadExecutor).join();
    ioExecutor.triggerAll();
    // The cache of the first upstream task should be removed since its partition is released
    assertNull(getConsumedCachedShuffleDescriptor(executionGraph, v2, 0));
    // The cache of the other upstream tasks should stay
    final ShuffleDescriptor[] shuffleDescriptorsForOtherVertex = deserializeShuffleDescriptors(getConsumedCachedShuffleDescriptor(executionGraph, v2, 1), jobId, blobWriter);
    assertEquals(1, shuffleDescriptorsForOtherVertex.length);
    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 20 with DefaultScheduler

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

the class RemoveCachedShuffleDescriptorTest method testRemoveCacheForAllToAllEdgeAfterFailover.

private void testRemoveCacheForAllToAllEdgeAfterFailover(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());
    triggerGlobalFailoverAndComplete(scheduler, v1);
    ioExecutor.triggerAll();
    // Cache should be removed during ExecutionVertex#resetForNewExecution
    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)

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