use of org.apache.flink.runtime.io.network.partition.consumer.TestInputChannel in project flink by apache.
the class AlternatingCheckpointsTest method testActiveTimeoutAfterLocalBarrierPassiveTimeout.
@Test
public void testActiveTimeoutAfterLocalBarrierPassiveTimeout() throws Exception {
int numChannels = 2;
ValidatingCheckpointHandler target = new ValidatingCheckpointHandler();
try (CheckpointedInputGate gate = new TestCheckpointedInputGateBuilder(numChannels, getTestBarrierHandlerFactory(target)).withMixedChannels(0).withMailboxExecutor().build()) {
long alignmentTimeout = 10;
Buffer checkpointBarrier = withTimeout(alignmentTimeout);
((TestInputChannel) gate.getChannel(0)).read(checkpointBarrier.retainBuffer());
((TestInputChannel) gate.getChannel(0)).read(dataBuffer());
assertBarrier(gate);
getChannel(gate, 1).onBuffer(dataBuffer(), 0, 0);
getChannel(gate, 1).onBuffer(checkpointBarrier.retainBuffer(), 1, 0);
assertEquals(0, target.getTriggeredCheckpointCounter());
clock.advanceTimeWithoutRunningCallables(alignmentTimeout + 1, TimeUnit.MILLISECONDS);
// the announcement should passively time out causing the barriers to overtake the data
// buffers
assertAnnouncement(gate);
// we simulate active time out firing after the passive one
clock.executeCallables();
assertBarrier(gate);
assertEquals(1, target.getTriggeredCheckpointCounter());
assertThat(target.getTriggeredCheckpointOptions(), contains(unaligned(CheckpointType.CHECKPOINT, getDefault())));
// Followed by overtaken buffers
assertData(gate);
assertData(gate);
}
}
use of org.apache.flink.runtime.io.network.partition.consumer.TestInputChannel in project flink by apache.
the class TestCheckpointedInputGateBuilder method buildTestGate.
private SingleInputGate buildTestGate() {
SingleInputGate gate = new SingleInputGateBuilder().setNumberOfChannels(numChannels).build();
TestInputChannel[] channels = new TestInputChannel[numChannels];
for (int i = 0; i < numChannels; i++) {
channels[i] = new TestInputChannel(gate, i, false, true);
}
gate.setInputChannels(channels);
return gate;
}
Aggregations