Search in sources :

Example 6 with TestCompletedCheckpointStorageLocation

use of org.apache.flink.runtime.state.testutils.TestCompletedCheckpointStorageLocation in project flink by apache.

the class CompletedCheckpointTest method testCompareCheckpointsWithSameCheckpointId.

/**
 * Verify that both JobID and checkpoint id are taken into account when comparing.
 */
@Test
public void testCompareCheckpointsWithSameCheckpointId() {
    JobID jobID1 = new JobID();
    JobID jobID2 = new JobID();
    CompletedCheckpoint checkpoint1 = new CompletedCheckpoint(jobID1, 0, 0, 1, new HashMap<>(), Collections.emptyList(), CheckpointProperties.forCheckpoint(CheckpointRetentionPolicy.RETAIN_ON_FAILURE), new TestCompletedCheckpointStorageLocation());
    CompletedCheckpoint checkpoint2 = new CompletedCheckpoint(jobID2, 0, 0, 1, new HashMap<>(), Collections.emptyList(), CheckpointProperties.forCheckpoint(CheckpointRetentionPolicy.RETAIN_ON_FAILURE), new TestCompletedCheckpointStorageLocation());
    List<CompletedCheckpoint> checkpoints1 = new ArrayList<>();
    checkpoints1.add(checkpoint1);
    List<CompletedCheckpoint> checkpoints2 = new ArrayList<>();
    checkpoints2.add(checkpoint2);
    assertFalse(CompletedCheckpoint.checkpointsMatch(checkpoints1, checkpoints2));
}
Also used : ArrayList(java.util.ArrayList) TestCompletedCheckpointStorageLocation(org.apache.flink.runtime.state.testutils.TestCompletedCheckpointStorageLocation) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Example 7 with TestCompletedCheckpointStorageLocation

use of org.apache.flink.runtime.state.testutils.TestCompletedCheckpointStorageLocation in project flink by apache.

the class CompletedCheckpointTest method testCompareCheckpointsWithSameJobID.

/**
 * Verify that both JobID and checkpoint id are taken into account when comparing.
 */
@Test
public void testCompareCheckpointsWithSameJobID() {
    JobID jobID = new JobID();
    CompletedCheckpoint checkpoint1 = new CompletedCheckpoint(jobID, 0, 0, 1, new HashMap<>(), Collections.emptyList(), CheckpointProperties.forCheckpoint(CheckpointRetentionPolicy.RETAIN_ON_FAILURE), new TestCompletedCheckpointStorageLocation());
    CompletedCheckpoint checkpoint2 = new CompletedCheckpoint(jobID, 1, 0, 1, new HashMap<>(), Collections.emptyList(), CheckpointProperties.forCheckpoint(CheckpointRetentionPolicy.RETAIN_ON_FAILURE), new TestCompletedCheckpointStorageLocation());
    List<CompletedCheckpoint> checkpoints1 = new ArrayList<>();
    checkpoints1.add(checkpoint1);
    List<CompletedCheckpoint> checkpoints2 = new ArrayList<>();
    checkpoints2.add(checkpoint2);
    assertFalse(CompletedCheckpoint.checkpointsMatch(checkpoints1, checkpoints2));
}
Also used : ArrayList(java.util.ArrayList) TestCompletedCheckpointStorageLocation(org.apache.flink.runtime.state.testutils.TestCompletedCheckpointStorageLocation) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Example 8 with TestCompletedCheckpointStorageLocation

use of org.apache.flink.runtime.state.testutils.TestCompletedCheckpointStorageLocation in project flink by apache.

the class CompletedCheckpointTest method testCleanUpOnSubsume.

/**
 * Tests that the garbage collection properties are respected when subsuming checkpoints.
 */
@Test
public void testCleanUpOnSubsume() throws Exception {
    OperatorState state = mock(OperatorState.class);
    Map<OperatorID, OperatorState> operatorStates = new HashMap<>();
    operatorStates.put(new OperatorID(), state);
    EmptyStreamStateHandle metadata = new EmptyStreamStateHandle();
    TestCompletedCheckpointStorageLocation location = new TestCompletedCheckpointStorageLocation(metadata, "ptr");
    CheckpointProperties props = new CheckpointProperties(false, CheckpointType.CHECKPOINT, true, false, false, false, false, false);
    CompletedCheckpoint checkpoint = new CompletedCheckpoint(new JobID(), 0, 0, 1, operatorStates, Collections.emptyList(), props, location);
    SharedStateRegistry sharedStateRegistry = new SharedStateRegistryImpl();
    checkpoint.registerSharedStatesAfterRestored(sharedStateRegistry);
    verify(state, times(1)).registerSharedStates(sharedStateRegistry, 0L);
    // Subsume
    checkpoint.discardOnSubsume();
    verify(state, times(1)).discardState();
    assertTrue(location.isDisposed());
    assertTrue(metadata.isDisposed());
}
Also used : EmptyStreamStateHandle(org.apache.flink.runtime.state.testutils.EmptyStreamStateHandle) HashMap(java.util.HashMap) SharedStateRegistryImpl(org.apache.flink.runtime.state.SharedStateRegistryImpl) TestCompletedCheckpointStorageLocation(org.apache.flink.runtime.state.testutils.TestCompletedCheckpointStorageLocation) OperatorID(org.apache.flink.runtime.jobgraph.OperatorID) JobID(org.apache.flink.api.common.JobID) SharedStateRegistry(org.apache.flink.runtime.state.SharedStateRegistry) Test(org.junit.Test)

