Class StreamTaskSourceInput<T>
- java.lang.Object
-
- org.apache.flink.streaming.runtime.io.StreamTaskSourceInput<T>
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,AvailabilityProvider
,CheckpointableInput
,PushingAsyncDataInput<T>
,StreamTaskInput<T>
- Direct Known Subclasses:
StreamTaskExternallyInducedSourceInput
,StreamTaskFinishedOnRestoreSourceInput
@Internal public class StreamTaskSourceInput<T> extends Object implements StreamTaskInput<T>, CheckpointableInput
Implementation ofStreamTaskInput
that reads data from theSourceOperator
and returns theDataInputStatus
to 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
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.runtime.io.AvailabilityProvider
AVAILABLE
-
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 void
blockConsumption(InputChannelInfo channelInfo)
void
checkpointStarted(CheckpointBarrier barrier)
This method is used with unaligned checkpoints to mark the arrival of a firstCheckpointBarrier
.void
checkpointStopped(long cancelledCheckpointId)
void
close()
void
convertToPriorityEvent(int channelIndex, int sequenceNumber)
DataInputStatus
emitNext(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<InputChannelInfo>
getChannelInfos()
int
getInputGateIndex()
int
getInputIndex()
Returns the input index of this input.int
getNumberOfInputChannels()
SourceOperator<T,?>
getOperator()
OperatorID
getOperatorID()
CompletableFuture<Void>
prepareSnapshot(ChannelStateWriter channelStateWriter, long checkpointId)
Prepares to spill the in-flight input buffers as checkpoint snapshot.void
resumeConsumption(InputChannelInfo channelInfo)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.flink.runtime.io.AvailabilityProvider
isApproximatelyAvailable, isAvailable
-
-
-
-
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:PushingAsyncDataInput
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.This method should be non blocking.
- Specified by:
emitNext
in interfacePushingAsyncDataInput<T>
- Throws:
Exception
-
getAvailableFuture
public CompletableFuture<?> getAvailableFuture()
- Specified by:
getAvailableFuture
in interfaceAvailabilityProvider
- Returns:
- a future that is completed if the respective provider is available.
-
blockConsumption
public void blockConsumption(InputChannelInfo channelInfo)
- Specified by:
blockConsumption
in interfaceCheckpointableInput
-
resumeConsumption
public void resumeConsumption(InputChannelInfo channelInfo)
- Specified by:
resumeConsumption
in interfaceCheckpointableInput
-
getChannelInfos
public List<InputChannelInfo> getChannelInfos()
- Specified by:
getChannelInfos
in interfaceCheckpointableInput
-
getNumberOfInputChannels
public int getNumberOfInputChannels()
- Specified by:
getNumberOfInputChannels
in interfaceCheckpointableInput
-
checkpointStarted
public void checkpointStarted(CheckpointBarrier barrier)
This method is used with unaligned checkpoints to mark the arrival of a firstCheckpointBarrier
. For chained sources, there is noCheckpointBarrier
per se flowing through the job graph. We can assume that an imaginaryCheckpointBarrier
was produced by the source, at any point of time of our choosing.We are choosing to interpret it, that
CheckpointBarrier
for sources was received immediately as soon as we receive either checkpoint start RPC, orCheckpointBarrier
from 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:
checkpointStarted
in interfaceCheckpointableInput
-
checkpointStopped
public void checkpointStopped(long cancelledCheckpointId)
- Specified by:
checkpointStopped
in interfaceCheckpointableInput
-
getInputGateIndex
public int getInputGateIndex()
- Specified by:
getInputGateIndex
in interfaceCheckpointableInput
-
convertToPriorityEvent
public void convertToPriorityEvent(int channelIndex, int sequenceNumber) throws IOException
- Specified by:
convertToPriorityEvent
in interfaceCheckpointableInput
- Throws:
IOException
-
getInputIndex
public int getInputIndex()
Description copied from interface:StreamTaskInput
Returns the input index of this input.- Specified by:
getInputIndex
in interfaceStreamTaskInput<T>
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
prepareSnapshot
public CompletableFuture<Void> prepareSnapshot(ChannelStateWriter channelStateWriter, long checkpointId) throws CheckpointException
Description copied from interface:StreamTaskInput
Prepares to spill the in-flight input buffers as checkpoint snapshot.- Specified by:
prepareSnapshot
in interfaceStreamTaskInput<T>
- Throws:
CheckpointException
-
getOperatorID
public OperatorID getOperatorID()
-
getOperator
public SourceOperator<T,?> getOperator()
-
-