Class StreamTaskSourceInput<T>
- java.lang.Object
-
- org.apache.flink.streaming.runtime.io.StreamTaskSourceInput<T>
-
- All Implemented Interfaces:
Closeable,AutoCloseable,org.apache.flink.runtime.io.AvailabilityProvider,org.apache.flink.runtime.io.network.partition.consumer.CheckpointableInput,PushingAsyncDataInput<T>,StreamTaskInput<T>
- Direct Known Subclasses:
StreamTaskExternallyInducedSourceInput,StreamTaskFinishedOnRestoreSourceInput
@Internal public class StreamTaskSourceInput<T> extends Object implements StreamTaskInput<T>, org.apache.flink.runtime.io.network.partition.consumer.CheckpointableInput
Implementation ofStreamTaskInputthat reads data from theSourceOperatorand returns theDataInputStatusto indicate whether the source state is available, unavailable or finished.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.flink.runtime.io.AvailabilityProvider
org.apache.flink.runtime.io.AvailabilityProvider.AvailabilityHelper
-
Nested classes/interfaces inherited from interface org.apache.flink.streaming.runtime.io.PushingAsyncDataInput
PushingAsyncDataInput.DataOutput<T>
-
-
Field Summary
-
Fields inherited from interface org.apache.flink.streaming.runtime.io.StreamTaskInput
UNSPECIFIED
-
-
Constructor Summary
Constructors Constructor Description StreamTaskSourceInput(SourceOperator<T,?> operator, int inputGateIndex, int inputIndex)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidblockConsumption(org.apache.flink.runtime.checkpoint.channel.InputChannelInfo channelInfo)voidcheckpointStarted(org.apache.flink.runtime.io.network.api.CheckpointBarrier barrier)This method is used with unaligned checkpoints to mark the arrival of a firstCheckpointBarrier.voidcheckpointStopped(long cancelledCheckpointId)voidclose()voidconvertToPriorityEvent(int channelIndex, int sequenceNumber)DataInputStatusemitNext(PushingAsyncDataInput.DataOutput<T> output)Pushes elements to the output from current data input, and returns the input status to indicate whether there are more available data in current input.CompletableFuture<?>getAvailableFuture()List<org.apache.flink.runtime.checkpoint.channel.InputChannelInfo>getChannelInfos()intgetInputGateIndex()intgetInputIndex()Returns the input index of this input.intgetNumberOfInputChannels()SourceOperator<T,?>getOperator()org.apache.flink.runtime.jobgraph.OperatorIDgetOperatorID()CompletableFuture<Void>prepareSnapshot(org.apache.flink.runtime.checkpoint.channel.ChannelStateWriter channelStateWriter, long checkpointId)Prepares to spill the in-flight input buffers as checkpoint snapshot.voidresumeConsumption(org.apache.flink.runtime.checkpoint.channel.InputChannelInfo channelInfo)
-
-
-
Constructor Detail
-
StreamTaskSourceInput
public StreamTaskSourceInput(SourceOperator<T,?> operator, int inputGateIndex, int inputIndex)
-
-
Method Detail
-
emitNext
public DataInputStatus emitNext(PushingAsyncDataInput.DataOutput<T> output) throws Exception
Description copied from interface:PushingAsyncDataInputPushes elements to the output from current data input, and returns the input status to indicate whether there are more available data in current input.This method should be non blocking.
- Specified by:
emitNextin interfacePushingAsyncDataInput<T>- Throws:
Exception
-
getAvailableFuture
public CompletableFuture<?> getAvailableFuture()
- Specified by:
getAvailableFuturein interfaceorg.apache.flink.runtime.io.AvailabilityProvider
-
blockConsumption
public void blockConsumption(org.apache.flink.runtime.checkpoint.channel.InputChannelInfo channelInfo)
- Specified by:
blockConsumptionin interfaceorg.apache.flink.runtime.io.network.partition.consumer.CheckpointableInput
-
resumeConsumption
public void resumeConsumption(org.apache.flink.runtime.checkpoint.channel.InputChannelInfo channelInfo)
- Specified by:
resumeConsumptionin interfaceorg.apache.flink.runtime.io.network.partition.consumer.CheckpointableInput
-
getChannelInfos
public List<org.apache.flink.runtime.checkpoint.channel.InputChannelInfo> getChannelInfos()
- Specified by:
getChannelInfosin interfaceorg.apache.flink.runtime.io.network.partition.consumer.CheckpointableInput
-
getNumberOfInputChannels
public int getNumberOfInputChannels()
- Specified by:
getNumberOfInputChannelsin interfaceorg.apache.flink.runtime.io.network.partition.consumer.CheckpointableInput
-
checkpointStarted
public void checkpointStarted(org.apache.flink.runtime.io.network.api.CheckpointBarrier barrier)
This method is used with unaligned checkpoints to mark the arrival of a firstCheckpointBarrier. For chained sources, there is noCheckpointBarrierper se flowing through the job graph. We can assume that an imaginaryCheckpointBarrierwas produced by the source, at any point of time of our choosing.We are choosing to interpret it, that
CheckpointBarrierfor sources was received immediately as soon as we receive either checkpoint start RPC, orCheckpointBarrierfrom a network input. So that we can checkpoint state of the source and all of the other operators at the same time.Also we are choosing to block the source, as a best effort optimisation as: - either there is no backpressure and the checkpoint "alignment" will happen very quickly anyway - or there is a backpressure, and it's better to prioritize processing data from the network to speed up checkpointing. From the cluster resource utilisation perspective, by blocking chained source doesn't block any resources from being used, as this task running the source has a backlog of buffered input data waiting to be processed.
However from the correctness point of view,
checkpointStarted(CheckpointBarrier)andcheckpointStopped(long)methods could be empty no-op.- Specified by:
checkpointStartedin interfaceorg.apache.flink.runtime.io.network.partition.consumer.CheckpointableInput
-
checkpointStopped
public void checkpointStopped(long cancelledCheckpointId)
- Specified by:
checkpointStoppedin interfaceorg.apache.flink.runtime.io.network.partition.consumer.CheckpointableInput
-
getInputGateIndex
public int getInputGateIndex()
- Specified by:
getInputGateIndexin interfaceorg.apache.flink.runtime.io.network.partition.consumer.CheckpointableInput
-
convertToPriorityEvent
public void convertToPriorityEvent(int channelIndex, int sequenceNumber) throws IOException- Specified by:
convertToPriorityEventin interfaceorg.apache.flink.runtime.io.network.partition.consumer.CheckpointableInput- Throws:
IOException
-
getInputIndex
public int getInputIndex()
Description copied from interface:StreamTaskInputReturns the input index of this input.- Specified by:
getInputIndexin interfaceStreamTaskInput<T>
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
prepareSnapshot
public CompletableFuture<Void> prepareSnapshot(org.apache.flink.runtime.checkpoint.channel.ChannelStateWriter channelStateWriter, long checkpointId) throws org.apache.flink.runtime.checkpoint.CheckpointException
Description copied from interface:StreamTaskInputPrepares to spill the in-flight input buffers as checkpoint snapshot.- Specified by:
prepareSnapshotin interfaceStreamTaskInput<T>- Throws:
org.apache.flink.runtime.checkpoint.CheckpointException
-
getOperatorID
public org.apache.flink.runtime.jobgraph.OperatorID getOperatorID()
-
getOperator
public SourceOperator<T,?> getOperator()
-
-