Class StreamTaskStateInitializerImpl

  • All Implemented Interfaces:
    StreamTaskStateInitializer

    public class StreamTaskStateInitializerImpl
    extends Object
    implements StreamTaskStateInitializer
    This class is the main implementation of a StreamTaskStateInitializer. This class obtains the state to create StreamOperatorStateContext objects for stream operators from the TaskStateManager of the task that runs the stream task and hence the operator.

    This implementation operates on top a TaskStateManager, from which it receives everything required to restore state in the backends from checkpoints or savepoints.

    • Constructor Summary

      Constructors 
      Constructor Description
      StreamTaskStateInitializerImpl​(org.apache.flink.runtime.execution.Environment environment, org.apache.flink.runtime.state.StateBackend stateBackend)  
      StreamTaskStateInitializerImpl​(org.apache.flink.runtime.execution.Environment environment, org.apache.flink.runtime.state.StateBackend stateBackend, org.apache.flink.runtime.checkpoint.SubTaskInitializationMetricsBuilder initializationMetrics, org.apache.flink.runtime.state.ttl.TtlTimeProvider ttlTimeProvider, InternalTimeServiceManager.Provider timeServiceManagerProvider, StreamTaskCancellationContext cancellationContext)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected <K,​R extends org.apache.flink.util.Disposable & Closeable>
      R
      keyedStatedBackend​(org.apache.flink.api.common.typeutils.TypeSerializer<K> keySerializer, String operatorIdentifierText, org.apache.flink.runtime.checkpoint.PrioritizedOperatorSubtaskState prioritizedOperatorSubtaskStates, org.apache.flink.core.fs.CloseableRegistry backendCloseableRegistry, org.apache.flink.metrics.MetricGroup metricGroup, double managedMemoryFraction, org.apache.flink.runtime.state.StateObject.StateObjectSizeStatsCollector statsCollector, StreamTaskStateInitializerImpl.KeyedStateBackendCreator<K,​R> keyedStateBackendCreator)  
      protected org.apache.flink.runtime.state.OperatorStateBackend operatorStateBackend​(String operatorIdentifierText, org.apache.flink.runtime.checkpoint.PrioritizedOperatorSubtaskState prioritizedOperatorSubtaskStates, org.apache.flink.core.fs.CloseableRegistry backendCloseableRegistry, org.apache.flink.runtime.state.StateObject.StateObjectSizeStatsCollector statsCollector)  
      protected org.apache.flink.util.CloseableIterable<org.apache.flink.runtime.state.KeyGroupStatePartitionStreamProvider> rawKeyedStateInputs​(Iterator<org.apache.flink.runtime.checkpoint.StateObjectCollection<org.apache.flink.runtime.state.KeyedStateHandle>> restoreStateAlternatives, org.apache.flink.runtime.state.StateObject.StateObjectSizeStatsCollector statsCollector)  
      protected org.apache.flink.util.CloseableIterable<org.apache.flink.runtime.state.StatePartitionStreamProvider> rawOperatorStateInputs​(Iterator<org.apache.flink.runtime.checkpoint.StateObjectCollection<org.apache.flink.runtime.state.OperatorStateHandle>> restoreStateAlternatives, org.apache.flink.runtime.state.StateObject.StateObjectSizeStatsCollector statsCollector)  
      StreamOperatorStateContext streamOperatorStateContext​(org.apache.flink.runtime.jobgraph.OperatorID operatorID, String operatorClassName, ProcessingTimeService processingTimeService, KeyContext keyContext, org.apache.flink.api.common.typeutils.TypeSerializer<?> keySerializer, org.apache.flink.core.fs.CloseableRegistry streamTaskCloseableRegistry, org.apache.flink.metrics.MetricGroup metricGroup, double managedMemoryFraction, boolean isUsingCustomRawKeyedState)
      Returns the StreamOperatorStateContext for an AbstractStreamOperator that runs in the stream task that owns this manager.
    • Constructor Detail

      • StreamTaskStateInitializerImpl

        public StreamTaskStateInitializerImpl​(org.apache.flink.runtime.execution.Environment environment,
                                              org.apache.flink.runtime.state.StateBackend stateBackend)
      • StreamTaskStateInitializerImpl

        public StreamTaskStateInitializerImpl​(org.apache.flink.runtime.execution.Environment environment,
                                              org.apache.flink.runtime.state.StateBackend stateBackend,
                                              org.apache.flink.runtime.checkpoint.SubTaskInitializationMetricsBuilder initializationMetrics,
                                              org.apache.flink.runtime.state.ttl.TtlTimeProvider ttlTimeProvider,
                                              InternalTimeServiceManager.Provider timeServiceManagerProvider,
                                              StreamTaskCancellationContext cancellationContext)
    • Method Detail

      • streamOperatorStateContext

        public StreamOperatorStateContext streamOperatorStateContext​(@Nonnull
                                                                     org.apache.flink.runtime.jobgraph.OperatorID operatorID,
                                                                     @Nonnull
                                                                     String operatorClassName,
                                                                     @Nonnull
                                                                     ProcessingTimeService processingTimeService,
                                                                     @Nonnull
                                                                     KeyContext keyContext,
                                                                     @Nullable
                                                                     org.apache.flink.api.common.typeutils.TypeSerializer<?> keySerializer,
                                                                     @Nonnull
                                                                     org.apache.flink.core.fs.CloseableRegistry streamTaskCloseableRegistry,
                                                                     @Nonnull
                                                                     org.apache.flink.metrics.MetricGroup metricGroup,
                                                                     double managedMemoryFraction,
                                                                     boolean isUsingCustomRawKeyedState)
                                                              throws Exception
        Description copied from interface: StreamTaskStateInitializer
        Returns the StreamOperatorStateContext for an AbstractStreamOperator that runs in the stream task that owns this manager.
        Specified by:
        streamOperatorStateContext in interface StreamTaskStateInitializer
        Parameters:
        operatorID - the id of the operator for which the context is created. Cannot be null.
        operatorClassName - the classname of the operator instance for which the context is created. Cannot be null.
        keyContext - the key context of the operator instance for which the context is created Cannot be null.
        keySerializer - the key-serializer for the operator. Can be null.
        streamTaskCloseableRegistry - the closeable registry to which created closeable objects will be registered.
        metricGroup - the parent metric group for all statebackend metrics
        managedMemoryFraction - the managed memory fraction of the operator for state backend
        isUsingCustomRawKeyedState - flag indicating whether or not the AbstractStreamOperator is writing custom raw keyed state.
        Returns:
        a context from which the given operator can initialize everything related to state.
        Throws:
        Exception - when something went wrong while creating the context.
      • operatorStateBackend

        protected org.apache.flink.runtime.state.OperatorStateBackend operatorStateBackend​(String operatorIdentifierText,
                                                                                           org.apache.flink.runtime.checkpoint.PrioritizedOperatorSubtaskState prioritizedOperatorSubtaskStates,
                                                                                           org.apache.flink.core.fs.CloseableRegistry backendCloseableRegistry,
                                                                                           org.apache.flink.runtime.state.StateObject.StateObjectSizeStatsCollector statsCollector)
                                                                                    throws Exception
        Throws:
        Exception
      • keyedStatedBackend

        protected <K,​R extends org.apache.flink.util.Disposable & Closeable> R keyedStatedBackend​(org.apache.flink.api.common.typeutils.TypeSerializer<K> keySerializer,
                                                                                                        String operatorIdentifierText,
                                                                                                        org.apache.flink.runtime.checkpoint.PrioritizedOperatorSubtaskState prioritizedOperatorSubtaskStates,
                                                                                                        org.apache.flink.core.fs.CloseableRegistry backendCloseableRegistry,
                                                                                                        org.apache.flink.metrics.MetricGroup metricGroup,
                                                                                                        double managedMemoryFraction,
                                                                                                        org.apache.flink.runtime.state.StateObject.StateObjectSizeStatsCollector statsCollector,
                                                                                                        StreamTaskStateInitializerImpl.KeyedStateBackendCreator<K,​R> keyedStateBackendCreator)
                                                                                                 throws Exception
        Throws:
        Exception
      • rawOperatorStateInputs

        protected org.apache.flink.util.CloseableIterable<org.apache.flink.runtime.state.StatePartitionStreamProvider> rawOperatorStateInputs​(@Nonnull
                                                                                                                                              Iterator<org.apache.flink.runtime.checkpoint.StateObjectCollection<org.apache.flink.runtime.state.OperatorStateHandle>> restoreStateAlternatives,
                                                                                                                                              @Nonnull
                                                                                                                                              org.apache.flink.runtime.state.StateObject.StateObjectSizeStatsCollector statsCollector)
      • rawKeyedStateInputs

        protected org.apache.flink.util.CloseableIterable<org.apache.flink.runtime.state.KeyGroupStatePartitionStreamProvider> rawKeyedStateInputs​(@Nonnull
                                                                                                                                                   Iterator<org.apache.flink.runtime.checkpoint.StateObjectCollection<org.apache.flink.runtime.state.KeyedStateHandle>> restoreStateAlternatives,
                                                                                                                                                   @Nonnull
                                                                                                                                                   org.apache.flink.runtime.state.StateObject.StateObjectSizeStatsCollector statsCollector)