Interface AsyncKeyedStateBackend<K>

    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      StateExecutor createStateExecutor()
      Creates a StateExecutor which supports to execute a batch of state requests asynchronously.
      <N,​S extends InternalKeyedState,​SV>
      S
      createStateInternal​(N defaultNamespace, org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer, org.apache.flink.api.common.state.v2.StateDescriptor<SV> stateDesc)
      Creates and returns a new state for internal usage.
      void dispose()  
      KeyGroupRange getKeyGroupRange()
      Returns the key groups which this state backend is responsible for.
      <N,​S extends org.apache.flink.api.common.state.v2.State,​SV>
      S
      getOrCreateKeyedState​(N defaultNamespace, org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer, org.apache.flink.api.common.state.v2.StateDescriptor<SV> stateDesc)
      Creates or retrieves a keyed state backed by this state backend.
      default boolean isSafeToReuseKVState()
      Whether it's safe to reuse key-values from the state-backend, e.g for the purpose of optimization.
      default boolean requiresLegacySynchronousTimerSnapshots​(SnapshotType checkpointType)
      Whether the keyed state backend requires legacy synchronous timer snapshots.
      void setup​(StateRequestHandler stateRequestHandler)
      Initializes with some contexts.
      default void switchContext​(RecordContext<K> context)
      By default, a state backend does nothing when a key is switched in async processing.
      • Methods inherited from interface org.apache.flink.api.common.state.CheckpointListener

        notifyCheckpointAborted, notifyCheckpointComplete
      • Methods inherited from interface org.apache.flink.api.common.state.InternalCheckpointListener

        notifyCheckpointSubsumed
    • Method Detail

      • setup

        void setup​(@Nonnull
                   StateRequestHandler stateRequestHandler)
        Initializes with some contexts.
        Parameters:
        stateRequestHandler - which handles state request.
      • getOrCreateKeyedState

        <N,​S extends org.apache.flink.api.common.state.v2.State,​SV> S getOrCreateKeyedState​(N defaultNamespace,
                                                                                                        org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer,
                                                                                                        org.apache.flink.api.common.state.v2.StateDescriptor<SV> stateDesc)
                                                                                                 throws Exception
        Creates or retrieves a keyed state backed by this state backend.
        Type Parameters:
        N - the type of namespace for partitioning.
        S - The type of the public API state.
        SV - The type of the stored state value.
        Parameters:
        defaultNamespace - the default namespace for this state.
        namespaceSerializer - the serializer for namespace.
        stateDesc - The StateDescriptor that contains the name of the state.
        Returns:
        A new key/value state backed by this backend.
        Throws:
        Exception - Exceptions may occur during initialization of the state and should be forwarded.
      • createStateInternal

        @Nonnull
        <N,​S extends InternalKeyedState,​SV> S createStateInternal​(@Nonnull
                                                                              N defaultNamespace,
                                                                              @Nonnull
                                                                              org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer,
                                                                              @Nonnull
                                                                              org.apache.flink.api.common.state.v2.StateDescriptor<SV> stateDesc)
                                                                       throws Exception
        Creates and returns a new state for internal usage.
        Type Parameters:
        N - the type of namespace for partitioning.
        S - The type of the public API state.
        SV - The type of the stored state value.
        Parameters:
        defaultNamespace - the default namespace for this state.
        namespaceSerializer - the serializer for namespace.
        stateDesc - The StateDescriptor that contains the name of the state.
        Throws:
        Exception - Exceptions may occur during initialization of the state.
      • createStateExecutor

        @Nonnull
        StateExecutor createStateExecutor()
        Creates a StateExecutor which supports to execute a batch of state requests asynchronously.

        Notice that the AsyncKeyedStateBackend is responsible for shutting down the StateExecutors created by itself when they are no longer in use.

        Returns:
        a StateExecutor which supports to execute a batch of state requests asynchronously.
      • getKeyGroupRange

        KeyGroupRange getKeyGroupRange()
        Returns the key groups which this state backend is responsible for.
      • requiresLegacySynchronousTimerSnapshots

        default boolean requiresLegacySynchronousTimerSnapshots​(SnapshotType checkpointType)
        Whether the keyed state backend requires legacy synchronous timer snapshots.
        Parameters:
        checkpointType -
        Returns:
        true as default in case of AsyncKeyedStateBackend
      • isSafeToReuseKVState

        default boolean isSafeToReuseKVState()
        Whether it's safe to reuse key-values from the state-backend, e.g for the purpose of optimization.

        NOTE: this method should not be used to check for InternalPriorityQueue, as the priority queue could be stored on different locations, e.g ForSt state-backend could store that on JVM heap if configuring HEAP as the time-service factory.

        Returns:
        returns ture if safe to reuse the key-values from the state-backend.
      • dispose

        void dispose()
        Specified by:
        dispose in interface org.apache.flink.util.Disposable