Search in sources :

Example 21 with DefaultScheduler

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

the class OperatorCoordinatorSchedulerTest method runningTaskCancellationNotifiesCoordinator.

@Ignore
@Test
public void runningTaskCancellationNotifiesCoordinator() throws Exception {
    final DefaultScheduler scheduler = createSchedulerAndDeployTasks();
    final TestingOperatorCoordinator coordinator = getCoordinator(scheduler);
    cancelTask(scheduler, 0);
    assertEquals(1, coordinator.getFailedTasks().size());
    assertThat(coordinator.getFailedTasks(), contains(0));
    assertThat(coordinator.getFailedTasks(), not(contains(1)));
}
Also used : DefaultScheduler(org.apache.flink.runtime.scheduler.DefaultScheduler) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 22 with DefaultScheduler

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

the class OperatorCoordinatorSchedulerTest method testCoordinatorDisposedWhenSchedulerStops.

@Test
public void testCoordinatorDisposedWhenSchedulerStops() throws Exception {
    final DefaultScheduler scheduler = createAndStartScheduler();
    final TestingOperatorCoordinator coordinator = getCoordinator(scheduler);
    closeScheduler(scheduler);
    assertTrue(coordinator.isClosed());
}
Also used : DefaultScheduler(org.apache.flink.runtime.scheduler.DefaultScheduler) Test(org.junit.Test)

Example 23 with DefaultScheduler

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

the class OperatorCoordinatorSchedulerTest method testBatchLocalFailoverResetsTask.

@Test
public void testBatchLocalFailoverResetsTask() throws Exception {
    final DefaultScheduler scheduler = createSchedulerWithoutCheckpointingAndDeployTasks();
    final TestingOperatorCoordinator coordinator = getCoordinator(scheduler);
    failAndRestartTask(scheduler, 1);
    assertEquals(1, coordinator.getRestoredTasks().size());
    final TestingOperatorCoordinator.SubtaskAndCheckpoint restoredTask = coordinator.getRestoredTasks().get(0);
    assertEquals(1, restoredTask.subtaskIndex);
    assertEquals(OperatorCoordinator.NO_CHECKPOINT, restoredTask.checkpointId);
}
Also used : DefaultScheduler(org.apache.flink.runtime.scheduler.DefaultScheduler) Test(org.junit.Test)

Example 24 with DefaultScheduler

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

the class OperatorCoordinatorSchedulerTest method testCoordinatorStartedWhenSchedulerStarts.

// ------------------------------------------------------------------------
// tests for scheduling
// ------------------------------------------------------------------------
@Test
public void testCoordinatorStartedWhenSchedulerStarts() throws Exception {
    final DefaultScheduler scheduler = createAndStartScheduler();
    final TestingOperatorCoordinator coordinator = getCoordinator(scheduler);
    assertTrue(coordinator.isStarted());
}
Also used : DefaultScheduler(org.apache.flink.runtime.scheduler.DefaultScheduler) Test(org.junit.Test)

Example 25 with DefaultScheduler

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

the class OperatorCoordinatorSchedulerTest method createSchedulerWithoutCheckpointingAndDeployTasks.

