use of org.apache.flink.runtime.io.network.partition.consumer.BufferOrEvent in project flink by apache.
the class CheckpointBarrierTrackerTest method testInterleavedCancellationBarriers.
/**
* Tests that each checkpoint is only aborted once in case of an interleaved cancellation
* barrier arrival of two consecutive checkpoints.
*/
@Test
public void testInterleavedCancellationBarriers() throws Exception {
BufferOrEvent[] sequence = { createBarrier(1L, 0), createCancellationBarrier(2L, 0), createCancellationBarrier(1L, 1), createCancellationBarrier(2L, 1), createCancellationBarrier(1L, 2), createCancellationBarrier(2L, 2), createBuffer(0) };
CheckpointSequenceValidator validator = new CheckpointSequenceValidator(-1, -2);
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 CheckpointedInputGateTest method testUpstreamResumedUponEndOfRecovery.
@Test
public void testUpstreamResumedUponEndOfRecovery() throws Exception {
int numberOfChannels = 11;
NetworkBufferPool bufferPool = new NetworkBufferPool(numberOfChannels * 3, 1024);
try {
ResumeCountingConnectionManager resumeCounter = new ResumeCountingConnectionManager();
CheckpointedInputGate gate = setupInputGate(numberOfChannels, bufferPool, resumeCounter);
assertFalse(gate.pollNext().isPresent());
for (int channelIndex = 0; channelIndex < numberOfChannels - 1; channelIndex++) {
enqueueEndOfState(gate, channelIndex);
Optional<BufferOrEvent> bufferOrEvent = gate.pollNext();
while (bufferOrEvent.isPresent() && bufferOrEvent.get().getEvent() instanceof EndOfChannelStateEvent && !gate.allChannelsRecovered()) {
bufferOrEvent = gate.pollNext();
}
assertFalse("should align (block all channels)", bufferOrEvent.isPresent());
}
enqueueEndOfState(gate, numberOfChannels - 1);
Optional<BufferOrEvent> polled = gate.pollNext();
assertTrue(polled.isPresent());
assertTrue(polled.get().isEvent());
assertEquals(EndOfChannelStateEvent.INSTANCE, polled.get().getEvent());
assertEquals(numberOfChannels, resumeCounter.getNumResumed());
assertFalse("should only be a single event no matter of what is the number of channels", gate.pollNext().isPresent());
} finally {
bufferPool.destroy();
}
}
use of org.apache.flink.runtime.io.network.partition.consumer.BufferOrEvent in project flink by apache.
the class AlignedCheckpointsTest method testSingleChannelWithBarriers.
/**
* Validates that the buffer preserved the order of elements for a input with a single input
* channel, and checkpoint events.
*/
@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), createEndOfPartition(0) };
ValidatingCheckpointHandler handler = new ValidatingCheckpointHandler();
inputGate = createCheckpointedInputGate(1, sequence, handler);
handler.setNextExpectedCheckpointId(1L);
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 AlignedCheckpointsTest method testTriggerCheckpointsWithEndOfPartition.
@Test
public void testTriggerCheckpointsWithEndOfPartition() throws Exception {
BufferOrEvent[] sequence = { createBarrier(1, 0), createBarrier(1, 1), createEndOfPartition(2) };
ValidatingCheckpointHandler validator = new ValidatingCheckpointHandler(-1L);
inputGate = createCheckpointedInputGate(3, sequence, validator);
for (BufferOrEvent bufferOrEvent : sequence) {
check(bufferOrEvent, inputGate.pollNext().get(), PAGE_SIZE);
}
assertThat(validator.triggeredCheckpoints, contains(1L));
assertEquals(0, validator.getAbortedCheckpointCounter());
assertThat(inputGate.getCheckpointBarrierHandler().isCheckpointPending(), equalTo(false));
}
use of org.apache.flink.runtime.io.network.partition.consumer.BufferOrEvent in project flink by apache.
the class AlignedCheckpointsTest method testTriggerCheckpointsAfterReceivedEndOfPartition.
@Test
public void testTriggerCheckpointsAfterReceivedEndOfPartition() throws Exception {
BufferOrEvent[] sequence = { /* 0 */
createEndOfPartition(2), /* 2 */
createBarrier(6, 0), /* 3 */
createBarrier(6, 1), /* 4 */
createEndOfPartition(1), /* 5 */
createBarrier(7, 0) };
ValidatingCheckpointHandler validator = new ValidatingCheckpointHandler(-1L);
inputGate = createCheckpointedInputGate(3, sequence, validator);
for (BufferOrEvent bufferOrEvent : sequence) {
check(bufferOrEvent, inputGate.pollNext().get(), PAGE_SIZE);
}
assertThat(validator.triggeredCheckpoints, contains(6L, 7L));
assertEquals(0, validator.getAbortedCheckpointCounter());
assertThat(inputGate.getCheckpointBarrierHandler().isCheckpointPending(), equalTo(false));
}
Aggregations