Interface ResultPartitionWriter
- All Superinterfaces:
AutoCloseable,AvailabilityProvider
- All Known Implementing Classes:
BoundedBlockingResultPartition,BufferWritingResultPartition,PipelinedResultPartition,ResultPartition,SortMergeResultPartition,TieredResultPartition
A record-oriented runtime result writer API for producing results.
If close() is called before fail(Throwable) or finish(), it abruptly
triggers failure and cancellation of production. In this case fail(Throwable) still needs to be called afterwards to fully release all
resources associated the partition and propagate failure cause to the consumer if possible.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.flink.runtime.io.AvailabilityProvider
AvailabilityProvider.AvailabilityHelper -
Field Summary
Fields inherited from interface org.apache.flink.runtime.io.AvailabilityProvider
AVAILABLE -
Method Summary
Modifier and TypeMethodDescriptionvoidabortCheckpoint(long checkpointId, CheckpointException cause) Abort the checkpoint.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.createSubpartitionView(ResultSubpartitionIndexSet indexSet, BufferAvailabilityListener availabilityListener) Returns a reader for the subpartition with the given index range.voidemitRecord(ByteBuffer record, int targetSubpartition) Writes the given serialized record to the target subpartition.voidFail the production of the partition.voidfinish()Successfully finish the production of the partition.voidflush(int subpartitionIndex) Manually trigger the consumption of data from the given subpartitions.voidflushAll()Manually trigger the consumption of data from all subpartitions.Gets the future indicating whether all the records has been processed by the downstream tasks.intintbooleanbooleanvoidnotifyEndOfData(StopMode mode) Notifies the downstream tasks that thisResultPartitionWriterhave emitted all the user records.voidReleases the partition writer which releases the produced data and no reader can consume the partition any more.voidsetMaxOverdraftBuffersPerGate(int maxOverdraftBuffersPerGate) Sets the max overdraft buffer size of per gate.voidsetMetricGroup(TaskIOMetricGroup metrics) Sets the metric group for theResultPartitionWriter.voidsetup()Setup partition, potentially heavy-weight, blocking operation comparing to just creation.Methods inherited from interface org.apache.flink.runtime.io.AvailabilityProvider
getAvailableFuture, isApproximatelyAvailable, isAvailable
-
Method Details
-
setup
Setup partition, potentially heavy-weight, blocking operation comparing to just creation.- Throws:
IOException
-
getPartitionId
ResultPartitionID getPartitionId() -
getNumberOfSubpartitions
int getNumberOfSubpartitions() -
getNumTargetKeyGroups
int getNumTargetKeyGroups() -
setMaxOverdraftBuffersPerGate
void setMaxOverdraftBuffersPerGate(int maxOverdraftBuffersPerGate) Sets the max overdraft buffer size of per gate. -
emitRecord
Writes the given serialized record to the target subpartition.- Throws:
IOException
-
broadcastRecord
Writes 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
Writes the givenAbstractEventto all subpartitions.- Throws:
IOException
-
alignedBarrierTimeout
Timeout the aligned barrier to unaligned barrier.- Throws:
IOException
-
abortCheckpoint
Abort the checkpoint. -
notifyEndOfData
Notifies the downstream tasks that thisResultPartitionWriterhave emitted all the user records.- 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
CompletableFuture<Void> getAllDataProcessedFuture()Gets the future indicating whether all the records has been processed by the downstream tasks. -
setMetricGroup
Sets the metric group for theResultPartitionWriter. -
createSubpartitionView
ResultSubpartitionView createSubpartitionView(ResultSubpartitionIndexSet indexSet, BufferAvailabilityListener availabilityListener) throws IOException Returns a reader for the subpartition with the given index range.- Throws:
IOException
-
flushAll
void flushAll()Manually trigger the consumption of data from all subpartitions. -
flush
void flush(int subpartitionIndex) Manually trigger the consumption of data from the given subpartitions. -
fail
Fail the production of the partition.This method propagates non-
nullfailure causes to consumers on a best-effort basis. This call also leads to the release of all resources associated with the partition. Closing of the partition is still needed afterwards if it has not been done before.- Parameters:
throwable- failure cause
-
finish
Successfully finish the production of the partition.Closing of partition is still needed afterwards.
- Throws:
IOException
-
isFinished
boolean isFinished() -
release
Releases the partition writer which releases the produced data and no reader can consume the partition any more. -
isReleased
boolean isReleased() -
close
Closes the partition writer which releases the allocated resource, for example the buffer pool.- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-