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 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)); } }
@Override public void finish() throws IOException { final Buffer buffer = EventSerializer.toBuffer(EndOfPartitionEvent.INSTANCE); // view reference accessible outside the lock, but assigned inside the locked scope final PipelinedSubpartitionView reader; synchronized (buffers) { if (isFinished || isReleased) { return; } buffers.add(buffer); reader = readView; updateStatistics(buffer); isFinished = true; } LOG.debug("Finished {}.", this); // Notify the listener outside of the synchronized block if (reader != null) { reader.notifyBuffersAvailable(1); } }
@Override public void finish() throws IOException { synchronized (buffers) { if (add(EventSerializer.toBuffer(EndOfPartitionEvent.INSTANCE))) { isFinished = true; } } // If we are spilling/have spilled, wait for the writer to finish if (spillWriter != null) { spillWriter.close(); } }
private void enqueueBuffer(Buffer buffer) throws IOException { synchronized (lock) { if (isReleased) { buffer.recycleBuffer(); return; } buffers.add(buffer); if (buffer.isBuffer()) { --currentCredit; totalReadLength += buffer.getSize(); } // If EOF is enqueued directly, the condition will fail and there will be no second EOF enqueued. if (totalReadLength == totalLength && totalLength != 0) { buffers.add(EventSerializer.toBuffer(EndOfPartitionEvent.INSTANCE)); } } listener.notifyDataAvailable(); }
public void broadcastEvent(AbstractEvent event) throws IOException, InterruptedException { final Buffer eventBuffer = EventSerializer.toBuffer(event); try { for (int targetChannel = 0; targetChannel < numChannels; targetChannel++) { RecordSerializer<T> serializer = serializers[targetChannel]; synchronized (serializer) { Buffer buffer = serializer.getCurrentBuffer(); if (buffer != null) { numBytesOut.inc(buffer.getSize()); writeAndClearBuffer(buffer, targetChannel, serializer); } else if (serializer.hasData()) { // sanity check throw new IllegalStateException("No buffer, but serializer has buffered data."); } // retain the buffer so that it can be recycled by each channel of targetPartition eventBuffer.retain(); targetPartition.writeBuffer(eventBuffer, targetChannel); } } } finally { // we do not need to further retain the eventBuffer // (it will be recycled after the last channel stops using it) eventBuffer.recycle(); } }
enqueueBuffer(EventSerializer.toBuffer(EndOfPartitionEvent.INSTANCE)); return;
output.writeBufferToAllChannels(EventSerializer.toBuffer(message)); } catch (Exception e) { exception = ExceptionUtils.firstOrSuppressed(