public class ConsumableNotifyingResultPartitionWriterDecorator extends Object implements ResultPartitionWriter
Before a consuming task can request the result, it has to be deployed. The time of deployment depends on the PIPELINED vs. BLOCKING characteristic of the result partition. With pipelined results, receivers are deployed as soon as the first buffer is added to the result partition. With blocking results on the other hand, receivers are deployed after the partition is finished.
AvailabilityProvider.AvailabilityHelper
AVAILABLE
Constructor and Description |
---|
ConsumableNotifyingResultPartitionWriterDecorator(TaskActions taskActions,
JobID jobId,
ResultPartitionWriter partitionWriter,
ResultPartitionConsumableNotifier partitionConsumableNotifier) |
Modifier and Type | Method and Description |
---|---|
boolean |
addBufferConsumer(BufferConsumer bufferConsumer,
int subpartitionIndex,
boolean isPriorityEvent)
Adds the bufferConsumer to the subpartition with the given index.
|
void |
close() |
static ResultPartitionWriter[] |
decorate(Collection<ResultPartitionDeploymentDescriptor> descs,
ResultPartitionWriter[] partitionWriters,
TaskActions taskActions,
JobID jobId,
ResultPartitionConsumableNotifier notifier) |
void |
fail(Throwable throwable)
Fail the production of the partition.
|
void |
finish()
Successfully finish the production of the partition.
|
void |
flush(int subpartitionIndex)
Manually trigger consumption from enqueued
BufferConsumers in one
specified subpartition. |
void |
flushAll()
Manually trigger consumption from enqueued
BufferConsumers in all
subpartitions. |
CompletableFuture<?> |
getAvailableFuture() |
BufferBuilder |
getBufferBuilder(int targetChannel)
Requests a
BufferBuilder from this partition for writing data. |
int |
getNumberOfSubpartitions() |
int |
getNumTargetKeyGroups() |
ResultPartitionID |
getPartitionId() |
ResultSubpartition |
getSubpartition(int subpartitionIndex)
Returns the subpartition with the given index.
|
void |
readRecoveredState(ChannelStateReader stateReader)
Reads the previous output states with the given reader for unaligned checkpoint.
|
void |
setup()
Setup partition, potentially heavy-weight, blocking operation comparing to just creation.
|
BufferBuilder |
tryGetBufferBuilder(int targetChannel)
Try to request a
BufferBuilder from this partition for writing data. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addBufferConsumer
isApproximatelyAvailable, isAvailable
public ConsumableNotifyingResultPartitionWriterDecorator(TaskActions taskActions, JobID jobId, ResultPartitionWriter partitionWriter, ResultPartitionConsumableNotifier partitionConsumableNotifier)
public BufferBuilder getBufferBuilder(int targetChannel) throws IOException, InterruptedException
ResultPartitionWriter
BufferBuilder
from this partition for writing data.getBufferBuilder
in interface ResultPartitionWriter
IOException
InterruptedException
public BufferBuilder tryGetBufferBuilder(int targetChannel) throws IOException
ResultPartitionWriter
BufferBuilder
from this partition for writing data.
Returns null
if no buffer is available or the buffer provider has been
destroyed.
tryGetBufferBuilder
in interface ResultPartitionWriter
IOException
public ResultPartitionID getPartitionId()
getPartitionId
in interface ResultPartitionWriter
public int getNumberOfSubpartitions()
getNumberOfSubpartitions
in interface ResultPartitionWriter
public int getNumTargetKeyGroups()
getNumTargetKeyGroups
in interface ResultPartitionWriter
public void setup() throws IOException
ResultPartitionWriter
setup
in interface ResultPartitionWriter
IOException
public ResultSubpartition getSubpartition(int subpartitionIndex)
ResultPartitionWriter
getSubpartition
in interface ResultPartitionWriter
public void readRecoveredState(ChannelStateReader stateReader) throws IOException, InterruptedException
ResultPartitionWriter
readRecoveredState
in interface ResultPartitionWriter
IOException
InterruptedException
public boolean addBufferConsumer(BufferConsumer bufferConsumer, int subpartitionIndex, boolean isPriorityEvent) throws IOException
ResultPartitionWriter
This method takes the ownership of the passed bufferConsumer
and thus is
responsible for releasing it's resources.
To avoid problems with data re-ordering, before adding new BufferConsumer
the
previously added one the given subpartitionIndex
must be marked as BufferConsumer.isFinished()
.
addBufferConsumer
in interface ResultPartitionWriter
IOException
public void flushAll()
ResultPartitionWriter
BufferConsumers
in all
subpartitions.flushAll
in interface ResultPartitionWriter
public void flush(int subpartitionIndex)
ResultPartitionWriter
BufferConsumers
in one
specified subpartition.flush
in interface ResultPartitionWriter
public void finish() throws IOException
ResultPartitionWriter
Closing of partition is still needed afterwards.
finish
in interface ResultPartitionWriter
IOException
public void fail(Throwable throwable)
ResultPartitionWriter
This method propagates non-null
failure 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.
fail
in interface ResultPartitionWriter
throwable
- failure causepublic CompletableFuture<?> getAvailableFuture()
getAvailableFuture
in interface AvailabilityProvider
public void close() throws Exception
close
in interface AutoCloseable
Exception
public static ResultPartitionWriter[] decorate(Collection<ResultPartitionDeploymentDescriptor> descs, ResultPartitionWriter[] partitionWriters, TaskActions taskActions, JobID jobId, ResultPartitionConsumableNotifier notifier)
Copyright © 2014–2021 The Apache Software Foundation. All rights reserved.