private static BufferOrEvent generateAndWriteEvent(FileChannel fileChannel, Random rnd, int numberOfChannels) throws IOException { long magicNumber = rnd.nextLong(); byte[] data = new byte[rnd.nextInt(1000)]; rnd.nextBytes(data); TestEvent evt = new TestEvent(magicNumber, data); int channelIndex = rnd.nextInt(numberOfChannels); ByteBuffer serializedEvent = EventSerializer.toSerializedEvent(evt); ByteBuffer header = ByteBuffer.allocate(9); header.order(ByteOrder.LITTLE_ENDIAN); header.putInt(channelIndex); header.putInt(serializedEvent.remaining()); header.put((byte) 1); header.flip(); FileUtils.writeCompletely(fileChannel, header); FileUtils.writeCompletely(fileChannel, serializedEvent); return new BufferOrEvent(evt, channelIndex); }
AbstractEvent evt = EventSerializer.fromSerializedEvent(buffer, getClass().getClassLoader()); buffer.limit(oldLimit);
return Optional.of(new BufferAndAvailability(EventSerializer.toBuffer(EndOfPartitionEvent.INSTANCE), moreAvailable, 0)); } else if (input != null && input.isStreamRecord()) { Object inputElement = input.getStreamRecord(); } else if (input != null && input.isEvent()) { AbstractEvent event = input.getEvent(); return Optional.of(new BufferAndAvailability(EventSerializer.toBuffer(event), moreAvailable, 0)); } else { return Optional.empty();
private boolean isEndOfPartitionEvent(Buffer buffer) throws IOException { return EventSerializer.isEvent(buffer, EndOfPartitionEvent.class); }
@Override public void finish() throws IOException { add(EventSerializer.toBufferConsumer(EndOfPartitionEvent.INSTANCE), true); LOG.debug("Finished {}.", this); }
final AbstractEvent event = EventSerializer.fromBuffer(buffer, getClass().getClassLoader());
return serializeCheckpointBarrier((CheckpointBarrier) event);
private boolean isEndOfPartitionEvent(Buffer buffer) throws IOException { return EventSerializer.isEvent(buffer, EndOfPartitionEvent.class); }
@Override public void finish() throws IOException { add(EventSerializer.toBufferConsumer(EndOfPartitionEvent.INSTANCE), true); LOG.debug("{}: Finished {}.", parent.getOwningTaskName(), this); }
final AbstractEvent event = EventSerializer.fromBuffer(buffer, getClass().getClassLoader());
return serializeCheckpointBarrier((CheckpointBarrier) event);
contents = EventSerializer.toSerializedEvent(boe.getEvent());
public static AbstractEvent fromBuffer(Buffer buffer, ClassLoader classLoader) throws IOException { return fromSerializedEvent(buffer.getNioBufferReadable(), classLoader); }
private void sendEventToSync(WorkerDoneEvent event) throws IOException, InterruptedException { if (log.isInfoEnabled()) { log.info(formatLogString("sending " + WorkerDoneEvent.class.getSimpleName() + " to sync")); } this.toSync.writeBufferToAllChannels(EventSerializer.toBuffer(event)); } }
private boolean isEndOfPartitionEvent(Buffer buffer) throws IOException { return EventSerializer.isEvent(buffer, EndOfPartitionEvent.class); }
@Override public void finish() throws IOException { add(EventSerializer.toBufferConsumer(EndOfPartitionEvent.INSTANCE), true); LOG.debug("{}: Finished {}.", parent.getOwningTaskName(), this); }
final AbstractEvent event = EventSerializer.fromBuffer(buffer, getClass().getClassLoader());
return serializeCheckpointBarrier((CheckpointBarrier) event);