Search in sources :

Example 1 with CheckpointStorageLocationReference

use of org.apache.flink.runtime.state.CheckpointStorageLocationReference in project flink by apache.

the class CheckpointOptionsTest method testCheckpointIsTimeoutable.

@Test
public void testCheckpointIsTimeoutable() {
    CheckpointStorageLocationReference location = CheckpointStorageLocationReference.getDefault();
    assertTimeoutable(CheckpointOptions.alignedWithTimeout(CheckpointType.CHECKPOINT, location, 10), false, true, 10);
    assertTimeoutable(CheckpointOptions.unaligned(CheckpointType.CHECKPOINT, location), true, false, NO_ALIGNED_CHECKPOINT_TIME_OUT);
    assertTimeoutable(CheckpointOptions.alignedWithTimeout(CheckpointType.CHECKPOINT, location, 10).withUnalignedUnsupported(), false, false, 10);
    assertTimeoutable(CheckpointOptions.unaligned(CheckpointType.CHECKPOINT, location).withUnalignedUnsupported(), false, false, NO_ALIGNED_CHECKPOINT_TIME_OUT);
}
Also used : CheckpointStorageLocationReference(org.apache.flink.runtime.state.CheckpointStorageLocationReference) Test(org.junit.Test)

Example 2 with CheckpointStorageLocationReference

use of org.apache.flink.runtime.state.CheckpointStorageLocationReference in project flink by apache.

the class EventSerializer method deserializeCheckpointBarrier.

private static CheckpointBarrier deserializeCheckpointBarrier(ByteBuffer buffer) throws IOException {
    final long id = buffer.getLong();
    final long timestamp = buffer.getLong();
    final byte checkpointTypeCode = buffer.get();
    final SnapshotType snapshotType;
    if (checkpointTypeCode == CHECKPOINT_TYPE_CHECKPOINT) {
        snapshotType = CheckpointType.CHECKPOINT;
    } else if (checkpointTypeCode == CHECKPOINT_TYPE_FULL_CHECKPOINT) {
        snapshotType = CheckpointType.FULL_CHECKPOINT;
    } else if (checkpointTypeCode == CHECKPOINT_TYPE_SAVEPOINT || checkpointTypeCode == CHECKPOINT_TYPE_SAVEPOINT_SUSPEND || checkpointTypeCode == CHECKPOINT_TYPE_SAVEPOINT_TERMINATE) {
        snapshotType = decodeSavepointType(checkpointTypeCode, buffer);
    } else {
        throw new IOException("Unknown checkpoint type code: " + checkpointTypeCode);
    }
    final CheckpointStorageLocationReference locationRef;
    final int locationRefLen = buffer.getInt();
    if (locationRefLen == -1) {
        locationRef = CheckpointStorageLocationReference.getDefault();
    } else {
        byte[] bytes = new byte[locationRefLen];
        buffer.get(bytes);
        locationRef = new CheckpointStorageLocationReference(bytes);
    }
    final CheckpointOptions.AlignmentType alignmentType = CheckpointOptions.AlignmentType.values()[buffer.get()];
    final long alignmentTimeout = buffer.getLong();
    return new CheckpointBarrier(id, timestamp, new CheckpointOptions(snapshotType, locationRef, alignmentType, alignmentTimeout));
}
Also used : CheckpointBarrier(org.apache.flink.runtime.io.network.api.CheckpointBarrier) CheckpointOptions(org.apache.flink.runtime.checkpoint.CheckpointOptions) SnapshotType(org.apache.flink.runtime.checkpoint.SnapshotType) IOException(java.io.IOException) CheckpointStorageLocationReference(org.apache.flink.runtime.state.CheckpointStorageLocationReference)

Example 3 with CheckpointStorageLocationReference

use of org.apache.flink.runtime.state.CheckpointStorageLocationReference in project flink by apache.

the class FsCheckpointStorageAccessTest method testResolveCheckpointStorageLocation.

@Test
public void testResolveCheckpointStorageLocation() throws Exception {
    final FileSystem checkpointFileSystem = mock(FileSystem.class);
    final FsCheckpointStorageAccess storage = new FsCheckpointStorageAccess(new TestingPath("hdfs:///checkpoint/", checkpointFileSystem), null, new JobID(), FILE_SIZE_THRESHOLD, WRITE_BUFFER_SIZE);
    final FsCheckpointStorageLocation checkpointStreamFactory = (FsCheckpointStorageLocation) storage.resolveCheckpointStorageLocation(1L, CheckpointStorageLocationReference.getDefault());
    assertEquals(checkpointFileSystem, checkpointStreamFactory.getFileSystem());
    final CheckpointStorageLocationReference savepointLocationReference = AbstractFsCheckpointStorageAccess.encodePathAsReference(new Path("file:///savepoint/"));
    final FsCheckpointStorageLocation savepointStreamFactory = (FsCheckpointStorageLocation) storage.resolveCheckpointStorageLocation(2L, savepointLocationReference);
    final FileSystem fileSystem = savepointStreamFactory.getFileSystem();
    assertTrue(fileSystem instanceof LocalFileSystem);
}
Also used : Path(org.apache.flink.core.fs.Path) LocalFileSystem(org.apache.flink.core.fs.local.LocalFileSystem) LocalFileSystem(org.apache.flink.core.fs.local.LocalFileSystem) TestFileSystem(org.apache.flink.testutils.TestFileSystem) DuplicatingFileSystem(org.apache.flink.core.fs.DuplicatingFileSystem) FileSystem(org.apache.flink.core.fs.FileSystem) JobID(org.apache.flink.api.common.JobID) CheckpointStorageLocationReference(org.apache.flink.runtime.state.CheckpointStorageLocationReference) Test(org.junit.Test)

