Class SingleInputGate
- All Implemented Interfaces:
AutoCloseable,AvailabilityProvider,ChannelStateHolder,CheckpointableInput,PullingAsyncDataInput<BufferOrEvent>
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.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.flink.runtime.io.network.partition.consumer.InputGate
InputGate.InputWithData<INPUT,DATA> Nested classes/interfaces inherited from interface org.apache.flink.runtime.io.AvailabilityProvider
AvailabilityProvider.AvailabilityHelperNested classes/interfaces inherited from interface org.apache.flink.runtime.io.PullingAsyncDataInput
PullingAsyncDataInput.EndOfDataStatus -
Field Summary
Fields inherited from class org.apache.flink.runtime.io.network.partition.consumer.InputGate
availabilityHelper, priorityAvailabilityHelperFields inherited from interface org.apache.flink.runtime.io.AvailabilityProvider
AVAILABLE -
Constructor Summary
ConstructorsConstructorDescriptionSingleInputGate(String owningTaskName, int gateIndex, IntermediateDataSetID consumedResultId, ResultPartitionType consumedPartitionType, 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) -
Method Summary
Modifier and TypeMethodDescriptionvoidacknowledgeAllRecordsProcessed(InputChannelInfo channelInfo) voidannounceBufferSize(int newBufferSize) voidclose()voidvoidgetChannel(int channelIndex) Returns the channel of this gate.Returns the type of this input channel's consumed result partition.intReturns the index of this input gate.Map<org.apache.flink.api.java.tuple.Tuple2<IntermediateResultPartitionID,InputChannelInfo>, InputChannel> protected PrioritizedDeque<InputChannel>getNext()Blocking call waiting for nextBufferOrEvent.intintlongReturns the list of channels that have not received EndOfPartitionEvent.Tells if we consumed all available data.booleanpollNext()Poll theBufferOrEvent.voidvoidresumeConsumption(InputChannelInfo channelInfo) voidvoidretriggerPartitionRequest(IntermediateResultPartitionID partitionId, InputChannelInfo inputChannelInfo) Retriggers a partition request.voidsendTaskEvent(TaskEvent event) voidsetBufferPool(BufferPool bufferPool) voidsetInputChannels(InputChannel... channels) voidsetTieredStorageService(List<TieredStorageConsumerSpec> tieredStorageConsumerSpecs, TieredStorageConsumerClient client, TieredStorageNettyServiceImpl nettyService) voidsetup()Setup gate, potentially heavy-weight, blocking operation comparing to just creation.voidAssign the exclusive buffers to all remote input channels directly for credit-based mode.toString()voidvoidupdateInputChannel(ResourceID localLocation, NettyShuffleDescriptor shuffleDescriptor) Methods inherited from class org.apache.flink.runtime.io.network.partition.consumer.IndexedInputGate
blockConsumption, checkpointStarted, checkpointStopped, convertToPriorityEvent, getInputGateIndexMethods inherited from class org.apache.flink.runtime.io.network.partition.consumer.InputGate
getAvailableFuture, getChannelInfos, getPriorityEventAvailableFuture, setChannelStateWriterMethods 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.partition.consumer.CheckpointableInput
getChannelInfos
-
Constructor Details
-
SingleInputGate
public SingleInputGate(String owningTaskName, int gateIndex, IntermediateDataSetID consumedResultId, ResultPartitionType consumedPartitionType, 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)
-
-
Method Details
-
getInputChannelsWithData
-
setup
Description copied from class:InputGateSetup gate, potentially heavy-weight, blocking operation comparing to just creation.- Specified by:
setupin classInputGate- Throws:
IOException
-
getStateConsumedFuture
- Specified by:
getStateConsumedFuturein classInputGate
-
requestPartitions
public void requestPartitions()- Specified by:
requestPartitionsin classInputGate
-
convertRecoveredInputChannels
@VisibleForTesting public void convertRecoveredInputChannels() -
finishReadRecoveredState
- Specified by:
finishReadRecoveredStatein classInputGate- Throws:
IOException
-
getNumberOfInputChannels
public int getNumberOfInputChannels()- Specified by:
getNumberOfInputChannelsin interfaceCheckpointableInput- Specified by:
getNumberOfInputChannelsin classInputGate
-
getGateIndex
public int getGateIndex()Description copied from class:IndexedInputGateReturns the index of this input gate. Only supported on- Specified by:
getGateIndexin classIndexedInputGate
-
getUnfinishedChannels
Description copied from class:IndexedInputGateReturns the list of channels that have not received EndOfPartitionEvent.- Specified by:
getUnfinishedChannelsin classIndexedInputGate
-
announceBufferSize
@VisibleForTesting public void announceBufferSize(int newBufferSize) -
triggerDebloating
public void triggerDebloating()- Specified by:
triggerDebloatingin classIndexedInputGate
-
getLastEstimatedTimeToConsume
-
getConsumedPartitionType
Returns the type of this input channel's consumed result partition.- Returns:
- consumed result partition type
-
getBufferPool
-
getOwningTaskName
-
getNumberOfQueuedBuffers
public int getNumberOfQueuedBuffers() -
getSizeOfQueuedBuffers
public long getSizeOfQueuedBuffers() -
getCloseFuture
-
getChannel
Description copied from class:InputGateReturns the channel of this gate.- Specified by:
getChannelin classInputGate
-
setBufferPool
-
setupChannels
Assign the exclusive buffers to all remote input channels directly for credit-based mode.- Throws:
IOException
-
setInputChannels
-
setTieredStorageService
public void setTieredStorageService(List<TieredStorageConsumerSpec> tieredStorageConsumerSpecs, TieredStorageConsumerClient client, TieredStorageNettyServiceImpl nettyService) -
updateInputChannel
public void updateInputChannel(ResourceID localLocation, NettyShuffleDescriptor shuffleDescriptor) throws IOException, InterruptedException - Throws:
IOExceptionInterruptedException
-
retriggerPartitionRequest
public void retriggerPartitionRequest(IntermediateResultPartitionID partitionId, InputChannelInfo inputChannelInfo) throws IOException Retriggers a partition request.- Throws:
IOException
-
close
- Throws:
IOException
-
isFinished
public boolean isFinished()- Specified by:
isFinishedin interfacePullingAsyncDataInput<BufferOrEvent>- Specified by:
isFinishedin classInputGate- Returns:
- true if is finished and for example end of input was reached, false otherwise.
-
hasReceivedEndOfData
Description copied from interface:PullingAsyncDataInputTells if we consumed all available data.Moreover 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. -
toString
-
getNext
Description copied from class:InputGateBlocking call waiting for nextBufferOrEvent.Note: It should be guaranteed that the previous returned buffer has been recycled before getting next one.
- Specified by:
getNextin classInputGate- Returns:
Optional.empty()ifInputGate.isFinished()returns true.- Throws:
IOExceptionInterruptedException
-
pollNext
Description copied from class:InputGatePoll theBufferOrEvent.Note: It should be guaranteed that the previous returned buffer has been recycled before polling next one.
- Specified by:
pollNextin interfacePullingAsyncDataInput<BufferOrEvent>- Specified by:
pollNextin classInputGate- Returns:
Optional.empty()if there is no data to return or ifInputGate.isFinished()returns true.- Throws:
IOExceptionInterruptedException
-
sendTaskEvent
- Specified by:
sendTaskEventin classInputGate- Throws:
IOException
-
resumeGateConsumption
- Specified by:
resumeGateConsumptionin classInputGate- Throws:
IOException
-
resumeConsumption
- Specified by:
resumeConsumptionin interfaceCheckpointableInput- Specified by:
resumeConsumptionin classInputGate- Throws:
IOException
-
acknowledgeAllRecordsProcessed
- Specified by:
acknowledgeAllRecordsProcessedin classInputGate- Throws:
IOException
-
getInputChannels
@VisibleForTesting public Map<org.apache.flink.api.java.tuple.Tuple2<IntermediateResultPartitionID,InputChannelInfo>, getInputChannels()InputChannel> -
inputChannels
-