use of org.apache.flink.runtime.operators.coordination.RecreateOnResetOperatorCoordinator in project flink by apache.
the class SourceCoordinatorProviderTest method testCheckpointAndReset.
@Test
public void testCheckpointAndReset() throws Exception {
final OperatorCoordinator.Context context = new MockOperatorCoordinatorContext(OPERATOR_ID, NUM_SPLITS);
final RecreateOnResetOperatorCoordinator coordinator = (RecreateOnResetOperatorCoordinator) provider.create(context);
final SourceCoordinator<?, ?> sourceCoordinator = (SourceCoordinator<?, ?>) coordinator.getInternalCoordinator();
// Start the coordinator.
coordinator.start();
// register reader 0 and take a checkpoint.
coordinator.handleEventFromOperator(0, new ReaderRegistrationEvent(0, "location"));
CompletableFuture<byte[]> future = new CompletableFuture<>();
coordinator.checkpointCoordinator(0L, future);
byte[] bytes = future.get();
// Register reader 1.
coordinator.handleEventFromOperator(1, new ReaderRegistrationEvent(1, "location"));
// Wait until the coordinator context is updated with registration of reader 1.
while (sourceCoordinator.getContext().registeredReaders().size() < 2) {
Thread.sleep(1);
}
// reset the coordinator to the checkpoint which only contains reader 0.
coordinator.resetToCheckpoint(0L, bytes);
final SourceCoordinator<?, ?> restoredSourceCoordinator = (SourceCoordinator<?, ?>) coordinator.getInternalCoordinator();
assertNotEquals("The restored source coordinator should be a different instance", restoredSourceCoordinator, sourceCoordinator);
// FLINK-21452: do not (re)store registered readers
assertEquals("There should be no registered reader.", 0, restoredSourceCoordinator.getContext().registeredReaders().size());
}
use of org.apache.flink.runtime.operators.coordination.RecreateOnResetOperatorCoordinator in project flink by apache.
the class SourceCoordinatorProviderTest method testCreate.
@Test
public void testCreate() throws Exception {
OperatorCoordinator coordinator = provider.create(new MockOperatorCoordinatorContext(OPERATOR_ID, NUM_SPLITS));
assertTrue(coordinator instanceof RecreateOnResetOperatorCoordinator);
}
use of org.apache.flink.runtime.operators.coordination.RecreateOnResetOperatorCoordinator in project flink by apache.
the class SourceCoordinatorProviderTest method testCallAsyncExceptionFailsJob.
@Test
public void testCallAsyncExceptionFailsJob() throws Exception {
MockOperatorCoordinatorContext context = new MockOperatorCoordinatorContext(OPERATOR_ID, NUM_SPLITS);
RecreateOnResetOperatorCoordinator coordinator = (RecreateOnResetOperatorCoordinator) provider.create(context);
SourceCoordinator<?, ?> sourceCoordinator = (SourceCoordinator<?, ?>) coordinator.getInternalCoordinator();
sourceCoordinator.getContext().callAsync(() -> null, (ignored, e) -> {
throw new RuntimeException();
});
CommonTestUtils.waitUtil(context::isJobFailed, Duration.ofSeconds(10L), "The job did not fail before timeout.");
}
Aggregations