Class StreamTaskSourceInput<T>
- All Implemented Interfaces:
Closeable,AutoCloseable,AvailabilityProvider,CheckpointableInput,PushingAsyncDataInput<T>,StreamTaskInput<T>
- Direct Known Subclasses:
StreamTaskExternallyInducedSourceInput,StreamTaskFinishedOnRestoreSourceInput
StreamTaskInput that reads data from the SourceOperator and
returns the DataInputStatus 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.AvailabilityHelperNested 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
AVAILABLEFields inherited from interface org.apache.flink.streaming.runtime.io.StreamTaskInput
UNSPECIFIED -
Constructor Summary
ConstructorsConstructorDescriptionStreamTaskSourceInput(SourceOperator<T, ?> operator, int inputGateIndex, int inputIndex) -
Method Summary
Modifier and TypeMethodDescriptionvoidblockConsumption(InputChannelInfo channelInfo) voidcheckpointStarted(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) 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.intintReturns the input index of this input.intSourceOperator<T,?> prepareSnapshot(ChannelStateWriter channelStateWriter, long checkpointId) Prepares to spill the in-flight input buffers as checkpoint snapshot.voidresumeConsumption(InputChannelInfo channelInfo) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.flink.runtime.io.AvailabilityProvider
isApproximatelyAvailable, isAvailable
-
Constructor Details
-
StreamTaskSourceInput
-
-
Method Details
-
emitNext
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
- Specified by:
getAvailableFuturein interfaceAvailabilityProvider- Returns:
- a future that is completed if the respective provider is available.
-
blockConsumption
- Specified by:
blockConsumptionin interfaceCheckpointableInput
-
resumeConsumption
- Specified by:
resumeConsumptionin interfaceCheckpointableInput
-
getChannelInfos
- Specified by:
getChannelInfosin interfaceCheckpointableInput
-
getNumberOfInputChannels
public int getNumberOfInputChannels()- Specified by:
getNumberOfInputChannelsin interfaceCheckpointableInput
-
checkpointStarted
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 interfaceCheckpointableInput
-
checkpointStopped
public void checkpointStopped(long cancelledCheckpointId) - Specified by:
checkpointStoppedin interfaceCheckpointableInput
-
getInputGateIndex
public int getInputGateIndex()- Specified by:
getInputGateIndexin interfaceCheckpointableInput
-
convertToPriorityEvent
- Specified by:
convertToPriorityEventin interfaceCheckpointableInput- 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(ChannelStateWriter channelStateWriter, long checkpointId) throws CheckpointException Description copied from interface:StreamTaskInputPrepares to spill the in-flight input buffers as checkpoint snapshot.- Specified by:
prepareSnapshotin interfaceStreamTaskInput<T>- Throws:
CheckpointException
-
getOperatorID
-
getOperator
-