use of org.apache.flink.streaming.util.TestCheckpointedInputGateBuilder in project flink by apache.
the class AlternatingCheckpointsTest method testNextFirstCheckpointBarrierOvertakesCancellationBarrier.
@Test
public void testNextFirstCheckpointBarrierOvertakesCancellationBarrier() throws Exception {
int numberOfChannels = 2;
ValidatingCheckpointHandler target = new ValidatingCheckpointHandler();
CheckpointedInputGate gate = new TestCheckpointedInputGateBuilder(numberOfChannels, getTestBarrierHandlerFactory(target)).withTestChannels().withSyncExecutor().build();
long alignmentTimeout = 10000;
Buffer checkpointBarrier = withTimeout(alignmentTimeout);
send(checkpointBarrier, 0, gate);
clock.advanceTime(Duration.ofSeconds(1));
send(withTimeout(2, alignmentTimeout), 0, gate);
clock.advanceTime(Duration.ofSeconds(1));
send(toBuffer(new CancelCheckpointMarker(1L), true), 1, gate);
clock.advanceTime(Duration.ofSeconds(1));
send(withTimeout(2, alignmentTimeout), 1, gate);
clock.advanceTime(Duration.ofSeconds(1));
assertEquals(Duration.ofSeconds(2).toNanos(), target.lastAlignmentDurationNanos.get().longValue());
}
use of org.apache.flink.streaming.util.TestCheckpointedInputGateBuilder in project flink by apache.
the class AlternatingCheckpointsTest method testActiveTimeoutBeforeFirstAnnouncementPassiveTimeout.
@Test
public void testActiveTimeoutBeforeFirstAnnouncementPassiveTimeout() throws Exception {
// given: Two barriers from two channels.
int numChannels = 2;
ValidatingCheckpointHandler target = new ValidatingCheckpointHandler();
try (CheckpointedInputGate gate = new TestCheckpointedInputGateBuilder(numChannels, getTestBarrierHandlerFactory(target)).withRemoteChannels().withMailboxExecutor().build()) {
long alignmentCheckpointTimeout = 10;
Buffer checkpointBarrier = withTimeout(alignmentCheckpointTimeout);
getChannel(gate, 0).onBuffer(dataBuffer(), 0, 0);
getChannel(gate, 0).onBuffer(checkpointBarrier.retainBuffer(), 1, 0);
getChannel(gate, 1).onBuffer(dataBuffer(), 0, 0);
getChannel(gate, 1).onBuffer(checkpointBarrier.retainBuffer(), 1, 0);
assertEquals(0, target.getTriggeredCheckpointCounter());
// when: The receiving of the first announcement is delayed on more than alignment
// checkpoint timeout.
clock.advanceTimeWithoutRunningCallables(alignmentCheckpointTimeout + 1, TimeUnit.MILLISECONDS);
assertAnnouncement(gate);
// we simulate active time out firing after the passive one
clock.executeCallables();
// then: Barriers should be reprioritized and the UC should be triggered.
assertAnnouncement(gate);
assertBarrier(gate);
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 testActiveTimeoutAlignmentOnFirstBarrier.
@Test
public void testActiveTimeoutAlignmentOnFirstBarrier() throws Exception {
int numberOfChannels = 2;
ValidatingCheckpointHandler target = new ValidatingCheckpointHandler();
CheckpointedInputGate gate = new TestCheckpointedInputGateBuilder(numberOfChannels, getTestBarrierHandlerFactory(target)).withRemoteChannels().withSyncExecutor().build();
long alignmentTimeout = 100;
Buffer checkpointBarrier = withTimeout(alignmentTimeout);
send(checkpointBarrier, 0, gate);
clock.advanceTime(alignmentTimeout + 1, TimeUnit.MILLISECONDS);
assertThat(target.getTriggeredCheckpointOptions(), contains(unaligned(CheckpointType.CHECKPOINT, getDefault())));
}
use of org.apache.flink.streaming.util.TestCheckpointedInputGateBuilder in project flink by apache.
the class AlternatingCheckpointsTest method testNoActiveTimeoutAlignmentAfterLastBarrier.
@Test
public void testNoActiveTimeoutAlignmentAfterLastBarrier() throws Exception {
int numberOfChannels = 2;
ValidatingCheckpointHandler target = new ValidatingCheckpointHandler();
CheckpointedInputGate gate = new TestCheckpointedInputGateBuilder(numberOfChannels, getTestBarrierHandlerFactory(target)).withTestChannels().withSyncExecutor().build();
long alignmentTimeout = 100;
Buffer checkpointBarrier = withTimeout(alignmentTimeout);
send(checkpointBarrier, 0, gate);
send(checkpointBarrier, 1, gate);
clock.advanceTime(alignmentTimeout + 1, TimeUnit.MILLISECONDS);
assertThat(target.getTriggeredCheckpointOptions(), not(contains(unaligned(CheckpointType.CHECKPOINT, getDefault()))));
}
use of org.apache.flink.streaming.util.TestCheckpointedInputGateBuilder in project flink by apache.
the class AlternatingCheckpointsTest method testAllChannelsUnblockedAfterAlignmentTimeout.
@Test
public void testAllChannelsUnblockedAfterAlignmentTimeout() throws Exception {
int numberOfChannels = 2;
ValidatingCheckpointHandler target = new ValidatingCheckpointHandler();
CheckpointedInputGate gate = new TestCheckpointedInputGateBuilder(numberOfChannels, getTestBarrierHandlerFactory(target)).withTestChannels().withSyncExecutor().build();
long alignmentTimeout = 100;
CheckpointBarrier checkpointBarrier = new CheckpointBarrier(1, clock.relativeTimeMillis(), alignedWithTimeout(CheckpointType.CHECKPOINT, getDefault(), alignmentTimeout));
Buffer checkpointBarrierBuffer = toBuffer(checkpointBarrier, false);
// we set timer on announcement and test channels do not produce announcements by themselves
send(EventSerializer.toBuffer(new EventAnnouncement(checkpointBarrier, 0), true), 0, gate);
// emulate blocking channels on aligned barriers
((TestInputChannel) gate.getChannel(0)).setBlocked(true);
send(checkpointBarrierBuffer, 0, gate);
clock.advanceTime(alignmentTimeout + 1, TimeUnit.MILLISECONDS);
send(EventSerializer.toBuffer(new EventAnnouncement(checkpointBarrier, 0), true), 1, gate);
// emulate blocking channels on aligned barriers
((TestInputChannel) gate.getChannel(1)).setBlocked(true);
send(checkpointBarrierBuffer, 1, gate);
assertThat(target.getTriggeredCheckpointOptions().size(), equalTo(1));
assertThat(target.getTriggeredCheckpointOptions(), contains(unaligned(CheckpointType.CHECKPOINT, getDefault())));
assertFalse(((TestInputChannel) gate.getChannel(0)).isBlocked());
assertFalse(((TestInputChannel) gate.getChannel(1)).isBlocked());
}
Aggregations