Class ResultSubpartition
- java.lang.Object
-
- org.apache.flink.runtime.io.network.partition.ResultSubpartition
-
- Direct Known Subclasses:
PipelinedSubpartition
public abstract class ResultSubpartition extends Object
A single subpartition of aResultPartitioninstance.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classResultSubpartition.BufferAndBacklogA combination of aBufferand the backlog length indicating how many non-event buffers are available in the subpartition.
-
Field Summary
Fields Modifier and Type Field Description static intADD_BUFFER_ERROR_CODEprotected ResultPartitionparentThe parent partition this subpartition belongs to.protected ResultSubpartitionInfosubpartitionInfoThe info of the subpartition to identify it globally within a task.
-
Constructor Summary
Constructors Constructor Description ResultSubpartition(int index, ResultPartition parent)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract voidabortCheckpoint(long checkpointId, CheckpointException cause)intadd(BufferConsumer bufferConsumer)abstract intadd(BufferConsumer bufferConsumer, int partialRecordLength)Adds the given buffer.abstract voidalignedBarrierTimeout(long checkpointId)abstract voidbufferSize(int desirableNewBufferSize)abstract ResultSubpartitionViewcreateReadView(BufferAvailabilityListener availabilityListener)abstract intfinish()Writing of data is finished.abstract voidflush()abstract intgetNumberOfQueuedBuffers()Get the current size of the queue.intgetSubPartitionIndex()ResultSubpartitionInfogetSubpartitionInfo()protected abstract longgetTotalNumberOfBuffersUnsafe()Gets the total numbers of buffers (data buffers plus events).protected abstract longgetTotalNumberOfBytesUnsafe()abstract booleanisReleased()protected voidonConsumedSubpartition()Notifies the parent partition about a consumedResultSubpartitionView.abstract voidrelease()abstract intunsynchronizedGetNumberOfQueuedBuffers()Makes a best effort to get the current size of the queue.
-
-
-
Field Detail
-
ADD_BUFFER_ERROR_CODE
public static final int ADD_BUFFER_ERROR_CODE
- See Also:
- Constant Field Values
-
subpartitionInfo
protected final ResultSubpartitionInfo subpartitionInfo
The info of the subpartition to identify it globally within a task.
-
parent
protected final ResultPartition parent
The parent partition this subpartition belongs to.
-
-
Constructor Detail
-
ResultSubpartition
public ResultSubpartition(int index, ResultPartition parent)
-
-
Method Detail
-
getSubpartitionInfo
public ResultSubpartitionInfo getSubpartitionInfo()
-
getTotalNumberOfBuffersUnsafe
protected abstract long getTotalNumberOfBuffersUnsafe()
Gets the total numbers of buffers (data buffers plus events).
-
getTotalNumberOfBytesUnsafe
protected abstract long getTotalNumberOfBytesUnsafe()
-
getSubPartitionIndex
public int getSubPartitionIndex()
-
onConsumedSubpartition
protected void onConsumedSubpartition()
Notifies the parent partition about a consumedResultSubpartitionView.
-
alignedBarrierTimeout
public abstract void alignedBarrierTimeout(long checkpointId) throws IOException- Throws:
IOException
-
abortCheckpoint
public abstract void abortCheckpoint(long checkpointId, CheckpointException cause)
-
add
@VisibleForTesting public final int add(BufferConsumer bufferConsumer) throws IOException
- Throws:
IOException
-
add
public abstract int add(BufferConsumer bufferConsumer, int partialRecordLength) throws IOException
Adds 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.- 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
ADD_BUFFER_ERROR_CODEif the add operation fails. - Throws:
IOException- thrown in case of errors while adding the buffer
-
flush
public abstract void flush()
-
finish
public abstract int finish() throws IOExceptionWriting of data is finished.- Returns:
- the size of data written for this subpartition inside of finish.
- Throws:
IOException
-
release
public abstract void release() throws IOException- Throws:
IOException
-
createReadView
public abstract ResultSubpartitionView createReadView(BufferAvailabilityListener availabilityListener) throws IOException
- Throws:
IOException
-
isReleased
public abstract boolean isReleased()
-
unsynchronizedGetNumberOfQueuedBuffers
public abstract int unsynchronizedGetNumberOfQueuedBuffers()
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.
-
getNumberOfQueuedBuffers
public abstract int getNumberOfQueuedBuffers()
Get the current size of the queue.
-
bufferSize
public abstract void bufferSize(int desirableNewBufferSize)
-
-