use of org.apache.flink.streaming.util.TestCheckpointedInputGateBuilder 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.streaming.util.TestCheckpointedInputGateBuilder in project flink by apache.
the class AlternatingCheckpointsTest method testActiveTimeoutAfterBarrierPassiveTimeout.
@Test
public void testActiveTimeoutAfterBarrierPassiveTimeout() throws Exception {
int numChannels = 2;
ValidatingCheckpointHandler target = new ValidatingCheckpointHandler();
try (CheckpointedInputGate gate = new TestCheckpointedInputGateBuilder(numChannels, getTestBarrierHandlerFactory(target)).withRemoteChannels().withMailboxExecutor().build()) {
long alignmentTimeout = 10;
Buffer checkpointBarrier = withTimeout(alignmentTimeout);
getChannel(gate, 0).onBuffer(dataBuffer(), 0, 0);
getChannel(gate, 0).onBuffer(dataBuffer(), 1, 0);
getChannel(gate, 0).onBuffer(checkpointBarrier.retainBuffer(), 2, 0);
assertEquals(0, target.getTriggeredCheckpointCounter());
assertAnnouncement(gate);
// we simulate active time out firing after the passive one
assertData(gate);
assertData(gate);
clock.advanceTimeWithoutRunningCallables(alignmentTimeout + 1, TimeUnit.MILLISECONDS);
// the first barrier should passively time out causing the second barrier to overtake
// the remaining data buffer
assertBarrier(gate);
clock.executeCallables();
getChannel(gate, 1).onBuffer(dataBuffer(), 0, 0);
getChannel(gate, 1).onBuffer(checkpointBarrier.retainBuffer(), 1, 0);
assertAnnouncement(gate);
assertBarrier(gate);
assertEquals(1, target.getTriggeredCheckpointCounter());
assertThat(target.getTriggeredCheckpointOptions(), contains(unaligned(CheckpointType.CHECKPOINT, getDefault())));
// Followed by overtaken buffers
assertData(gate);
}
}
Aggregations