Class HashMapStateBackend

  • All Implemented Interfaces:
    Serializable, ConfigurableStateBackend, StateBackend

    @PublicEvolving
    public class HashMapStateBackend
    extends AbstractStateBackend
    implements ConfigurableStateBackend
    This state backend holds the working state in the memory (JVM heap) of the TaskManagers and checkpoints based on the configured CheckpointStorage.

    State Size Considerations

    Working state is kept on the TaskManager heap. If a TaskManager executes multiple tasks concurrently (if the TaskManager has multiple slots, or if slot-sharing is used) then the aggregate state of all tasks needs to fit into that TaskManager's memory.

    Configuration

    As for all state backends, this backend can either be configured within the application (by creating the backend with the respective constructor parameters and setting it on the execution environment) or by specifying it in the Flink configuration.

    If the state backend was specified in the application, it may pick up additional configuration parameters from the Flink configuration. For example, if the backend if configured in the application without a default savepoint directory, it will pick up a default savepoint directory specified in the Flink configuration of the running job/cluster. That behavior is implemented via the configure(ReadableConfig, ClassLoader) method.

    See Also:
    Serialized Form
    • Constructor Detail

      • HashMapStateBackend

        public HashMapStateBackend()
        Creates a new state backend.
    • Method Detail

      • configure

        public HashMapStateBackend configure​(org.apache.flink.configuration.ReadableConfig config,
                                             ClassLoader classLoader)
                                      throws org.apache.flink.configuration.IllegalConfigurationException
        Description copied from interface: ConfigurableStateBackend
        Creates a variant of the state backend that applies additional configuration parameters.

        Settings that were directly done on the original state backend object in the application program typically have precedence over setting picked up from the configuration.

        If no configuration is applied, or if the method directly applies configuration values to the (mutable) state backend object, this method may return the original state backend object. Otherwise it typically returns a modified copy.

        Specified by:
        configure in interface ConfigurableStateBackend
        Parameters:
        config - The configuration to pick the values from.
        classLoader - The class loader that should be used to load the state backend.
        Returns:
        A reconfigured state backend.
        Throws:
        org.apache.flink.configuration.IllegalConfigurationException - Thrown if the configuration contained invalid entries.
      • supportsSavepointFormat

        public boolean supportsSavepointFormat​(org.apache.flink.core.execution.SavepointFormatType formatType)
        Specified by:
        supportsSavepointFormat in interface StateBackend
      • createKeyedStateBackend

        public <K> AbstractKeyedStateBackend<K> createKeyedStateBackend​(Environment env,
                                                                        org.apache.flink.api.common.JobID jobID,
                                                                        String operatorIdentifier,
                                                                        org.apache.flink.api.common.typeutils.TypeSerializer<K> keySerializer,
                                                                        int numberOfKeyGroups,
                                                                        KeyGroupRange keyGroupRange,
                                                                        TaskKvStateRegistry kvStateRegistry,
                                                                        TtlTimeProvider ttlTimeProvider,
                                                                        org.apache.flink.metrics.MetricGroup metricGroup,
                                                                        @Nonnull
                                                                        Collection<KeyedStateHandle> stateHandles,
                                                                        org.apache.flink.core.fs.CloseableRegistry cancelStreamRegistry)
                                                                 throws IOException
        Description copied from interface: StateBackend
        Creates a new CheckpointableKeyedStateBackend that is responsible for holding keyed state and checkpointing it.

        Keyed State is state where each value is bound to a key.

        Specified by:
        createKeyedStateBackend in interface StateBackend
        Specified by:
        createKeyedStateBackend in class AbstractStateBackend
        Type Parameters:
        K - The type of the keys by which the state is organized.
        Parameters:
        env - The environment of the task.
        jobID - The ID of the job that the task belongs to.
        operatorIdentifier - The identifier text of the operator.
        keySerializer - The key-serializer for the operator.
        numberOfKeyGroups - The number of key-groups aka max parallelism.
        keyGroupRange - Range of key-groups for which the to-be-created backend is responsible.
        kvStateRegistry - KvStateRegistry helper for this task.
        ttlTimeProvider - Provider for TTL logic to judge about state expiration.
        metricGroup - The parent metric group for all state backend metrics.
        stateHandles - The state handles for restore.
        cancelStreamRegistry - The registry to which created closeable objects will be registered during restore.
        Returns:
        The Keyed State Backend for the given job, operator, and key group range.
        Throws:
        IOException