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 finishedBufferConsumer
or a secondBufferConsumer
(in which case we will assume the first one finished), we willnotify
a 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 unfinishedBufferConsumer
left from which the notifications will eventually start again.Explicit calls to
flush()
will force thisnotification
for anyBufferConsumer
present 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 void
abortCheckpoint(long checkpointId, CheckpointException cause)
void
acknowledgeAllDataProcessed()
int
add(BufferConsumer bufferConsumer, int partialRecordLength)
Adds the given buffer.void
alignedBarrierTimeout(long checkpointId)
void
bufferSize(int desirableNewBufferSize)
PipelinedSubpartitionView
createReadView(BufferAvailabilityListener availabilityListener)
int
finish()
Writing of data is finished.void
flush()
ResultSubpartitionView.AvailabilityWithBacklog
getAvailabilityAndBacklog(boolean isCreditAvailable)
int
getBuffersInBacklogUnsafe()
Gets the number of non-event buffers in this subpartition.long
getChannelStateCheckpointId()
int
getNumberOfQueuedBuffers()
Get the current size of the queue.protected long
getTotalNumberOfBuffersUnsafe()
Gets the total numbers of buffers (data buffers plus events).protected long
getTotalNumberOfBytesUnsafe()
boolean
isReleased()
boolean
isSupportChannelStateRecover()
void
release()
void
setChannelStateWriter(ChannelStateWriter channelStateWriter)
Injects theChannelStateWriter
.String
toString()
int
unsynchronizedGetNumberOfQueuedBuffers()
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:ChannelStateHolder
Injects theChannelStateWriter
. Must only be called once.- Specified by:
setChannelStateWriter
in interfaceChannelStateHolder
-
add
public int add(BufferConsumer bufferConsumer, int partialRecordLength)
Description copied from class:ResultSubpartition
Adds the given buffer.The request may be executed synchronously, or asynchronously, depending on the implementation.
IMPORTANT: Before adding new
BufferConsumer
previously 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:
add
in 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_CODE
if the add operation fails.
-
isSupportChannelStateRecover
public boolean isSupportChannelStateRecover()
-
finish
public int finish() throws IOException
Description copied from class:ResultSubpartition
Writing of data is finished.- Specified by:
finish
in 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:
alignedBarrierTimeout
in classResultSubpartition
- Throws:
IOException
-
abortCheckpoint
public void abortCheckpoint(long checkpointId, CheckpointException cause)
- Specified by:
abortCheckpoint
in classResultSubpartition
-
release
public void release()
- Specified by:
release
in classResultSubpartition
-
acknowledgeAllDataProcessed
public void acknowledgeAllDataProcessed()
-
isReleased
public boolean isReleased()
- Specified by:
isReleased
in classResultSubpartition
-
createReadView
public PipelinedSubpartitionView createReadView(BufferAvailabilityListener availabilityListener)
- Specified by:
createReadView
in classResultSubpartition
-
getAvailabilityAndBacklog
public ResultSubpartitionView.AvailabilityWithBacklog getAvailabilityAndBacklog(boolean isCreditAvailable)
-
getNumberOfQueuedBuffers
public int getNumberOfQueuedBuffers()
Description copied from class:ResultSubpartition
Get the current size of the queue.- Specified by:
getNumberOfQueuedBuffers
in classResultSubpartition
-
bufferSize
public void bufferSize(int desirableNewBufferSize)
- Specified by:
bufferSize
in classResultSubpartition
-
unsynchronizedGetNumberOfQueuedBuffers
public int unsynchronizedGetNumberOfQueuedBuffers()
Description copied from class:ResultSubpartition
Makes 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:
unsynchronizedGetNumberOfQueuedBuffers
in classResultSubpartition
-
flush
public void flush()
- Specified by:
flush
in classResultSubpartition
-
getTotalNumberOfBuffersUnsafe
protected long getTotalNumberOfBuffersUnsafe()
Description copied from class:ResultSubpartition
Gets the total numbers of buffers (data buffers plus events).- Specified by:
getTotalNumberOfBuffersUnsafe
in classResultSubpartition
-
getTotalNumberOfBytesUnsafe
protected long getTotalNumberOfBytesUnsafe()
- Specified by:
getTotalNumberOfBytesUnsafe
in classResultSubpartition
-
getBuffersInBacklogUnsafe
public int getBuffersInBacklogUnsafe()
Gets the number of non-event buffers in this subpartition.
-
getChannelStateCheckpointId
@VisibleForTesting public long getChannelStateCheckpointId()
-
-