Class RemoteInputChannel
java.lang.Object
org.apache.flink.runtime.io.network.partition.consumer.InputChannel
org.apache.flink.runtime.io.network.partition.consumer.RemoteInputChannel
An input channel, which requests a remote partition queue.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.flink.runtime.io.network.partition.consumer.InputChannel
InputChannel.BufferAndAvailability -
Field Summary
Fields inherited from class org.apache.flink.runtime.io.network.partition.consumer.InputChannel
channelInfo, consumedSubpartitionIndexSet, currentBackoff, initialBackoff, inputGate, maxBackoff, numBuffersIn, numBytesIn, partitionId -
Constructor Summary
ConstructorsConstructorDescriptionRemoteInputChannel(SingleInputGate inputGate, int channelIndex, ResultPartitionID partitionId, ResultSubpartitionIndexSet consumedSubpartitionIndexSet, ConnectionID connectionId, ConnectionManager connectionManager, int initialBackOff, int maxBackoff, int partitionRequestListenerTimeout, int networkBuffersPerChannel, org.apache.flink.metrics.Counter numBytesIn, org.apache.flink.metrics.Counter numBuffersIn, ChannelStateWriter stateWriter) -
Method Summary
Modifier and TypeMethodDescriptionvoidWhen receivedEndOfDatafrom one channel, it need to acknowledge after this event get processed.voidcheckpointStarted(CheckpointBarrier barrier) Spills all queued buffers on checkpoint start.voidcheckpointStopped(long checkpointId) Called by task thread on cancel/complete to clean-up temporary data.voidconvertToPriorityEvent(int sequenceNumber) intGets the unannounced credit and resets it to 0 atomically.intReturns the next buffer from the consumed subpartitions orOptional.empty()if there is no data to return.intintGets the current number of received buffers which have not been processed yet.intintintGets the currently unannounced credit.protected booleanThe remote task manager creates partition request listener and returnsPartitionNotFoundExceptionuntil the listener is timeout, so the backoff should add the timeout milliseconds if it exists.booleanvoidnotifyBufferAvailable(int numAvailableBuffers) The unannounced credit is increased by the given amount and might notify increased credit to the producer.voidnotifyRequiredSegmentId(int subpartitionId, int segmentId) Notify the upstream the id of required segment that should be sent to netty connection.voidHandles the input buffer.voidonEmptyBuffer(int sequenceNumber, int backlog) voidvoidvoidonSenderBacklog(int backlog) Receives the backlog from the producer's buffer response.protected 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.Requests buffer from input channel directly for receiving network data.voidRequests a remote subpartition.voidAfter sending aCheckpointBarrierof exactly-once mode, the upstream will be blocked and become unavailable.toString()intintintlongMethods inherited from class org.apache.flink.runtime.io.network.partition.consumer.InputChannel
checkError, getChannelIndex, getChannelInfo, getConsumedSubpartitionIndexSet, getCurrentBackoff, getPartitionId, notifyChannelNonEmpty, notifyPriorityEvent, peekNextBufferSubpartitionId, setError
-
Constructor Details
-
RemoteInputChannel
public RemoteInputChannel(SingleInputGate inputGate, int channelIndex, ResultPartitionID partitionId, ResultSubpartitionIndexSet consumedSubpartitionIndexSet, ConnectionID connectionId, ConnectionManager connectionManager, int initialBackOff, int maxBackoff, int partitionRequestListenerTimeout, int networkBuffersPerChannel, org.apache.flink.metrics.Counter numBytesIn, org.apache.flink.metrics.Counter numBuffersIn, ChannelStateWriter stateWriter)
-
-
Method Details
-
requestSubpartitions
Requests a remote subpartition.- Throws:
IOExceptionInterruptedException
-
increaseBackoff
protected boolean increaseBackoff()The remote task manager creates partition request listener and returnsPartitionNotFoundExceptionuntil the listener is timeout, so the backoff should add the timeout milliseconds if it exists.- Overrides:
increaseBackoffin classInputChannel- Returns:
true, iff the operation was successful. Otherwise,false.
-
peekNextBufferSubpartitionIdInternal
Description copied from class:InputChannelReturns 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.- Specified by:
peekNextBufferSubpartitionIdInternalin classInputChannel- Throws:
IOException
-
getNextBuffer
Description copied from class:InputChannelReturns the next buffer from the consumed subpartitions orOptional.empty()if there is no data to return.- Specified by:
getNextBufferin classInputChannel- Throws:
IOException
-
isReleased
public boolean isReleased() -
toString
-
getNumberOfAvailableBuffers
@VisibleForTesting public int getNumberOfAvailableBuffers() -
getNumberOfRequiredBuffers
@VisibleForTesting public int getNumberOfRequiredBuffers() -
getSenderBacklog
@VisibleForTesting public int getSenderBacklog() -
getNextReceivedBuffer
-
notifyBufferAvailable
The unannounced credit is increased by the given amount and might notify increased credit to the producer.- Overrides:
notifyBufferAvailablein classInputChannel- Throws:
IOException
-
resumeConsumption
Description copied from class:InputChannelAfter 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.- Specified by:
resumeConsumptionin classInputChannel- Throws:
IOException
-
acknowledgeAllRecordsProcessed
Description copied from class:InputChannelWhen receivedEndOfDatafrom one channel, it need to acknowledge after this event get processed.- Specified by:
acknowledgeAllRecordsProcessedin classInputChannel- Throws:
IOException
-
getUnannouncedCredit
public int getUnannouncedCredit()Gets the currently unannounced credit.- Returns:
- Credit which was not announced to the sender yet.
-
getAndResetUnannouncedCredit
public int getAndResetUnannouncedCredit()Gets the unannounced credit and resets it to 0 atomically.- Returns:
- Credit which was not announced to the sender yet.
-
getNumberOfQueuedBuffers
public int getNumberOfQueuedBuffers()Gets the current number of received buffers which have not been processed yet.- Returns:
- Buffers queued for processing.
-
unsynchronizedGetNumberOfQueuedBuffers
public int unsynchronizedGetNumberOfQueuedBuffers()- Overrides:
unsynchronizedGetNumberOfQueuedBuffersin classInputChannel
-
unsynchronizedGetSizeOfQueuedBuffers
public long unsynchronizedGetSizeOfQueuedBuffers()- Overrides:
unsynchronizedGetSizeOfQueuedBuffersin classInputChannel
-
unsynchronizedGetExclusiveBuffersUsed
public int unsynchronizedGetExclusiveBuffersUsed() -
unsynchronizedGetFloatingBuffersAvailable
public int unsynchronizedGetFloatingBuffersAvailable() -
getInputChannelId
-
getInitialCredit
public int getInitialCredit() -
getBufferProvider
- Throws:
IOException
-
requestBuffer
Requests buffer from input channel directly for receiving network data. It should always return an available buffer in credit-based mode unless the channel has been released.- Returns:
- The available buffer.
-
onSenderBacklog
Receives the backlog from the producer's buffer response. If the number of available buffers is less than backlog + initialCredit, it will request floating buffers from the buffer manager, and then notify unannounced credits to the producer.- Parameters:
backlog- The number of unsent buffers in the producer's sub partition.- Throws:
IOException
-
onBuffer
public void onBuffer(Buffer buffer, int sequenceNumber, int backlog, int subpartitionId) throws IOException Handles the input buffer. This method is taking over the ownership of the buffer and is fully responsible for cleaning it up both on the happy path and in case of an error.- Throws:
IOException
-
checkpointStarted
Spills all queued buffers on checkpoint start. If barrier has already been received (and reordered), spill only the overtaken buffers.- Overrides:
checkpointStartedin classInputChannel- Throws:
CheckpointException
-
checkpointStopped
public void checkpointStopped(long checkpointId) Description copied from class:InputChannelCalled by task thread on cancel/complete to clean-up temporary data.- Overrides:
checkpointStoppedin classInputChannel
-
convertToPriorityEvent
- Overrides:
convertToPriorityEventin classInputChannel- Throws:
IOException
-
onEmptyBuffer
- Throws:
IOException
-
onFailedPartitionRequest
public void onFailedPartitionRequest() -
onError
-
notifyRequiredSegmentId
Description copied from class:InputChannelNotify the upstream the id of required segment that should be sent to netty connection.- Overrides:
notifyRequiredSegmentIdin classInputChannel- Parameters:
subpartitionId- The id of the corresponding subpartition.segmentId- The id of required segment.- Throws:
IOException
-