Class AsyncKeyedStateBackendAdaptor<K>

    • Method Detail

      • getOrCreateKeyedState

        public <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
        Description copied from interface: AsyncKeyedStateBackend
        Creates or retrieves a keyed state backed by this state backend.
        Specified by:
        getOrCreateKeyedState in interface AsyncKeyedStateBackend<K>
        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
        public <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
        Description copied from interface: AsyncKeyedStateBackend
        Creates and returns a new state for internal usage.
        Specified by:
        createStateInternal in interface AsyncKeyedStateBackend<K>
        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
        public StateExecutor createStateExecutor()
        Description copied from interface: AsyncKeyedStateBackend
        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.

        Specified by:
        createStateExecutor in interface AsyncKeyedStateBackend<K>
        Returns:
        a StateExecutor which supports to execute a batch of state requests asynchronously.
      • dispose

        public void dispose()
        Specified by:
        dispose in interface AsyncKeyedStateBackend<K>
        Specified by:
        dispose in interface org.apache.flink.util.Disposable
      • notifyCheckpointComplete

        public void notifyCheckpointComplete​(long checkpointId)
                                      throws Exception
        Specified by:
        notifyCheckpointComplete in interface org.apache.flink.api.common.state.CheckpointListener
        Throws:
        Exception
      • notifyCheckpointAborted

        public void notifyCheckpointAborted​(long checkpointId)
                                     throws Exception
        Specified by:
        notifyCheckpointAborted in interface org.apache.flink.api.common.state.CheckpointListener
        Throws:
        Exception
      • notifyCheckpointSubsumed

        public void notifyCheckpointSubsumed​(long checkpointId)
                                      throws Exception
        Specified by:
        notifyCheckpointSubsumed in interface org.apache.flink.api.common.state.InternalCheckpointListener
        Throws:
        Exception
      • snapshot

        @Nonnull
        public RunnableFuture<SnapshotResult<KeyedStateHandle>> snapshot​(long checkpointId,
                                                                         long timestamp,
                                                                         @Nonnull
                                                                         CheckpointStreamFactory streamFactory,
                                                                         @Nonnull
                                                                         CheckpointOptions checkpointOptions)
                                                                  throws Exception
        Description copied from interface: Snapshotable
        Operation that writes a snapshot into a stream that is provided by the given CheckpointStreamFactory and returns a @RunnableFuture that gives a state handle to the snapshot. It is up to the implementation if the operation is performed synchronous or asynchronous. In the later case, the returned Runnable must be executed first before obtaining the handle.
        Specified by:
        snapshot in interface Snapshotable<K>
        Parameters:
        checkpointId - The ID of the checkpoint.
        timestamp - The timestamp of the checkpoint.
        streamFactory - The factory that we can use for writing our state to streams.
        checkpointOptions - Options for how to perform this checkpoint.
        Returns:
        A runnable future that will yield a StateObject.
        Throws:
        Exception
      • create

        public <T extends HeapPriorityQueueElement & PriorityComparable<? super T> & Keyed<?>> KeyGroupedInternalPriorityQueue<T> create​(@Nonnull
                                                                                                                                         String stateName,
                                                                                                                                         @Nonnull
                                                                                                                                         org.apache.flink.api.common.typeutils.TypeSerializer<T> byteOrderedElementSerializer,
                                                                                                                                         boolean allowFutureMetadataUpdates)
        Description copied from interface: PriorityQueueSetFactory
        Specified by:
        create in interface PriorityQueueSetFactory
        Type Parameters:
        T - type of the stored elements.
        Parameters:
        stateName - unique name for associated with this queue.
        byteOrderedElementSerializer - a serializer that with a format that is lexicographically ordered in alignment with elementPriorityComparator.
        allowFutureMetadataUpdates - whether allow metadata to update in the future or not.
        Returns:
        the queue with the specified unique name.
      • isSafeToReuseKVState

        public boolean isSafeToReuseKVState()
        Description copied from interface: AsyncKeyedStateBackend
        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.

        Specified by:
        isSafeToReuseKVState in interface AsyncKeyedStateBackend<K>
        Returns:
        returns ture if safe to reuse the key-values from the state-backend.