Class PipelinedSubpartition
- java.lang.Object
-
- org.apache.flink.runtime.io.network.partition.ResultSubpartition
-
- org.apache.flink.runtime.io.network.partition.PipelinedSubpartition
-
- All Implemented Interfaces:
ChannelStateHolder
- Direct Known Subclasses:
PipelinedApproximateSubpartition
public class PipelinedSubpartition extends ResultSubpartition implements ChannelStateHolder
A pipelined in-memory only subpartition, which can be consumed once.Whenever
ResultSubpartition.add(BufferConsumer)adds a finishedBufferConsumeror a secondBufferConsumer(in which case we will assume the first one finished), we willnotifya read view created viaResultSubpartition.createReadView(BufferAvailabilityListener)of new data availability. Except by callingflush()explicitly, we always only notify when the first finished buffer turns up and then, the reader has to drain the buffers viapollBuffer()until its return value shows no more buffers being available. This results in a buffer queue which is either empty or has an unfinishedBufferConsumerleft from which the notifications will eventually start again.Explicit calls to
flush()will force thisnotificationfor anyBufferConsumerpresent in the queue.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.flink.runtime.io.network.partition.ResultSubpartition
ResultSubpartition.BufferAndBacklog
-
-
Field Summary
-
Fields inherited from class org.apache.flink.runtime.io.network.partition.ResultSubpartition
ADD_BUFFER_ERROR_CODE, parent, subpartitionInfo
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidabortCheckpoint(long checkpointId, CheckpointException cause)voidacknowledgeAllDataProcessed()intadd(BufferConsumer bufferConsumer, int partialRecordLength)Adds the given buffer.voidalignedBarrierTimeout(long checkpointId)voidbufferSize(int desirableNewBufferSize)PipelinedSubpartitionViewcreateReadView(BufferAvailabilityListener availabilityListener)intfinish()Writing of data is finished.voidflush()ResultSubpartitionView.AvailabilityWithBackloggetAvailabilityAndBacklog(boolean isCreditAvailable)intgetBuffersInBacklogUnsafe()Gets the number of non-event buffers in this subpartition.longgetChannelStateCheckpointId()intgetNumberOfQueuedBuffers()Get the current size of the queue.protected longgetTotalNumberOfBuffersUnsafe()Gets the total numbers of buffers (data buffers plus events).protected longgetTotalNumberOfBytesUnsafe()booleanisReleased()booleanisSupportChannelStateRecover()voidrelease()voidsetChannelStateWriter(ChannelStateWriter channelStateWriter)Injects theChannelStateWriter.StringtoString()intunsynchronizedGetNumberOfQueuedBuffers()Makes a best effort to get the current size of the queue.-
Methods inherited from class org.apache.flink.runtime.io.network.partition.ResultSubpartition
add, getSubPartitionIndex, getSubpartitionInfo, onConsumedSubpartition
-
-
-
-
Method Detail
-
setChannelStateWriter
public void setChannelStateWriter(ChannelStateWriter channelStateWriter)
Description copied from interface:ChannelStateHolderInjects theChannelStateWriter. Must only be called once.- Specified by:
setChannelStateWriterin interfaceChannelStateHolder
-
add
public int add(BufferConsumer bufferConsumer, int partialRecordLength)
Description copied from class:ResultSubpartitionAdds the given buffer.The request may be executed synchronously, or asynchronously, depending on the implementation.
IMPORTANT: Before adding new
BufferConsumerpreviously added must be in finished state. Because of the performance reasons, this is only enforced during the data reading. Priority events can be added while the previous buffer consumer is still open, in which case the open buffer consumer is overtaken.- Specified by:
addin classResultSubpartition- Parameters:
bufferConsumer- the buffer to add (transferring ownership to this writer)partialRecordLength- the length of bytes to skip in order to start with a complete record, from position index 0 of the underlying .- Returns:
- the preferable buffer size for this subpartition or
ResultSubpartition.ADD_BUFFER_ERROR_CODEif the add operation fails.
-
isSupportChannelStateRecover
public boolean isSupportChannelStateRecover()
-
finish
public int finish() throws IOExceptionDescription copied from class:ResultSubpartitionWriting of data is finished.- Specified by:
finishin classResultSubpartition- Returns:
- the size of data written for this subpartition inside of finish.
- Throws:
IOException
-
alignedBarrierTimeout
public void alignedBarrierTimeout(long checkpointId) throws IOException- Specified by:
alignedBarrierTimeoutin classResultSubpartition- Throws:
IOException
-
abortCheckpoint
public void abortCheckpoint(long checkpointId, CheckpointException cause)- Specified by:
abortCheckpointin classResultSubpartition
-
release
public void release()
- Specified by:
releasein classResultSubpartition
-
acknowledgeAllDataProcessed
public void acknowledgeAllDataProcessed()
-
isReleased
public boolean isReleased()
- Specified by:
isReleasedin classResultSubpartition
-
createReadView
public PipelinedSubpartitionView createReadView(BufferAvailabilityListener availabilityListener)
- Specified by:
createReadViewin classResultSubpartition
-
getAvailabilityAndBacklog
public ResultSubpartitionView.AvailabilityWithBacklog getAvailabilityAndBacklog(boolean isCreditAvailable)
-
getNumberOfQueuedBuffers
public int getNumberOfQueuedBuffers()
Description copied from class:ResultSubpartitionGet the current size of the queue.- Specified by:
getNumberOfQueuedBuffersin classResultSubpartition
-
bufferSize
public void bufferSize(int desirableNewBufferSize)
- Specified by:
bufferSizein classResultSubpartition
-
unsynchronizedGetNumberOfQueuedBuffers
public int unsynchronizedGetNumberOfQueuedBuffers()
Description copied from class:ResultSubpartitionMakes a best effort to get the current size of the queue. This method must not acquire locks or interfere with the task and network threads in any way.- Specified by:
unsynchronizedGetNumberOfQueuedBuffersin classResultSubpartition
-
flush
public void flush()
- Specified by:
flushin classResultSubpartition
-
getTotalNumberOfBuffersUnsafe
protected long getTotalNumberOfBuffersUnsafe()
Description copied from class:ResultSubpartitionGets the total numbers of buffers (data buffers plus events).- Specified by:
getTotalNumberOfBuffersUnsafein classResultSubpartition
-
getTotalNumberOfBytesUnsafe
protected long getTotalNumberOfBytesUnsafe()
- Specified by:
getTotalNumberOfBytesUnsafein classResultSubpartition
-
getBuffersInBacklogUnsafe
public int getBuffersInBacklogUnsafe()
Gets the number of non-event buffers in this subpartition.
-
getChannelStateCheckpointId
@VisibleForTesting public long getChannelStateCheckpointId()
-
-