use of org.apache.flink.runtime.io.network.partition.consumer.TestInputChannel in project flink by apache.
the class TestCheckpointedInputGateBuilder method buildMixedGate.
private SingleInputGate buildMixedGate(Integer... testChannelIds) throws IOException {
Set<Integer> testChannelIdSet = new HashSet<>(Arrays.asList(testChannelIds));
SingleInputGate gate = buildRemoteGate();
InputChannel[] channels = new InputChannel[numChannels];
for (int i = 0; i < numChannels; i++) {
if (testChannelIdSet.contains(i)) {
channels[i] = new TestInputChannel(gate, i, false, true);
} else {
channels[i] = gate.getChannel(i);
}
}
gate.setInputChannels(channels);
return gate;
}
use of org.apache.flink.runtime.io.network.partition.consumer.TestInputChannel in project flink by apache.
the class AlternatingCheckpointsTest method testHasInflightDataBeforeProcessBarrier.
@Test
public void testHasInflightDataBeforeProcessBarrier() throws Exception {
SingleInputGate inputGate = new SingleInputGateBuilder().setNumberOfChannels(2).build();
inputGate.setInputChannels(new TestInputChannel(inputGate, 0), new TestInputChannel(inputGate, 1));
ValidatingCheckpointHandler target = new ValidatingCheckpointHandler();
SingleCheckpointBarrierHandler barrierHandler = getTestBarrierHandlerFactory(target).create(inputGate);
final long id = 1;
barrierHandler.processBarrier(new CheckpointBarrier(id, clock.relativeTimeMillis(), new CheckpointOptions(CHECKPOINT, getDefault())), new InputChannelInfo(0, 0), false);
assertFalse(barrierHandler.getAllBarriersReceivedFuture(id).isDone());
}
use of org.apache.flink.runtime.io.network.partition.consumer.TestInputChannel in project flink by apache.
the class AlternatingCheckpointsTest method testPreviousHandlerReset.
@Test
public void testPreviousHandlerReset() throws Exception {
SingleInputGate inputGate = new SingleInputGateBuilder().setNumberOfChannels(2).build();
TestInputChannel[] channels = { new TestInputChannel(inputGate, 0), new TestInputChannel(inputGate, 1) };
inputGate.setInputChannels(channels);
ValidatingCheckpointHandler target = new ValidatingCheckpointHandler();
SingleCheckpointBarrierHandler barrierHandler = getTestBarrierHandlerFactory(target).create(inputGate);
for (int i = 0; i < 4; i++) {
int channel = i % 2;
SnapshotType type = channel == 0 ? SavepointType.savepoint(SavepointFormatType.CANONICAL) : CHECKPOINT;
target.setNextExpectedCheckpointId(-1);
if (type.isSavepoint()) {
channels[channel].setBlocked(true);
}
barrierHandler.processBarrier(new CheckpointBarrier(i, clock.relativeTimeMillis(), new CheckpointOptions(type, getDefault())), new InputChannelInfo(0, channel), false);
if (type.isSavepoint()) {
assertTrue(channels[channel].isBlocked());
assertFalse(channels[(channel + 1) % 2].isBlocked());
} else {
assertFalse(channels[0].isBlocked());
assertFalse(channels[1].isBlocked());
}
assertTrue(barrierHandler.isCheckpointPending());
assertFalse(barrierHandler.getAllBarriersReceivedFuture(i).isDone());
channels[0].setBlocked(false);
channels[1].setBlocked(false);
}
}
use of org.apache.flink.runtime.io.network.partition.consumer.TestInputChannel in project flink by apache.
the class AlternatingCheckpointsTest method testTimeoutAlignmentBeforeFirstBarrier.
@Test
public void testTimeoutAlignmentBeforeFirstBarrier() throws Exception {
// given: Local channels.
int numChannels = 2;
ValidatingCheckpointHandler target = new ValidatingCheckpointHandler();
CheckpointedInputGate gate = new TestCheckpointedInputGateBuilder(numChannels, getTestBarrierHandlerFactory(target)).withTestChannels().withMailboxExecutor().build();
long alignedCheckpointTimeout = 100;
// when: Aligned checkpoint timeout expired before the first barrier received.
Buffer checkpointBarrier = withTimeout(1, alignedCheckpointTimeout);
clock.advanceTime(alignedCheckpointTimeout + 1, TimeUnit.MILLISECONDS);
((TestInputChannel) gate.getChannel(0)).read(checkpointBarrier.retainBuffer());
// then: The UC is triggered as soon as the first barrier is received.
assertBarrier(gate);
assertEquals(1, target.getTriggeredCheckpointCounter());
}
use of org.apache.flink.runtime.io.network.partition.consumer.TestInputChannel in project flink by apache.
the class AlternatingCheckpointsTest method testOutOfOrderBarrier.
@Test
public void testOutOfOrderBarrier() throws Exception {
SingleInputGate inputGate = new SingleInputGateBuilder().setNumberOfChannels(2).build();
TestInputChannel firstChannel = new TestInputChannel(inputGate, 0);
TestInputChannel secondChannel = new TestInputChannel(inputGate, 1);
inputGate.setInputChannels(firstChannel, secondChannel);
ValidatingCheckpointHandler target = new ValidatingCheckpointHandler();
SingleCheckpointBarrierHandler barrierHandler = getTestBarrierHandlerFactory(target).create(inputGate);
long checkpointId = 10;
long outOfOrderSavepointId = 5;
barrierHandler.processBarrier(new CheckpointBarrier(checkpointId, clock.relativeTimeMillis(), new CheckpointOptions(CHECKPOINT, getDefault())), new InputChannelInfo(0, 0), false);
secondChannel.setBlocked(true);
barrierHandler.processBarrier(new CheckpointBarrier(outOfOrderSavepointId, clock.relativeTimeMillis(), new CheckpointOptions(SavepointType.savepoint(SavepointFormatType.CANONICAL), getDefault())), new InputChannelInfo(0, 1), false);
assertEquals(checkpointId, barrierHandler.getLatestCheckpointId());
assertFalse(secondChannel.isBlocked());
}
Aggregations