Class OperatorChain<OUT,​OP extends StreamOperator<OUT>>

  • Type Parameters:
    OUT - The type of elements accepted by the chain, i.e., the input type of the chain's main operator.
    All Implemented Interfaces:
    Closeable, AutoCloseable, BoundedMultiInput
    Direct Known Subclasses:
    FinishedOperatorChain, RegularOperatorChain

    public abstract class OperatorChain<OUT,​OP extends StreamOperator<OUT>>
    extends Object
    implements BoundedMultiInput, Closeable
    The OperatorChain contains all operators that are executed as one chain within a single StreamTask.

    The main entry point to the chain is it's mainOperator. mainOperator is driving the execution of the StreamTask, by pulling the records from network inputs and/or source inputs and pushing produced records to the remaining chained operators.

    • Constructor Detail

      • OperatorChain

        public OperatorChain​(StreamTask<OUT,​OP> containingTask,
                             org.apache.flink.runtime.io.network.api.writer.RecordWriterDelegate<org.apache.flink.runtime.plugable.SerializationDelegate<StreamRecord<OUT>>> recordWriterDelegate)
    • Method Detail

      • isTaskDeployedAsFinished

        public abstract boolean isTaskDeployedAsFinished()
      • dispatchOperatorEvent

        public abstract void dispatchOperatorEvent​(org.apache.flink.runtime.jobgraph.OperatorID operator,
                                                   org.apache.flink.util.SerializedValue<org.apache.flink.runtime.operators.coordination.OperatorEvent> event)
                                            throws org.apache.flink.util.FlinkException
        Throws:
        org.apache.flink.util.FlinkException
      • prepareSnapshotPreBarrier

        public abstract void prepareSnapshotPreBarrier​(long checkpointId)
                                                throws Exception
        Throws:
        Exception
      • endInput

        public abstract void endInput​(int inputId)
                               throws Exception
        Ends the main operator input specified by inputId).
        Specified by:
        endInput in interface BoundedMultiInput
        Parameters:
        inputId - the input ID starts from 1 which indicates the first input.
        Throws:
        Exception
      • notifyCheckpointComplete

        public abstract void notifyCheckpointComplete​(long checkpointId)
                                               throws Exception
        Throws:
        Exception
      • notifyCheckpointAborted

        public abstract void notifyCheckpointAborted​(long checkpointId)
                                              throws Exception
        Throws:
        Exception
      • notifyCheckpointSubsumed

        public abstract void notifyCheckpointSubsumed​(long checkpointId)
                                               throws Exception
        Throws:
        Exception
      • snapshotState

        public abstract void snapshotState​(Map<org.apache.flink.runtime.jobgraph.OperatorID,​OperatorSnapshotFutures> operatorSnapshotsInProgress,
                                           org.apache.flink.runtime.checkpoint.CheckpointMetaData checkpointMetaData,
                                           org.apache.flink.runtime.checkpoint.CheckpointOptions checkpointOptions,
                                           Supplier<Boolean> isRunning,
                                           org.apache.flink.runtime.checkpoint.channel.ChannelStateWriter.ChannelStateWriteResult channelStateWriteResult,
                                           org.apache.flink.runtime.state.CheckpointStreamFactory storage)
                                    throws Exception
        Throws:
        Exception
      • getOperatorEventDispatcher

        public org.apache.flink.runtime.operators.coordination.OperatorEventDispatcher getOperatorEventDispatcher()
      • broadcastEvent

        public void broadcastEvent​(org.apache.flink.runtime.event.AbstractEvent event)
                            throws IOException
        Throws:
        IOException
      • broadcastEvent

        public void broadcastEvent​(org.apache.flink.runtime.event.AbstractEvent event,
                                   boolean isPriorityEvent)
                            throws IOException
        Throws:
        IOException
      • alignedBarrierTimeout

        public void alignedBarrierTimeout​(long checkpointId)
                                   throws IOException
        Throws:
        IOException
      • abortCheckpoint

        public void abortCheckpoint​(long checkpointId,
                                    org.apache.flink.runtime.checkpoint.CheckpointException cause)
      • getAllOperators

        protected Iterable<StreamOperatorWrapper<?,​?>> getAllOperators​(boolean reverse)
        Returns an Iterable which traverses all operators in forward or reverse topological order.
      • getFinishedOnRestoreInputOrDefault

        public Input getFinishedOnRestoreInputOrDefault​(Input defaultInput)
      • getNumberOfOperators

        public int getNumberOfOperators()
      • flushOutputs

        public void flushOutputs()
                          throws IOException
        This method should be called before finishing the record emission, to make sure any data that is still buffered will be sent. It also ensures that all data sending related exceptions are recognized.
        Throws:
        IOException - Thrown, if the buffered data cannot be pushed into the output streams.
      • close

        public void close()
                   throws IOException
        This method releases all resources of the record writer output. It stops the output flushing thread (if there is one) and releases all buffers currently held by the output serializers.

        This method should never fail.

        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Closeable
        Throws:
        IOException
      • getMainOperator

        @Nullable
        public OP getMainOperator()
      • snapshotChannelStates

        protected void snapshotChannelStates​(StreamOperator<?> op,
                                             org.apache.flink.runtime.checkpoint.channel.ChannelStateWriter.ChannelStateWriteResult channelStateWriteResult,
                                             OperatorSnapshotFutures snapshotInProgress)
      • isClosed

        public boolean isClosed()
      • sendAcknowledgeCheckpointEvent

        protected void sendAcknowledgeCheckpointEvent​(long checkpointId)