Example 4 with CheckpointStorageLocationReference

use of org.apache.flink.runtime.state.CheckpointStorageLocationReference in project flink by apache.

the class StreamTaskExecutionDecorationTest method testTriggerCheckpointOnBarrierIsDecorated.

@Test
public void testTriggerCheckpointOnBarrierIsDecorated() throws Exception {
    task.triggerCheckpointOnBarrier(new CheckpointMetaData(1, 2), new CheckpointOptions(CheckpointType.CHECKPOINT, new CheckpointStorageLocationReference(new byte[] { 1 })), null);
    Assert.assertTrue("execution decorator was not called", decorator.wasCalled());
}
Also used : CheckpointOptions(org.apache.flink.runtime.checkpoint.CheckpointOptions) CheckpointMetaData(org.apache.flink.runtime.checkpoint.CheckpointMetaData) CheckpointStorageLocationReference(org.apache.flink.runtime.state.CheckpointStorageLocationReference) Test(org.junit.Test)

Example 5 with CheckpointStorageLocationReference

use of org.apache.flink.runtime.state.CheckpointStorageLocationReference in project flink by apache.

the class StreamTaskExecutionDecorationTest method testTriggerCheckpointAsyncIsDecorated.

@Test
public void testTriggerCheckpointAsyncIsDecorated() {
    task.triggerCheckpointAsync(new CheckpointMetaData(1, 2), new CheckpointOptions(CheckpointType.CHECKPOINT, new CheckpointStorageLocationReference(new byte[] { 1 })));
    Assert.assertTrue("mailbox is empty", mailbox.hasMail());
    Assert.assertFalse("execution decorator was called preliminary", decorator.wasCalled());
    mailbox.drain().forEach(m -> {
        try {
            m.run();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    });
    Assert.assertTrue("execution decorator was not called", decorator.wasCalled());
}
Also used : CheckpointOptions(org.apache.flink.runtime.checkpoint.CheckpointOptions) CheckpointMetaData(org.apache.flink.runtime.checkpoint.CheckpointMetaData) CheckpointStorageLocationReference(org.apache.flink.runtime.state.CheckpointStorageLocationReference) RunnableWithException(org.apache.flink.util.function.RunnableWithException) CheckpointException(org.apache.flink.runtime.checkpoint.CheckpointException) Test(org.junit.Test)

Aggregations

CheckpointStorageLocationReference (org.apache.flink.runtime.state.CheckpointStorageLocationReference)19 Test (org.junit.Test)16 CheckpointOptions (org.apache.flink.runtime.checkpoint.CheckpointOptions)12 CheckpointBarrier (org.apache.flink.runtime.io.network.api.CheckpointBarrier)4 Random (java.util.Random)2 Path (org.apache.flink.core.fs.Path)2 CheckpointMetaData (org.apache.flink.runtime.checkpoint.CheckpointMetaData)2 RecordingChannelStateWriter (org.apache.flink.runtime.checkpoint.channel.RecordingChannelStateWriter)2 Buffer (org.apache.flink.runtime.io.network.buffer.Buffer)2 BufferBuilderTestUtils.createEventBufferConsumer (org.apache.flink.runtime.io.network.buffer.BufferBuilderTestUtils.createEventBufferConsumer)2 BufferBuilderTestUtils.createFilledFinishedBufferConsumer (org.apache.flink.runtime.io.network.buffer.BufferBuilderTestUtils.createFilledFinishedBufferConsumer)2 BufferBuilderTestUtils.createFilledUnfinishedBufferConsumer (org.apache.flink.runtime.io.network.buffer.BufferBuilderTestUtils.createFilledUnfinishedBufferConsumer)2 BufferConsumer (org.apache.flink.runtime.io.network.buffer.BufferConsumer)2 IOException (java.io.IOException)1 JobID (org.apache.flink.api.common.JobID)1 DuplicatingFileSystem (org.apache.flink.core.fs.DuplicatingFileSystem)1 FileSystem (org.apache.flink.core.fs.FileSystem)1 LocalFileSystem (org.apache.flink.core.fs.local.LocalFileSystem)1 CheckpointException (org.apache.flink.runtime.checkpoint.CheckpointException)1 SnapshotType (org.apache.flink.runtime.checkpoint.SnapshotType)1