use of org.apache.flink.runtime.io.network.api.EndOfPartitionEvent in project flink by apache.
the class EventSerializerTest method testIsEventPeakOnly.
/**
* Tests {@link EventSerializer#isEvent(Buffer, Class, ClassLoader)}
* whether it peaks into the buffer only, i.e. after the call, the buffer
* is still de-serializable.
*
* @throws Exception
*/
@Test
public void testIsEventPeakOnly() throws Exception {
final Buffer serializedEvent = EventSerializer.toBuffer(EndOfPartitionEvent.INSTANCE);
try {
final ClassLoader cl = getClass().getClassLoader();
assertTrue(EventSerializer.isEvent(serializedEvent, EndOfPartitionEvent.class, cl));
EndOfPartitionEvent event = (EndOfPartitionEvent) EventSerializer.fromBuffer(serializedEvent, cl);
assertEquals(EndOfPartitionEvent.INSTANCE, event);
} finally {
serializedEvent.recycle();
}
}
use of org.apache.flink.runtime.io.network.api.EndOfPartitionEvent in project flink by apache.
the class MockInputGate method getNextBufferOrEvent.
@Override
public BufferOrEvent getNextBufferOrEvent() {
BufferOrEvent next = boes.poll();
if (next == null) {
return null;
}
int channelIdx = next.getChannelIndex();
if (closed[channelIdx]) {
throw new RuntimeException("Inconsistent: Channel " + channelIdx + " has data even though it is already closed.");
}
if (next.isEvent() && next.getEvent() instanceof EndOfPartitionEvent) {
closed[channelIdx] = true;
closedChannels++;
}
return next;
}
Aggregations