Class SingleInputGate
- java.lang.Object
-
- org.apache.flink.runtime.io.network.partition.consumer.InputGate
-
- org.apache.flink.runtime.io.network.partition.consumer.IndexedInputGate
-
- org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate
-
- All Implemented Interfaces:
AutoCloseable,AvailabilityProvider,ChannelStateHolder,CheckpointableInput,PullingAsyncDataInput<BufferOrEvent>
public class SingleInputGate extends IndexedInputGate
An input gate consumes one or more partitions of a single produced intermediate result.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.AvailabilityHelper
-
Nested 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, priorityAvailabilityHelper
-
Fields inherited from interface org.apache.flink.runtime.io.AvailabilityProvider
AVAILABLE
-
-
Constructor Summary
Constructors Constructor Description SingleInputGate(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
-
Methods inherited from class org.apache.flink.runtime.io.network.partition.consumer.IndexedInputGate
blockConsumption, checkpointStarted, checkpointStopped, convertToPriorityEvent, getInputGateIndex
-
Methods inherited from class org.apache.flink.runtime.io.network.partition.consumer.InputGate
getAvailableFuture, getChannelInfos, getPriorityEventAvailableFuture, setChannelStateWriter
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.flink.runtime.io.AvailabilityProvider
isApproximatelyAvailable, isAvailable
-
Methods inherited from interface org.apache.flink.runtime.io.network.partition.consumer.CheckpointableInput
getChannelInfos
-
-
-
-
Constructor Detail
-
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 Detail
-
getInputChannelsWithData
protected PrioritizedDeque<InputChannel> getInputChannelsWithData()
-
setup
public void setup() throws IOExceptionDescription copied from class:InputGateSetup gate, potentially heavy-weight, blocking operation comparing to just creation.- Specified by:
setupin classInputGate- Throws:
IOException
-
getStateConsumedFuture
public CompletableFuture<Void> getStateConsumedFuture()
- Specified by:
getStateConsumedFuturein classInputGate
-
requestPartitions
public void requestPartitions()
- Specified by:
requestPartitionsin classInputGate
-
convertRecoveredInputChannels
@VisibleForTesting public void convertRecoveredInputChannels()
-
finishReadRecoveredState
public void finishReadRecoveredState() throws IOException- 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
public List<InputChannelInfo> 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
public Duration getLastEstimatedTimeToConsume()
-
getConsumedPartitionType
public ResultPartitionType getConsumedPartitionType()
Description copied from class:IndexedInputGateReturns the type of this input channel's consumed result partition.- Specified by:
getConsumedPartitionTypein classIndexedInputGate- Returns:
- consumed result partition type
-
getBufferPool
public BufferPool getBufferPool()
-
getOwningTaskName
public String getOwningTaskName()
-
getNumberOfQueuedBuffers
public int getNumberOfQueuedBuffers()
-
getSizeOfQueuedBuffers
public long getSizeOfQueuedBuffers()
-
getCloseFuture
public CompletableFuture<Void> getCloseFuture()
-
getChannel
public InputChannel getChannel(int channelIndex)
Description copied from class:InputGateReturns the channel of this gate.- Specified by:
getChannelin classInputGate
-
setBufferPool
public void setBufferPool(BufferPool bufferPool)
-
setupChannels
@VisibleForTesting public void setupChannels() throws IOExceptionAssign the exclusive buffers to all remote input channels directly for credit-based mode.- Throws:
IOException
-
setInputChannels
public void setInputChannels(InputChannel... channels)
-
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
public void close() throws IOException- 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
public PullingAsyncDataInput.EndOfDataStatus 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.
-
getNext
public Optional<BufferOrEvent> getNext() throws IOException, InterruptedException
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
public Optional<BufferOrEvent> pollNext() throws IOException, InterruptedException
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
public void sendTaskEvent(TaskEvent event) throws IOException
- Specified by:
sendTaskEventin classInputGate- Throws:
IOException
-
resumeGateConsumption
public void resumeGateConsumption() throws IOException- Specified by:
resumeGateConsumptionin classInputGate- Throws:
IOException
-
resumeConsumption
public void resumeConsumption(InputChannelInfo channelInfo) throws IOException
- Specified by:
resumeConsumptionin interfaceCheckpointableInput- Specified by:
resumeConsumptionin classInputGate- Throws:
IOException
-
acknowledgeAllRecordsProcessed
public void acknowledgeAllRecordsProcessed(InputChannelInfo channelInfo) throws IOException
- Specified by:
acknowledgeAllRecordsProcessedin classInputGate- Throws:
IOException
-
getInputChannels
@VisibleForTesting public Map<org.apache.flink.api.java.tuple.Tuple2<IntermediateResultPartitionID,InputChannelInfo>,InputChannel> getInputChannels()
-
inputChannels
public Iterable<InputChannel> inputChannels()
-
-