private DefaultScheduler createSchedulerWithoutCheckpointingAndDeployTasks() throws Exception {
    final Consumer<JobGraph> noCheckpoints = (jobGraph) -> jobGraph.setSnapshotSettings(null);
    final DefaultScheduler scheduler = setupTestJobAndScheduler(new TestingOperatorCoordinator.Provider(testOperatorId), null, noCheckpoints, false);
    // guard test assumptions: this must set up a scheduler without checkpoints
    assertNull(scheduler.getExecutionGraph().getCheckpointCoordinator());
    scheduleAllTasksToRunning(scheduler);
    return scheduler;
}
Also used : ComponentMainThreadExecutorServiceAdapter(org.apache.flink.runtime.concurrent.ComponentMainThreadExecutorServiceAdapter) CheckpointCoordinator(org.apache.flink.runtime.checkpoint.CheckpointCoordinator) OperatorState(org.apache.flink.runtime.checkpoint.OperatorState) JobGraph(org.apache.flink.runtime.jobgraph.JobGraph) Matchers.not(org.hamcrest.Matchers.not) ExceptionUtils(org.apache.flink.util.ExceptionUtils) Random(java.util.Random) DefaultScheduler(org.apache.flink.runtime.scheduler.DefaultScheduler) Assert.assertThat(org.junit.Assert.assertThat) StateBackend(org.apache.flink.runtime.state.StateBackend) CloseableRegistry(org.apache.flink.core.fs.CloseableRegistry) TestingCheckpointStorageAccessCoordinatorView(org.apache.flink.runtime.state.TestingCheckpointStorageAccessCoordinatorView) After(org.junit.After) Duration(java.time.Duration) TestLogger(org.apache.flink.util.TestLogger) OperatorStateBackend(org.apache.flink.runtime.state.OperatorStateBackend) Checkpoints(org.apache.flink.runtime.checkpoint.Checkpoints) Assert.fail(org.junit.Assert.fail) CompletedCheckpoint(org.apache.flink.runtime.checkpoint.CompletedCheckpoint) FlinkMatchers.futureFailedWith(org.apache.flink.core.testutils.FlinkMatchers.futureFailedWith) KeyGroupRange(org.apache.flink.runtime.state.KeyGroupRange) TypeSerializer(org.apache.flink.api.common.typeutils.TypeSerializer) KeyedStateHandle(org.apache.flink.runtime.state.KeyedStateHandle) Collection(java.util.Collection) ExecutionVertexID(org.apache.flink.runtime.scheduler.strategy.ExecutionVertexID) CommonTestUtils(org.apache.flink.core.testutils.CommonTestUtils) Acknowledge(org.apache.flink.runtime.messages.Acknowledge) CheckpointMetadata(org.apache.flink.runtime.checkpoint.metadata.CheckpointMetadata) Matchers.instanceOf(org.hamcrest.Matchers.instanceOf) MetricGroup(org.apache.flink.metrics.MetricGroup) TtlTimeProvider(org.apache.flink.runtime.state.ttl.TtlTimeProvider) SerializedValue(org.apache.flink.util.SerializedValue) Matchers.contains(org.hamcrest.Matchers.contains) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) OperatorID(org.apache.flink.runtime.jobgraph.OperatorID) Optional(java.util.Optional) RestartAllFailoverStrategy(org.apache.flink.runtime.executiongraph.failover.flip1.RestartAllFailoverStrategy) SchedulerTestingUtils(org.apache.flink.runtime.scheduler.SchedulerTestingUtils) Environment(org.apache.flink.runtime.execution.Environment) FlinkException(org.apache.flink.util.FlinkException) ComponentMainThreadExecutor(org.apache.flink.runtime.concurrent.ComponentMainThreadExecutor) JobVertex(org.apache.flink.runtime.jobgraph.JobVertex) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ManuallyTriggeredScheduledExecutorService(org.apache.flink.runtime.concurrent.ManuallyTriggeredScheduledExecutorService) CompletableFuture(java.util.concurrent.CompletableFuture) JobVertexID(org.apache.flink.runtime.jobgraph.JobVertexID) Assert.assertSame(org.junit.Assert.assertSame) FutureUtils(org.apache.flink.util.concurrent.FutureUtils) Assert.assertArrayEquals(org.junit.Assert.assertArrayEquals) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) FlinkMatchers.futureWillCompleteExceptionally(org.apache.flink.core.testutils.FlinkMatchers.futureWillCompleteExceptionally) OperatorStateHandle(org.apache.flink.runtime.state.OperatorStateHandle) TaskExecutorOperatorEventGateway(org.apache.flink.runtime.taskexecutor.TaskExecutorOperatorEventGateway) Nonnull(javax.annotation.Nonnull) CheckpointableKeyedStateBackend(org.apache.flink.runtime.state.CheckpointableKeyedStateBackend) Nullable(javax.annotation.Nullable) SchedulerTestingUtils.setExecutionToState(org.apache.flink.runtime.scheduler.SchedulerTestingUtils.setExecutionToState) ExecutionJobVertex(org.apache.flink.runtime.executiongraph.ExecutionJobVertex) TaskKvStateRegistry(org.apache.flink.runtime.query.TaskKvStateRegistry) Matchers.empty(org.hamcrest.Matchers.empty) JobGraphBuilder(org.apache.flink.runtime.jobgraph.JobGraphBuilder) Assert.assertNotNull(org.junit.Assert.assertNotNull) ExecutionState(org.apache.flink.runtime.execution.ExecutionState) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) IOException(java.io.IOException) OperatorIDPair(org.apache.flink.runtime.OperatorIDPair) StreamStateHandle(org.apache.flink.runtime.state.StreamStateHandle) Consumer(java.util.function.Consumer) ExecutionAttemptID(org.apache.flink.runtime.executiongraph.ExecutionAttemptID) JobID(org.apache.flink.api.common.JobID) Assert.assertNull(org.junit.Assert.assertNull) Ignore(org.junit.Ignore) Matcher(org.hamcrest.Matcher) ByteStreamStateHandle(org.apache.flink.runtime.state.memory.ByteStreamStateHandle) SavepointRestoreSettings(org.apache.flink.runtime.jobgraph.SavepointRestoreSettings) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) NoOpInvokable(org.apache.flink.runtime.testtasks.NoOpInvokable) JobGraph(org.apache.flink.runtime.jobgraph.JobGraph) 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