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);
}
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));
}
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);
}
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());
}
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());
}
Aggregations