use of org.apache.flink.runtime.io.network.partition.consumer.BufferOrEvent in project flink by apache.
the class CheckpointBarrierTrackerTest method testSingleChannelWithBarriers.
@Test
public void testSingleChannelWithBarriers() throws Exception {
BufferOrEvent[] sequence = { createBuffer(0), createBuffer(0), createBuffer(0), createBarrier(1, 0), createBuffer(0), createBuffer(0), createBuffer(0), createBuffer(0), createBarrier(2, 0), createBarrier(3, 0), createBuffer(0), createBuffer(0), createBarrier(4, 0), createBarrier(5, 0), createBarrier(6, 0), createBuffer(0) };
CheckpointSequenceValidator validator = new CheckpointSequenceValidator(1, 2, 3, 4, 5, 6);
inputGate = createCheckpointedInputGate(1, sequence, validator);
for (BufferOrEvent boe : sequence) {
assertEquals(boe, inputGate.pollNext().get());
}
}
use of org.apache.flink.runtime.io.network.partition.consumer.BufferOrEvent in project flink by apache.
the class CheckpointBarrierTrackerTest method testNextFirstCheckpointBarrierOvertakesCancellationBarrier.
@Test
public void testNextFirstCheckpointBarrierOvertakesCancellationBarrier() throws Exception {
BufferOrEvent[] sequence = { // start checkpoint 1
createBarrier(1, 1), // start checkpoint 2(just suppose checkpoint 1 was canceled)
createBarrier(2, 1), // cancellation barrier of checkpoint 1
createCancellationBarrier(1, 0), // finish the checkpoint 2
createBarrier(2, 0) };
ValidatingCheckpointHandler validator = new ValidatingCheckpointHandler();
ManualClock manualClock = new ManualClock();
inputGate = createCheckpointedInputGate(2, sequence, validator, manualClock);
for (BufferOrEvent boe : sequence) {
assertEquals(boe, inputGate.pollNext().get());
manualClock.advanceTime(Duration.ofSeconds(1));
}
assertEquals(Duration.ofSeconds(2).toNanos(), validator.lastAlignmentDurationNanos.get().longValue());
}
use of org.apache.flink.runtime.io.network.partition.consumer.BufferOrEvent in project flink by apache.
the class CheckpointBarrierTrackerTest method testMultiChannelAbortCheckpoint.
@Test
public void testMultiChannelAbortCheckpoint() throws Exception {
BufferOrEvent[] sequence = { // some buffers and a successful checkpoint
createBuffer(0), createBuffer(2), createBuffer(0), createBarrier(1, 1), createBarrier(1, 2), createBuffer(2), createBuffer(1), createBarrier(1, 0), // aborted on last barrier
createBuffer(0), createBuffer(2), createBarrier(2, 0), createBarrier(2, 2), createBuffer(0), createBuffer(2), createCancellationBarrier(2, 1), // successful checkpoint
createBuffer(2), createBuffer(1), createBarrier(3, 1), createBarrier(3, 2), createBarrier(3, 0), // abort on first barrier
createBuffer(0), createBuffer(1), createCancellationBarrier(4, 1), createBarrier(4, 2), createBuffer(0), createBarrier(4, 0), // another successful checkpoint
createBuffer(0), createBuffer(1), createBuffer(2), createBarrier(5, 2), createBarrier(5, 1), createBarrier(5, 0), // abort multiple cancellations and a barrier after the cancellations
createBuffer(0), createBuffer(1), createCancellationBarrier(6, 1), createCancellationBarrier(6, 2), createBarrier(6, 0), createBuffer(0) };
// negative values mean an expected cancellation call!
CheckpointSequenceValidator validator = new CheckpointSequenceValidator(1, -2, 3, -4, 5, -6);
inputGate = createCheckpointedInputGate(3, sequence, validator);
for (BufferOrEvent boe : sequence) {
assertEquals(boe, inputGate.pollNext().get());
}
}
use of org.apache.flink.runtime.io.network.partition.consumer.BufferOrEvent in project flink by apache.
the class CheckpointBarrierTrackerTest method testTriggerCheckpointsWithEndOfPartition.
@Test
public void testTriggerCheckpointsWithEndOfPartition() throws Exception {
BufferOrEvent[] sequence = { createBarrier(1, 0), createBarrier(2, 0), createBarrier(2, 1), createBarrier(3, 0), createBarrier(4, 0), createBarrier(4, 1), createBarrier(5, 1), createEndOfPartition(2) };
ValidatingCheckpointHandler validator = new ValidatingCheckpointHandler(4);
inputGate = createCheckpointedInputGate(3, sequence, validator);
CheckpointBarrierTracker checkpointBarrierTracker = (CheckpointBarrierTracker) inputGate.getCheckpointBarrierHandler();
for (BufferOrEvent boe : sequence) {
assertEquals(boe, inputGate.pollNext().get());
}
// Only checkpoints 4 is triggered and the previous checkpoints are ignored.
assertThat(validator.triggeredCheckpoints, contains(4L));
assertEquals(0, validator.getAbortedCheckpointCounter());
assertThat(checkpointBarrierTracker.getPendingCheckpointIds(), contains(5L));
assertEquals(2, checkpointBarrierTracker.getNumOpenChannels());
}
use of org.apache.flink.runtime.io.network.partition.consumer.BufferOrEvent in project flink by apache.
the class CheckpointBarrierTrackerTest method testSingleChannelAbortCheckpoint.
@Test
public void testSingleChannelAbortCheckpoint() throws Exception {
BufferOrEvent[] sequence = { createBuffer(0), createBarrier(1, 0), createBuffer(0), createBarrier(2, 0), createCancellationBarrier(4, 0), createBarrier(5, 0), createBuffer(0), createCancellationBarrier(6, 0), createBuffer(0) };
// negative values mean an expected cancellation call!
CheckpointSequenceValidator validator = new CheckpointSequenceValidator(1, 2, -4, 5, -6);
inputGate = createCheckpointedInputGate(1, sequence, validator);
for (BufferOrEvent boe : sequence) {
assertEquals(boe, inputGate.pollNext().get());
}
}
Aggregations