public class SingleInputGate extends IndexedInputGate
Each intermediate result is partitioned over its producing parallel subtasks; each of these partitions is furthermore partitioned into one or more subpartitions.
As an example, consider a map-reduce program, where the map operator produces data and the reduce operator consumes the produced data.
+-----+ +---------------------+ +--------+
| Map | = produce => | Intermediate Result | <= consume = | Reduce |
+-----+ +---------------------+ +--------+
When deploying such a program in parallel, the intermediate result will be partitioned over its producing parallel subtasks; each of these partitions is furthermore partitioned into one or more subpartitions.
Intermediate result
+-----------------------------------------+
| +----------------+ | +-----------------------+
+-------+ | +-------------+ +=> | Subpartition 1 | | <=======+=== | Input Gate | Reduce 1 |
| Map 1 | ==> | | Partition 1 | =| +----------------+ | | +-----------------------+
+-------+ | +-------------+ +=> | Subpartition 2 | | <==+ |
| +----------------+ | | | Subpartition request
| | | |
| +----------------+ | | |
+-------+ | +-------------+ +=> | Subpartition 1 | | <==+====+
| Map 2 | ==> | | Partition 2 | =| +----------------+ | | +-----------------------+
+-------+ | +-------------+ +=> | Subpartition 2 | | <==+======== | Input Gate | Reduce 2 |
| +----------------+ | +-----------------------+
+-----------------------------------------+
In the above example, two map subtasks produce the intermediate result in parallel, resulting in two partitions (Partition 1 and 2). Each of these partitions is further partitioned into two subpartitions -- one for each parallel reduce subtask.
InputGate.InputWithData<INPUT,DATA>PullingAsyncDataInput.EndOfDataStatusAvailabilityProvider.AvailabilityHelperavailabilityHelper, priorityAvailabilityHelperAVAILABLE| 构造器和说明 |
|---|
SingleInputGate(String owningTaskName,
int gateIndex,
IntermediateDataSetID consumedResultId,
ResultPartitionType consumedPartitionType,
IndexRange subpartitionIndexRange,
int numberOfInputChannels,
PartitionProducerStateProvider partitionProducerStateProvider,
org.apache.flink.util.function.SupplierWithException<BufferPool,IOException> bufferPoolFactory,
BufferDecompressor bufferDecompressor,
org.apache.flink.core.memory.MemorySegmentProvider memorySegmentProvider,
int segmentSize,
ThroughputCalculator throughputCalculator,
BufferDebloater bufferDebloater) |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
acknowledgeAllRecordsProcessed(InputChannelInfo channelInfo) |
void |
announceBufferSize(int newBufferSize) |
void |
close() |
void |
convertRecoveredInputChannels() |
void |
finishReadRecoveredState() |
BufferPool |
getBufferPool() |
InputChannel |
getChannel(int channelIndex)
Returns the channel of this gate.
|
CompletableFuture<Void> |
getCloseFuture() |
ResultPartitionType |
getConsumedPartitionType()
Returns the type of this input channel's consumed result partition.
|
int |
getGateIndex()
Returns the index of this input gate.
|
Map<org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate.SubpartitionInfo,InputChannel> |
getInputChannels() |
protected PrioritizedDeque<InputChannel> |
getInputChannelsWithData() |
java.time.Duration |
getLastEstimatedTimeToConsume() |
Optional<BufferOrEvent> |
getNext()
Blocking call waiting for next
BufferOrEvent. |
int |
getNumberOfInputChannels() |
int |
getNumberOfQueuedBuffers() |
String |
getOwningTaskName() |
long |
getSizeOfQueuedBuffers() |
CompletableFuture<Void> |
getStateConsumedFuture() |
List<InputChannelInfo> |
getUnfinishedChannels()
Returns the list of channels that have not received EndOfPartitionEvent.
|
PullingAsyncDataInput.EndOfDataStatus |
hasReceivedEndOfData()
Tells if we consumed all available data.
|
boolean |
isFinished() |
Optional<BufferOrEvent> |
pollNext()
Poll the
BufferOrEvent. |
void |
requestPartitions() |
void |
resumeConsumption(InputChannelInfo channelInfo) |
void |
retriggerPartitionRequest(IntermediateResultPartitionID partitionId,
int subpartitionIndex)
Retriggers a partition request.
|
void |
sendTaskEvent(TaskEvent event) |
void |
setBufferPool(BufferPool bufferPool) |
void |
setInputChannels(InputChannel... channels) |
void |
setup()
Setup gate, potentially heavy-weight, blocking operation comparing to just creation.
|
void |
setupChannels()
Assign the exclusive buffers to all remote input channels directly for credit-based mode.
|
String |
toString() |
void |
triggerDebloating() |
void |
updateInputChannel(ResourceID localLocation,
NettyShuffleDescriptor shuffleDescriptor) |
blockConsumption, checkpointStarted, checkpointStopped, convertToPriorityEvent, getInputGateIndexgetAvailableFuture, getChannelInfos, getPriorityEventAvailableFuture, setChannelStateWriterclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetChannelInfosand, isApproximatelyAvailable, isAvailable, orpublic SingleInputGate(String owningTaskName, int gateIndex, IntermediateDataSetID consumedResultId, ResultPartitionType consumedPartitionType, IndexRange subpartitionIndexRange, int numberOfInputChannels, PartitionProducerStateProvider partitionProducerStateProvider, org.apache.flink.util.function.SupplierWithException<BufferPool,IOException> bufferPoolFactory, @Nullable BufferDecompressor bufferDecompressor, org.apache.flink.core.memory.MemorySegmentProvider memorySegmentProvider, int segmentSize, ThroughputCalculator throughputCalculator, @Nullable BufferDebloater bufferDebloater)
protected PrioritizedDeque<InputChannel> getInputChannelsWithData()
public void setup()
throws IOException
InputGatesetup 在类中 InputGateIOExceptionpublic CompletableFuture<Void> getStateConsumedFuture()
getStateConsumedFuture 在类中 InputGatepublic void requestPartitions()
requestPartitions 在类中 InputGate@VisibleForTesting public void convertRecoveredInputChannels()
public void finishReadRecoveredState()
throws IOException
finishReadRecoveredState 在类中 InputGateIOExceptionpublic int getNumberOfInputChannels()
getNumberOfInputChannels 在接口中 CheckpointableInputgetNumberOfInputChannels 在类中 InputGatepublic int getGateIndex()
IndexedInputGategetGateIndex 在类中 IndexedInputGatepublic List<InputChannelInfo> getUnfinishedChannels()
IndexedInputGategetUnfinishedChannels 在类中 IndexedInputGate@VisibleForTesting public void announceBufferSize(int newBufferSize)
public void triggerDebloating()
triggerDebloating 在类中 IndexedInputGatepublic java.time.Duration getLastEstimatedTimeToConsume()
public ResultPartitionType getConsumedPartitionType()
public BufferPool getBufferPool()
public String getOwningTaskName()
public int getNumberOfQueuedBuffers()
public long getSizeOfQueuedBuffers()
public CompletableFuture<Void> getCloseFuture()
public InputChannel getChannel(int channelIndex)
InputGategetChannel 在类中 InputGatepublic void setBufferPool(BufferPool bufferPool)
@VisibleForTesting
public void setupChannels()
throws IOException
IOExceptionpublic void setInputChannels(InputChannel... channels)
public void updateInputChannel(ResourceID localLocation, NettyShuffleDescriptor shuffleDescriptor) throws IOException, InterruptedException
public void retriggerPartitionRequest(IntermediateResultPartitionID partitionId, int subpartitionIndex) throws IOException
IOExceptionpublic void close()
throws IOException
IOExceptionpublic boolean isFinished()
isFinished 在接口中 PullingAsyncDataInput<BufferOrEvent>isFinished 在类中 InputGatepublic PullingAsyncDataInput.EndOfDataStatus hasReceivedEndOfData()
PullingAsyncDataInputMoreover it tells us the reason why there is no more data incoming. If any of the upstream
subtasks finished because of the stop-with-savepoint --no-drain, we should not drain the
input. See also StopMode.
public Optional<BufferOrEvent> getNext() throws IOException, InterruptedException
InputGateBufferOrEvent.
Note: It should be guaranteed that the previous returned buffer has been recycled before getting next one.
getNext 在类中 InputGateOptional.empty() if InputGate.isFinished() returns true.IOExceptionInterruptedExceptionpublic Optional<BufferOrEvent> pollNext() throws IOException, InterruptedException
InputGateBufferOrEvent.
Note: It should be guaranteed that the previous returned buffer has been recycled before polling next one.
pollNext 在接口中 PullingAsyncDataInput<BufferOrEvent>pollNext 在类中 InputGateOptional.empty() if there is no data to return or if InputGate.isFinished()
returns true.IOExceptionInterruptedExceptionpublic void sendTaskEvent(TaskEvent event) throws IOException
sendTaskEvent 在类中 InputGateIOExceptionpublic void resumeConsumption(InputChannelInfo channelInfo) throws IOException
resumeConsumption 在接口中 CheckpointableInputresumeConsumption 在类中 InputGateIOExceptionpublic void acknowledgeAllRecordsProcessed(InputChannelInfo channelInfo) throws IOException
acknowledgeAllRecordsProcessed 在类中 InputGateIOExceptionpublic Map<org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate.SubpartitionInfo,InputChannel> getInputChannels()
Copyright © 2014–2023 The Apache Software Foundation. All rights reserved.