Search in sources :

Example 26 with DefaultScheduler

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

the class OperatorCoordinatorSchedulerTest method testTakeCheckpoint.

// ------------------------------------------------------------------------
// tests for checkpointing
// ------------------------------------------------------------------------
@Test
public void testTakeCheckpoint() throws Exception {
    final byte[] checkpointData = new byte[656];
    new Random().nextBytes(checkpointData);
    final DefaultScheduler scheduler = createSchedulerAndDeployTasks();
    final TestingOperatorCoordinator coordinator = getCoordinator(scheduler);
    final CompletableFuture<CompletedCheckpoint> checkpointFuture = triggerCheckpoint(scheduler);
    coordinator.getLastTriggeredCheckpoint().complete(checkpointData);
    acknowledgeCurrentCheckpoint(scheduler);
    final OperatorState state = checkpointFuture.get().getOperatorStates().get(testOperatorId);
    assertArrayEquals(checkpointData, getStateHandleContents(state.getCoordinatorState()));
}
Also used : CompletedCheckpoint(org.apache.flink.runtime.checkpoint.CompletedCheckpoint) Random(java.util.Random) OperatorState(org.apache.flink.runtime.checkpoint.OperatorState) DefaultScheduler(org.apache.flink.runtime.scheduler.DefaultScheduler) Test(org.junit.Test)

Example 27 with DefaultScheduler

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

the class OperatorCoordinatorSchedulerTest method taskTaskManagerFailuresAreReportedBack.

@Test
public void taskTaskManagerFailuresAreReportedBack() throws Exception {
    final DefaultScheduler scheduler = createSchedulerAndDeployTasks(new FailingTaskExecutorOperatorEventGateway());
    final TestingOperatorCoordinator coordinator = getCoordinator(scheduler);
    final OperatorCoordinator.SubtaskGateway gateway = coordinator.getSubtaskGateway(0);
    final CompletableFuture<?> result = gateway.sendEvent(new TestOperatorEvent());
    // process event sending
    executor.triggerAll();
    assertThat(result, futureFailedWith(TestException.class));
}
Also used : DefaultScheduler(org.apache.flink.runtime.scheduler.DefaultScheduler) Test(org.junit.Test)

Example 28 with DefaultScheduler

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

the class OperatorCoordinatorSchedulerTest method taskGatewayNotSetBeforeTasksRunning.

@Test
public void taskGatewayNotSetBeforeTasksRunning() throws Exception {
    final DefaultScheduler scheduler = createAndStartScheduler();
    final TestingOperatorCoordinator coordinator = getCoordinator(scheduler);
    final OperatorCoordinator.SubtaskGateway gateway = coordinator.getSubtaskGateway(0);
    assertNull(gateway);
}
Also used : DefaultScheduler(org.apache.flink.runtime.scheduler.DefaultScheduler) Test(org.junit.Test)

Example 29 with DefaultScheduler

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

the class OperatorCoordinatorSchedulerTest method createSchedulerWithRestoredSavepoint.

private DefaultScheduler createSchedulerWithRestoredSavepoint(byte[] coordinatorState) throws Exception {
    final byte[] savepointMetadata = serializeAsCheckpointMetadata(testOperatorId, coordinatorState);
    final String savepointPointer = "testingSavepointPointer";
    final TestingCheckpointStorageAccessCoordinatorView storage = new TestingCheckpointStorageAccessCoordinatorView();
    storage.registerSavepoint(savepointPointer, savepointMetadata);
    final Consumer<JobGraph> savepointConfigurer = (jobGraph) -> {
        SchedulerTestingUtils.enableCheckpointing(jobGraph, new ModernStateBackend(), storage.asCheckpointStorage());
        jobGraph.setSavepointRestoreSettings(SavepointRestoreSettings.forPath(savepointPointer));
    };
    final DefaultScheduler scheduler = setupTestJobAndScheduler(new TestingOperatorCoordinator.Provider(testOperatorId), null, savepointConfigurer, false);
    scheduler.startScheduling();
    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) TestingCheckpointStorageAccessCoordinatorView(org.apache.flink.runtime.state.TestingCheckpointStorageAccessCoordinatorView) DefaultScheduler(org.apache.flink.runtime.scheduler.DefaultScheduler)

Example 30 with DefaultScheduler

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

the class OperatorCoordinatorSchedulerTest method deployingTaskCancellationNotifiesCoordinator.

// THESE TESTS BELOW SHOULD LEGITIMATELY WORK, BUT THE SCHEDULER ITSELF SEEMS TO NOT HANDLE
// THIS SITUATION AT THE MOMENT
// WE KEEP THESE TESTS HERE TO ENABLE THEM ONCE THE SCHEDULER'S CONTRACT SUPPORTS THEM
@Ignore
@Test
public void deployingTaskCancellationNotifiesCoordinator() throws Exception {
    final DefaultScheduler scheduler = createAndStartScheduler();
    final TestingOperatorCoordinator coordinator = getCoordinator(scheduler);
    cancelTask(scheduler, 1);
    assertEquals(1, coordinator.getFailedTasks().size());
    assertThat(coordinator.getFailedTasks(), contains(1));
    assertThat(coordinator.getFailedTasks(), not(contains(0)));
}
Also used : DefaultScheduler(org.apache.flink.runtime.scheduler.DefaultScheduler) Ignore(org.junit.Ignore) 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