Class InputChannel
java.lang.Object
org.apache.flink.runtime.io.network.partition.consumer.InputChannel
- Direct Known Subclasses:
LocalInputChannel,RecoveredInputChannel,RemoteInputChannel
An input channel consumes a single
ResultSubpartitionView.
For each channel, the consumption life cycle is as follows:
requestSubpartitions()getNextBuffer()releaseAllResources()
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA combination of aBufferand a flag indicating availability of further buffers, and the backlog length indicating how many non-event buffers are available in the subpartitions. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final InputChannelInfoThe info of the input channel to identify it globally within a task.protected final ResultSubpartitionIndexSetThe indexes of the subpartitions consumed by this channel.protected intThe current backoff (in ms).protected final intThe initial backoff (in ms).protected final SingleInputGateprotected final intThe maximum backoff (in ms).protected final org.apache.flink.metrics.Counterprotected final org.apache.flink.metrics.Counterprotected final ResultPartitionIDThe parent partition of the subpartitions consumed by this channel. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedInputChannel(SingleInputGate inputGate, int channelIndex, ResultPartitionID partitionId, ResultSubpartitionIndexSet consumedSubpartitionIndexSet, int initialBackoff, int maxBackoff, org.apache.flink.metrics.Counter numBytesIn, org.apache.flink.metrics.Counter numBuffersIn) -
Method Summary
Modifier and TypeMethodDescriptionabstract voidWhen receivedEndOfDatafrom one channel, it need to acknowledge after this event get processed.protected voidChecks for an error and rethrows it if one was reported.voidcheckpointStarted(CheckpointBarrier barrier) Called by task thread when checkpointing is started (e.g., any input channel received barrier).voidcheckpointStopped(long checkpointId) Called by task thread on cancel/complete to clean-up temporary data.voidconvertToPriorityEvent(int sequenceNumber) intReturns the index of this channel within itsSingleInputGate.Returns the info of this channel, which uniquely identifies the channel in respect to its operator instance.protected intReturns the current backoff in ms.abstract Optional<InputChannel.BufferAndAvailability>Returns the next buffer from the consumed subpartitions orOptional.empty()if there is no data to return.protected booleanIncreases the current backoff and returns whether the operation was successful.protected voidnotifyBufferAvailable(int numAvailableBuffers) protected voidNotifies the owningSingleInputGatethat this channel became non-empty.voidnotifyPriorityEvent(int priorityBufferNumber) voidnotifyRequiredSegmentId(int subpartitionId, int segmentId) Notify the upstream the id of required segment that should be sent to netty connection.intReturns the index of the subpartition where the next buffer locates, or -1 if there is no buffer available and the subpartition to be consumed is not determined.protected abstract intReturns the index of the subpartition where the next buffer locates, or -1 if there is no buffer available and the subpartition to be consumed is not determined.abstract voidAfter sending aCheckpointBarrierof exactly-once mode, the upstream will be blocked and become unavailable.protected voidAtomically sets an error for this channel and notifies the input gate about available data to trigger querying this channel by the task thread.intlong
-
Field Details
-
channelInfo
The info of the input channel to identify it globally within a task. -
partitionId
The parent partition of the subpartitions consumed by this channel. -
consumedSubpartitionIndexSet
The indexes of the subpartitions consumed by this channel. -
inputGate
-
initialBackoff
protected final int initialBackoffThe initial backoff (in ms). -
maxBackoff
protected final int maxBackoffThe maximum backoff (in ms). -
numBytesIn
protected final org.apache.flink.metrics.Counter numBytesIn -
numBuffersIn
protected final org.apache.flink.metrics.Counter numBuffersIn -
currentBackoff
protected int currentBackoffThe current backoff (in ms).
-
-
Constructor Details
-
InputChannel
protected InputChannel(SingleInputGate inputGate, int channelIndex, ResultPartitionID partitionId, ResultSubpartitionIndexSet consumedSubpartitionIndexSet, int initialBackoff, int maxBackoff, org.apache.flink.metrics.Counter numBytesIn, org.apache.flink.metrics.Counter numBuffersIn)
-
-
Method Details
-
getChannelIndex
public int getChannelIndex()Returns the index of this channel within itsSingleInputGate. -
getChannelInfo
Returns the info of this channel, which uniquely identifies the channel in respect to its operator instance. -
getPartitionId
-
getConsumedSubpartitionIndexSet
-
resumeConsumption
After sending aCheckpointBarrierof exactly-once mode, the upstream will be blocked and become unavailable. This method tries to unblock the corresponding upstream and resume data consumption.- Throws:
IOException
-
acknowledgeAllRecordsProcessed
When receivedEndOfDatafrom one channel, it need to acknowledge after this event get processed.- Throws:
IOException
-
notifyChannelNonEmpty
protected void notifyChannelNonEmpty()Notifies the owningSingleInputGatethat this channel became non-empty.This is guaranteed to be called only when a Buffer was added to a previously empty input channel. The notion of empty is atomically consistent with the flag
InputChannel.BufferAndAvailability.moreAvailable()when polling the next buffer from this channel.Note: When the input channel observes an exception, this method is called regardless of whether the channel was empty before. That ensures that the parent InputGate will always be notified about the exception.
-
notifyPriorityEvent
public void notifyPriorityEvent(int priorityBufferNumber) -
notifyBufferAvailable
- Throws:
IOException
-
peekNextBufferSubpartitionId
Returns the index of the subpartition where the next buffer locates, or -1 if there is no buffer available and the subpartition to be consumed is not determined.- Throws:
IOException
-
peekNextBufferSubpartitionIdInternal
Returns the index of the subpartition where the next buffer locates, or -1 if there is no buffer available and the subpartition to be consumed is not determined.- Throws:
IOException
-
getNextBuffer
public abstract Optional<InputChannel.BufferAndAvailability> getNextBuffer() throws IOException, InterruptedExceptionReturns the next buffer from the consumed subpartitions orOptional.empty()if there is no data to return.- Throws:
IOExceptionInterruptedException
-
checkpointStarted
Called by task thread when checkpointing is started (e.g., any input channel received barrier).- Throws:
CheckpointException
-
checkpointStopped
public void checkpointStopped(long checkpointId) Called by task thread on cancel/complete to clean-up temporary data. -
convertToPriorityEvent
- Throws:
IOException
-
checkError
Checks for an error and rethrows it if one was reported.Note: Any
PartitionExceptioninstances should not be transformed and make sure they are always visible in task failure cause.- Throws:
IOException
-
setError
Atomically sets an error for this channel and notifies the input gate about available data to trigger querying this channel by the task thread. -
getCurrentBackoff
protected int getCurrentBackoff()Returns the current backoff in ms. -
increaseBackoff
protected boolean increaseBackoff()Increases the current backoff and returns whether the operation was successful.- Returns:
true, iff the operation was successful. Otherwise,false.
-
unsynchronizedGetNumberOfQueuedBuffers
public int unsynchronizedGetNumberOfQueuedBuffers() -
unsynchronizedGetSizeOfQueuedBuffers
public long unsynchronizedGetSizeOfQueuedBuffers() -
notifyRequiredSegmentId
Notify the upstream the id of required segment that should be sent to netty connection.- Parameters:
subpartitionId- The id of the corresponding subpartition.segmentId- The id of required segment.- Throws:
IOException
-