public abstract class BufferWritingResultPartition extends ResultPartition
ResultPartition
which writes buffers directly to ResultSubpartition
s. 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.
AvailabilityProvider.AvailabilityHelper
Modifier and Type | Field and Description |
---|---|
protected ResultSubpartition[] |
subpartitions
The subpartitions of this partition.
|
bufferCompressor, bufferPool, LOG, numBuffersOut, numBytesOut, numSubpartitions, partitionId, partitionManager, partitionType
AVAILABLE
Constructor and Description |
---|
BufferWritingResultPartition(String owningTaskName,
int partitionIndex,
ResultPartitionID partitionId,
ResultPartitionType partitionType,
ResultSubpartition[] subpartitions,
int numTargetKeyGroups,
ResultPartitionManager partitionManager,
BufferCompressor bufferCompressor,
SupplierWithException<BufferPool,IOException> bufferPoolFactory) |
Modifier and Type | Method and Description |
---|---|
void |
broadcastEvent(AbstractEvent event,
boolean isPriorityEvent)
Writes the given
AbstractEvent to all channels. |
void |
broadcastRecord(ByteBuffer record)
Writes the given serialized record to all subpartitions.
|
ResultSubpartitionView |
createSubpartitionView(int subpartitionIndex,
BufferAvailabilityListener availabilityListener)
Returns a reader for the subpartition with the given index.
|
void |
emitRecord(ByteBuffer record,
int targetSubpartition)
Writes the given serialized record to the target subpartition.
|
void |
finish()
Finishes the result partition.
|
protected void |
flushAllSubpartitions(boolean finishProducers) |
protected void |
flushSubpartition(int targetSubpartition,
boolean finishProducers) |
ResultSubpartition[] |
getAllPartitions() |
Meter |
getIdleTimeMsPerSecond() |
int |
getNumberOfQueuedBuffers()
Returns the total number of queued buffers of all subpartitions.
|
int |
getNumberOfQueuedBuffers(int targetSubpartition)
Returns the number of queued buffers of the given target subpartition.
|
protected void |
releaseInternal()
Releases all produced data including both those stored in memory and persisted on disk.
|
void |
setMetricGroup(TaskIOMetricGroup metrics)
Sets the metric group for the
ResultPartitionWriter . |
void |
setup()
Registers a buffer pool with this result partition.
|
canBeCompressed, checkInProduceState, close, fail, getAvailableFuture, getBufferPool, getFailureCause, getNumberOfSubpartitions, getNumTargetKeyGroups, getOwningTaskName, getPartitionId, getPartitionIndex, getPartitionManager, getPartitionType, isFinished, isReleased, release, release, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
flush, flushAll
and, isApproximatelyAvailable, isAvailable, or
protected final ResultSubpartition[] subpartitions
public BufferWritingResultPartition(String owningTaskName, int partitionIndex, ResultPartitionID partitionId, ResultPartitionType partitionType, ResultSubpartition[] subpartitions, int numTargetKeyGroups, ResultPartitionManager partitionManager, @Nullable BufferCompressor bufferCompressor, SupplierWithException<BufferPool,IOException> bufferPoolFactory)
public void setup() throws IOException
ResultPartition
There is one pool for each result partition, which is shared by all its sub partitions.
The pool is registered with the partition *after* it as been constructed in order to
conform to the life-cycle of task registrations in the TaskExecutor
.
setup
in interface ResultPartitionWriter
setup
in class ResultPartition
IOException
public int getNumberOfQueuedBuffers()
ResultPartition
getNumberOfQueuedBuffers
in class ResultPartition
public int getNumberOfQueuedBuffers(int targetSubpartition)
ResultPartition
getNumberOfQueuedBuffers
in class ResultPartition
protected void flushSubpartition(int targetSubpartition, boolean finishProducers)
protected void flushAllSubpartitions(boolean finishProducers)
public void emitRecord(ByteBuffer record, int targetSubpartition) throws IOException
ResultPartitionWriter
IOException
public void broadcastRecord(ByteBuffer record) throws IOException
ResultPartitionWriter
IOException
public void broadcastEvent(AbstractEvent event, boolean isPriorityEvent) throws IOException
ResultPartitionWriter
AbstractEvent
to all channels.IOException
public void setMetricGroup(TaskIOMetricGroup metrics)
ResultPartitionWriter
ResultPartitionWriter
.setMetricGroup
in interface ResultPartitionWriter
setMetricGroup
in class ResultPartition
public ResultSubpartitionView createSubpartitionView(int subpartitionIndex, BufferAvailabilityListener availabilityListener) throws IOException
ResultPartitionWriter
IOException
public void finish() throws IOException
ResultPartition
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.
finish
in interface ResultPartitionWriter
finish
in class ResultPartition
IOException
protected void releaseInternal()
ResultPartition
releaseInternal
in class ResultPartition
@VisibleForTesting public Meter getIdleTimeMsPerSecond()
@VisibleForTesting public ResultSubpartition[] getAllPartitions()
Copyright © 2014–2021 The Apache Software Foundation. All rights reserved.