Class PipelinedResultPartition
- java.lang.Object
-
- org.apache.flink.runtime.io.network.partition.ResultPartition
-
- org.apache.flink.runtime.io.network.partition.BufferWritingResultPartition
-
- org.apache.flink.runtime.io.network.partition.PipelinedResultPartition
-
- All Implemented Interfaces:
AutoCloseable,AvailabilityProvider,ResultPartitionWriter,ChannelStateHolder,CheckpointedResultPartition
public class PipelinedResultPartition extends BufferWritingResultPartition implements CheckpointedResultPartition, ChannelStateHolder
A result output of a task, pipelined (streamed) to the receivers.This result partition implementation is used both in batch and streaming. For streaming, it supports low latency transfers (ensure data is sent within x milliseconds) or unconstrained while for batch it transfers only once a buffer is full. Additionally, for streaming use this typically limits the length of the buffer backlog to not have too much data in flight, while for batch we do not constrain this.
Specifics of the PipelinedResultPartition
The PipelinedResultPartition cannot reconnect once a consumer disconnects (finished or errored). Once all consumers have disconnected (released the subpartition, notified via the call
onConsumedSubpartition(int)) then the partition as a whole is disposed and all buffers are freed.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.flink.runtime.io.AvailabilityProvider
AvailabilityProvider.AvailabilityHelper
-
-
Field Summary
-
Fields inherited from class org.apache.flink.runtime.io.network.partition.BufferWritingResultPartition
subpartitions
-
Fields inherited from class org.apache.flink.runtime.io.network.partition.ResultPartition
bufferCompressor, bufferPool, LOG, numBuffersOut, numBytesOut, numSubpartitions, partitionId, partitionManager, partitionType, resultPartitionBytes
-
Fields inherited from interface org.apache.flink.runtime.io.AvailabilityProvider
AVAILABLE
-
-
Constructor Summary
Constructors Constructor Description PipelinedResultPartition(String owningTaskName, int partitionIndex, ResultPartitionID partitionId, ResultPartitionType partitionType, ResultSubpartition[] subpartitions, int numTargetKeyGroups, ResultPartitionManager partitionManager, BufferCompressor bufferCompressor, org.apache.flink.util.function.SupplierWithException<BufferPool,IOException> bufferPoolFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddRecovered(int subpartitionIndex, BufferConsumer bufferConsumer)voidclose()Closes the partition writer which releases the allocated resource, for example the buffer pool.voidfinishReadRecoveredState(boolean notifyAndBlockOnCompletion)voidflush(int targetSubpartition)Manually trigger the consumption of data from the given subpartitions.voidflushAll()Manually trigger the consumption of data from all subpartitions.CompletableFuture<Void>getAllDataProcessedFuture()Gets the future indicating whether all the records has been processed by the downstream tasks.ResultSubpartitionInfogetCheckpointedSubpartitionInfo(int subpartitionIndex)Gets the checkpointed subpartition info with the given subpartitionIndex.voidnotifyEndOfData(StopMode mode)Notifies the downstream tasks that thisResultPartitionWriterhave emitted all the user records.voidonSubpartitionAllDataProcessed(int subpartition)The subpartition notifies that the corresponding downstream task have processed all the user records.BufferBuilderrequestBufferBuilderBlocking()voidsetChannelStateWriter(ChannelStateWriter channelStateWriter)Injects theChannelStateWriter.StringtoString()-
Methods inherited from class org.apache.flink.runtime.io.network.partition.BufferWritingResultPartition
abortCheckpoint, addToSubpartition, alignedBarrierTimeout, broadcastEvent, broadcastRecord, createSubpartitionView, emitRecord, finish, flushAllSubpartitions, flushSubpartition, getAllPartitions, getHardBackPressuredTimeMsPerSecond, getNumberOfQueuedBuffers, getNumberOfQueuedBuffers, getSizeOfQueuedBuffersUnsafe, releaseInternal, setMetricGroup, setupInternal
-
Methods inherited from class org.apache.flink.runtime.io.network.partition.ResultPartition
canBeCompressed, checkInProduceState, createSubpartitionView, fail, getAvailableFuture, getBufferPool, getFailureCause, getNumberOfSubpartitions, getNumTargetKeyGroups, getOwningTaskName, getPartitionId, getPartitionIndex, getPartitionManager, getPartitionType, getResultPartitionBytes, isFinished, isNumberOfPartitionConsumerUndefined, isNumberOfPartitionConsumerUndefined, isReleased, release, release, setMaxOverdraftBuffersPerGate, setup
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.flink.runtime.io.AvailabilityProvider
isApproximatelyAvailable, isAvailable
-
-
-
-
Constructor Detail
-
PipelinedResultPartition
public PipelinedResultPartition(String owningTaskName, int partitionIndex, ResultPartitionID partitionId, ResultPartitionType partitionType, ResultSubpartition[] subpartitions, int numTargetKeyGroups, ResultPartitionManager partitionManager, @Nullable BufferCompressor bufferCompressor, org.apache.flink.util.function.SupplierWithException<BufferPool,IOException> bufferPoolFactory)
-
-
Method Detail
-
setChannelStateWriter
public void setChannelStateWriter(ChannelStateWriter channelStateWriter)
Description copied from interface:ChannelStateHolderInjects theChannelStateWriter. Must only be called once.- Specified by:
setChannelStateWriterin interfaceChannelStateHolder
-
getCheckpointedSubpartitionInfo
public ResultSubpartitionInfo getCheckpointedSubpartitionInfo(int subpartitionIndex)
Description copied from interface:CheckpointedResultPartitionGets the checkpointed subpartition info with the given subpartitionIndex.- Specified by:
getCheckpointedSubpartitionInfoin interfaceCheckpointedResultPartition
-
flushAll
public void flushAll()
Description copied from interface:ResultPartitionWriterManually trigger the consumption of data from all subpartitions.- Specified by:
flushAllin interfaceResultPartitionWriter
-
flush
public void flush(int targetSubpartition)
Description copied from interface:ResultPartitionWriterManually trigger the consumption of data from the given subpartitions.- Specified by:
flushin interfaceResultPartitionWriter
-
notifyEndOfData
public void notifyEndOfData(StopMode mode) throws IOException
Description copied from interface:ResultPartitionWriterNotifies the downstream tasks that thisResultPartitionWriterhave emitted all the user records.- Specified by:
notifyEndOfDatain interfaceResultPartitionWriter- Overrides:
notifyEndOfDatain classResultPartition- Parameters:
mode- tells if we should flush all records or not (it is false in case of stop-with-savepoint (--no-drain))- Throws:
IOException
-
getAllDataProcessedFuture
public CompletableFuture<Void> getAllDataProcessedFuture()
Description copied from interface:ResultPartitionWriterGets the future indicating whether all the records has been processed by the downstream tasks.- Specified by:
getAllDataProcessedFuturein interfaceResultPartitionWriter- Overrides:
getAllDataProcessedFuturein classResultPartition
-
onSubpartitionAllDataProcessed
public void onSubpartitionAllDataProcessed(int subpartition)
Description copied from class:ResultPartitionThe subpartition notifies that the corresponding downstream task have processed all the user records.- Overrides:
onSubpartitionAllDataProcessedin classResultPartition- Parameters:
subpartition- The index of the subpartition sending the notification.- See Also:
EndOfData
-
toString
public String toString()
- Overrides:
toStringin classResultPartition
-
finishReadRecoveredState
public void finishReadRecoveredState(boolean notifyAndBlockOnCompletion) throws IOException- Specified by:
finishReadRecoveredStatein interfaceCheckpointedResultPartition- Throws:
IOException
-
requestBufferBuilderBlocking
public BufferBuilder requestBufferBuilderBlocking() throws IOException, RuntimeException, InterruptedException
- Specified by:
requestBufferBuilderBlockingin interfaceCheckpointedResultPartition- Throws:
IOExceptionRuntimeExceptionInterruptedException
-
addRecovered
public void addRecovered(int subpartitionIndex, BufferConsumer bufferConsumer) throws IOException- Specified by:
addRecoveredin interfaceCheckpointedResultPartition- Throws:
IOException
-
close
public void close()
Description copied from interface:ResultPartitionWriterCloses the partition writer which releases the allocated resource, for example the buffer pool.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceResultPartitionWriter- Overrides:
closein classBufferWritingResultPartition
-
-