use of org.apache.flink.runtime.io.network.partition.consumer.EndOfChannelStateEvent 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();
}
}
Aggregations