use of org.apache.flink.runtime.state.TestingStreamStateHandle in project flink by apache.
the class PendingCheckpointTest method testAcknowledgedCoordinatorStates.
@Test
public void testAcknowledgedCoordinatorStates() throws Exception {
final OperatorInfo coord1 = new TestingOperatorInfo();
final OperatorInfo coord2 = new TestingOperatorInfo();
final PendingCheckpoint checkpoint = createPendingCheckpointWithCoordinators(coord1, coord2);
final TaskAcknowledgeResult ack1 = checkpoint.acknowledgeCoordinatorState(coord1, new TestingStreamStateHandle());
final TaskAcknowledgeResult ack2 = checkpoint.acknowledgeCoordinatorState(coord2, null);
assertEquals(TaskAcknowledgeResult.SUCCESS, ack1);
assertEquals(TaskAcknowledgeResult.SUCCESS, ack2);
assertEquals(0, checkpoint.getNumberOfNonAcknowledgedOperatorCoordinators());
assertTrue(checkpoint.isFullyAcknowledged());
assertThat(checkpoint.getOperatorStates().keySet(), containsInAnyOrder(OPERATOR_ID, coord1.operatorId(), coord2.operatorId()));
}
use of org.apache.flink.runtime.state.TestingStreamStateHandle in project flink by apache.
the class DefaultCompletedCheckpointStoreTest method testShutdownShouldNotDiscardStateHandleWhenJobIsNotGloballyTerminalState.
@Test
public void testShutdownShouldNotDiscardStateHandleWhenJobIsNotGloballyTerminalState() throws Exception {
final AtomicInteger removeCalledNum = new AtomicInteger(0);
final CompletableFuture<Void> removeAllFuture = new CompletableFuture<>();
final CompletableFuture<Void> releaseAllFuture = new CompletableFuture<>();
final TestingStateHandleStore<CompletedCheckpoint> stateHandleStore = builder.setGetAllSupplier(() -> createStateHandles(3)).setRemoveFunction(ignore -> {
removeCalledNum.incrementAndGet();
return true;
}).setReleaseAllHandlesRunnable(() -> releaseAllFuture.complete(null)).setClearEntriesRunnable(() -> removeAllFuture.complete(null)).build();
final CompletedCheckpointStore completedCheckpointStore = createCompletedCheckpointStore(stateHandleStore);
assertThat(completedCheckpointStore.getAllCheckpoints().size(), is(3));
TestingStreamStateHandle streamStateHandle = registerState(completedCheckpointStore, 3L);
completedCheckpointStore.shutdown(JobStatus.CANCELLING, new CheckpointsCleaner());
try {
removeAllFuture.get(timeout, TimeUnit.MILLISECONDS);
fail("We should get an expected timeout because the job is not globally terminated.");
} catch (TimeoutException ex) {
// expected
}
assertThat(removeCalledNum.get(), is(0));
assertThat(removeAllFuture.isDone(), is(false));
assertThat(releaseAllFuture.isDone(), is(true));
assertThat(completedCheckpointStore.getAllCheckpoints().size(), is(0));
assertThat(streamStateHandle.isDisposed(), is(false));
}
use of org.apache.flink.runtime.state.TestingStreamStateHandle in project flink by apache.
the class PendingCheckpointTest method testDisposeDisposesCoordinatorStates.
@Test
public void testDisposeDisposesCoordinatorStates() throws Exception {
final TestingStreamStateHandle handle1 = new TestingStreamStateHandle();
final TestingStreamStateHandle handle2 = new TestingStreamStateHandle();
final PendingCheckpoint checkpoint = createPendingCheckpointWithAcknowledgedCoordinators(handle1, handle2);
abort(checkpoint, CheckpointFailureReason.CHECKPOINT_EXPIRED);
assertTrue(handle1.isDisposed());
assertTrue(handle2.isDisposed());
}
use of org.apache.flink.runtime.state.TestingStreamStateHandle in project flink by apache.
the class DefaultCheckpointPlanTest method testFulfillFullyFinishedStatesWithCoordinator.
@Test
public void testFulfillFullyFinishedStatesWithCoordinator() throws Exception {
JobVertexID finishedJobVertexID = new JobVertexID();
OperatorID finishedOperatorID = new OperatorID();
ExecutionGraph executionGraph = new CheckpointCoordinatorTestingUtils.CheckpointExecutionGraphBuilder().addJobVertex(finishedJobVertexID, 1, 256, Collections.singletonList(OperatorIDPair.generatedIDOnly(finishedOperatorID)), true).build();
executionGraph.getJobVertex(finishedJobVertexID).getTaskVertices()[0].getCurrentExecutionAttempt().markFinished();
CheckpointPlan checkpointPlan = createCheckpointPlan(executionGraph);
Map<OperatorID, OperatorState> operatorStates = new HashMap<>();
OperatorState operatorState = new OperatorState(finishedOperatorID, 1, 256);
operatorState.setCoordinatorState(new TestingStreamStateHandle());
operatorStates.put(finishedOperatorID, operatorState);
checkpointPlan.fulfillFinishedTaskStatus(operatorStates);
assertEquals(1, operatorStates.size());
assertTrue(operatorStates.get(finishedOperatorID).isFullyFinished());
}
Aggregations