Class BufferWritingResultPartition
java.lang.Object
org.apache.flink.runtime.io.network.partition.ResultPartition
org.apache.flink.runtime.io.network.partition.BufferWritingResultPartition
- All Implemented Interfaces:
AutoCloseable,AvailabilityProvider,ResultPartitionWriter
- Direct Known Subclasses:
BoundedBlockingResultPartition,PipelinedResultPartition
A
ResultPartition which writes buffers directly to ResultSubpartitions. This is
in contrast to implementations where records are written to a joint structure, from which the
subpartitions draw the data after the write phase is finished, for example the sort-based
partitioning.
To avoid confusion: On the read side, all subpartitions return buffers (and backlog) to be transported through the network.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.flink.runtime.io.AvailabilityProvider
AvailabilityProvider.AvailabilityHelper -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ResultSubpartition[]The subpartitions of this partition.Fields inherited from class org.apache.flink.runtime.io.network.partition.ResultPartition
bufferCompressor, bufferPool, LOG, numBuffersOut, numBytesOut, numSubpartitions, partitionId, partitionManager, partitionType, resultPartitionBytesFields inherited from interface org.apache.flink.runtime.io.AvailabilityProvider
AVAILABLE -
Constructor Summary
ConstructorsConstructorDescriptionBufferWritingResultPartition(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
Modifier and TypeMethodDescriptionvoidabortCheckpoint(long checkpointId, CheckpointException cause) Abort the checkpoint.protected intaddToSubpartition(int targetSubpartition, BufferConsumer bufferConsumer, int partialRecordLength) voidalignedBarrierTimeout(long checkpointId) Timeout the aligned barrier to unaligned barrier.voidbroadcastEvent(AbstractEvent event, boolean isPriorityEvent) Writes the givenAbstractEventto all subpartitions.voidbroadcastRecord(ByteBuffer record) Writes the given serialized record to all subpartitions.voidclose()Closes the partition writer which releases the allocated resource, for example the buffer pool.protected ResultSubpartitionViewcreateSubpartitionView(int subpartitionIndex, BufferAvailabilityListener availabilityListener) Returns a reader for the subpartition with the given index.voidemitRecord(ByteBuffer record, int targetSubpartition) Writes the given serialized record to the target subpartition.voidfinish()Finishes the result partition.protected voidflushAllSubpartitions(boolean finishProducers) protected voidflushSubpartition(int targetSubpartition, boolean finishProducers) intReturns the total number of queued buffers of all subpartitions.intgetNumberOfQueuedBuffers(int targetSubpartition) Returns the number of queued buffers of the given target subpartition.longReturns the total size in bytes of queued buffers of all subpartitions.protected voidReleases all produced data including both those stored in memory and persisted on disk.voidsetMetricGroup(TaskIOMetricGroup metrics) Sets the metric group for theResultPartitionWriter.protected voidDo the subclass's own setup operation.Methods inherited from class org.apache.flink.runtime.io.network.partition.ResultPartition
canBeCompressed, checkInProduceState, createSubpartitionView, fail, getAllDataProcessedFuture, getAvailableFuture, getBufferPool, getFailureCause, getNumberOfSubpartitions, getNumTargetKeyGroups, getOwningTaskName, getPartitionId, getPartitionIndex, getPartitionManager, getPartitionType, getResultPartitionBytes, isFinished, isNumberOfPartitionConsumerUndefined, isNumberOfPartitionConsumerUndefined, isReleased, notifyEndOfData, onSubpartitionAllDataProcessed, release, release, setMaxOverdraftBuffersPerGate, setup, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.flink.runtime.io.AvailabilityProvider
isApproximatelyAvailable, isAvailableMethods inherited from interface org.apache.flink.runtime.io.network.api.writer.ResultPartitionWriter
flush, flushAll
-
Field Details
-
subpartitions
The subpartitions of this partition. At least one.
-
-
Constructor Details
-
BufferWritingResultPartition
public BufferWritingResultPartition(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 Details
-
setupInternal
Description copied from class:ResultPartitionDo the subclass's own setup operation.- Specified by:
setupInternalin classResultPartition- Throws:
IOException
-
getNumberOfQueuedBuffers
public int getNumberOfQueuedBuffers()Description copied from class:ResultPartitionReturns the total number of queued buffers of all subpartitions.- Specified by:
getNumberOfQueuedBuffersin classResultPartition
-
getSizeOfQueuedBuffersUnsafe
public long getSizeOfQueuedBuffersUnsafe()Description copied from class:ResultPartitionReturns the total size in bytes of queued buffers of all subpartitions.- Specified by:
getSizeOfQueuedBuffersUnsafein classResultPartition
-
getNumberOfQueuedBuffers
public int getNumberOfQueuedBuffers(int targetSubpartition) Description copied from class:ResultPartitionReturns the number of queued buffers of the given target subpartition.- Specified by:
getNumberOfQueuedBuffersin classResultPartition
-
flushSubpartition
protected void flushSubpartition(int targetSubpartition, boolean finishProducers) -
flushAllSubpartitions
protected void flushAllSubpartitions(boolean finishProducers) -
emitRecord
Description copied from interface:ResultPartitionWriterWrites the given serialized record to the target subpartition.- Throws:
IOException
-
broadcastRecord
Description copied from interface:ResultPartitionWriterWrites the given serialized record to all subpartitions. One can also achieve the same effect by emitting the same record to all subpartitions one by one, however, this method can have better performance for the underlying implementation can do some optimizations, for example coping the given serialized record only once to a shared channel which can be consumed by all subpartitions.- Throws:
IOException
-
broadcastEvent
Description copied from interface:ResultPartitionWriterWrites the givenAbstractEventto all subpartitions.- Throws:
IOException
-
alignedBarrierTimeout
Description copied from interface:ResultPartitionWriterTimeout the aligned barrier to unaligned barrier.- Throws:
IOException
-
abortCheckpoint
Description copied from interface:ResultPartitionWriterAbort the checkpoint. -
setMetricGroup
Description copied from interface:ResultPartitionWriterSets the metric group for theResultPartitionWriter.- Specified by:
setMetricGroupin interfaceResultPartitionWriter- Overrides:
setMetricGroupin classResultPartition
-
createSubpartitionView
protected ResultSubpartitionView createSubpartitionView(int subpartitionIndex, BufferAvailabilityListener availabilityListener) throws IOException Description copied from class:ResultPartitionReturns a reader for the subpartition with the given index.Given that the function to merge outputs from multiple subpartition views is supported uniformly in
UnionResultSubpartitionView, subclasses ofResultPartitiononly needs to take care of creating subpartition view for a single subpartition.- Specified by:
createSubpartitionViewin classResultPartition- Throws:
IOException
-
finish
Description copied from class:ResultPartitionFinishes the result partition.After this operation, it is not possible to add further data to the result partition.
For BLOCKING results, this will trigger the deployment of consuming tasks.
- Specified by:
finishin interfaceResultPartitionWriter- Overrides:
finishin classResultPartition- Throws:
IOException
-
releaseInternal
protected void releaseInternal()Description copied from class:ResultPartitionReleases all produced data including both those stored in memory and persisted on disk.- Specified by:
releaseInternalin classResultPartition
-
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 classResultPartition
-
addToSubpartition
protected int addToSubpartition(int targetSubpartition, BufferConsumer bufferConsumer, int partialRecordLength) throws IOException - Throws:
IOException
-
getHardBackPressuredTimeMsPerSecond
-
getAllPartitions
-