Example 9 with TestCompletedCheckpointStorageLocation

use of org.apache.flink.runtime.state.testutils.TestCompletedCheckpointStorageLocation in project flink by apache.

the class StandaloneCompletedCheckpointStoreTest method testAddCheckpointWithFailedRemove.

/**
 * Tests that the checkpoint does not exist in the store when we fail to add it into the store
 * (i.e., there exists an exception thrown by the method).
 */
@Test
public void testAddCheckpointWithFailedRemove() throws Exception {
    final int numCheckpointsToRetain = 1;
    CompletedCheckpointStore store = createRecoveredCompletedCheckpointStore(numCheckpointsToRetain, Executors.directExecutor());
    CountDownLatch discardAttempted = new CountDownLatch(1);
    for (long i = 0; i < numCheckpointsToRetain + 1; ++i) {
        CompletedCheckpoint checkpointToAdd = new CompletedCheckpoint(new JobID(), i, i, i, Collections.emptyMap(), Collections.emptyList(), CheckpointProperties.forCheckpoint(NEVER_RETAIN_AFTER_TERMINATION), new TestCompletedCheckpointStorageLocation()) {

            @Override
            public boolean discardOnSubsume() {
                discardAttempted.countDown();
                throw new RuntimeException();
            }
        };
        // should fail despite the exception
        store.addCheckpointAndSubsumeOldestOne(checkpointToAdd, new CheckpointsCleaner(), () -> {
        });
    }
    discardAttempted.await();
}
Also used : TestCompletedCheckpointStorageLocation(org.apache.flink.runtime.state.testutils.TestCompletedCheckpointStorageLocation) CountDownLatch(java.util.concurrent.CountDownLatch) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Example 10 with TestCompletedCheckpointStorageLocation

use of org.apache.flink.runtime.state.testutils.TestCompletedCheckpointStorageLocation in project flink by apache.

the class SchedulerUtilsTest method buildCheckpoint.

private CompletedCheckpoint buildCheckpoint(KeyedStateHandle incremental) {
    OperatorID operatorID = new OperatorID();
    OperatorState operatorState = new OperatorState(operatorID, 1, 1);
    operatorState.putState(0, OperatorSubtaskState.builder().setManagedKeyedState(incremental).build());
    return new CompletedCheckpoint(new JobID(), 1, 1, 1, singletonMap(operatorID, operatorState), emptyList(), CheckpointProperties.forCheckpoint(NEVER_RETAIN_AFTER_TERMINATION), new TestCompletedCheckpointStorageLocation());
}
Also used : CompletedCheckpoint(org.apache.flink.runtime.checkpoint.CompletedCheckpoint) TestCompletedCheckpointStorageLocation(org.apache.flink.runtime.state.testutils.TestCompletedCheckpointStorageLocation) OperatorID(org.apache.flink.runtime.jobgraph.OperatorID) OperatorState(org.apache.flink.runtime.checkpoint.OperatorState) JobID(org.apache.flink.api.common.JobID)

Aggregations

TestCompletedCheckpointStorageLocation (org.apache.flink.runtime.state.testutils.TestCompletedCheckpointStorageLocation)18 Test (org.junit.Test)15 JobID (org.apache.flink.api.common.JobID)14 OperatorID (org.apache.flink.runtime.jobgraph.OperatorID)8 HashMap (java.util.HashMap)7 ArrayList (java.util.ArrayList)6 JobVertexID (org.apache.flink.runtime.jobgraph.JobVertexID)6 ExecutionGraph (org.apache.flink.runtime.executiongraph.ExecutionGraph)5 CheckpointCoordinatorBuilder (org.apache.flink.runtime.checkpoint.CheckpointCoordinatorTestingUtils.CheckpointCoordinatorBuilder)4 ExecutionJobVertex (org.apache.flink.runtime.executiongraph.ExecutionJobVertex)4 SharedStateRegistry (org.apache.flink.runtime.state.SharedStateRegistry)4 HashSet (java.util.HashSet)3 OperatorIDPair (org.apache.flink.runtime.OperatorIDPair)3 ManuallyTriggeredScheduledExecutor (org.apache.flink.util.concurrent.ManuallyTriggeredScheduledExecutor)3 IOException (java.io.IOException)2 Collection (java.util.Collection)2 Collections.emptyList (java.util.Collections.emptyList)2 Collections.singletonList (java.util.Collections.singletonList)2 List (java.util.List)2 CountDownLatch (java.util.concurrent.CountDownLatch)2