use of org.apache.flink.runtime.state.CheckpointStorageLocationReference in project flink by apache.
the class PipelinedSubpartitionWithReadViewTest method testBarrierOvertaking.
@Test
public void testBarrierOvertaking() throws Exception {
final RecordingChannelStateWriter channelStateWriter = new RecordingChannelStateWriter();
subpartition.setChannelStateWriter(channelStateWriter);
subpartition.add(createFilledFinishedBufferConsumer(1));
assertEquals(0, availablityListener.getNumNotifications());
assertEquals(0, availablityListener.getNumPriorityEvents());
subpartition.add(createFilledFinishedBufferConsumer(2));
assertEquals(1, availablityListener.getNumNotifications());
assertEquals(0, availablityListener.getNumPriorityEvents());
BufferConsumer eventBuffer = EventSerializer.toBufferConsumer(EndOfSuperstepEvent.INSTANCE, false);
subpartition.add(eventBuffer);
assertEquals(1, availablityListener.getNumNotifications());
assertEquals(0, availablityListener.getNumPriorityEvents());
subpartition.add(createFilledFinishedBufferConsumer(4));
assertEquals(1, availablityListener.getNumNotifications());
assertEquals(0, availablityListener.getNumPriorityEvents());
CheckpointOptions options = CheckpointOptions.unaligned(CheckpointType.CHECKPOINT, new CheckpointStorageLocationReference(new byte[] { 0, 1, 2 }));
channelStateWriter.start(0, options);
BufferConsumer barrierBuffer = EventSerializer.toBufferConsumer(new CheckpointBarrier(0, 0, options), true);
subpartition.add(barrierBuffer);
assertEquals(1, availablityListener.getNumNotifications());
assertEquals(1, availablityListener.getNumPriorityEvents());
final List<Buffer> inflight = channelStateWriter.getAddedOutput().get(subpartition.getSubpartitionInfo());
assertEquals(Arrays.asList(1, 2, 4), inflight.stream().map(Buffer::getSize).collect(Collectors.toList()));
inflight.forEach(Buffer::recycleBuffer);
assertNextEvent(readView, barrierBuffer.getWrittenBytes(), CheckpointBarrier.class, true, 2, false, true);
assertNextBuffer(readView, 1, true, 1, false, true);
assertNextBuffer(readView, 2, true, 0, true, true);
assertNextEvent(readView, eventBuffer.getWrittenBytes(), EndOfSuperstepEvent.class, false, 0, false, true);
assertNextBuffer(readView, 4, false, 0, false, true);
assertNoNextBuffer(readView);
}
use of org.apache.flink.runtime.state.CheckpointStorageLocationReference in project flink by apache.
the class PipelinedSubpartitionWithReadViewTest method testAvailabilityAfterPriority.
@Test
public void testAvailabilityAfterPriority() throws Exception {
subpartition.setChannelStateWriter(ChannelStateWriter.NO_OP);
CheckpointOptions options = CheckpointOptions.unaligned(CheckpointType.CHECKPOINT, new CheckpointStorageLocationReference(new byte[] { 0, 1, 2 }));
BufferConsumer barrierBuffer = EventSerializer.toBufferConsumer(new CheckpointBarrier(0, 0, options), true);
subpartition.add(barrierBuffer);
assertEquals(1, availablityListener.getNumNotifications());
assertEquals(1, availablityListener.getNumPriorityEvents());
subpartition.add(createFilledFinishedBufferConsumer(1));
assertEquals(2, availablityListener.getNumNotifications());
assertEquals(1, availablityListener.getNumPriorityEvents());
subpartition.add(createFilledFinishedBufferConsumer(2));
assertEquals(2, availablityListener.getNumNotifications());
assertEquals(1, availablityListener.getNumPriorityEvents());
assertNextEvent(readView, barrierBuffer.getWrittenBytes(), CheckpointBarrier.class, true, 1, false, true);
assertNextBuffer(readView, 1, false, 0, false, true);
assertNextBuffer(readView, 2, false, 0, false, true);
assertNoNextBuffer(readView);
}
use of org.apache.flink.runtime.state.CheckpointStorageLocationReference in project flink by apache.
the class CheckpointOptionsTest method testForceAlignmentIsReversable.
@Test
public void testForceAlignmentIsReversable() {
CheckpointStorageLocationReference location = CheckpointStorageLocationReference.getDefault();
assertReversable(CheckpointOptions.alignedWithTimeout(CheckpointType.CHECKPOINT, location, 10), true);
assertReversable(CheckpointOptions.unaligned(CheckpointType.CHECKPOINT, location), true);
assertReversable(CheckpointOptions.alignedNoTimeout(CHECKPOINT, location), false);
assertReversable(CheckpointOptions.alignedNoTimeout(SavepointType.savepoint(SavepointFormatType.CANONICAL), location), false);
assertReversable(CheckpointOptions.notExactlyOnce(CHECKPOINT, location), false);
assertReversable(CheckpointOptions.notExactlyOnce(SavepointType.savepoint(SavepointFormatType.CANONICAL), location), false);
}
use of org.apache.flink.runtime.state.CheckpointStorageLocationReference in project flink by apache.
the class CheckpointOptionsTest method testCheckpointNeedsAlignment.
@Test
public void testCheckpointNeedsAlignment() {
CheckpointStorageLocationReference location = CheckpointStorageLocationReference.getDefault();
assertFalse(new CheckpointOptions(CHECKPOINT, location, AlignmentType.UNALIGNED, NO_ALIGNED_CHECKPOINT_TIME_OUT).needsAlignment());
assertTrue(new CheckpointOptions(CHECKPOINT, location, AlignmentType.ALIGNED, NO_ALIGNED_CHECKPOINT_TIME_OUT).needsAlignment());
assertTrue(new CheckpointOptions(CHECKPOINT, location, AlignmentType.FORCED_ALIGNED, NO_ALIGNED_CHECKPOINT_TIME_OUT).needsAlignment());
assertFalse(new CheckpointOptions(CHECKPOINT, location, AlignmentType.AT_LEAST_ONCE, NO_ALIGNED_CHECKPOINT_TIME_OUT).needsAlignment());
}
use of org.apache.flink.runtime.state.CheckpointStorageLocationReference in project flink by apache.
the class CheckpointOptionsTest method testSavepoint.
@Test
public void testSavepoint() throws Exception {
final Random rnd = new Random();
final byte[] locationBytes = new byte[rnd.nextInt(41) + 1];
rnd.nextBytes(locationBytes);
final SnapshotType[] snapshotTypes = { CHECKPOINT, FULL_CHECKPOINT, SavepointType.savepoint(SavepointFormatType.CANONICAL), SavepointType.suspend(SavepointFormatType.CANONICAL), SavepointType.terminate(SavepointFormatType.CANONICAL) };
final CheckpointOptions options = new CheckpointOptions(snapshotTypes[rnd.nextInt(snapshotTypes.length)], new CheckpointStorageLocationReference(locationBytes));
final CheckpointOptions copy = CommonTestUtils.createCopySerializable(options);
assertEquals(options.getCheckpointType(), copy.getCheckpointType());
assertArrayEquals(locationBytes, copy.getTargetLocation().getReferenceBytes());
}
Aggregations