You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2020/11/04 06:30:09 UTC

[GitHub] [flink] dianfu commented on a change in pull request #13912: [FLINK-19466][FLINK-19467][runtime / state backends] Add Flip-142 public interfaces and methods

dianfu commented on a change in pull request #13912:
URL: https://github.com/apache/flink/pull/13912#discussion_r517112769



##########
File path: flink-python/pyflink/datastream/checkpoint_config.py
##########
@@ -330,6 +331,47 @@ def disable_unaligned_checkpoints(self) -> 'CheckpointConfig':
         self.enable_unaligned_checkpoints(False)
         return self
 
+    def set_checkpoint_storage(self, checkpoint_storage):
+        """
+        Sets the checkpoint storage that describes how to checkpoint operator state. It
+        defines where checkpointed data will be persisted.
+        The :class:`~pyflink.datastream.JobManagerCheckpointStorage` is lightweight without extra
+        dependencies, but can checkpoint only small states(some counters).
+        In contrast, the :class:`~pyflink.datastream.FileSystemCheckpointStorage` stores checkpoints
+        of the state in files. When using a replicated file system (like HDFS,
+        S3, MapR FS, Alluxio, etc) this will guarantee that state is not lost upon failures of
+        individual nodes and that streaming program can be executed highly available and strongly
+        consistent(assuming that Flink is run in high-availability mode). This checkpoint storage is
+        recommended for most production deployments.
+
+        The build-in state backend includes:
+            :class:`~pyflink.datastream.JobManagerCheckpointStorage`,
+            and :class:`~pyflink.datastream.FileSystemCheckpointStorage`.
+
+        .. seealso:: :func:`get_checkpoint_storage`
+
+        Example:
+        ::
+            >>> env.get_checkpoint_config()\
+                .set_checkpoint_storage(FileSystemCheckpointStorage("file://var/checkpoints/"))
+        :param checkpoint_storage: The :class:`CheckpointStorage`.
+        """
+
+        self._j_checkpoint_config.setCheckpointStorage(checkpoint_storage._j_checkpoint_storage)
+
+    def get_checkpoint_storage(self):

Review comment:
       ```suggestion
       def get_checkpoint_storage(self) -> CheckpointStorage:
   ```

##########
File path: flink-python/pyflink/datastream/checkpoint_config.py
##########
@@ -330,6 +331,47 @@ def disable_unaligned_checkpoints(self) -> 'CheckpointConfig':
         self.enable_unaligned_checkpoints(False)
         return self
 
+    def set_checkpoint_storage(self, checkpoint_storage):

Review comment:
       ```suggestion
       def set_checkpoint_storage(self, checkpoint_storage: CheckpointStorage):  -> 'CheckpointConfig':
   ```

##########
File path: flink-python/pyflink/datastream/checkpoint_config.py
##########
@@ -330,6 +331,47 @@ def disable_unaligned_checkpoints(self) -> 'CheckpointConfig':
         self.enable_unaligned_checkpoints(False)
         return self
 
+    def set_checkpoint_storage(self, checkpoint_storage):
+        """
+        Sets the checkpoint storage that describes how to checkpoint operator state. It
+        defines where checkpointed data will be persisted.
+        The :class:`~pyflink.datastream.JobManagerCheckpointStorage` is lightweight without extra
+        dependencies, but can checkpoint only small states(some counters).
+        In contrast, the :class:`~pyflink.datastream.FileSystemCheckpointStorage` stores checkpoints
+        of the state in files. When using a replicated file system (like HDFS,
+        S3, MapR FS, Alluxio, etc) this will guarantee that state is not lost upon failures of
+        individual nodes and that streaming program can be executed highly available and strongly
+        consistent(assuming that Flink is run in high-availability mode). This checkpoint storage is
+        recommended for most production deployments.
+
+        The build-in state backend includes:
+            :class:`~pyflink.datastream.JobManagerCheckpointStorage`,
+            and :class:`~pyflink.datastream.FileSystemCheckpointStorage`.
+
+        .. seealso:: :func:`get_checkpoint_storage`
+
+        Example:
+        ::
+            >>> env.get_checkpoint_config()\
+                .set_checkpoint_storage(FileSystemCheckpointStorage("file://var/checkpoints/"))
+        :param checkpoint_storage: The :class:`CheckpointStorage`.
+        """
+
+        self._j_checkpoint_config.setCheckpointStorage(checkpoint_storage._j_checkpoint_storage)

Review comment:
       ```suggestion
           self._j_checkpoint_config.setCheckpointStorage(checkpoint_storage._j_checkpoint_storage)
           return self
   ```

##########
File path: flink-python/pyflink/datastream/checkpoint_storage.py
##########
@@ -0,0 +1,302 @@
+################################################################################
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+# limitations under the License.
+################################################################################
+
+from abc import ABCMeta
+
+from py4j.java_gateway import get_java_class
+
+from pyflink.java_gateway import get_gateway
+
+__all__ = [
+    'CheckpointStorage',
+    'JobManagerCheckpointStorage',
+    'FileSystemCheckpointStorage',
+    'CustomCheckpointStorage'
+]
+
+
+def _from_j_checkpoint_storage(j_checkpoint_storage):
+    if j_checkpoint_storage is None:
+        return None
+    gateway = get_gateway()
+    JCheckpointStorage = gateway.jvm.org.apache.flink.runtime.state.CheckpointStorage
+    JJobManagerCheckpointStorage = gateway.jvm.org.apache.flink.runtime.state.storage \
+        .JobManagerCheckpointStorage
+    JFileSystemCheckpointStorage = gateway.jvm.org.apache.flink.runtime.state.storage \
+        .FileSystemCheckpointStorage
+    j_clz = j_checkpoint_storage.getClass()
+
+    if not get_java_class(JCheckpointStorage).isAssignableFrom(j_clz):
+        raise TypeError("The input %s is not an instance of CheckpointStorage."
+                        % j_checkpoint_storage)
+
+    if get_java_class(JJobManagerCheckpointStorage).isAssignableFrom(j_clz):
+        return JobManagerCheckpointStorage(j_jobmanager_checkpoint_storage=j_checkpoint_storage)
+    elif get_java_class(JFileSystemCheckpointStorage).isAssignableFrom(j_clz):
+        return FileSystemCheckpointStorage(j_fs_checkpoint_storage=j_checkpoint_storage)
+    else:
+        return CustomCheckpointStorage(j_checkpoint_storage)  # users' customized state backend
+
+
+class CheckpointStorage(object):
+    """
+    CheckpointStorage defines how :class:`StateBackend`'s checkpoint their state for fault
+    tolerance in streaming applications. Various implementations store their checkpoints in
+    different fashions and have different requirements and availability guarantees.
+
+    For example, :class:`JobManagerCheckpointStorage` stores checkpoints in the memory of
+    the JobManager. It is lightweight and without additional dependencies but is not highly
+    available and only supports small state sizes. This checkpoint storage policy is convenient
+    for local testing and development.
+
+    :class`FileSystemCheckpointStorage` stores checkpoints in a filesystem. For systems like HDFS,
+    NFS Drives, S3, and GCS, this storage policy supports large state size, in the magnitude of
+    many terabytes while providing a highly available foundation for stateful applications. This
+    checkpoint storage policy is recommended for most production deployments.
+
+    **Raw Bytes Storage**
+
+    The **CheckpointStorage** creates services for raw bytes storage.
+
+    The raw bytes storage (through the CheckpointStreamFactory) is the fundamental service that
+    simply stores bytes in a fault tolerant fashion. This service is used by the JobManager
+    to store checkpoint and recovery metadata and is typically also used by the keyed- and operator
+    state backends to store checkpointed state.
+
+    **Serializability**
+
+    Checkpoint storage need to be serializable, because they distributed across parallel processes
+    (for distributed execution) together with the streaming application code.
+
+    Because of that, **CheckpointStorage** implementations are meant to be like factories
+    that create the proper states stores that provide access to the persistent. That way, the
+    Checkpoint Storage can be very lightweight (contain only configurations) which makes it easier
+    to be serializable.
+
+    **Thread Safety**
+
+    Checkpoint storage implementations have to be thread-safe. Multiple threads may be creating
+    streams concurrently.
+    """
+
+    __metaclass__ = ABCMeta
+
+    def __init__(self, j_checkpoint_storage):
+        self._j_checkpoint_storage = j_checkpoint_storage
+
+
+class JobManagerCheckpointStorage(CheckpointStorage):
+    """
+     This **CheckpointStorage** checkpoints state directly to the JobManager's memory (hence the
+     name), but savepoints will be persisted to a file system.
+
+    This checkpoint storage is primarily  for experimentation, quick local setups, or for streaming
+    applications that have very small state: Because it requires checkpoints to go through the
+    JobManager's memory, larger state will occupy larger portions of the JobManager's main memory,
+    reducing operational stability.
+
+    For any other setup, the :class:`FileSystemCheckpointStorage` should be used. The
+    **FileSystemCheckpointStorage** checkpoints state directly to files rather than
+    to the JobManager's memory, thus supporting larger state sizes and more highly available
+    recovery.
+
+    **State Size Considerations**
+
+    State checkpointing with this state backend is subject to the following conditions:
+
+    - Each individual state must not exceed the configured maximum state size
+      (see :func:`get_max_state_size`.
+
+    - All state from one task (i.e., the sum of all operator states and keyed states from all
+      chained operators of the task) must not exceed what the RPC system supports, which is
+      be default < 10 MB. That limit can be configured up, but that is typically not advised.
+
+    - The sum of all states in the application times all retained checkpoints must comfortably
+      fit into the JobManager's JVM heap space.
+
+    **Persistence Guarantees**
+
+    For the use cases where the state sizes can be handled by this backend, the backend does
+    guarantee persistence for savepoints, externalized checkpoints (of configured), and checkpoints
+    (when high-availability is configured).
+
+    **Configuration**
+
+    As for all checkpoint storage, this storage policy can either be configured within the
+    application (by creating the storage with the respective constructor parameters and setting
+    it on the execution environment) or by specifying it in the Flink configuration.
+
+    If the checkpoint storage was specified in the application, it may pick up additional
+    configuration parameters from the Flink configuration. That behavior is
+    implemented via the :func:`configure` method.
+    """
+
+    # The default maximal size that the snapshotted memory state may have (5 MiBytes).
+    DEFAULT_MAX_STATE_SIZE = 5 * 1024 * 1024
+
+    def __init__(self,
+                 checkpoint_path=None,
+                 max_state_size=None,
+                 j_jobmanager_checkpoint_storage=None):
+        """
+        Creates a new JobManagerCheckpointStorage, setting optionally the paths to persist
+        checkpoint metadata, as well as configuring state thresholds.
+
+        WARNING: Increasing the size of this value beyond the default value
+        (:data:`DEFAULT_MAX_STATE_SIZE`) should be done with care.
+        The checkpointed state needs to be send to the JobManager via limited size RPC messages,
+        and there and the JobManager needs to be able to hold all aggregated state in its memory.
+
+        Example:
+        ::
+            >>> checkpoint_storage = JobManagerCheckpointStorage()
+
+        :param checkpoint_path: The path to write checkpoint metadata to. If none, the value from
+                                the runtime configuration will be used.
+        :param max_state_size: The maximal size of the serialized state. If none, the
+                               :data:`DEFAULT_MAX_STATE_SIZE` will be used.
+        :param j_jobmanager_checkpoint_storage: For internal use, please keep none.
+        """
+        if j_jobmanager_checkpoint_storage is None:
+            gateway = get_gateway()
+            JJobManagerCheckpointStorage = gateway.jvm.org.apache.flink.runtime.state.storage \
+                .JobManagerCheckpointStorage
+            if max_state_size is None:
+                max_state_size = JJobManagerCheckpointStorage.DEFAULT_MAX_STATE_SIZE
+            j_jobmanager_checkpoint_storage = JJobManagerCheckpointStorage(checkpoint_path,
+                                                                           max_state_size)
+
+        self._j_jobmanager_checkpoint_storage = j_jobmanager_checkpoint_storage

Review comment:
       could be removed

##########
File path: flink-python/pyflink/datastream/state_backend.py
##########
@@ -116,8 +125,320 @@ def __init__(self, j_state_backend):
         self._j_state_backend = j_state_backend
 
 
+class HashMapStateBackend(StateBackend):
+    """
+    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 :func:`configure` method.
+    """
+
+    def __init__(self,
+                 using_asynchronous_snapshots=None,
+                 j_hashmap_state_backend=None):
+        """
+        Creates a new HashMapStateBackend, enabling optionally asynchronous operations.
+
+        Example:
+        ::
+            >>> state_backend = HashMapStateBackend()
+
+        :param using_asynchronous_snapshots: Flag to switch between synchronous and asynchronous
+                                             snapshot mode. If null, the value configured in the
+                                             runtime configuration will be used.
+        :param j_hashmap_state_backend: For internal use, please keep none.
+        """
+        if j_hashmap_state_backend is None:
+            gateway = get_gateway()
+            JTernaryBoolean = gateway.jvm.org.apache.flink.util.TernaryBoolean
+            JHashMapStateBackend = gateway.jvm.org.apache.flink.runtime.state.hashmap \
+                .HashMapStateBackend
+            if using_asynchronous_snapshots is None:
+                j_asynchronous_snapshots = JTernaryBoolean.UNDEFINED
+            elif using_asynchronous_snapshots is True:
+                j_asynchronous_snapshots = JTernaryBoolean.TRUE
+            elif using_asynchronous_snapshots is False:
+                j_asynchronous_snapshots = JTernaryBoolean.FALSE
+            else:
+                raise TypeError("Unsupported input for 'using_asynchronous_snapshots': %s, "
+                                "the value of the parameter should be None or"
+                                "True or False.")
+            j_hashmap_state_backend = JHashMapStateBackend(j_asynchronous_snapshots)
+
+        self._j_memory_state_backend = j_hashmap_state_backend
+        super(HashMapStateBackend, self).__init__(j_hashmap_state_backend)
+
+    def is_using_asynchronous_snapshots(self):
+        """
+        Gets whether the key/value data structures are asynchronously snapshotted.
+
+        If not explicitly configured, this is the default value of
+        ``org.apache.flink.configuration.CheckpointingOptions.ASYNC_SNAPSHOTS``.
+
+        :return: True if the key/value data structures are asynchronously snapshotted,
+                 false otherwise.
+        """
+        return self._j_memory_state_backend.isUsingAsynchronousSnapshots()
+
+    def __str__(self):
+        return self._j_memory_state_backend.toString()
+
+
+class EmbeddedRocksDBStateBackend(StateBackend):
+    """
+    A State Backend that stores its state in an embedded ``RocksDB``. This state backend can
+    store very large state that exceeds memory and spills to disk.
+
+    All key/value state (including windows) is stored in the key/value index of RocksDB.
+    For persistence against loss of machines, please configure a checkpoint storage
+    instance for the Job.
+
+    The behavior of the RocksDB instances can be parametrized by setting RocksDB Options
+    using the methods :func:`set_predefined_options` and :func:`set_options`.
+    """
+
+    def __init__(self,
+                 enable_incremental_checkpointing=None,
+                 j_rocks_db_state_backend=None):
+        """
+        Creates a new :class:`RocksDBStateBackend` that stores its checkpoint data in the given
+        state backend or the location of given URI.
+
+        If using state backend, typically, one would supply a filesystem or database state backend
+        here where the snapshots from RocksDB would be stored.
+
+        If using URI, a state backend that stores checkpoints in HDFS or S3 must specify the file
+        system host and port in the URI, or have the Hadoop configuration that describes the file
+        system (host / high-availability group / possibly credentials) either referenced from the
+        Flink config, or included in the classpath.
+
+        Example:
+        ::
+
+            >>> state_backend = EmbeddedRocksDBStateBackend()
+
+        :param enable_incremental_checkpointing: True if incremental checkpointing is enabled.
+        :param j_rocks_db_state_backend: For internal use, please keep none.
+        """
+        if j_rocks_db_state_backend is None:
+            gateway = get_gateway()
+            JTernaryBoolean = gateway.jvm.org.apache.flink.util.TernaryBoolean
+            JEmbeddedRocksDBStateBackend = gateway.jvm.org.apache.flink.contrib.streaming.state \
+                .EmbeddedRocksDBStateBackend
+
+            if enable_incremental_checkpointing not in (None, True, False):
+                raise TypeError("Unsupported input for 'enable_incremental_checkpointing': %s, "
+                                "the value of the parameter should be None or"
+                                "True or False.")
+
+            if enable_incremental_checkpointing is None:
+                j_enable_incremental_checkpointing = JTernaryBoolean.UNDEFINED
+            elif enable_incremental_checkpointing is True:
+                j_enable_incremental_checkpointing = JTernaryBoolean.TRUE
+            else:
+                j_enable_incremental_checkpointing = JTernaryBoolean.FALSE
+
+            j_rocks_db_state_backend = \
+                JEmbeddedRocksDBStateBackend(j_enable_incremental_checkpointing)
+
+        self._j_rocks_db_state_backend = j_rocks_db_state_backend

Review comment:
       could be removed

##########
File path: flink-python/pyflink/datastream/state_backend.py
##########
@@ -116,8 +125,320 @@ def __init__(self, j_state_backend):
         self._j_state_backend = j_state_backend
 
 
+class HashMapStateBackend(StateBackend):
+    """
+    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 :func:`configure` method.
+    """
+
+    def __init__(self,
+                 using_asynchronous_snapshots=None,
+                 j_hashmap_state_backend=None):
+        """
+        Creates a new HashMapStateBackend, enabling optionally asynchronous operations.
+
+        Example:
+        ::
+            >>> state_backend = HashMapStateBackend()
+
+        :param using_asynchronous_snapshots: Flag to switch between synchronous and asynchronous
+                                             snapshot mode. If null, the value configured in the
+                                             runtime configuration will be used.
+        :param j_hashmap_state_backend: For internal use, please keep none.
+        """
+        if j_hashmap_state_backend is None:
+            gateway = get_gateway()
+            JTernaryBoolean = gateway.jvm.org.apache.flink.util.TernaryBoolean
+            JHashMapStateBackend = gateway.jvm.org.apache.flink.runtime.state.hashmap \
+                .HashMapStateBackend
+            if using_asynchronous_snapshots is None:
+                j_asynchronous_snapshots = JTernaryBoolean.UNDEFINED
+            elif using_asynchronous_snapshots is True:
+                j_asynchronous_snapshots = JTernaryBoolean.TRUE
+            elif using_asynchronous_snapshots is False:
+                j_asynchronous_snapshots = JTernaryBoolean.FALSE
+            else:
+                raise TypeError("Unsupported input for 'using_asynchronous_snapshots': %s, "
+                                "the value of the parameter should be None or"
+                                "True or False.")
+            j_hashmap_state_backend = JHashMapStateBackend(j_asynchronous_snapshots)
+
+        self._j_memory_state_backend = j_hashmap_state_backend
+        super(HashMapStateBackend, self).__init__(j_hashmap_state_backend)
+
+    def is_using_asynchronous_snapshots(self):
+        """
+        Gets whether the key/value data structures are asynchronously snapshotted.
+
+        If not explicitly configured, this is the default value of
+        ``org.apache.flink.configuration.CheckpointingOptions.ASYNC_SNAPSHOTS``.
+
+        :return: True if the key/value data structures are asynchronously snapshotted,
+                 false otherwise.
+        """
+        return self._j_memory_state_backend.isUsingAsynchronousSnapshots()
+
+    def __str__(self):
+        return self._j_memory_state_backend.toString()
+
+
+class EmbeddedRocksDBStateBackend(StateBackend):
+    """
+    A State Backend that stores its state in an embedded ``RocksDB``. This state backend can
+    store very large state that exceeds memory and spills to disk.
+
+    All key/value state (including windows) is stored in the key/value index of RocksDB.
+    For persistence against loss of machines, please configure a checkpoint storage
+    instance for the Job.
+
+    The behavior of the RocksDB instances can be parametrized by setting RocksDB Options
+    using the methods :func:`set_predefined_options` and :func:`set_options`.
+    """
+
+    def __init__(self,
+                 enable_incremental_checkpointing=None,
+                 j_rocks_db_state_backend=None):
+        """
+        Creates a new :class:`RocksDBStateBackend` that stores its checkpoint data in the given
+        state backend or the location of given URI.
+
+        If using state backend, typically, one would supply a filesystem or database state backend
+        here where the snapshots from RocksDB would be stored.
+
+        If using URI, a state backend that stores checkpoints in HDFS or S3 must specify the file
+        system host and port in the URI, or have the Hadoop configuration that describes the file
+        system (host / high-availability group / possibly credentials) either referenced from the
+        Flink config, or included in the classpath.
+
+        Example:
+        ::
+
+            >>> state_backend = EmbeddedRocksDBStateBackend()
+
+        :param enable_incremental_checkpointing: True if incremental checkpointing is enabled.
+        :param j_rocks_db_state_backend: For internal use, please keep none.
+        """
+        if j_rocks_db_state_backend is None:
+            gateway = get_gateway()
+            JTernaryBoolean = gateway.jvm.org.apache.flink.util.TernaryBoolean
+            JEmbeddedRocksDBStateBackend = gateway.jvm.org.apache.flink.contrib.streaming.state \
+                .EmbeddedRocksDBStateBackend
+
+            if enable_incremental_checkpointing not in (None, True, False):
+                raise TypeError("Unsupported input for 'enable_incremental_checkpointing': %s, "
+                                "the value of the parameter should be None or"
+                                "True or False.")
+
+            if enable_incremental_checkpointing is None:
+                j_enable_incremental_checkpointing = JTernaryBoolean.UNDEFINED
+            elif enable_incremental_checkpointing is True:
+                j_enable_incremental_checkpointing = JTernaryBoolean.TRUE
+            else:
+                j_enable_incremental_checkpointing = JTernaryBoolean.FALSE
+
+            j_rocks_db_state_backend = \
+                JEmbeddedRocksDBStateBackend(j_enable_incremental_checkpointing)
+
+        self._j_rocks_db_state_backend = j_rocks_db_state_backend
+        super(EmbeddedRocksDBStateBackend, self).__init__(j_rocks_db_state_backend)
+
+    def set_db_storage_paths(self, *paths):
+        """
+        Sets the directories in which the local RocksDB database puts its files (like SST and
+        metadata files). These directories do not need to be persistent, they can be ephemeral,
+        meaning that they are lost on a machine failure, because state in RocksDB is persisted
+        in checkpoints.
+
+        If nothing is configured, these directories default to the TaskManager's local
+        temporary file directories.
+
+        Each distinct state will be stored in one path, but when the state backend creates
+        multiple states, they will store their files on different paths.
+
+        Passing ``None`` to this function restores the default behavior, where the configured
+        temp directories will be used.
+
+        :param paths: The paths across which the local RocksDB database files will be spread. this
+                      parameter is optional.
+        """
+        if len(paths) < 1:
+            self._j_rocks_db_state_backend.setDbStoragePath(None)
+        else:
+            gateway = get_gateway()
+            j_path_array = gateway.new_array(gateway.jvm.String, len(paths))
+            for i in range(0, len(paths)):
+                j_path_array[i] = paths[i]
+            self._j_rocks_db_state_backend.setDbStoragePaths(j_path_array)
+
+    def get_db_storage_paths(self):
+        """
+        Gets the configured local DB storage paths, or null, if none were configured.
+
+        Under these directories on the TaskManager, RocksDB stores its SST files and
+        metadata files. These directories do not need to be persistent, they can be ephermeral,
+        meaning that they are lost on a machine failure, because state in RocksDB is persisted
+        in checkpoints.
+
+        If nothing is configured, these directories default to the TaskManager's local
+        temporary file directories.
+
+        :return: The list of configured local DB storage paths.
+        """
+        return list(self._j_rocks_db_state_backend.getDbStoragePaths())
+
+    def is_incremental_checkpoints_enabled(self):

Review comment:
       ```suggestion
       def is_incremental_checkpoints_enabled(self) -> bool:
   ```

##########
File path: flink-python/pyflink/datastream/checkpoint_storage.py
##########
@@ -0,0 +1,302 @@
+################################################################################
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+# limitations under the License.
+################################################################################
+
+from abc import ABCMeta
+
+from py4j.java_gateway import get_java_class
+
+from pyflink.java_gateway import get_gateway
+
+__all__ = [
+    'CheckpointStorage',
+    'JobManagerCheckpointStorage',
+    'FileSystemCheckpointStorage',
+    'CustomCheckpointStorage'
+]
+
+
+def _from_j_checkpoint_storage(j_checkpoint_storage):
+    if j_checkpoint_storage is None:
+        return None
+    gateway = get_gateway()
+    JCheckpointStorage = gateway.jvm.org.apache.flink.runtime.state.CheckpointStorage
+    JJobManagerCheckpointStorage = gateway.jvm.org.apache.flink.runtime.state.storage \
+        .JobManagerCheckpointStorage
+    JFileSystemCheckpointStorage = gateway.jvm.org.apache.flink.runtime.state.storage \
+        .FileSystemCheckpointStorage
+    j_clz = j_checkpoint_storage.getClass()
+
+    if not get_java_class(JCheckpointStorage).isAssignableFrom(j_clz):
+        raise TypeError("The input %s is not an instance of CheckpointStorage."
+                        % j_checkpoint_storage)
+
+    if get_java_class(JJobManagerCheckpointStorage).isAssignableFrom(j_clz):
+        return JobManagerCheckpointStorage(j_jobmanager_checkpoint_storage=j_checkpoint_storage)
+    elif get_java_class(JFileSystemCheckpointStorage).isAssignableFrom(j_clz):
+        return FileSystemCheckpointStorage(j_fs_checkpoint_storage=j_checkpoint_storage)
+    else:
+        return CustomCheckpointStorage(j_checkpoint_storage)  # users' customized state backend
+
+
+class CheckpointStorage(object):

Review comment:
       ```suggestion
   class CheckpointStorage(abc.ABC):
   ```
   
   See https://issues.apache.org/jira/browse/FLINK-19892 for more details.

##########
File path: flink-python/pyflink/datastream/checkpoint_storage.py
##########
@@ -0,0 +1,302 @@
+################################################################################
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+# limitations under the License.
+################################################################################
+
+from abc import ABCMeta
+
+from py4j.java_gateway import get_java_class
+
+from pyflink.java_gateway import get_gateway
+
+__all__ = [
+    'CheckpointStorage',
+    'JobManagerCheckpointStorage',
+    'FileSystemCheckpointStorage',
+    'CustomCheckpointStorage'
+]
+
+
+def _from_j_checkpoint_storage(j_checkpoint_storage):
+    if j_checkpoint_storage is None:
+        return None
+    gateway = get_gateway()
+    JCheckpointStorage = gateway.jvm.org.apache.flink.runtime.state.CheckpointStorage
+    JJobManagerCheckpointStorage = gateway.jvm.org.apache.flink.runtime.state.storage \
+        .JobManagerCheckpointStorage
+    JFileSystemCheckpointStorage = gateway.jvm.org.apache.flink.runtime.state.storage \
+        .FileSystemCheckpointStorage
+    j_clz = j_checkpoint_storage.getClass()
+
+    if not get_java_class(JCheckpointStorage).isAssignableFrom(j_clz):
+        raise TypeError("The input %s is not an instance of CheckpointStorage."
+                        % j_checkpoint_storage)
+
+    if get_java_class(JJobManagerCheckpointStorage).isAssignableFrom(j_clz):
+        return JobManagerCheckpointStorage(j_jobmanager_checkpoint_storage=j_checkpoint_storage)
+    elif get_java_class(JFileSystemCheckpointStorage).isAssignableFrom(j_clz):
+        return FileSystemCheckpointStorage(j_fs_checkpoint_storage=j_checkpoint_storage)
+    else:
+        return CustomCheckpointStorage(j_checkpoint_storage)  # users' customized state backend
+
+
+class CheckpointStorage(object):
+    """
+    CheckpointStorage defines how :class:`StateBackend`'s checkpoint their state for fault
+    tolerance in streaming applications. Various implementations store their checkpoints in
+    different fashions and have different requirements and availability guarantees.
+
+    For example, :class:`JobManagerCheckpointStorage` stores checkpoints in the memory of
+    the JobManager. It is lightweight and without additional dependencies but is not highly
+    available and only supports small state sizes. This checkpoint storage policy is convenient
+    for local testing and development.
+
+    :class`FileSystemCheckpointStorage` stores checkpoints in a filesystem. For systems like HDFS,
+    NFS Drives, S3, and GCS, this storage policy supports large state size, in the magnitude of
+    many terabytes while providing a highly available foundation for stateful applications. This
+    checkpoint storage policy is recommended for most production deployments.
+
+    **Raw Bytes Storage**
+
+    The **CheckpointStorage** creates services for raw bytes storage.
+
+    The raw bytes storage (through the CheckpointStreamFactory) is the fundamental service that
+    simply stores bytes in a fault tolerant fashion. This service is used by the JobManager
+    to store checkpoint and recovery metadata and is typically also used by the keyed- and operator
+    state backends to store checkpointed state.
+
+    **Serializability**
+
+    Checkpoint storage need to be serializable, because they distributed across parallel processes
+    (for distributed execution) together with the streaming application code.
+
+    Because of that, **CheckpointStorage** implementations are meant to be like factories
+    that create the proper states stores that provide access to the persistent. That way, the
+    Checkpoint Storage can be very lightweight (contain only configurations) which makes it easier
+    to be serializable.
+
+    **Thread Safety**
+
+    Checkpoint storage implementations have to be thread-safe. Multiple threads may be creating
+    streams concurrently.
+    """
+
+    __metaclass__ = ABCMeta
+
+    def __init__(self, j_checkpoint_storage):
+        self._j_checkpoint_storage = j_checkpoint_storage
+
+
+class JobManagerCheckpointStorage(CheckpointStorage):
+    """
+     This **CheckpointStorage** checkpoints state directly to the JobManager's memory (hence the
+     name), but savepoints will be persisted to a file system.
+
+    This checkpoint storage is primarily  for experimentation, quick local setups, or for streaming
+    applications that have very small state: Because it requires checkpoints to go through the
+    JobManager's memory, larger state will occupy larger portions of the JobManager's main memory,
+    reducing operational stability.
+
+    For any other setup, the :class:`FileSystemCheckpointStorage` should be used. The
+    **FileSystemCheckpointStorage** checkpoints state directly to files rather than
+    to the JobManager's memory, thus supporting larger state sizes and more highly available
+    recovery.
+
+    **State Size Considerations**
+
+    State checkpointing with this state backend is subject to the following conditions:
+
+    - Each individual state must not exceed the configured maximum state size
+      (see :func:`get_max_state_size`.
+
+    - All state from one task (i.e., the sum of all operator states and keyed states from all
+      chained operators of the task) must not exceed what the RPC system supports, which is
+      be default < 10 MB. That limit can be configured up, but that is typically not advised.
+
+    - The sum of all states in the application times all retained checkpoints must comfortably
+      fit into the JobManager's JVM heap space.
+
+    **Persistence Guarantees**
+
+    For the use cases where the state sizes can be handled by this backend, the backend does
+    guarantee persistence for savepoints, externalized checkpoints (of configured), and checkpoints
+    (when high-availability is configured).
+
+    **Configuration**
+
+    As for all checkpoint storage, this storage policy can either be configured within the
+    application (by creating the storage with the respective constructor parameters and setting
+    it on the execution environment) or by specifying it in the Flink configuration.
+
+    If the checkpoint storage was specified in the application, it may pick up additional
+    configuration parameters from the Flink configuration. That behavior is
+    implemented via the :func:`configure` method.
+    """
+
+    # The default maximal size that the snapshotted memory state may have (5 MiBytes).
+    DEFAULT_MAX_STATE_SIZE = 5 * 1024 * 1024
+
+    def __init__(self,
+                 checkpoint_path=None,
+                 max_state_size=None,
+                 j_jobmanager_checkpoint_storage=None):
+        """
+        Creates a new JobManagerCheckpointStorage, setting optionally the paths to persist
+        checkpoint metadata, as well as configuring state thresholds.
+
+        WARNING: Increasing the size of this value beyond the default value
+        (:data:`DEFAULT_MAX_STATE_SIZE`) should be done with care.
+        The checkpointed state needs to be send to the JobManager via limited size RPC messages,
+        and there and the JobManager needs to be able to hold all aggregated state in its memory.
+
+        Example:
+        ::
+            >>> checkpoint_storage = JobManagerCheckpointStorage()
+
+        :param checkpoint_path: The path to write checkpoint metadata to. If none, the value from
+                                the runtime configuration will be used.
+        :param max_state_size: The maximal size of the serialized state. If none, the
+                               :data:`DEFAULT_MAX_STATE_SIZE` will be used.
+        :param j_jobmanager_checkpoint_storage: For internal use, please keep none.
+        """
+        if j_jobmanager_checkpoint_storage is None:
+            gateway = get_gateway()
+            JJobManagerCheckpointStorage = gateway.jvm.org.apache.flink.runtime.state.storage \
+                .JobManagerCheckpointStorage
+            if max_state_size is None:
+                max_state_size = JJobManagerCheckpointStorage.DEFAULT_MAX_STATE_SIZE
+            j_jobmanager_checkpoint_storage = JJobManagerCheckpointStorage(checkpoint_path,
+                                                                           max_state_size)
+
+        self._j_jobmanager_checkpoint_storage = j_jobmanager_checkpoint_storage
+        super(CheckpointStorage, self).__init__(j_jobmanager_checkpoint_storage)
+
+    def get_max_state_size(self):

Review comment:
       ```suggestion
       def get_max_state_size(self) -> int:
   ```

##########
File path: flink-python/pyflink/datastream/checkpoint_storage.py
##########
@@ -0,0 +1,302 @@
+################################################################################
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+# limitations under the License.
+################################################################################
+
+from abc import ABCMeta
+
+from py4j.java_gateway import get_java_class
+
+from pyflink.java_gateway import get_gateway
+
+__all__ = [
+    'CheckpointStorage',
+    'JobManagerCheckpointStorage',
+    'FileSystemCheckpointStorage',
+    'CustomCheckpointStorage'
+]
+
+
+def _from_j_checkpoint_storage(j_checkpoint_storage):
+    if j_checkpoint_storage is None:
+        return None
+    gateway = get_gateway()
+    JCheckpointStorage = gateway.jvm.org.apache.flink.runtime.state.CheckpointStorage
+    JJobManagerCheckpointStorage = gateway.jvm.org.apache.flink.runtime.state.storage \
+        .JobManagerCheckpointStorage
+    JFileSystemCheckpointStorage = gateway.jvm.org.apache.flink.runtime.state.storage \
+        .FileSystemCheckpointStorage
+    j_clz = j_checkpoint_storage.getClass()
+
+    if not get_java_class(JCheckpointStorage).isAssignableFrom(j_clz):
+        raise TypeError("The input %s is not an instance of CheckpointStorage."
+                        % j_checkpoint_storage)
+
+    if get_java_class(JJobManagerCheckpointStorage).isAssignableFrom(j_clz):
+        return JobManagerCheckpointStorage(j_jobmanager_checkpoint_storage=j_checkpoint_storage)
+    elif get_java_class(JFileSystemCheckpointStorage).isAssignableFrom(j_clz):
+        return FileSystemCheckpointStorage(j_fs_checkpoint_storage=j_checkpoint_storage)
+    else:
+        return CustomCheckpointStorage(j_checkpoint_storage)  # users' customized state backend
+
+
+class CheckpointStorage(object):
+    """
+    CheckpointStorage defines how :class:`StateBackend`'s checkpoint their state for fault
+    tolerance in streaming applications. Various implementations store their checkpoints in
+    different fashions and have different requirements and availability guarantees.
+
+    For example, :class:`JobManagerCheckpointStorage` stores checkpoints in the memory of
+    the JobManager. It is lightweight and without additional dependencies but is not highly
+    available and only supports small state sizes. This checkpoint storage policy is convenient
+    for local testing and development.
+
+    :class`FileSystemCheckpointStorage` stores checkpoints in a filesystem. For systems like HDFS,
+    NFS Drives, S3, and GCS, this storage policy supports large state size, in the magnitude of
+    many terabytes while providing a highly available foundation for stateful applications. This
+    checkpoint storage policy is recommended for most production deployments.
+
+    **Raw Bytes Storage**
+
+    The **CheckpointStorage** creates services for raw bytes storage.
+
+    The raw bytes storage (through the CheckpointStreamFactory) is the fundamental service that
+    simply stores bytes in a fault tolerant fashion. This service is used by the JobManager
+    to store checkpoint and recovery metadata and is typically also used by the keyed- and operator
+    state backends to store checkpointed state.
+
+    **Serializability**
+
+    Checkpoint storage need to be serializable, because they distributed across parallel processes
+    (for distributed execution) together with the streaming application code.
+
+    Because of that, **CheckpointStorage** implementations are meant to be like factories
+    that create the proper states stores that provide access to the persistent. That way, the
+    Checkpoint Storage can be very lightweight (contain only configurations) which makes it easier
+    to be serializable.
+
+    **Thread Safety**
+
+    Checkpoint storage implementations have to be thread-safe. Multiple threads may be creating
+    streams concurrently.
+    """
+
+    __metaclass__ = ABCMeta

Review comment:
       We can remove this then.

##########
File path: flink-python/pyflink/datastream/checkpoint_storage.py
##########
@@ -0,0 +1,302 @@
+################################################################################
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+# limitations under the License.
+################################################################################
+
+from abc import ABCMeta
+
+from py4j.java_gateway import get_java_class
+
+from pyflink.java_gateway import get_gateway
+
+__all__ = [
+    'CheckpointStorage',
+    'JobManagerCheckpointStorage',
+    'FileSystemCheckpointStorage',
+    'CustomCheckpointStorage'
+]
+
+
+def _from_j_checkpoint_storage(j_checkpoint_storage):
+    if j_checkpoint_storage is None:
+        return None
+    gateway = get_gateway()
+    JCheckpointStorage = gateway.jvm.org.apache.flink.runtime.state.CheckpointStorage
+    JJobManagerCheckpointStorage = gateway.jvm.org.apache.flink.runtime.state.storage \
+        .JobManagerCheckpointStorage
+    JFileSystemCheckpointStorage = gateway.jvm.org.apache.flink.runtime.state.storage \
+        .FileSystemCheckpointStorage
+    j_clz = j_checkpoint_storage.getClass()
+
+    if not get_java_class(JCheckpointStorage).isAssignableFrom(j_clz):
+        raise TypeError("The input %s is not an instance of CheckpointStorage."
+                        % j_checkpoint_storage)
+
+    if get_java_class(JJobManagerCheckpointStorage).isAssignableFrom(j_clz):
+        return JobManagerCheckpointStorage(j_jobmanager_checkpoint_storage=j_checkpoint_storage)
+    elif get_java_class(JFileSystemCheckpointStorage).isAssignableFrom(j_clz):
+        return FileSystemCheckpointStorage(j_fs_checkpoint_storage=j_checkpoint_storage)
+    else:
+        return CustomCheckpointStorage(j_checkpoint_storage)  # users' customized state backend
+
+
+class CheckpointStorage(object):
+    """
+    CheckpointStorage defines how :class:`StateBackend`'s checkpoint their state for fault
+    tolerance in streaming applications. Various implementations store their checkpoints in
+    different fashions and have different requirements and availability guarantees.
+
+    For example, :class:`JobManagerCheckpointStorage` stores checkpoints in the memory of
+    the JobManager. It is lightweight and without additional dependencies but is not highly
+    available and only supports small state sizes. This checkpoint storage policy is convenient
+    for local testing and development.
+
+    :class`FileSystemCheckpointStorage` stores checkpoints in a filesystem. For systems like HDFS,
+    NFS Drives, S3, and GCS, this storage policy supports large state size, in the magnitude of
+    many terabytes while providing a highly available foundation for stateful applications. This
+    checkpoint storage policy is recommended for most production deployments.
+
+    **Raw Bytes Storage**
+
+    The **CheckpointStorage** creates services for raw bytes storage.
+
+    The raw bytes storage (through the CheckpointStreamFactory) is the fundamental service that
+    simply stores bytes in a fault tolerant fashion. This service is used by the JobManager
+    to store checkpoint and recovery metadata and is typically also used by the keyed- and operator
+    state backends to store checkpointed state.
+
+    **Serializability**
+
+    Checkpoint storage need to be serializable, because they distributed across parallel processes
+    (for distributed execution) together with the streaming application code.
+
+    Because of that, **CheckpointStorage** implementations are meant to be like factories
+    that create the proper states stores that provide access to the persistent. That way, the
+    Checkpoint Storage can be very lightweight (contain only configurations) which makes it easier
+    to be serializable.
+
+    **Thread Safety**
+
+    Checkpoint storage implementations have to be thread-safe. Multiple threads may be creating
+    streams concurrently.
+    """
+
+    __metaclass__ = ABCMeta
+
+    def __init__(self, j_checkpoint_storage):
+        self._j_checkpoint_storage = j_checkpoint_storage
+
+
+class JobManagerCheckpointStorage(CheckpointStorage):
+    """
+     This **CheckpointStorage** checkpoints state directly to the JobManager's memory (hence the
+     name), but savepoints will be persisted to a file system.
+
+    This checkpoint storage is primarily  for experimentation, quick local setups, or for streaming
+    applications that have very small state: Because it requires checkpoints to go through the
+    JobManager's memory, larger state will occupy larger portions of the JobManager's main memory,
+    reducing operational stability.
+
+    For any other setup, the :class:`FileSystemCheckpointStorage` should be used. The
+    **FileSystemCheckpointStorage** checkpoints state directly to files rather than
+    to the JobManager's memory, thus supporting larger state sizes and more highly available
+    recovery.
+
+    **State Size Considerations**
+
+    State checkpointing with this state backend is subject to the following conditions:
+
+    - Each individual state must not exceed the configured maximum state size
+      (see :func:`get_max_state_size`.
+
+    - All state from one task (i.e., the sum of all operator states and keyed states from all
+      chained operators of the task) must not exceed what the RPC system supports, which is
+      be default < 10 MB. That limit can be configured up, but that is typically not advised.
+
+    - The sum of all states in the application times all retained checkpoints must comfortably
+      fit into the JobManager's JVM heap space.
+
+    **Persistence Guarantees**
+
+    For the use cases where the state sizes can be handled by this backend, the backend does
+    guarantee persistence for savepoints, externalized checkpoints (of configured), and checkpoints
+    (when high-availability is configured).
+
+    **Configuration**
+
+    As for all checkpoint storage, this storage policy can either be configured within the
+    application (by creating the storage with the respective constructor parameters and setting
+    it on the execution environment) or by specifying it in the Flink configuration.
+
+    If the checkpoint storage was specified in the application, it may pick up additional
+    configuration parameters from the Flink configuration. That behavior is
+    implemented via the :func:`configure` method.
+    """
+
+    # The default maximal size that the snapshotted memory state may have (5 MiBytes).
+    DEFAULT_MAX_STATE_SIZE = 5 * 1024 * 1024
+
+    def __init__(self,
+                 checkpoint_path=None,
+                 max_state_size=None,
+                 j_jobmanager_checkpoint_storage=None):
+        """
+        Creates a new JobManagerCheckpointStorage, setting optionally the paths to persist
+        checkpoint metadata, as well as configuring state thresholds.
+
+        WARNING: Increasing the size of this value beyond the default value
+        (:data:`DEFAULT_MAX_STATE_SIZE`) should be done with care.
+        The checkpointed state needs to be send to the JobManager via limited size RPC messages,
+        and there and the JobManager needs to be able to hold all aggregated state in its memory.
+
+        Example:
+        ::
+            >>> checkpoint_storage = JobManagerCheckpointStorage()
+
+        :param checkpoint_path: The path to write checkpoint metadata to. If none, the value from
+                                the runtime configuration will be used.
+        :param max_state_size: The maximal size of the serialized state. If none, the
+                               :data:`DEFAULT_MAX_STATE_SIZE` will be used.
+        :param j_jobmanager_checkpoint_storage: For internal use, please keep none.
+        """
+        if j_jobmanager_checkpoint_storage is None:
+            gateway = get_gateway()
+            JJobManagerCheckpointStorage = gateway.jvm.org.apache.flink.runtime.state.storage \
+                .JobManagerCheckpointStorage
+            if max_state_size is None:
+                max_state_size = JJobManagerCheckpointStorage.DEFAULT_MAX_STATE_SIZE
+            j_jobmanager_checkpoint_storage = JJobManagerCheckpointStorage(checkpoint_path,
+                                                                           max_state_size)
+
+        self._j_jobmanager_checkpoint_storage = j_jobmanager_checkpoint_storage
+        super(CheckpointStorage, self).__init__(j_jobmanager_checkpoint_storage)
+
+    def get_max_state_size(self):
+        """
+        Gets the maximum size that an individual state can have, as configured in the
+        constructor (by default :data:`DEFAULT_MAX_STATE_SIZE`).
+
+        :return: The maximum size that an individual state can have.
+        """
+        return self._j_jobmanager_checkpoint_storage.getMaxStateSize()
+
+    def __str__(self):
+        return self._j_jobmanager_checkpoint_storage.toString()
+
+
+class FileSystemCheckpointStorage(CheckpointStorage):
+    """
+    This checkpoint storage checkpoints state as files to a file system (hence the name).
+
+    Each checkpoint individually will store all its files in a subdirectory that includes the
+    checkpoint number, such as ``hdfs://namenode:port/flink-checkpoints/chk-17/``.
+
+    **State Size Considerations**
+
+    This checkpoint storage stores small state chunks directly with the metadata, to avoid creating
+    many small files. The threshold for that is configurable. When increasing this threshold, the
+    size of the checkpoint metadata increases. The checkpoint metadata of all retained completed
+    checkpoints needs to fit into the JobManager's heap memory. This is typically not a problem,
+    unless the threshold :func:`get_min_file_size_threshold` is increased significantly.
+
+    **Persistence Guarantees**
+
+    Checkpoints from this storage instance are as persistent and available as filesystem that is
+    written to. If the file system is a persistent distributed file system, this state backend
+    supports highly available setups. The backend additionally supports savepoints and externalized
+    checkpoints.
+
+    **Configuration**
+
+    As for all checkpoint storage, this storage can either be configured within the application (by
+    creating the instance with the respective constructor parameters and setting it on the execution
+    environment) or by specifying it in the Flink configuration.
+
+    If the checkpoint storage was specified in the application, it may pick up additional
+    configuration parameters from the Flink configuration. That behavior is implemented via
+    the :func:`configure` method.
+    """
+
+    def __init__(self,
+                 checkpoint_directory_uri=None,
+                 file_state_size_threshold=None,
+                 write_buffer_size=None,
+                 j_fs_checkpoint_storage=None):
+
+        if j_fs_checkpoint_storage is None:
+            gateway = get_gateway()
+            JFileSystemCheckpointStorage = gateway.jvm.org.apache.flink.runtime.state.storage \
+                .FileSystemCheckpointStorage
+            JPath = gateway.jvm.org.apache.flink.core.fs.Path
+            if checkpoint_directory_uri is None:
+                raise ValueError("The parameter 'checkpoint_directory_uri' is required!")
+            j_checkpoint_directory_uri = JPath(checkpoint_directory_uri).toUri()
+
+            if file_state_size_threshold is None:
+                file_state_size_threshold = -1
+
+            if write_buffer_size is None:
+                write_buffer_size = -1
+
+            j_fs_checkpoint_storage = JFileSystemCheckpointStorage(j_checkpoint_directory_uri,
+                                                                   file_state_size_threshold,
+                                                                   write_buffer_size)
+
+        self._j_fs_checkpoint_storage = j_fs_checkpoint_storage

Review comment:
       could be removed

##########
File path: flink-python/pyflink/datastream/checkpoint_storage.py
##########
@@ -0,0 +1,302 @@
+################################################################################
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+# limitations under the License.
+################################################################################
+
+from abc import ABCMeta
+
+from py4j.java_gateway import get_java_class
+
+from pyflink.java_gateway import get_gateway
+
+__all__ = [
+    'CheckpointStorage',
+    'JobManagerCheckpointStorage',
+    'FileSystemCheckpointStorage',
+    'CustomCheckpointStorage'
+]
+
+
+def _from_j_checkpoint_storage(j_checkpoint_storage):
+    if j_checkpoint_storage is None:
+        return None
+    gateway = get_gateway()
+    JCheckpointStorage = gateway.jvm.org.apache.flink.runtime.state.CheckpointStorage
+    JJobManagerCheckpointStorage = gateway.jvm.org.apache.flink.runtime.state.storage \
+        .JobManagerCheckpointStorage
+    JFileSystemCheckpointStorage = gateway.jvm.org.apache.flink.runtime.state.storage \
+        .FileSystemCheckpointStorage
+    j_clz = j_checkpoint_storage.getClass()
+
+    if not get_java_class(JCheckpointStorage).isAssignableFrom(j_clz):
+        raise TypeError("The input %s is not an instance of CheckpointStorage."
+                        % j_checkpoint_storage)
+
+    if get_java_class(JJobManagerCheckpointStorage).isAssignableFrom(j_clz):
+        return JobManagerCheckpointStorage(j_jobmanager_checkpoint_storage=j_checkpoint_storage)
+    elif get_java_class(JFileSystemCheckpointStorage).isAssignableFrom(j_clz):
+        return FileSystemCheckpointStorage(j_fs_checkpoint_storage=j_checkpoint_storage)
+    else:
+        return CustomCheckpointStorage(j_checkpoint_storage)  # users' customized state backend
+
+
+class CheckpointStorage(object):
+    """
+    CheckpointStorage defines how :class:`StateBackend`'s checkpoint their state for fault
+    tolerance in streaming applications. Various implementations store their checkpoints in
+    different fashions and have different requirements and availability guarantees.
+
+    For example, :class:`JobManagerCheckpointStorage` stores checkpoints in the memory of
+    the JobManager. It is lightweight and without additional dependencies but is not highly
+    available and only supports small state sizes. This checkpoint storage policy is convenient
+    for local testing and development.
+
+    :class`FileSystemCheckpointStorage` stores checkpoints in a filesystem. For systems like HDFS,
+    NFS Drives, S3, and GCS, this storage policy supports large state size, in the magnitude of
+    many terabytes while providing a highly available foundation for stateful applications. This
+    checkpoint storage policy is recommended for most production deployments.
+
+    **Raw Bytes Storage**
+
+    The **CheckpointStorage** creates services for raw bytes storage.
+
+    The raw bytes storage (through the CheckpointStreamFactory) is the fundamental service that
+    simply stores bytes in a fault tolerant fashion. This service is used by the JobManager
+    to store checkpoint and recovery metadata and is typically also used by the keyed- and operator
+    state backends to store checkpointed state.
+
+    **Serializability**
+
+    Checkpoint storage need to be serializable, because they distributed across parallel processes
+    (for distributed execution) together with the streaming application code.
+
+    Because of that, **CheckpointStorage** implementations are meant to be like factories
+    that create the proper states stores that provide access to the persistent. That way, the
+    Checkpoint Storage can be very lightweight (contain only configurations) which makes it easier
+    to be serializable.
+
+    **Thread Safety**
+
+    Checkpoint storage implementations have to be thread-safe. Multiple threads may be creating
+    streams concurrently.
+    """
+
+    __metaclass__ = ABCMeta
+
+    def __init__(self, j_checkpoint_storage):
+        self._j_checkpoint_storage = j_checkpoint_storage
+
+
+class JobManagerCheckpointStorage(CheckpointStorage):
+    """
+     This **CheckpointStorage** checkpoints state directly to the JobManager's memory (hence the
+     name), but savepoints will be persisted to a file system.
+
+    This checkpoint storage is primarily  for experimentation, quick local setups, or for streaming
+    applications that have very small state: Because it requires checkpoints to go through the
+    JobManager's memory, larger state will occupy larger portions of the JobManager's main memory,
+    reducing operational stability.
+
+    For any other setup, the :class:`FileSystemCheckpointStorage` should be used. The
+    **FileSystemCheckpointStorage** checkpoints state directly to files rather than
+    to the JobManager's memory, thus supporting larger state sizes and more highly available
+    recovery.
+
+    **State Size Considerations**
+
+    State checkpointing with this state backend is subject to the following conditions:
+
+    - Each individual state must not exceed the configured maximum state size
+      (see :func:`get_max_state_size`.
+
+    - All state from one task (i.e., the sum of all operator states and keyed states from all
+      chained operators of the task) must not exceed what the RPC system supports, which is
+      be default < 10 MB. That limit can be configured up, but that is typically not advised.
+
+    - The sum of all states in the application times all retained checkpoints must comfortably
+      fit into the JobManager's JVM heap space.
+
+    **Persistence Guarantees**
+
+    For the use cases where the state sizes can be handled by this backend, the backend does
+    guarantee persistence for savepoints, externalized checkpoints (of configured), and checkpoints
+    (when high-availability is configured).
+
+    **Configuration**
+
+    As for all checkpoint storage, this storage policy can either be configured within the
+    application (by creating the storage with the respective constructor parameters and setting
+    it on the execution environment) or by specifying it in the Flink configuration.
+
+    If the checkpoint storage was specified in the application, it may pick up additional
+    configuration parameters from the Flink configuration. That behavior is
+    implemented via the :func:`configure` method.
+    """
+
+    # The default maximal size that the snapshotted memory state may have (5 MiBytes).
+    DEFAULT_MAX_STATE_SIZE = 5 * 1024 * 1024
+
+    def __init__(self,
+                 checkpoint_path=None,
+                 max_state_size=None,
+                 j_jobmanager_checkpoint_storage=None):
+        """
+        Creates a new JobManagerCheckpointStorage, setting optionally the paths to persist
+        checkpoint metadata, as well as configuring state thresholds.
+
+        WARNING: Increasing the size of this value beyond the default value
+        (:data:`DEFAULT_MAX_STATE_SIZE`) should be done with care.
+        The checkpointed state needs to be send to the JobManager via limited size RPC messages,
+        and there and the JobManager needs to be able to hold all aggregated state in its memory.
+
+        Example:
+        ::
+            >>> checkpoint_storage = JobManagerCheckpointStorage()
+
+        :param checkpoint_path: The path to write checkpoint metadata to. If none, the value from
+                                the runtime configuration will be used.
+        :param max_state_size: The maximal size of the serialized state. If none, the
+                               :data:`DEFAULT_MAX_STATE_SIZE` will be used.
+        :param j_jobmanager_checkpoint_storage: For internal use, please keep none.
+        """
+        if j_jobmanager_checkpoint_storage is None:
+            gateway = get_gateway()
+            JJobManagerCheckpointStorage = gateway.jvm.org.apache.flink.runtime.state.storage \
+                .JobManagerCheckpointStorage
+            if max_state_size is None:
+                max_state_size = JJobManagerCheckpointStorage.DEFAULT_MAX_STATE_SIZE
+            j_jobmanager_checkpoint_storage = JJobManagerCheckpointStorage(checkpoint_path,
+                                                                           max_state_size)
+
+        self._j_jobmanager_checkpoint_storage = j_jobmanager_checkpoint_storage
+        super(CheckpointStorage, self).__init__(j_jobmanager_checkpoint_storage)
+
+    def get_max_state_size(self):
+        """
+        Gets the maximum size that an individual state can have, as configured in the
+        constructor (by default :data:`DEFAULT_MAX_STATE_SIZE`).
+
+        :return: The maximum size that an individual state can have.
+        """
+        return self._j_jobmanager_checkpoint_storage.getMaxStateSize()
+
+    def __str__(self):
+        return self._j_jobmanager_checkpoint_storage.toString()
+
+
+class FileSystemCheckpointStorage(CheckpointStorage):
+    """
+    This checkpoint storage checkpoints state as files to a file system (hence the name).
+
+    Each checkpoint individually will store all its files in a subdirectory that includes the
+    checkpoint number, such as ``hdfs://namenode:port/flink-checkpoints/chk-17/``.
+
+    **State Size Considerations**
+
+    This checkpoint storage stores small state chunks directly with the metadata, to avoid creating
+    many small files. The threshold for that is configurable. When increasing this threshold, the
+    size of the checkpoint metadata increases. The checkpoint metadata of all retained completed
+    checkpoints needs to fit into the JobManager's heap memory. This is typically not a problem,
+    unless the threshold :func:`get_min_file_size_threshold` is increased significantly.
+
+    **Persistence Guarantees**
+
+    Checkpoints from this storage instance are as persistent and available as filesystem that is
+    written to. If the file system is a persistent distributed file system, this state backend
+    supports highly available setups. The backend additionally supports savepoints and externalized
+    checkpoints.
+
+    **Configuration**
+
+    As for all checkpoint storage, this storage can either be configured within the application (by
+    creating the instance with the respective constructor parameters and setting it on the execution
+    environment) or by specifying it in the Flink configuration.
+
+    If the checkpoint storage was specified in the application, it may pick up additional
+    configuration parameters from the Flink configuration. That behavior is implemented via
+    the :func:`configure` method.
+    """
+
+    def __init__(self,
+                 checkpoint_directory_uri=None,

Review comment:
       Add typehint for these parameters?

##########
File path: flink-python/pyflink/datastream/checkpoint_storage.py
##########
@@ -0,0 +1,302 @@
+################################################################################
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+# limitations under the License.
+################################################################################
+
+from abc import ABCMeta
+
+from py4j.java_gateway import get_java_class
+
+from pyflink.java_gateway import get_gateway
+
+__all__ = [
+    'CheckpointStorage',
+    'JobManagerCheckpointStorage',
+    'FileSystemCheckpointStorage',
+    'CustomCheckpointStorage'
+]
+
+
+def _from_j_checkpoint_storage(j_checkpoint_storage):
+    if j_checkpoint_storage is None:
+        return None
+    gateway = get_gateway()
+    JCheckpointStorage = gateway.jvm.org.apache.flink.runtime.state.CheckpointStorage
+    JJobManagerCheckpointStorage = gateway.jvm.org.apache.flink.runtime.state.storage \
+        .JobManagerCheckpointStorage
+    JFileSystemCheckpointStorage = gateway.jvm.org.apache.flink.runtime.state.storage \
+        .FileSystemCheckpointStorage
+    j_clz = j_checkpoint_storage.getClass()
+
+    if not get_java_class(JCheckpointStorage).isAssignableFrom(j_clz):
+        raise TypeError("The input %s is not an instance of CheckpointStorage."
+                        % j_checkpoint_storage)
+
+    if get_java_class(JJobManagerCheckpointStorage).isAssignableFrom(j_clz):
+        return JobManagerCheckpointStorage(j_jobmanager_checkpoint_storage=j_checkpoint_storage)
+    elif get_java_class(JFileSystemCheckpointStorage).isAssignableFrom(j_clz):
+        return FileSystemCheckpointStorage(j_fs_checkpoint_storage=j_checkpoint_storage)
+    else:
+        return CustomCheckpointStorage(j_checkpoint_storage)  # users' customized state backend
+
+
+class CheckpointStorage(object):
+    """
+    CheckpointStorage defines how :class:`StateBackend`'s checkpoint their state for fault
+    tolerance in streaming applications. Various implementations store their checkpoints in
+    different fashions and have different requirements and availability guarantees.
+
+    For example, :class:`JobManagerCheckpointStorage` stores checkpoints in the memory of
+    the JobManager. It is lightweight and without additional dependencies but is not highly
+    available and only supports small state sizes. This checkpoint storage policy is convenient
+    for local testing and development.
+
+    :class`FileSystemCheckpointStorage` stores checkpoints in a filesystem. For systems like HDFS,
+    NFS Drives, S3, and GCS, this storage policy supports large state size, in the magnitude of
+    many terabytes while providing a highly available foundation for stateful applications. This
+    checkpoint storage policy is recommended for most production deployments.
+
+    **Raw Bytes Storage**
+
+    The **CheckpointStorage** creates services for raw bytes storage.
+
+    The raw bytes storage (through the CheckpointStreamFactory) is the fundamental service that
+    simply stores bytes in a fault tolerant fashion. This service is used by the JobManager
+    to store checkpoint and recovery metadata and is typically also used by the keyed- and operator
+    state backends to store checkpointed state.
+
+    **Serializability**
+
+    Checkpoint storage need to be serializable, because they distributed across parallel processes
+    (for distributed execution) together with the streaming application code.
+
+    Because of that, **CheckpointStorage** implementations are meant to be like factories
+    that create the proper states stores that provide access to the persistent. That way, the
+    Checkpoint Storage can be very lightweight (contain only configurations) which makes it easier
+    to be serializable.
+
+    **Thread Safety**
+
+    Checkpoint storage implementations have to be thread-safe. Multiple threads may be creating
+    streams concurrently.
+    """
+
+    __metaclass__ = ABCMeta
+
+    def __init__(self, j_checkpoint_storage):
+        self._j_checkpoint_storage = j_checkpoint_storage
+
+
+class JobManagerCheckpointStorage(CheckpointStorage):
+    """
+     This **CheckpointStorage** checkpoints state directly to the JobManager's memory (hence the
+     name), but savepoints will be persisted to a file system.
+
+    This checkpoint storage is primarily  for experimentation, quick local setups, or for streaming
+    applications that have very small state: Because it requires checkpoints to go through the
+    JobManager's memory, larger state will occupy larger portions of the JobManager's main memory,
+    reducing operational stability.
+
+    For any other setup, the :class:`FileSystemCheckpointStorage` should be used. The
+    **FileSystemCheckpointStorage** checkpoints state directly to files rather than
+    to the JobManager's memory, thus supporting larger state sizes and more highly available
+    recovery.
+
+    **State Size Considerations**
+
+    State checkpointing with this state backend is subject to the following conditions:
+
+    - Each individual state must not exceed the configured maximum state size
+      (see :func:`get_max_state_size`.
+
+    - All state from one task (i.e., the sum of all operator states and keyed states from all
+      chained operators of the task) must not exceed what the RPC system supports, which is
+      be default < 10 MB. That limit can be configured up, but that is typically not advised.
+
+    - The sum of all states in the application times all retained checkpoints must comfortably
+      fit into the JobManager's JVM heap space.
+
+    **Persistence Guarantees**
+
+    For the use cases where the state sizes can be handled by this backend, the backend does
+    guarantee persistence for savepoints, externalized checkpoints (of configured), and checkpoints
+    (when high-availability is configured).
+
+    **Configuration**
+
+    As for all checkpoint storage, this storage policy can either be configured within the
+    application (by creating the storage with the respective constructor parameters and setting
+    it on the execution environment) or by specifying it in the Flink configuration.
+
+    If the checkpoint storage was specified in the application, it may pick up additional
+    configuration parameters from the Flink configuration. That behavior is
+    implemented via the :func:`configure` method.
+    """
+
+    # The default maximal size that the snapshotted memory state may have (5 MiBytes).
+    DEFAULT_MAX_STATE_SIZE = 5 * 1024 * 1024
+
+    def __init__(self,
+                 checkpoint_path=None,

Review comment:
       Add type hint for these parameters?

##########
File path: flink-python/pyflink/datastream/state_backend.py
##########
@@ -116,8 +125,320 @@ def __init__(self, j_state_backend):
         self._j_state_backend = j_state_backend
 
 
+class HashMapStateBackend(StateBackend):
+    """
+    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 :func:`configure` method.
+    """
+
+    def __init__(self,
+                 using_asynchronous_snapshots=None,
+                 j_hashmap_state_backend=None):
+        """
+        Creates a new HashMapStateBackend, enabling optionally asynchronous operations.
+
+        Example:
+        ::
+            >>> state_backend = HashMapStateBackend()
+
+        :param using_asynchronous_snapshots: Flag to switch between synchronous and asynchronous
+                                             snapshot mode. If null, the value configured in the
+                                             runtime configuration will be used.
+        :param j_hashmap_state_backend: For internal use, please keep none.
+        """
+        if j_hashmap_state_backend is None:
+            gateway = get_gateway()
+            JTernaryBoolean = gateway.jvm.org.apache.flink.util.TernaryBoolean
+            JHashMapStateBackend = gateway.jvm.org.apache.flink.runtime.state.hashmap \
+                .HashMapStateBackend
+            if using_asynchronous_snapshots is None:
+                j_asynchronous_snapshots = JTernaryBoolean.UNDEFINED
+            elif using_asynchronous_snapshots is True:
+                j_asynchronous_snapshots = JTernaryBoolean.TRUE
+            elif using_asynchronous_snapshots is False:
+                j_asynchronous_snapshots = JTernaryBoolean.FALSE
+            else:
+                raise TypeError("Unsupported input for 'using_asynchronous_snapshots': %s, "
+                                "the value of the parameter should be None or"
+                                "True or False.")
+            j_hashmap_state_backend = JHashMapStateBackend(j_asynchronous_snapshots)
+
+        self._j_memory_state_backend = j_hashmap_state_backend

Review comment:
       could be removed

##########
File path: flink-python/pyflink/datastream/checkpoint_storage.py
##########
@@ -0,0 +1,302 @@
+################################################################################
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+# limitations under the License.
+################################################################################
+
+from abc import ABCMeta
+
+from py4j.java_gateway import get_java_class
+
+from pyflink.java_gateway import get_gateway
+
+__all__ = [
+    'CheckpointStorage',
+    'JobManagerCheckpointStorage',
+    'FileSystemCheckpointStorage',
+    'CustomCheckpointStorage'
+]
+
+
+def _from_j_checkpoint_storage(j_checkpoint_storage):
+    if j_checkpoint_storage is None:
+        return None
+    gateway = get_gateway()
+    JCheckpointStorage = gateway.jvm.org.apache.flink.runtime.state.CheckpointStorage
+    JJobManagerCheckpointStorage = gateway.jvm.org.apache.flink.runtime.state.storage \
+        .JobManagerCheckpointStorage
+    JFileSystemCheckpointStorage = gateway.jvm.org.apache.flink.runtime.state.storage \
+        .FileSystemCheckpointStorage
+    j_clz = j_checkpoint_storage.getClass()
+
+    if not get_java_class(JCheckpointStorage).isAssignableFrom(j_clz):
+        raise TypeError("The input %s is not an instance of CheckpointStorage."
+                        % j_checkpoint_storage)
+
+    if get_java_class(JJobManagerCheckpointStorage).isAssignableFrom(j_clz):
+        return JobManagerCheckpointStorage(j_jobmanager_checkpoint_storage=j_checkpoint_storage)
+    elif get_java_class(JFileSystemCheckpointStorage).isAssignableFrom(j_clz):
+        return FileSystemCheckpointStorage(j_fs_checkpoint_storage=j_checkpoint_storage)
+    else:
+        return CustomCheckpointStorage(j_checkpoint_storage)  # users' customized state backend
+
+
+class CheckpointStorage(object):
+    """
+    CheckpointStorage defines how :class:`StateBackend`'s checkpoint their state for fault
+    tolerance in streaming applications. Various implementations store their checkpoints in
+    different fashions and have different requirements and availability guarantees.
+
+    For example, :class:`JobManagerCheckpointStorage` stores checkpoints in the memory of
+    the JobManager. It is lightweight and without additional dependencies but is not highly
+    available and only supports small state sizes. This checkpoint storage policy is convenient
+    for local testing and development.
+
+    :class`FileSystemCheckpointStorage` stores checkpoints in a filesystem. For systems like HDFS,
+    NFS Drives, S3, and GCS, this storage policy supports large state size, in the magnitude of
+    many terabytes while providing a highly available foundation for stateful applications. This
+    checkpoint storage policy is recommended for most production deployments.
+
+    **Raw Bytes Storage**
+
+    The **CheckpointStorage** creates services for raw bytes storage.
+
+    The raw bytes storage (through the CheckpointStreamFactory) is the fundamental service that
+    simply stores bytes in a fault tolerant fashion. This service is used by the JobManager
+    to store checkpoint and recovery metadata and is typically also used by the keyed- and operator
+    state backends to store checkpointed state.
+
+    **Serializability**
+
+    Checkpoint storage need to be serializable, because they distributed across parallel processes
+    (for distributed execution) together with the streaming application code.
+
+    Because of that, **CheckpointStorage** implementations are meant to be like factories
+    that create the proper states stores that provide access to the persistent. That way, the
+    Checkpoint Storage can be very lightweight (contain only configurations) which makes it easier
+    to be serializable.
+
+    **Thread Safety**
+
+    Checkpoint storage implementations have to be thread-safe. Multiple threads may be creating
+    streams concurrently.
+    """
+
+    __metaclass__ = ABCMeta
+
+    def __init__(self, j_checkpoint_storage):
+        self._j_checkpoint_storage = j_checkpoint_storage
+
+
+class JobManagerCheckpointStorage(CheckpointStorage):
+    """
+     This **CheckpointStorage** checkpoints state directly to the JobManager's memory (hence the
+     name), but savepoints will be persisted to a file system.
+
+    This checkpoint storage is primarily  for experimentation, quick local setups, or for streaming
+    applications that have very small state: Because it requires checkpoints to go through the
+    JobManager's memory, larger state will occupy larger portions of the JobManager's main memory,
+    reducing operational stability.
+
+    For any other setup, the :class:`FileSystemCheckpointStorage` should be used. The
+    **FileSystemCheckpointStorage** checkpoints state directly to files rather than
+    to the JobManager's memory, thus supporting larger state sizes and more highly available
+    recovery.
+
+    **State Size Considerations**
+
+    State checkpointing with this state backend is subject to the following conditions:
+
+    - Each individual state must not exceed the configured maximum state size
+      (see :func:`get_max_state_size`.
+
+    - All state from one task (i.e., the sum of all operator states and keyed states from all
+      chained operators of the task) must not exceed what the RPC system supports, which is
+      be default < 10 MB. That limit can be configured up, but that is typically not advised.
+
+    - The sum of all states in the application times all retained checkpoints must comfortably
+      fit into the JobManager's JVM heap space.
+
+    **Persistence Guarantees**
+
+    For the use cases where the state sizes can be handled by this backend, the backend does
+    guarantee persistence for savepoints, externalized checkpoints (of configured), and checkpoints
+    (when high-availability is configured).
+
+    **Configuration**
+
+    As for all checkpoint storage, this storage policy can either be configured within the
+    application (by creating the storage with the respective constructor parameters and setting
+    it on the execution environment) or by specifying it in the Flink configuration.
+
+    If the checkpoint storage was specified in the application, it may pick up additional
+    configuration parameters from the Flink configuration. That behavior is
+    implemented via the :func:`configure` method.
+    """
+
+    # The default maximal size that the snapshotted memory state may have (5 MiBytes).
+    DEFAULT_MAX_STATE_SIZE = 5 * 1024 * 1024
+
+    def __init__(self,
+                 checkpoint_path=None,
+                 max_state_size=None,
+                 j_jobmanager_checkpoint_storage=None):
+        """
+        Creates a new JobManagerCheckpointStorage, setting optionally the paths to persist
+        checkpoint metadata, as well as configuring state thresholds.
+
+        WARNING: Increasing the size of this value beyond the default value
+        (:data:`DEFAULT_MAX_STATE_SIZE`) should be done with care.
+        The checkpointed state needs to be send to the JobManager via limited size RPC messages,
+        and there and the JobManager needs to be able to hold all aggregated state in its memory.
+
+        Example:
+        ::
+            >>> checkpoint_storage = JobManagerCheckpointStorage()
+
+        :param checkpoint_path: The path to write checkpoint metadata to. If none, the value from
+                                the runtime configuration will be used.
+        :param max_state_size: The maximal size of the serialized state. If none, the
+                               :data:`DEFAULT_MAX_STATE_SIZE` will be used.
+        :param j_jobmanager_checkpoint_storage: For internal use, please keep none.
+        """
+        if j_jobmanager_checkpoint_storage is None:
+            gateway = get_gateway()
+            JJobManagerCheckpointStorage = gateway.jvm.org.apache.flink.runtime.state.storage \
+                .JobManagerCheckpointStorage
+            if max_state_size is None:
+                max_state_size = JJobManagerCheckpointStorage.DEFAULT_MAX_STATE_SIZE
+            j_jobmanager_checkpoint_storage = JJobManagerCheckpointStorage(checkpoint_path,
+                                                                           max_state_size)
+
+        self._j_jobmanager_checkpoint_storage = j_jobmanager_checkpoint_storage
+        super(CheckpointStorage, self).__init__(j_jobmanager_checkpoint_storage)
+
+    def get_max_state_size(self):
+        """
+        Gets the maximum size that an individual state can have, as configured in the
+        constructor (by default :data:`DEFAULT_MAX_STATE_SIZE`).
+
+        :return: The maximum size that an individual state can have.
+        """
+        return self._j_jobmanager_checkpoint_storage.getMaxStateSize()
+
+    def __str__(self):
+        return self._j_jobmanager_checkpoint_storage.toString()
+
+
+class FileSystemCheckpointStorage(CheckpointStorage):
+    """
+    This checkpoint storage checkpoints state as files to a file system (hence the name).
+
+    Each checkpoint individually will store all its files in a subdirectory that includes the
+    checkpoint number, such as ``hdfs://namenode:port/flink-checkpoints/chk-17/``.
+
+    **State Size Considerations**
+
+    This checkpoint storage stores small state chunks directly with the metadata, to avoid creating
+    many small files. The threshold for that is configurable. When increasing this threshold, the
+    size of the checkpoint metadata increases. The checkpoint metadata of all retained completed
+    checkpoints needs to fit into the JobManager's heap memory. This is typically not a problem,
+    unless the threshold :func:`get_min_file_size_threshold` is increased significantly.
+
+    **Persistence Guarantees**
+
+    Checkpoints from this storage instance are as persistent and available as filesystem that is
+    written to. If the file system is a persistent distributed file system, this state backend
+    supports highly available setups. The backend additionally supports savepoints and externalized
+    checkpoints.
+
+    **Configuration**
+
+    As for all checkpoint storage, this storage can either be configured within the application (by
+    creating the instance with the respective constructor parameters and setting it on the execution
+    environment) or by specifying it in the Flink configuration.
+
+    If the checkpoint storage was specified in the application, it may pick up additional
+    configuration parameters from the Flink configuration. That behavior is implemented via
+    the :func:`configure` method.
+    """
+
+    def __init__(self,
+                 checkpoint_directory_uri=None,
+                 file_state_size_threshold=None,
+                 write_buffer_size=None,
+                 j_fs_checkpoint_storage=None):
+
+        if j_fs_checkpoint_storage is None:
+            gateway = get_gateway()
+            JFileSystemCheckpointStorage = gateway.jvm.org.apache.flink.runtime.state.storage \
+                .FileSystemCheckpointStorage
+            JPath = gateway.jvm.org.apache.flink.core.fs.Path
+            if checkpoint_directory_uri is None:
+                raise ValueError("The parameter 'checkpoint_directory_uri' is required!")
+            j_checkpoint_directory_uri = JPath(checkpoint_directory_uri).toUri()
+
+            if file_state_size_threshold is None:
+                file_state_size_threshold = -1
+
+            if write_buffer_size is None:
+                write_buffer_size = -1
+
+            j_fs_checkpoint_storage = JFileSystemCheckpointStorage(j_checkpoint_directory_uri,
+                                                                   file_state_size_threshold,
+                                                                   write_buffer_size)
+
+        self._j_fs_checkpoint_storage = j_fs_checkpoint_storage
+        super(FileSystemCheckpointStorage, self).__init__(j_fs_checkpoint_storage)
+
+    def get_checkpoint_path(self):
+        """
+        Gets the base directory where all the checkpoints are stored.
+        The job-specific checkpoint directory is created inside this directory.
+
+        :return: The base directory for checkpoints.
+        """
+        return self._j_fs_checkpoint_storage.getCheckpointPath().toString()
+
+    def get_min_file_size_threshold(self):

Review comment:
       ```suggestion
       def get_min_file_size_threshold(self) -> int:
   ```

##########
File path: flink-python/pyflink/datastream/checkpoint_storage.py
##########
@@ -0,0 +1,302 @@
+################################################################################
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+# limitations under the License.
+################################################################################
+
+from abc import ABCMeta
+
+from py4j.java_gateway import get_java_class
+
+from pyflink.java_gateway import get_gateway
+
+__all__ = [
+    'CheckpointStorage',
+    'JobManagerCheckpointStorage',
+    'FileSystemCheckpointStorage',
+    'CustomCheckpointStorage'
+]
+
+
+def _from_j_checkpoint_storage(j_checkpoint_storage):
+    if j_checkpoint_storage is None:
+        return None
+    gateway = get_gateway()
+    JCheckpointStorage = gateway.jvm.org.apache.flink.runtime.state.CheckpointStorage
+    JJobManagerCheckpointStorage = gateway.jvm.org.apache.flink.runtime.state.storage \
+        .JobManagerCheckpointStorage
+    JFileSystemCheckpointStorage = gateway.jvm.org.apache.flink.runtime.state.storage \
+        .FileSystemCheckpointStorage
+    j_clz = j_checkpoint_storage.getClass()
+
+    if not get_java_class(JCheckpointStorage).isAssignableFrom(j_clz):
+        raise TypeError("The input %s is not an instance of CheckpointStorage."
+                        % j_checkpoint_storage)
+
+    if get_java_class(JJobManagerCheckpointStorage).isAssignableFrom(j_clz):
+        return JobManagerCheckpointStorage(j_jobmanager_checkpoint_storage=j_checkpoint_storage)
+    elif get_java_class(JFileSystemCheckpointStorage).isAssignableFrom(j_clz):
+        return FileSystemCheckpointStorage(j_fs_checkpoint_storage=j_checkpoint_storage)
+    else:
+        return CustomCheckpointStorage(j_checkpoint_storage)  # users' customized state backend
+
+
+class CheckpointStorage(object):
+    """
+    CheckpointStorage defines how :class:`StateBackend`'s checkpoint their state for fault
+    tolerance in streaming applications. Various implementations store their checkpoints in
+    different fashions and have different requirements and availability guarantees.
+
+    For example, :class:`JobManagerCheckpointStorage` stores checkpoints in the memory of
+    the JobManager. It is lightweight and without additional dependencies but is not highly
+    available and only supports small state sizes. This checkpoint storage policy is convenient
+    for local testing and development.
+
+    :class`FileSystemCheckpointStorage` stores checkpoints in a filesystem. For systems like HDFS,
+    NFS Drives, S3, and GCS, this storage policy supports large state size, in the magnitude of
+    many terabytes while providing a highly available foundation for stateful applications. This
+    checkpoint storage policy is recommended for most production deployments.
+
+    **Raw Bytes Storage**
+
+    The **CheckpointStorage** creates services for raw bytes storage.
+
+    The raw bytes storage (through the CheckpointStreamFactory) is the fundamental service that
+    simply stores bytes in a fault tolerant fashion. This service is used by the JobManager
+    to store checkpoint and recovery metadata and is typically also used by the keyed- and operator
+    state backends to store checkpointed state.
+
+    **Serializability**
+
+    Checkpoint storage need to be serializable, because they distributed across parallel processes
+    (for distributed execution) together with the streaming application code.
+
+    Because of that, **CheckpointStorage** implementations are meant to be like factories
+    that create the proper states stores that provide access to the persistent. That way, the
+    Checkpoint Storage can be very lightweight (contain only configurations) which makes it easier
+    to be serializable.
+
+    **Thread Safety**
+
+    Checkpoint storage implementations have to be thread-safe. Multiple threads may be creating
+    streams concurrently.
+    """
+
+    __metaclass__ = ABCMeta
+
+    def __init__(self, j_checkpoint_storage):
+        self._j_checkpoint_storage = j_checkpoint_storage
+
+
+class JobManagerCheckpointStorage(CheckpointStorage):
+    """
+     This **CheckpointStorage** checkpoints state directly to the JobManager's memory (hence the
+     name), but savepoints will be persisted to a file system.
+
+    This checkpoint storage is primarily  for experimentation, quick local setups, or for streaming
+    applications that have very small state: Because it requires checkpoints to go through the
+    JobManager's memory, larger state will occupy larger portions of the JobManager's main memory,
+    reducing operational stability.
+
+    For any other setup, the :class:`FileSystemCheckpointStorage` should be used. The
+    **FileSystemCheckpointStorage** checkpoints state directly to files rather than
+    to the JobManager's memory, thus supporting larger state sizes and more highly available
+    recovery.
+
+    **State Size Considerations**
+
+    State checkpointing with this state backend is subject to the following conditions:
+
+    - Each individual state must not exceed the configured maximum state size
+      (see :func:`get_max_state_size`.
+
+    - All state from one task (i.e., the sum of all operator states and keyed states from all
+      chained operators of the task) must not exceed what the RPC system supports, which is
+      be default < 10 MB. That limit can be configured up, but that is typically not advised.
+
+    - The sum of all states in the application times all retained checkpoints must comfortably
+      fit into the JobManager's JVM heap space.
+
+    **Persistence Guarantees**
+
+    For the use cases where the state sizes can be handled by this backend, the backend does
+    guarantee persistence for savepoints, externalized checkpoints (of configured), and checkpoints
+    (when high-availability is configured).
+
+    **Configuration**
+
+    As for all checkpoint storage, this storage policy can either be configured within the
+    application (by creating the storage with the respective constructor parameters and setting
+    it on the execution environment) or by specifying it in the Flink configuration.
+
+    If the checkpoint storage was specified in the application, it may pick up additional
+    configuration parameters from the Flink configuration. That behavior is
+    implemented via the :func:`configure` method.
+    """
+
+    # The default maximal size that the snapshotted memory state may have (5 MiBytes).
+    DEFAULT_MAX_STATE_SIZE = 5 * 1024 * 1024
+
+    def __init__(self,
+                 checkpoint_path=None,
+                 max_state_size=None,
+                 j_jobmanager_checkpoint_storage=None):
+        """
+        Creates a new JobManagerCheckpointStorage, setting optionally the paths to persist
+        checkpoint metadata, as well as configuring state thresholds.
+
+        WARNING: Increasing the size of this value beyond the default value
+        (:data:`DEFAULT_MAX_STATE_SIZE`) should be done with care.
+        The checkpointed state needs to be send to the JobManager via limited size RPC messages,
+        and there and the JobManager needs to be able to hold all aggregated state in its memory.
+
+        Example:
+        ::
+            >>> checkpoint_storage = JobManagerCheckpointStorage()
+
+        :param checkpoint_path: The path to write checkpoint metadata to. If none, the value from
+                                the runtime configuration will be used.
+        :param max_state_size: The maximal size of the serialized state. If none, the
+                               :data:`DEFAULT_MAX_STATE_SIZE` will be used.
+        :param j_jobmanager_checkpoint_storage: For internal use, please keep none.
+        """
+        if j_jobmanager_checkpoint_storage is None:
+            gateway = get_gateway()
+            JJobManagerCheckpointStorage = gateway.jvm.org.apache.flink.runtime.state.storage \
+                .JobManagerCheckpointStorage
+            if max_state_size is None:
+                max_state_size = JJobManagerCheckpointStorage.DEFAULT_MAX_STATE_SIZE
+            j_jobmanager_checkpoint_storage = JJobManagerCheckpointStorage(checkpoint_path,
+                                                                           max_state_size)
+
+        self._j_jobmanager_checkpoint_storage = j_jobmanager_checkpoint_storage
+        super(CheckpointStorage, self).__init__(j_jobmanager_checkpoint_storage)
+
+    def get_max_state_size(self):
+        """
+        Gets the maximum size that an individual state can have, as configured in the
+        constructor (by default :data:`DEFAULT_MAX_STATE_SIZE`).
+
+        :return: The maximum size that an individual state can have.
+        """
+        return self._j_jobmanager_checkpoint_storage.getMaxStateSize()
+
+    def __str__(self):
+        return self._j_jobmanager_checkpoint_storage.toString()
+
+
+class FileSystemCheckpointStorage(CheckpointStorage):
+    """
+    This checkpoint storage checkpoints state as files to a file system (hence the name).
+
+    Each checkpoint individually will store all its files in a subdirectory that includes the
+    checkpoint number, such as ``hdfs://namenode:port/flink-checkpoints/chk-17/``.
+
+    **State Size Considerations**
+
+    This checkpoint storage stores small state chunks directly with the metadata, to avoid creating
+    many small files. The threshold for that is configurable. When increasing this threshold, the
+    size of the checkpoint metadata increases. The checkpoint metadata of all retained completed
+    checkpoints needs to fit into the JobManager's heap memory. This is typically not a problem,
+    unless the threshold :func:`get_min_file_size_threshold` is increased significantly.
+
+    **Persistence Guarantees**
+
+    Checkpoints from this storage instance are as persistent and available as filesystem that is
+    written to. If the file system is a persistent distributed file system, this state backend
+    supports highly available setups. The backend additionally supports savepoints and externalized
+    checkpoints.
+
+    **Configuration**
+
+    As for all checkpoint storage, this storage can either be configured within the application (by
+    creating the instance with the respective constructor parameters and setting it on the execution
+    environment) or by specifying it in the Flink configuration.
+
+    If the checkpoint storage was specified in the application, it may pick up additional
+    configuration parameters from the Flink configuration. That behavior is implemented via
+    the :func:`configure` method.
+    """
+
+    def __init__(self,
+                 checkpoint_directory_uri=None,
+                 file_state_size_threshold=None,
+                 write_buffer_size=None,
+                 j_fs_checkpoint_storage=None):
+
+        if j_fs_checkpoint_storage is None:
+            gateway = get_gateway()
+            JFileSystemCheckpointStorage = gateway.jvm.org.apache.flink.runtime.state.storage \
+                .FileSystemCheckpointStorage
+            JPath = gateway.jvm.org.apache.flink.core.fs.Path
+            if checkpoint_directory_uri is None:
+                raise ValueError("The parameter 'checkpoint_directory_uri' is required!")
+            j_checkpoint_directory_uri = JPath(checkpoint_directory_uri).toUri()
+
+            if file_state_size_threshold is None:
+                file_state_size_threshold = -1
+
+            if write_buffer_size is None:
+                write_buffer_size = -1
+
+            j_fs_checkpoint_storage = JFileSystemCheckpointStorage(j_checkpoint_directory_uri,
+                                                                   file_state_size_threshold,
+                                                                   write_buffer_size)
+
+        self._j_fs_checkpoint_storage = j_fs_checkpoint_storage
+        super(FileSystemCheckpointStorage, self).__init__(j_fs_checkpoint_storage)
+
+    def get_checkpoint_path(self):

Review comment:
       ```suggestion
       def get_checkpoint_path(self) -> str:
   ```

##########
File path: flink-python/pyflink/datastream/state_backend.py
##########
@@ -116,8 +125,320 @@ def __init__(self, j_state_backend):
         self._j_state_backend = j_state_backend
 
 
+class HashMapStateBackend(StateBackend):
+    """
+    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 :func:`configure` method.
+    """
+
+    def __init__(self,
+                 using_asynchronous_snapshots=None,
+                 j_hashmap_state_backend=None):
+        """
+        Creates a new HashMapStateBackend, enabling optionally asynchronous operations.
+
+        Example:
+        ::
+            >>> state_backend = HashMapStateBackend()
+
+        :param using_asynchronous_snapshots: Flag to switch between synchronous and asynchronous
+                                             snapshot mode. If null, the value configured in the
+                                             runtime configuration will be used.
+        :param j_hashmap_state_backend: For internal use, please keep none.
+        """
+        if j_hashmap_state_backend is None:
+            gateway = get_gateway()
+            JTernaryBoolean = gateway.jvm.org.apache.flink.util.TernaryBoolean
+            JHashMapStateBackend = gateway.jvm.org.apache.flink.runtime.state.hashmap \
+                .HashMapStateBackend
+            if using_asynchronous_snapshots is None:
+                j_asynchronous_snapshots = JTernaryBoolean.UNDEFINED
+            elif using_asynchronous_snapshots is True:
+                j_asynchronous_snapshots = JTernaryBoolean.TRUE
+            elif using_asynchronous_snapshots is False:
+                j_asynchronous_snapshots = JTernaryBoolean.FALSE
+            else:
+                raise TypeError("Unsupported input for 'using_asynchronous_snapshots': %s, "
+                                "the value of the parameter should be None or"
+                                "True or False.")
+            j_hashmap_state_backend = JHashMapStateBackend(j_asynchronous_snapshots)
+
+        self._j_memory_state_backend = j_hashmap_state_backend
+        super(HashMapStateBackend, self).__init__(j_hashmap_state_backend)
+
+    def is_using_asynchronous_snapshots(self):

Review comment:
       ```suggestion
       def is_using_asynchronous_snapshots(self) -> bool:
   ```

##########
File path: flink-python/pyflink/datastream/state_backend.py
##########
@@ -116,8 +125,320 @@ def __init__(self, j_state_backend):
         self._j_state_backend = j_state_backend
 
 
+class HashMapStateBackend(StateBackend):
+    """
+    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 :func:`configure` method.
+    """
+
+    def __init__(self,
+                 using_asynchronous_snapshots=None,
+                 j_hashmap_state_backend=None):
+        """
+        Creates a new HashMapStateBackend, enabling optionally asynchronous operations.
+
+        Example:
+        ::
+            >>> state_backend = HashMapStateBackend()
+
+        :param using_asynchronous_snapshots: Flag to switch between synchronous and asynchronous
+                                             snapshot mode. If null, the value configured in the
+                                             runtime configuration will be used.
+        :param j_hashmap_state_backend: For internal use, please keep none.
+        """
+        if j_hashmap_state_backend is None:
+            gateway = get_gateway()
+            JTernaryBoolean = gateway.jvm.org.apache.flink.util.TernaryBoolean
+            JHashMapStateBackend = gateway.jvm.org.apache.flink.runtime.state.hashmap \
+                .HashMapStateBackend
+            if using_asynchronous_snapshots is None:
+                j_asynchronous_snapshots = JTernaryBoolean.UNDEFINED
+            elif using_asynchronous_snapshots is True:
+                j_asynchronous_snapshots = JTernaryBoolean.TRUE
+            elif using_asynchronous_snapshots is False:
+                j_asynchronous_snapshots = JTernaryBoolean.FALSE
+            else:
+                raise TypeError("Unsupported input for 'using_asynchronous_snapshots': %s, "
+                                "the value of the parameter should be None or"
+                                "True or False.")
+            j_hashmap_state_backend = JHashMapStateBackend(j_asynchronous_snapshots)
+
+        self._j_memory_state_backend = j_hashmap_state_backend
+        super(HashMapStateBackend, self).__init__(j_hashmap_state_backend)
+
+    def is_using_asynchronous_snapshots(self):
+        """
+        Gets whether the key/value data structures are asynchronously snapshotted.
+
+        If not explicitly configured, this is the default value of
+        ``org.apache.flink.configuration.CheckpointingOptions.ASYNC_SNAPSHOTS``.
+
+        :return: True if the key/value data structures are asynchronously snapshotted,
+                 false otherwise.
+        """
+        return self._j_memory_state_backend.isUsingAsynchronousSnapshots()
+
+    def __str__(self):
+        return self._j_memory_state_backend.toString()
+
+
+class EmbeddedRocksDBStateBackend(StateBackend):
+    """
+    A State Backend that stores its state in an embedded ``RocksDB``. This state backend can
+    store very large state that exceeds memory and spills to disk.
+
+    All key/value state (including windows) is stored in the key/value index of RocksDB.
+    For persistence against loss of machines, please configure a checkpoint storage
+    instance for the Job.
+
+    The behavior of the RocksDB instances can be parametrized by setting RocksDB Options
+    using the methods :func:`set_predefined_options` and :func:`set_options`.
+    """
+
+    def __init__(self,
+                 enable_incremental_checkpointing=None,
+                 j_rocks_db_state_backend=None):
+        """
+        Creates a new :class:`RocksDBStateBackend` that stores its checkpoint data in the given
+        state backend or the location of given URI.
+
+        If using state backend, typically, one would supply a filesystem or database state backend
+        here where the snapshots from RocksDB would be stored.
+
+        If using URI, a state backend that stores checkpoints in HDFS or S3 must specify the file
+        system host and port in the URI, or have the Hadoop configuration that describes the file
+        system (host / high-availability group / possibly credentials) either referenced from the
+        Flink config, or included in the classpath.
+
+        Example:
+        ::
+
+            >>> state_backend = EmbeddedRocksDBStateBackend()
+
+        :param enable_incremental_checkpointing: True if incremental checkpointing is enabled.
+        :param j_rocks_db_state_backend: For internal use, please keep none.
+        """
+        if j_rocks_db_state_backend is None:
+            gateway = get_gateway()
+            JTernaryBoolean = gateway.jvm.org.apache.flink.util.TernaryBoolean
+            JEmbeddedRocksDBStateBackend = gateway.jvm.org.apache.flink.contrib.streaming.state \
+                .EmbeddedRocksDBStateBackend
+
+            if enable_incremental_checkpointing not in (None, True, False):
+                raise TypeError("Unsupported input for 'enable_incremental_checkpointing': %s, "
+                                "the value of the parameter should be None or"
+                                "True or False.")
+
+            if enable_incremental_checkpointing is None:
+                j_enable_incremental_checkpointing = JTernaryBoolean.UNDEFINED
+            elif enable_incremental_checkpointing is True:
+                j_enable_incremental_checkpointing = JTernaryBoolean.TRUE
+            else:
+                j_enable_incremental_checkpointing = JTernaryBoolean.FALSE
+
+            j_rocks_db_state_backend = \
+                JEmbeddedRocksDBStateBackend(j_enable_incremental_checkpointing)
+
+        self._j_rocks_db_state_backend = j_rocks_db_state_backend
+        super(EmbeddedRocksDBStateBackend, self).__init__(j_rocks_db_state_backend)
+
+    def set_db_storage_paths(self, *paths):

Review comment:
       ```suggestion
       def set_db_storage_paths(self, *paths: str):
   ```

##########
File path: flink-python/pyflink/datastream/state_backend.py
##########
@@ -116,8 +125,320 @@ def __init__(self, j_state_backend):
         self._j_state_backend = j_state_backend
 
 
+class HashMapStateBackend(StateBackend):
+    """
+    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 :func:`configure` method.
+    """
+
+    def __init__(self,
+                 using_asynchronous_snapshots=None,
+                 j_hashmap_state_backend=None):
+        """
+        Creates a new HashMapStateBackend, enabling optionally asynchronous operations.
+
+        Example:
+        ::
+            >>> state_backend = HashMapStateBackend()
+
+        :param using_asynchronous_snapshots: Flag to switch between synchronous and asynchronous
+                                             snapshot mode. If null, the value configured in the
+                                             runtime configuration will be used.
+        :param j_hashmap_state_backend: For internal use, please keep none.
+        """
+        if j_hashmap_state_backend is None:
+            gateway = get_gateway()
+            JTernaryBoolean = gateway.jvm.org.apache.flink.util.TernaryBoolean
+            JHashMapStateBackend = gateway.jvm.org.apache.flink.runtime.state.hashmap \
+                .HashMapStateBackend
+            if using_asynchronous_snapshots is None:
+                j_asynchronous_snapshots = JTernaryBoolean.UNDEFINED
+            elif using_asynchronous_snapshots is True:
+                j_asynchronous_snapshots = JTernaryBoolean.TRUE
+            elif using_asynchronous_snapshots is False:
+                j_asynchronous_snapshots = JTernaryBoolean.FALSE
+            else:
+                raise TypeError("Unsupported input for 'using_asynchronous_snapshots': %s, "
+                                "the value of the parameter should be None or"
+                                "True or False.")
+            j_hashmap_state_backend = JHashMapStateBackend(j_asynchronous_snapshots)
+
+        self._j_memory_state_backend = j_hashmap_state_backend
+        super(HashMapStateBackend, self).__init__(j_hashmap_state_backend)
+
+    def is_using_asynchronous_snapshots(self):
+        """
+        Gets whether the key/value data structures are asynchronously snapshotted.
+
+        If not explicitly configured, this is the default value of
+        ``org.apache.flink.configuration.CheckpointingOptions.ASYNC_SNAPSHOTS``.
+
+        :return: True if the key/value data structures are asynchronously snapshotted,
+                 false otherwise.
+        """
+        return self._j_memory_state_backend.isUsingAsynchronousSnapshots()
+
+    def __str__(self):
+        return self._j_memory_state_backend.toString()
+
+
+class EmbeddedRocksDBStateBackend(StateBackend):
+    """
+    A State Backend that stores its state in an embedded ``RocksDB``. This state backend can
+    store very large state that exceeds memory and spills to disk.
+
+    All key/value state (including windows) is stored in the key/value index of RocksDB.
+    For persistence against loss of machines, please configure a checkpoint storage
+    instance for the Job.
+
+    The behavior of the RocksDB instances can be parametrized by setting RocksDB Options
+    using the methods :func:`set_predefined_options` and :func:`set_options`.
+    """
+
+    def __init__(self,
+                 enable_incremental_checkpointing=None,
+                 j_rocks_db_state_backend=None):
+        """
+        Creates a new :class:`RocksDBStateBackend` that stores its checkpoint data in the given
+        state backend or the location of given URI.
+
+        If using state backend, typically, one would supply a filesystem or database state backend
+        here where the snapshots from RocksDB would be stored.
+
+        If using URI, a state backend that stores checkpoints in HDFS or S3 must specify the file
+        system host and port in the URI, or have the Hadoop configuration that describes the file
+        system (host / high-availability group / possibly credentials) either referenced from the
+        Flink config, or included in the classpath.
+
+        Example:
+        ::
+
+            >>> state_backend = EmbeddedRocksDBStateBackend()
+
+        :param enable_incremental_checkpointing: True if incremental checkpointing is enabled.
+        :param j_rocks_db_state_backend: For internal use, please keep none.
+        """
+        if j_rocks_db_state_backend is None:
+            gateway = get_gateway()
+            JTernaryBoolean = gateway.jvm.org.apache.flink.util.TernaryBoolean
+            JEmbeddedRocksDBStateBackend = gateway.jvm.org.apache.flink.contrib.streaming.state \
+                .EmbeddedRocksDBStateBackend
+
+            if enable_incremental_checkpointing not in (None, True, False):
+                raise TypeError("Unsupported input for 'enable_incremental_checkpointing': %s, "
+                                "the value of the parameter should be None or"
+                                "True or False.")
+
+            if enable_incremental_checkpointing is None:
+                j_enable_incremental_checkpointing = JTernaryBoolean.UNDEFINED
+            elif enable_incremental_checkpointing is True:
+                j_enable_incremental_checkpointing = JTernaryBoolean.TRUE
+            else:
+                j_enable_incremental_checkpointing = JTernaryBoolean.FALSE
+
+            j_rocks_db_state_backend = \
+                JEmbeddedRocksDBStateBackend(j_enable_incremental_checkpointing)
+
+        self._j_rocks_db_state_backend = j_rocks_db_state_backend
+        super(EmbeddedRocksDBStateBackend, self).__init__(j_rocks_db_state_backend)
+
+    def set_db_storage_paths(self, *paths):
+        """
+        Sets the directories in which the local RocksDB database puts its files (like SST and
+        metadata files). These directories do not need to be persistent, they can be ephemeral,
+        meaning that they are lost on a machine failure, because state in RocksDB is persisted
+        in checkpoints.
+
+        If nothing is configured, these directories default to the TaskManager's local
+        temporary file directories.
+
+        Each distinct state will be stored in one path, but when the state backend creates
+        multiple states, they will store their files on different paths.
+
+        Passing ``None`` to this function restores the default behavior, where the configured
+        temp directories will be used.
+
+        :param paths: The paths across which the local RocksDB database files will be spread. this
+                      parameter is optional.
+        """
+        if len(paths) < 1:
+            self._j_rocks_db_state_backend.setDbStoragePath(None)
+        else:
+            gateway = get_gateway()
+            j_path_array = gateway.new_array(gateway.jvm.String, len(paths))
+            for i in range(0, len(paths)):
+                j_path_array[i] = paths[i]
+            self._j_rocks_db_state_backend.setDbStoragePaths(j_path_array)
+
+    def get_db_storage_paths(self):

Review comment:
       ```suggestion
       def get_db_storage_paths(self) -> str:
   ```

##########
File path: flink-python/pyflink/datastream/state_backend.py
##########
@@ -116,8 +125,320 @@ def __init__(self, j_state_backend):
         self._j_state_backend = j_state_backend
 
 
+class HashMapStateBackend(StateBackend):
+    """
+    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 :func:`configure` method.
+    """
+
+    def __init__(self,
+                 using_asynchronous_snapshots=None,
+                 j_hashmap_state_backend=None):
+        """
+        Creates a new HashMapStateBackend, enabling optionally asynchronous operations.
+
+        Example:
+        ::
+            >>> state_backend = HashMapStateBackend()
+
+        :param using_asynchronous_snapshots: Flag to switch between synchronous and asynchronous
+                                             snapshot mode. If null, the value configured in the
+                                             runtime configuration will be used.
+        :param j_hashmap_state_backend: For internal use, please keep none.
+        """
+        if j_hashmap_state_backend is None:
+            gateway = get_gateway()
+            JTernaryBoolean = gateway.jvm.org.apache.flink.util.TernaryBoolean
+            JHashMapStateBackend = gateway.jvm.org.apache.flink.runtime.state.hashmap \
+                .HashMapStateBackend
+            if using_asynchronous_snapshots is None:
+                j_asynchronous_snapshots = JTernaryBoolean.UNDEFINED
+            elif using_asynchronous_snapshots is True:
+                j_asynchronous_snapshots = JTernaryBoolean.TRUE
+            elif using_asynchronous_snapshots is False:
+                j_asynchronous_snapshots = JTernaryBoolean.FALSE
+            else:
+                raise TypeError("Unsupported input for 'using_asynchronous_snapshots': %s, "
+                                "the value of the parameter should be None or"
+                                "True or False.")
+            j_hashmap_state_backend = JHashMapStateBackend(j_asynchronous_snapshots)
+
+        self._j_memory_state_backend = j_hashmap_state_backend
+        super(HashMapStateBackend, self).__init__(j_hashmap_state_backend)
+
+    def is_using_asynchronous_snapshots(self):
+        """
+        Gets whether the key/value data structures are asynchronously snapshotted.
+
+        If not explicitly configured, this is the default value of
+        ``org.apache.flink.configuration.CheckpointingOptions.ASYNC_SNAPSHOTS``.
+
+        :return: True if the key/value data structures are asynchronously snapshotted,
+                 false otherwise.
+        """
+        return self._j_memory_state_backend.isUsingAsynchronousSnapshots()
+
+    def __str__(self):
+        return self._j_memory_state_backend.toString()
+
+
+class EmbeddedRocksDBStateBackend(StateBackend):
+    """
+    A State Backend that stores its state in an embedded ``RocksDB``. This state backend can
+    store very large state that exceeds memory and spills to disk.
+
+    All key/value state (including windows) is stored in the key/value index of RocksDB.
+    For persistence against loss of machines, please configure a checkpoint storage
+    instance for the Job.
+
+    The behavior of the RocksDB instances can be parametrized by setting RocksDB Options
+    using the methods :func:`set_predefined_options` and :func:`set_options`.
+    """
+
+    def __init__(self,
+                 enable_incremental_checkpointing=None,
+                 j_rocks_db_state_backend=None):
+        """
+        Creates a new :class:`RocksDBStateBackend` that stores its checkpoint data in the given
+        state backend or the location of given URI.
+
+        If using state backend, typically, one would supply a filesystem or database state backend
+        here where the snapshots from RocksDB would be stored.
+
+        If using URI, a state backend that stores checkpoints in HDFS or S3 must specify the file
+        system host and port in the URI, or have the Hadoop configuration that describes the file
+        system (host / high-availability group / possibly credentials) either referenced from the
+        Flink config, or included in the classpath.
+
+        Example:
+        ::
+
+            >>> state_backend = EmbeddedRocksDBStateBackend()
+
+        :param enable_incremental_checkpointing: True if incremental checkpointing is enabled.
+        :param j_rocks_db_state_backend: For internal use, please keep none.
+        """
+        if j_rocks_db_state_backend is None:
+            gateway = get_gateway()
+            JTernaryBoolean = gateway.jvm.org.apache.flink.util.TernaryBoolean
+            JEmbeddedRocksDBStateBackend = gateway.jvm.org.apache.flink.contrib.streaming.state \
+                .EmbeddedRocksDBStateBackend
+
+            if enable_incremental_checkpointing not in (None, True, False):
+                raise TypeError("Unsupported input for 'enable_incremental_checkpointing': %s, "
+                                "the value of the parameter should be None or"
+                                "True or False.")
+
+            if enable_incremental_checkpointing is None:
+                j_enable_incremental_checkpointing = JTernaryBoolean.UNDEFINED
+            elif enable_incremental_checkpointing is True:
+                j_enable_incremental_checkpointing = JTernaryBoolean.TRUE
+            else:
+                j_enable_incremental_checkpointing = JTernaryBoolean.FALSE
+
+            j_rocks_db_state_backend = \
+                JEmbeddedRocksDBStateBackend(j_enable_incremental_checkpointing)
+
+        self._j_rocks_db_state_backend = j_rocks_db_state_backend
+        super(EmbeddedRocksDBStateBackend, self).__init__(j_rocks_db_state_backend)
+
+    def set_db_storage_paths(self, *paths):
+        """
+        Sets the directories in which the local RocksDB database puts its files (like SST and
+        metadata files). These directories do not need to be persistent, they can be ephemeral,
+        meaning that they are lost on a machine failure, because state in RocksDB is persisted
+        in checkpoints.
+
+        If nothing is configured, these directories default to the TaskManager's local
+        temporary file directories.
+
+        Each distinct state will be stored in one path, but when the state backend creates
+        multiple states, they will store their files on different paths.
+
+        Passing ``None`` to this function restores the default behavior, where the configured
+        temp directories will be used.
+
+        :param paths: The paths across which the local RocksDB database files will be spread. this
+                      parameter is optional.
+        """
+        if len(paths) < 1:
+            self._j_rocks_db_state_backend.setDbStoragePath(None)
+        else:
+            gateway = get_gateway()
+            j_path_array = gateway.new_array(gateway.jvm.String, len(paths))
+            for i in range(0, len(paths)):
+                j_path_array[i] = paths[i]
+            self._j_rocks_db_state_backend.setDbStoragePaths(j_path_array)
+
+    def get_db_storage_paths(self):
+        """
+        Gets the configured local DB storage paths, or null, if none were configured.
+
+        Under these directories on the TaskManager, RocksDB stores its SST files and
+        metadata files. These directories do not need to be persistent, they can be ephermeral,
+        meaning that they are lost on a machine failure, because state in RocksDB is persisted
+        in checkpoints.
+
+        If nothing is configured, these directories default to the TaskManager's local
+        temporary file directories.
+
+        :return: The list of configured local DB storage paths.
+        """
+        return list(self._j_rocks_db_state_backend.getDbStoragePaths())
+
+    def is_incremental_checkpoints_enabled(self):
+        """
+        Gets whether incremental checkpoints are enabled for this state backend.
+
+        :return: True if incremental checkpoints are enabled, false otherwise.
+        """
+        return self._j_rocks_db_state_backend.isIncrementalCheckpointsEnabled()
+
+    def set_predefined_options(self, options):
+        """
+        Sets the predefined options for RocksDB.
+
+        If user-configured options within ``RocksDBConfigurableOptions`` is set (through
+        flink-conf.yaml) or a user-defined options factory is set (via :func:`setOptions`),
+        then the options from the factory are applied on top of the here specified
+        predefined options and customized options.
+
+        Example:
+        ::
+
+            >>> state_backend.set_predefined_options(PredefinedOptions.SPINNING_DISK_OPTIMIZED)
+
+        :param options: The options to set (must not be null), see :class:`PredefinedOptions`.
+        """
+        gateway = get_gateway()

Review comment:
       could be replaced with only one line as following:
   ```
   self._j_rocks_db_state_backend.setPredefinedOptions(options._to_j_predefined_options()
   ```

##########
File path: flink-python/pyflink/datastream/checkpoint_storage.py
##########
@@ -0,0 +1,302 @@
+################################################################################
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+# limitations under the License.
+################################################################################
+
+from abc import ABCMeta
+
+from py4j.java_gateway import get_java_class
+
+from pyflink.java_gateway import get_gateway
+
+__all__ = [
+    'CheckpointStorage',
+    'JobManagerCheckpointStorage',
+    'FileSystemCheckpointStorage',
+    'CustomCheckpointStorage'
+]
+
+
+def _from_j_checkpoint_storage(j_checkpoint_storage):
+    if j_checkpoint_storage is None:
+        return None
+    gateway = get_gateway()
+    JCheckpointStorage = gateway.jvm.org.apache.flink.runtime.state.CheckpointStorage
+    JJobManagerCheckpointStorage = gateway.jvm.org.apache.flink.runtime.state.storage \
+        .JobManagerCheckpointStorage
+    JFileSystemCheckpointStorage = gateway.jvm.org.apache.flink.runtime.state.storage \
+        .FileSystemCheckpointStorage
+    j_clz = j_checkpoint_storage.getClass()
+
+    if not get_java_class(JCheckpointStorage).isAssignableFrom(j_clz):
+        raise TypeError("The input %s is not an instance of CheckpointStorage."
+                        % j_checkpoint_storage)
+
+    if get_java_class(JJobManagerCheckpointStorage).isAssignableFrom(j_clz):
+        return JobManagerCheckpointStorage(j_jobmanager_checkpoint_storage=j_checkpoint_storage)
+    elif get_java_class(JFileSystemCheckpointStorage).isAssignableFrom(j_clz):
+        return FileSystemCheckpointStorage(j_fs_checkpoint_storage=j_checkpoint_storage)
+    else:
+        return CustomCheckpointStorage(j_checkpoint_storage)  # users' customized state backend
+
+
+class CheckpointStorage(object):
+    """
+    CheckpointStorage defines how :class:`StateBackend`'s checkpoint their state for fault
+    tolerance in streaming applications. Various implementations store their checkpoints in
+    different fashions and have different requirements and availability guarantees.
+
+    For example, :class:`JobManagerCheckpointStorage` stores checkpoints in the memory of
+    the JobManager. It is lightweight and without additional dependencies but is not highly
+    available and only supports small state sizes. This checkpoint storage policy is convenient
+    for local testing and development.
+
+    :class`FileSystemCheckpointStorage` stores checkpoints in a filesystem. For systems like HDFS,
+    NFS Drives, S3, and GCS, this storage policy supports large state size, in the magnitude of
+    many terabytes while providing a highly available foundation for stateful applications. This
+    checkpoint storage policy is recommended for most production deployments.
+
+    **Raw Bytes Storage**
+
+    The **CheckpointStorage** creates services for raw bytes storage.
+
+    The raw bytes storage (through the CheckpointStreamFactory) is the fundamental service that
+    simply stores bytes in a fault tolerant fashion. This service is used by the JobManager
+    to store checkpoint and recovery metadata and is typically also used by the keyed- and operator
+    state backends to store checkpointed state.
+
+    **Serializability**
+
+    Checkpoint storage need to be serializable, because they distributed across parallel processes
+    (for distributed execution) together with the streaming application code.
+
+    Because of that, **CheckpointStorage** implementations are meant to be like factories
+    that create the proper states stores that provide access to the persistent. That way, the
+    Checkpoint Storage can be very lightweight (contain only configurations) which makes it easier
+    to be serializable.
+
+    **Thread Safety**
+
+    Checkpoint storage implementations have to be thread-safe. Multiple threads may be creating
+    streams concurrently.
+    """
+
+    __metaclass__ = ABCMeta
+
+    def __init__(self, j_checkpoint_storage):
+        self._j_checkpoint_storage = j_checkpoint_storage
+
+
+class JobManagerCheckpointStorage(CheckpointStorage):
+    """
+     This **CheckpointStorage** checkpoints state directly to the JobManager's memory (hence the
+     name), but savepoints will be persisted to a file system.
+
+    This checkpoint storage is primarily  for experimentation, quick local setups, or for streaming
+    applications that have very small state: Because it requires checkpoints to go through the
+    JobManager's memory, larger state will occupy larger portions of the JobManager's main memory,
+    reducing operational stability.
+
+    For any other setup, the :class:`FileSystemCheckpointStorage` should be used. The
+    **FileSystemCheckpointStorage** checkpoints state directly to files rather than
+    to the JobManager's memory, thus supporting larger state sizes and more highly available
+    recovery.
+
+    **State Size Considerations**
+
+    State checkpointing with this state backend is subject to the following conditions:
+
+    - Each individual state must not exceed the configured maximum state size
+      (see :func:`get_max_state_size`.
+
+    - All state from one task (i.e., the sum of all operator states and keyed states from all
+      chained operators of the task) must not exceed what the RPC system supports, which is
+      be default < 10 MB. That limit can be configured up, but that is typically not advised.
+
+    - The sum of all states in the application times all retained checkpoints must comfortably
+      fit into the JobManager's JVM heap space.
+
+    **Persistence Guarantees**
+
+    For the use cases where the state sizes can be handled by this backend, the backend does
+    guarantee persistence for savepoints, externalized checkpoints (of configured), and checkpoints
+    (when high-availability is configured).
+
+    **Configuration**
+
+    As for all checkpoint storage, this storage policy can either be configured within the
+    application (by creating the storage with the respective constructor parameters and setting
+    it on the execution environment) or by specifying it in the Flink configuration.
+
+    If the checkpoint storage was specified in the application, it may pick up additional
+    configuration parameters from the Flink configuration. That behavior is
+    implemented via the :func:`configure` method.
+    """
+
+    # The default maximal size that the snapshotted memory state may have (5 MiBytes).
+    DEFAULT_MAX_STATE_SIZE = 5 * 1024 * 1024
+
+    def __init__(self,
+                 checkpoint_path=None,
+                 max_state_size=None,
+                 j_jobmanager_checkpoint_storage=None):
+        """
+        Creates a new JobManagerCheckpointStorage, setting optionally the paths to persist
+        checkpoint metadata, as well as configuring state thresholds.
+
+        WARNING: Increasing the size of this value beyond the default value
+        (:data:`DEFAULT_MAX_STATE_SIZE`) should be done with care.
+        The checkpointed state needs to be send to the JobManager via limited size RPC messages,
+        and there and the JobManager needs to be able to hold all aggregated state in its memory.
+
+        Example:
+        ::
+            >>> checkpoint_storage = JobManagerCheckpointStorage()
+
+        :param checkpoint_path: The path to write checkpoint metadata to. If none, the value from
+                                the runtime configuration will be used.
+        :param max_state_size: The maximal size of the serialized state. If none, the
+                               :data:`DEFAULT_MAX_STATE_SIZE` will be used.
+        :param j_jobmanager_checkpoint_storage: For internal use, please keep none.
+        """
+        if j_jobmanager_checkpoint_storage is None:
+            gateway = get_gateway()
+            JJobManagerCheckpointStorage = gateway.jvm.org.apache.flink.runtime.state.storage \
+                .JobManagerCheckpointStorage
+            if max_state_size is None:
+                max_state_size = JJobManagerCheckpointStorage.DEFAULT_MAX_STATE_SIZE
+            j_jobmanager_checkpoint_storage = JJobManagerCheckpointStorage(checkpoint_path,
+                                                                           max_state_size)
+
+        self._j_jobmanager_checkpoint_storage = j_jobmanager_checkpoint_storage
+        super(CheckpointStorage, self).__init__(j_jobmanager_checkpoint_storage)
+
+    def get_max_state_size(self):
+        """
+        Gets the maximum size that an individual state can have, as configured in the
+        constructor (by default :data:`DEFAULT_MAX_STATE_SIZE`).
+
+        :return: The maximum size that an individual state can have.
+        """
+        return self._j_jobmanager_checkpoint_storage.getMaxStateSize()
+
+    def __str__(self):
+        return self._j_jobmanager_checkpoint_storage.toString()
+
+
+class FileSystemCheckpointStorage(CheckpointStorage):
+    """
+    This checkpoint storage checkpoints state as files to a file system (hence the name).
+
+    Each checkpoint individually will store all its files in a subdirectory that includes the
+    checkpoint number, such as ``hdfs://namenode:port/flink-checkpoints/chk-17/``.
+
+    **State Size Considerations**
+
+    This checkpoint storage stores small state chunks directly with the metadata, to avoid creating
+    many small files. The threshold for that is configurable. When increasing this threshold, the
+    size of the checkpoint metadata increases. The checkpoint metadata of all retained completed
+    checkpoints needs to fit into the JobManager's heap memory. This is typically not a problem,
+    unless the threshold :func:`get_min_file_size_threshold` is increased significantly.
+
+    **Persistence Guarantees**
+
+    Checkpoints from this storage instance are as persistent and available as filesystem that is
+    written to. If the file system is a persistent distributed file system, this state backend
+    supports highly available setups. The backend additionally supports savepoints and externalized
+    checkpoints.
+
+    **Configuration**
+
+    As for all checkpoint storage, this storage can either be configured within the application (by
+    creating the instance with the respective constructor parameters and setting it on the execution
+    environment) or by specifying it in the Flink configuration.
+
+    If the checkpoint storage was specified in the application, it may pick up additional
+    configuration parameters from the Flink configuration. That behavior is implemented via
+    the :func:`configure` method.
+    """
+
+    def __init__(self,
+                 checkpoint_directory_uri=None,
+                 file_state_size_threshold=None,
+                 write_buffer_size=None,
+                 j_fs_checkpoint_storage=None):
+
+        if j_fs_checkpoint_storage is None:
+            gateway = get_gateway()
+            JFileSystemCheckpointStorage = gateway.jvm.org.apache.flink.runtime.state.storage \
+                .FileSystemCheckpointStorage
+            JPath = gateway.jvm.org.apache.flink.core.fs.Path
+            if checkpoint_directory_uri is None:
+                raise ValueError("The parameter 'checkpoint_directory_uri' is required!")
+            j_checkpoint_directory_uri = JPath(checkpoint_directory_uri).toUri()
+
+            if file_state_size_threshold is None:
+                file_state_size_threshold = -1
+
+            if write_buffer_size is None:
+                write_buffer_size = -1
+
+            j_fs_checkpoint_storage = JFileSystemCheckpointStorage(j_checkpoint_directory_uri,
+                                                                   file_state_size_threshold,
+                                                                   write_buffer_size)
+
+        self._j_fs_checkpoint_storage = j_fs_checkpoint_storage
+        super(FileSystemCheckpointStorage, self).__init__(j_fs_checkpoint_storage)
+
+    def get_checkpoint_path(self):
+        """
+        Gets the base directory where all the checkpoints are stored.
+        The job-specific checkpoint directory is created inside this directory.
+
+        :return: The base directory for checkpoints.
+        """
+        return self._j_fs_checkpoint_storage.getCheckpointPath().toString()
+
+    def get_min_file_size_threshold(self):
+        """
+        Gets the threshold below which state is stored as part of the metadata, rather than in
+        files. This threshold ensures that the backend does not create a large amount of very
+        small files, where potentially the file pointers are larger than the state itself.
+
+        If not explicitly configured, this is the default value of
+        ``org.apache.flink.configuration.CheckpointingOptions.FS_SMALL_FILE_THRESHOLD``.
+
+        :return: The file size threshold, in bytes.
+        """
+        return self._j_fs_checkpoint_storage.getMinFileSizeThreshold()
+
+    def get_write_buffer_size(self):

Review comment:
       ```suggestion
       def get_write_buffer_size(self) -> int:
   ```

##########
File path: flink-python/pyflink/datastream/state_backend.py
##########
@@ -116,8 +125,320 @@ def __init__(self, j_state_backend):
         self._j_state_backend = j_state_backend
 
 
+class HashMapStateBackend(StateBackend):
+    """
+    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 :func:`configure` method.
+    """
+
+    def __init__(self,
+                 using_asynchronous_snapshots=None,
+                 j_hashmap_state_backend=None):
+        """
+        Creates a new HashMapStateBackend, enabling optionally asynchronous operations.
+
+        Example:
+        ::
+            >>> state_backend = HashMapStateBackend()
+
+        :param using_asynchronous_snapshots: Flag to switch between synchronous and asynchronous
+                                             snapshot mode. If null, the value configured in the
+                                             runtime configuration will be used.
+        :param j_hashmap_state_backend: For internal use, please keep none.
+        """
+        if j_hashmap_state_backend is None:
+            gateway = get_gateway()
+            JTernaryBoolean = gateway.jvm.org.apache.flink.util.TernaryBoolean
+            JHashMapStateBackend = gateway.jvm.org.apache.flink.runtime.state.hashmap \
+                .HashMapStateBackend
+            if using_asynchronous_snapshots is None:
+                j_asynchronous_snapshots = JTernaryBoolean.UNDEFINED
+            elif using_asynchronous_snapshots is True:
+                j_asynchronous_snapshots = JTernaryBoolean.TRUE
+            elif using_asynchronous_snapshots is False:
+                j_asynchronous_snapshots = JTernaryBoolean.FALSE
+            else:
+                raise TypeError("Unsupported input for 'using_asynchronous_snapshots': %s, "
+                                "the value of the parameter should be None or"
+                                "True or False.")
+            j_hashmap_state_backend = JHashMapStateBackend(j_asynchronous_snapshots)
+
+        self._j_memory_state_backend = j_hashmap_state_backend
+        super(HashMapStateBackend, self).__init__(j_hashmap_state_backend)
+
+    def is_using_asynchronous_snapshots(self):
+        """
+        Gets whether the key/value data structures are asynchronously snapshotted.
+
+        If not explicitly configured, this is the default value of
+        ``org.apache.flink.configuration.CheckpointingOptions.ASYNC_SNAPSHOTS``.
+
+        :return: True if the key/value data structures are asynchronously snapshotted,
+                 false otherwise.
+        """
+        return self._j_memory_state_backend.isUsingAsynchronousSnapshots()
+
+    def __str__(self):
+        return self._j_memory_state_backend.toString()
+
+
+class EmbeddedRocksDBStateBackend(StateBackend):
+    """
+    A State Backend that stores its state in an embedded ``RocksDB``. This state backend can
+    store very large state that exceeds memory and spills to disk.
+
+    All key/value state (including windows) is stored in the key/value index of RocksDB.
+    For persistence against loss of machines, please configure a checkpoint storage
+    instance for the Job.
+
+    The behavior of the RocksDB instances can be parametrized by setting RocksDB Options
+    using the methods :func:`set_predefined_options` and :func:`set_options`.
+    """
+
+    def __init__(self,
+                 enable_incremental_checkpointing=None,
+                 j_rocks_db_state_backend=None):
+        """
+        Creates a new :class:`RocksDBStateBackend` that stores its checkpoint data in the given
+        state backend or the location of given URI.
+
+        If using state backend, typically, one would supply a filesystem or database state backend
+        here where the snapshots from RocksDB would be stored.
+
+        If using URI, a state backend that stores checkpoints in HDFS or S3 must specify the file
+        system host and port in the URI, or have the Hadoop configuration that describes the file
+        system (host / high-availability group / possibly credentials) either referenced from the
+        Flink config, or included in the classpath.
+
+        Example:
+        ::
+
+            >>> state_backend = EmbeddedRocksDBStateBackend()
+
+        :param enable_incremental_checkpointing: True if incremental checkpointing is enabled.
+        :param j_rocks_db_state_backend: For internal use, please keep none.
+        """
+        if j_rocks_db_state_backend is None:
+            gateway = get_gateway()
+            JTernaryBoolean = gateway.jvm.org.apache.flink.util.TernaryBoolean
+            JEmbeddedRocksDBStateBackend = gateway.jvm.org.apache.flink.contrib.streaming.state \
+                .EmbeddedRocksDBStateBackend
+
+            if enable_incremental_checkpointing not in (None, True, False):
+                raise TypeError("Unsupported input for 'enable_incremental_checkpointing': %s, "
+                                "the value of the parameter should be None or"
+                                "True or False.")
+
+            if enable_incremental_checkpointing is None:
+                j_enable_incremental_checkpointing = JTernaryBoolean.UNDEFINED
+            elif enable_incremental_checkpointing is True:
+                j_enable_incremental_checkpointing = JTernaryBoolean.TRUE
+            else:
+                j_enable_incremental_checkpointing = JTernaryBoolean.FALSE
+
+            j_rocks_db_state_backend = \
+                JEmbeddedRocksDBStateBackend(j_enable_incremental_checkpointing)
+
+        self._j_rocks_db_state_backend = j_rocks_db_state_backend
+        super(EmbeddedRocksDBStateBackend, self).__init__(j_rocks_db_state_backend)
+
+    def set_db_storage_paths(self, *paths):
+        """
+        Sets the directories in which the local RocksDB database puts its files (like SST and
+        metadata files). These directories do not need to be persistent, they can be ephemeral,
+        meaning that they are lost on a machine failure, because state in RocksDB is persisted
+        in checkpoints.
+
+        If nothing is configured, these directories default to the TaskManager's local
+        temporary file directories.
+
+        Each distinct state will be stored in one path, but when the state backend creates
+        multiple states, they will store their files on different paths.
+
+        Passing ``None`` to this function restores the default behavior, where the configured
+        temp directories will be used.
+
+        :param paths: The paths across which the local RocksDB database files will be spread. this
+                      parameter is optional.
+        """
+        if len(paths) < 1:
+            self._j_rocks_db_state_backend.setDbStoragePath(None)
+        else:
+            gateway = get_gateway()
+            j_path_array = gateway.new_array(gateway.jvm.String, len(paths))
+            for i in range(0, len(paths)):
+                j_path_array[i] = paths[i]
+            self._j_rocks_db_state_backend.setDbStoragePaths(j_path_array)
+
+    def get_db_storage_paths(self):
+        """
+        Gets the configured local DB storage paths, or null, if none were configured.
+
+        Under these directories on the TaskManager, RocksDB stores its SST files and
+        metadata files. These directories do not need to be persistent, they can be ephermeral,
+        meaning that they are lost on a machine failure, because state in RocksDB is persisted
+        in checkpoints.
+
+        If nothing is configured, these directories default to the TaskManager's local
+        temporary file directories.
+
+        :return: The list of configured local DB storage paths.
+        """
+        return list(self._j_rocks_db_state_backend.getDbStoragePaths())
+
+    def is_incremental_checkpoints_enabled(self):
+        """
+        Gets whether incremental checkpoints are enabled for this state backend.
+
+        :return: True if incremental checkpoints are enabled, false otherwise.
+        """
+        return self._j_rocks_db_state_backend.isIncrementalCheckpointsEnabled()
+
+    def set_predefined_options(self, options):
+        """
+        Sets the predefined options for RocksDB.
+
+        If user-configured options within ``RocksDBConfigurableOptions`` is set (through
+        flink-conf.yaml) or a user-defined options factory is set (via :func:`setOptions`),
+        then the options from the factory are applied on top of the here specified
+        predefined options and customized options.
+
+        Example:
+        ::
+
+            >>> state_backend.set_predefined_options(PredefinedOptions.SPINNING_DISK_OPTIMIZED)
+
+        :param options: The options to set (must not be null), see :class:`PredefinedOptions`.
+        """
+        gateway = get_gateway()
+        JPredefinedOptions = gateway.jvm.org.apache.flink.contrib.streaming.state.PredefinedOptions
+        if options == PredefinedOptions.DEFAULT:
+            self._j_rocks_db_state_backend.setPredefinedOptions(JPredefinedOptions.DEFAULT)
+        elif options == PredefinedOptions.SPINNING_DISK_OPTIMIZED:
+            self._j_rocks_db_state_backend.setPredefinedOptions(
+                JPredefinedOptions.SPINNING_DISK_OPTIMIZED)
+        elif options == PredefinedOptions.SPINNING_DISK_OPTIMIZED_HIGH_MEM:
+            self._j_rocks_db_state_backend.setPredefinedOptions(
+                JPredefinedOptions.SPINNING_DISK_OPTIMIZED_HIGH_MEM)
+        elif options == PredefinedOptions.FLASH_SSD_OPTIMIZED:
+            self._j_rocks_db_state_backend.setPredefinedOptions(
+                JPredefinedOptions.FLASH_SSD_OPTIMIZED)
+        else:
+            raise TypeError("Unsupported options: %s, the supported options are: "
+                            "PredefinedOptions.DEFAULT, PredefinedOptions.SPINNING_DISK_OPTIMIZED,"
+                            " PredefinedOptions.SPINNING_DISK_OPTIMIZED_HIGH_MEM and "
+                            "PredefinedOptions.FLASH_SSD_OPTIMIZED")
+
+    def get_predefined_options(self):
+        """
+        Gets the current predefined options for RocksDB.
+        The default options (if nothing was set via :func:`setPredefinedOptions`)
+        are :data:`PredefinedOptions.DEFAULT`.
+
+        If user-configured options within ``RocksDBConfigurableOptions`` is set (through
+        flink-conf.yaml) or a user-defined options factory is set (via :func:`setOptions`),
+        then the options from the factory are applied on top of the predefined and customized
+        options.
+
+        .. seealso:: :func:`set_predefined_options`
+
+        :return: Current predefined options.
+        """
+        j_predefined_options = self._j_rocks_db_state_backend.getPredefinedOptions()
+        gateway = get_gateway()
+        JPredefinedOptions = gateway.jvm.org.apache.flink.contrib.streaming.state.PredefinedOptions
+        if j_predefined_options == JPredefinedOptions.DEFAULT:
+            return PredefinedOptions.DEFAULT
+        elif j_predefined_options == JPredefinedOptions.FLASH_SSD_OPTIMIZED:
+            return PredefinedOptions.FLASH_SSD_OPTIMIZED
+        elif j_predefined_options == JPredefinedOptions.SPINNING_DISK_OPTIMIZED:
+            return PredefinedOptions.SPINNING_DISK_OPTIMIZED
+        elif j_predefined_options == JPredefinedOptions.SPINNING_DISK_OPTIMIZED_HIGH_MEM:
+            return PredefinedOptions.SPINNING_DISK_OPTIMIZED_HIGH_MEM
+        else:
+            raise Exception("Unsupported java options: %s" % j_predefined_options)
+
+    def set_options(self, options_factory_class_name):

Review comment:
       add type hint for parameter options_factory_class_name

##########
File path: flink-python/pyflink/datastream/state_backend.py
##########
@@ -116,8 +125,320 @@ def __init__(self, j_state_backend):
         self._j_state_backend = j_state_backend
 
 
+class HashMapStateBackend(StateBackend):
+    """
+    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 :func:`configure` method.
+    """
+
+    def __init__(self,
+                 using_asynchronous_snapshots=None,
+                 j_hashmap_state_backend=None):
+        """
+        Creates a new HashMapStateBackend, enabling optionally asynchronous operations.
+
+        Example:
+        ::
+            >>> state_backend = HashMapStateBackend()
+
+        :param using_asynchronous_snapshots: Flag to switch between synchronous and asynchronous
+                                             snapshot mode. If null, the value configured in the
+                                             runtime configuration will be used.
+        :param j_hashmap_state_backend: For internal use, please keep none.
+        """
+        if j_hashmap_state_backend is None:
+            gateway = get_gateway()
+            JTernaryBoolean = gateway.jvm.org.apache.flink.util.TernaryBoolean
+            JHashMapStateBackend = gateway.jvm.org.apache.flink.runtime.state.hashmap \
+                .HashMapStateBackend
+            if using_asynchronous_snapshots is None:
+                j_asynchronous_snapshots = JTernaryBoolean.UNDEFINED
+            elif using_asynchronous_snapshots is True:
+                j_asynchronous_snapshots = JTernaryBoolean.TRUE
+            elif using_asynchronous_snapshots is False:
+                j_asynchronous_snapshots = JTernaryBoolean.FALSE
+            else:
+                raise TypeError("Unsupported input for 'using_asynchronous_snapshots': %s, "
+                                "the value of the parameter should be None or"
+                                "True or False.")
+            j_hashmap_state_backend = JHashMapStateBackend(j_asynchronous_snapshots)
+
+        self._j_memory_state_backend = j_hashmap_state_backend
+        super(HashMapStateBackend, self).__init__(j_hashmap_state_backend)
+
+    def is_using_asynchronous_snapshots(self):
+        """
+        Gets whether the key/value data structures are asynchronously snapshotted.
+
+        If not explicitly configured, this is the default value of
+        ``org.apache.flink.configuration.CheckpointingOptions.ASYNC_SNAPSHOTS``.
+
+        :return: True if the key/value data structures are asynchronously snapshotted,
+                 false otherwise.
+        """
+        return self._j_memory_state_backend.isUsingAsynchronousSnapshots()
+
+    def __str__(self):
+        return self._j_memory_state_backend.toString()
+
+
+class EmbeddedRocksDBStateBackend(StateBackend):
+    """
+    A State Backend that stores its state in an embedded ``RocksDB``. This state backend can
+    store very large state that exceeds memory and spills to disk.
+
+    All key/value state (including windows) is stored in the key/value index of RocksDB.
+    For persistence against loss of machines, please configure a checkpoint storage
+    instance for the Job.
+
+    The behavior of the RocksDB instances can be parametrized by setting RocksDB Options
+    using the methods :func:`set_predefined_options` and :func:`set_options`.
+    """
+
+    def __init__(self,
+                 enable_incremental_checkpointing=None,
+                 j_rocks_db_state_backend=None):
+        """
+        Creates a new :class:`RocksDBStateBackend` that stores its checkpoint data in the given
+        state backend or the location of given URI.
+
+        If using state backend, typically, one would supply a filesystem or database state backend
+        here where the snapshots from RocksDB would be stored.
+
+        If using URI, a state backend that stores checkpoints in HDFS or S3 must specify the file
+        system host and port in the URI, or have the Hadoop configuration that describes the file
+        system (host / high-availability group / possibly credentials) either referenced from the
+        Flink config, or included in the classpath.
+
+        Example:
+        ::
+
+            >>> state_backend = EmbeddedRocksDBStateBackend()
+
+        :param enable_incremental_checkpointing: True if incremental checkpointing is enabled.
+        :param j_rocks_db_state_backend: For internal use, please keep none.
+        """
+        if j_rocks_db_state_backend is None:
+            gateway = get_gateway()
+            JTernaryBoolean = gateway.jvm.org.apache.flink.util.TernaryBoolean
+            JEmbeddedRocksDBStateBackend = gateway.jvm.org.apache.flink.contrib.streaming.state \
+                .EmbeddedRocksDBStateBackend
+
+            if enable_incremental_checkpointing not in (None, True, False):
+                raise TypeError("Unsupported input for 'enable_incremental_checkpointing': %s, "
+                                "the value of the parameter should be None or"
+                                "True or False.")
+
+            if enable_incremental_checkpointing is None:
+                j_enable_incremental_checkpointing = JTernaryBoolean.UNDEFINED
+            elif enable_incremental_checkpointing is True:
+                j_enable_incremental_checkpointing = JTernaryBoolean.TRUE
+            else:
+                j_enable_incremental_checkpointing = JTernaryBoolean.FALSE
+
+            j_rocks_db_state_backend = \
+                JEmbeddedRocksDBStateBackend(j_enable_incremental_checkpointing)
+
+        self._j_rocks_db_state_backend = j_rocks_db_state_backend
+        super(EmbeddedRocksDBStateBackend, self).__init__(j_rocks_db_state_backend)
+
+    def set_db_storage_paths(self, *paths):
+        """
+        Sets the directories in which the local RocksDB database puts its files (like SST and
+        metadata files). These directories do not need to be persistent, they can be ephemeral,
+        meaning that they are lost on a machine failure, because state in RocksDB is persisted
+        in checkpoints.
+
+        If nothing is configured, these directories default to the TaskManager's local
+        temporary file directories.
+
+        Each distinct state will be stored in one path, but when the state backend creates
+        multiple states, they will store their files on different paths.
+
+        Passing ``None`` to this function restores the default behavior, where the configured
+        temp directories will be used.
+
+        :param paths: The paths across which the local RocksDB database files will be spread. this
+                      parameter is optional.
+        """
+        if len(paths) < 1:
+            self._j_rocks_db_state_backend.setDbStoragePath(None)
+        else:
+            gateway = get_gateway()
+            j_path_array = gateway.new_array(gateway.jvm.String, len(paths))
+            for i in range(0, len(paths)):
+                j_path_array[i] = paths[i]
+            self._j_rocks_db_state_backend.setDbStoragePaths(j_path_array)
+
+    def get_db_storage_paths(self):
+        """
+        Gets the configured local DB storage paths, or null, if none were configured.
+
+        Under these directories on the TaskManager, RocksDB stores its SST files and
+        metadata files. These directories do not need to be persistent, they can be ephermeral,
+        meaning that they are lost on a machine failure, because state in RocksDB is persisted
+        in checkpoints.
+
+        If nothing is configured, these directories default to the TaskManager's local
+        temporary file directories.
+
+        :return: The list of configured local DB storage paths.
+        """
+        return list(self._j_rocks_db_state_backend.getDbStoragePaths())
+
+    def is_incremental_checkpoints_enabled(self):
+        """
+        Gets whether incremental checkpoints are enabled for this state backend.
+
+        :return: True if incremental checkpoints are enabled, false otherwise.
+        """
+        return self._j_rocks_db_state_backend.isIncrementalCheckpointsEnabled()
+
+    def set_predefined_options(self, options):

Review comment:
       ```suggestion
       def set_predefined_options(self, options: PredefinedOptions):
   ```

##########
File path: flink-python/pyflink/datastream/state_backend.py
##########
@@ -116,8 +125,320 @@ def __init__(self, j_state_backend):
         self._j_state_backend = j_state_backend
 
 
+class HashMapStateBackend(StateBackend):
+    """
+    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 :func:`configure` method.
+    """
+
+    def __init__(self,
+                 using_asynchronous_snapshots=None,
+                 j_hashmap_state_backend=None):
+        """
+        Creates a new HashMapStateBackend, enabling optionally asynchronous operations.
+
+        Example:
+        ::
+            >>> state_backend = HashMapStateBackend()
+
+        :param using_asynchronous_snapshots: Flag to switch between synchronous and asynchronous
+                                             snapshot mode. If null, the value configured in the
+                                             runtime configuration will be used.
+        :param j_hashmap_state_backend: For internal use, please keep none.
+        """
+        if j_hashmap_state_backend is None:
+            gateway = get_gateway()
+            JTernaryBoolean = gateway.jvm.org.apache.flink.util.TernaryBoolean
+            JHashMapStateBackend = gateway.jvm.org.apache.flink.runtime.state.hashmap \
+                .HashMapStateBackend
+            if using_asynchronous_snapshots is None:
+                j_asynchronous_snapshots = JTernaryBoolean.UNDEFINED
+            elif using_asynchronous_snapshots is True:
+                j_asynchronous_snapshots = JTernaryBoolean.TRUE
+            elif using_asynchronous_snapshots is False:
+                j_asynchronous_snapshots = JTernaryBoolean.FALSE
+            else:
+                raise TypeError("Unsupported input for 'using_asynchronous_snapshots': %s, "
+                                "the value of the parameter should be None or"
+                                "True or False.")
+            j_hashmap_state_backend = JHashMapStateBackend(j_asynchronous_snapshots)
+
+        self._j_memory_state_backend = j_hashmap_state_backend
+        super(HashMapStateBackend, self).__init__(j_hashmap_state_backend)
+
+    def is_using_asynchronous_snapshots(self):
+        """
+        Gets whether the key/value data structures are asynchronously snapshotted.
+
+        If not explicitly configured, this is the default value of
+        ``org.apache.flink.configuration.CheckpointingOptions.ASYNC_SNAPSHOTS``.
+
+        :return: True if the key/value data structures are asynchronously snapshotted,
+                 false otherwise.
+        """
+        return self._j_memory_state_backend.isUsingAsynchronousSnapshots()
+
+    def __str__(self):
+        return self._j_memory_state_backend.toString()
+
+
+class EmbeddedRocksDBStateBackend(StateBackend):
+    """
+    A State Backend that stores its state in an embedded ``RocksDB``. This state backend can
+    store very large state that exceeds memory and spills to disk.
+
+    All key/value state (including windows) is stored in the key/value index of RocksDB.
+    For persistence against loss of machines, please configure a checkpoint storage
+    instance for the Job.
+
+    The behavior of the RocksDB instances can be parametrized by setting RocksDB Options
+    using the methods :func:`set_predefined_options` and :func:`set_options`.
+    """
+
+    def __init__(self,
+                 enable_incremental_checkpointing=None,
+                 j_rocks_db_state_backend=None):
+        """
+        Creates a new :class:`RocksDBStateBackend` that stores its checkpoint data in the given
+        state backend or the location of given URI.
+
+        If using state backend, typically, one would supply a filesystem or database state backend
+        here where the snapshots from RocksDB would be stored.
+
+        If using URI, a state backend that stores checkpoints in HDFS or S3 must specify the file
+        system host and port in the URI, or have the Hadoop configuration that describes the file
+        system (host / high-availability group / possibly credentials) either referenced from the
+        Flink config, or included in the classpath.
+
+        Example:
+        ::
+
+            >>> state_backend = EmbeddedRocksDBStateBackend()
+
+        :param enable_incremental_checkpointing: True if incremental checkpointing is enabled.
+        :param j_rocks_db_state_backend: For internal use, please keep none.
+        """
+        if j_rocks_db_state_backend is None:
+            gateway = get_gateway()
+            JTernaryBoolean = gateway.jvm.org.apache.flink.util.TernaryBoolean
+            JEmbeddedRocksDBStateBackend = gateway.jvm.org.apache.flink.contrib.streaming.state \
+                .EmbeddedRocksDBStateBackend
+
+            if enable_incremental_checkpointing not in (None, True, False):
+                raise TypeError("Unsupported input for 'enable_incremental_checkpointing': %s, "
+                                "the value of the parameter should be None or"
+                                "True or False.")
+
+            if enable_incremental_checkpointing is None:
+                j_enable_incremental_checkpointing = JTernaryBoolean.UNDEFINED
+            elif enable_incremental_checkpointing is True:
+                j_enable_incremental_checkpointing = JTernaryBoolean.TRUE
+            else:
+                j_enable_incremental_checkpointing = JTernaryBoolean.FALSE
+
+            j_rocks_db_state_backend = \
+                JEmbeddedRocksDBStateBackend(j_enable_incremental_checkpointing)
+
+        self._j_rocks_db_state_backend = j_rocks_db_state_backend
+        super(EmbeddedRocksDBStateBackend, self).__init__(j_rocks_db_state_backend)
+
+    def set_db_storage_paths(self, *paths):
+        """
+        Sets the directories in which the local RocksDB database puts its files (like SST and
+        metadata files). These directories do not need to be persistent, they can be ephemeral,
+        meaning that they are lost on a machine failure, because state in RocksDB is persisted
+        in checkpoints.
+
+        If nothing is configured, these directories default to the TaskManager's local
+        temporary file directories.
+
+        Each distinct state will be stored in one path, but when the state backend creates
+        multiple states, they will store their files on different paths.
+
+        Passing ``None`` to this function restores the default behavior, where the configured
+        temp directories will be used.
+
+        :param paths: The paths across which the local RocksDB database files will be spread. this
+                      parameter is optional.
+        """
+        if len(paths) < 1:
+            self._j_rocks_db_state_backend.setDbStoragePath(None)
+        else:
+            gateway = get_gateway()
+            j_path_array = gateway.new_array(gateway.jvm.String, len(paths))
+            for i in range(0, len(paths)):
+                j_path_array[i] = paths[i]
+            self._j_rocks_db_state_backend.setDbStoragePaths(j_path_array)
+
+    def get_db_storage_paths(self):
+        """
+        Gets the configured local DB storage paths, or null, if none were configured.
+
+        Under these directories on the TaskManager, RocksDB stores its SST files and
+        metadata files. These directories do not need to be persistent, they can be ephermeral,
+        meaning that they are lost on a machine failure, because state in RocksDB is persisted
+        in checkpoints.
+
+        If nothing is configured, these directories default to the TaskManager's local
+        temporary file directories.
+
+        :return: The list of configured local DB storage paths.
+        """
+        return list(self._j_rocks_db_state_backend.getDbStoragePaths())
+
+    def is_incremental_checkpoints_enabled(self):
+        """
+        Gets whether incremental checkpoints are enabled for this state backend.
+
+        :return: True if incremental checkpoints are enabled, false otherwise.
+        """
+        return self._j_rocks_db_state_backend.isIncrementalCheckpointsEnabled()
+
+    def set_predefined_options(self, options):
+        """
+        Sets the predefined options for RocksDB.
+
+        If user-configured options within ``RocksDBConfigurableOptions`` is set (through
+        flink-conf.yaml) or a user-defined options factory is set (via :func:`setOptions`),
+        then the options from the factory are applied on top of the here specified
+        predefined options and customized options.
+
+        Example:
+        ::
+
+            >>> state_backend.set_predefined_options(PredefinedOptions.SPINNING_DISK_OPTIMIZED)
+
+        :param options: The options to set (must not be null), see :class:`PredefinedOptions`.
+        """
+        gateway = get_gateway()
+        JPredefinedOptions = gateway.jvm.org.apache.flink.contrib.streaming.state.PredefinedOptions
+        if options == PredefinedOptions.DEFAULT:
+            self._j_rocks_db_state_backend.setPredefinedOptions(JPredefinedOptions.DEFAULT)
+        elif options == PredefinedOptions.SPINNING_DISK_OPTIMIZED:
+            self._j_rocks_db_state_backend.setPredefinedOptions(
+                JPredefinedOptions.SPINNING_DISK_OPTIMIZED)
+        elif options == PredefinedOptions.SPINNING_DISK_OPTIMIZED_HIGH_MEM:
+            self._j_rocks_db_state_backend.setPredefinedOptions(
+                JPredefinedOptions.SPINNING_DISK_OPTIMIZED_HIGH_MEM)
+        elif options == PredefinedOptions.FLASH_SSD_OPTIMIZED:
+            self._j_rocks_db_state_backend.setPredefinedOptions(
+                JPredefinedOptions.FLASH_SSD_OPTIMIZED)
+        else:
+            raise TypeError("Unsupported options: %s, the supported options are: "
+                            "PredefinedOptions.DEFAULT, PredefinedOptions.SPINNING_DISK_OPTIMIZED,"
+                            " PredefinedOptions.SPINNING_DISK_OPTIMIZED_HIGH_MEM and "
+                            "PredefinedOptions.FLASH_SSD_OPTIMIZED")
+
+    def get_predefined_options(self):
+        """
+        Gets the current predefined options for RocksDB.
+        The default options (if nothing was set via :func:`setPredefinedOptions`)
+        are :data:`PredefinedOptions.DEFAULT`.
+
+        If user-configured options within ``RocksDBConfigurableOptions`` is set (through
+        flink-conf.yaml) or a user-defined options factory is set (via :func:`setOptions`),
+        then the options from the factory are applied on top of the predefined and customized
+        options.
+
+        .. seealso:: :func:`set_predefined_options`
+
+        :return: Current predefined options.
+        """
+        j_predefined_options = self._j_rocks_db_state_backend.getPredefinedOptions()
+        gateway = get_gateway()
+        JPredefinedOptions = gateway.jvm.org.apache.flink.contrib.streaming.state.PredefinedOptions
+        if j_predefined_options == JPredefinedOptions.DEFAULT:
+            return PredefinedOptions.DEFAULT
+        elif j_predefined_options == JPredefinedOptions.FLASH_SSD_OPTIMIZED:
+            return PredefinedOptions.FLASH_SSD_OPTIMIZED
+        elif j_predefined_options == JPredefinedOptions.SPINNING_DISK_OPTIMIZED:
+            return PredefinedOptions.SPINNING_DISK_OPTIMIZED
+        elif j_predefined_options == JPredefinedOptions.SPINNING_DISK_OPTIMIZED_HIGH_MEM:
+            return PredefinedOptions.SPINNING_DISK_OPTIMIZED_HIGH_MEM
+        else:
+            raise Exception("Unsupported java options: %s" % j_predefined_options)
+
+    def set_options(self, options_factory_class_name):
+        """
+        Sets ``org.rocksdb.Options`` for the RocksDB instances.
+        Because the options are not serializable and hold native code references,
+        they must be specified through a factory.
+
+        The options created by the factory here are applied on top of the pre-defined
+        options profile selected via :func:`set_predefined_options`.
+        If the pre-defined options profile is the default (:data:`PredefinedOptions.DEFAULT`),
+        then the factory fully controls the RocksDB options.
+
+        :param options_factory_class_name: The fully-qualified class name of the options
+                                           factory in Java that lazily creates the RocksDB options.
+                                           The options factory must have a default constructor.
+        """
+        gateway = get_gateway()
+        JOptionsFactory = gateway.jvm.org.apache.flink.contrib.streaming.state.RocksDBOptionsFactory
+        j_options_factory_clz = load_java_class(options_factory_class_name)
+        if not get_java_class(JOptionsFactory).isAssignableFrom(j_options_factory_clz):
+            raise ValueError("The input class does not implement RocksDBOptionsFactory.")
+        self._j_rocks_db_state_backend.setRocksDBOptions(j_options_factory_clz.newInstance())
+
+    def get_options(self):
+        """
+        Gets the fully-qualified class name of the options factory in Java that lazily creates
+        the RocksDB options.
+
+        :return: The fully-qualified class name of the options factory in Java.
+        """
+        j_options_factory = self._j_rocks_db_state_backend.getRocksDBOptions()
+        if j_options_factory is not None:
+            return j_options_factory.getClass().getName()
+        else:
+            return None
+
+    def get_number_of_transfering_threads(self):

Review comment:
       ditto

##########
File path: flink-python/pyflink/datastream/state_backend.py
##########
@@ -116,8 +125,320 @@ def __init__(self, j_state_backend):
         self._j_state_backend = j_state_backend
 
 
+class HashMapStateBackend(StateBackend):
+    """
+    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 :func:`configure` method.
+    """
+
+    def __init__(self,
+                 using_asynchronous_snapshots=None,
+                 j_hashmap_state_backend=None):
+        """
+        Creates a new HashMapStateBackend, enabling optionally asynchronous operations.
+
+        Example:
+        ::
+            >>> state_backend = HashMapStateBackend()
+
+        :param using_asynchronous_snapshots: Flag to switch between synchronous and asynchronous
+                                             snapshot mode. If null, the value configured in the
+                                             runtime configuration will be used.
+        :param j_hashmap_state_backend: For internal use, please keep none.
+        """
+        if j_hashmap_state_backend is None:
+            gateway = get_gateway()
+            JTernaryBoolean = gateway.jvm.org.apache.flink.util.TernaryBoolean
+            JHashMapStateBackend = gateway.jvm.org.apache.flink.runtime.state.hashmap \
+                .HashMapStateBackend
+            if using_asynchronous_snapshots is None:
+                j_asynchronous_snapshots = JTernaryBoolean.UNDEFINED
+            elif using_asynchronous_snapshots is True:
+                j_asynchronous_snapshots = JTernaryBoolean.TRUE
+            elif using_asynchronous_snapshots is False:
+                j_asynchronous_snapshots = JTernaryBoolean.FALSE
+            else:
+                raise TypeError("Unsupported input for 'using_asynchronous_snapshots': %s, "
+                                "the value of the parameter should be None or"
+                                "True or False.")
+            j_hashmap_state_backend = JHashMapStateBackend(j_asynchronous_snapshots)
+
+        self._j_memory_state_backend = j_hashmap_state_backend
+        super(HashMapStateBackend, self).__init__(j_hashmap_state_backend)
+
+    def is_using_asynchronous_snapshots(self):
+        """
+        Gets whether the key/value data structures are asynchronously snapshotted.
+
+        If not explicitly configured, this is the default value of
+        ``org.apache.flink.configuration.CheckpointingOptions.ASYNC_SNAPSHOTS``.
+
+        :return: True if the key/value data structures are asynchronously snapshotted,
+                 false otherwise.
+        """
+        return self._j_memory_state_backend.isUsingAsynchronousSnapshots()
+
+    def __str__(self):
+        return self._j_memory_state_backend.toString()
+
+
+class EmbeddedRocksDBStateBackend(StateBackend):
+    """
+    A State Backend that stores its state in an embedded ``RocksDB``. This state backend can
+    store very large state that exceeds memory and spills to disk.
+
+    All key/value state (including windows) is stored in the key/value index of RocksDB.
+    For persistence against loss of machines, please configure a checkpoint storage
+    instance for the Job.
+
+    The behavior of the RocksDB instances can be parametrized by setting RocksDB Options
+    using the methods :func:`set_predefined_options` and :func:`set_options`.
+    """
+
+    def __init__(self,
+                 enable_incremental_checkpointing=None,
+                 j_rocks_db_state_backend=None):
+        """
+        Creates a new :class:`RocksDBStateBackend` that stores its checkpoint data in the given
+        state backend or the location of given URI.
+
+        If using state backend, typically, one would supply a filesystem or database state backend
+        here where the snapshots from RocksDB would be stored.
+
+        If using URI, a state backend that stores checkpoints in HDFS or S3 must specify the file
+        system host and port in the URI, or have the Hadoop configuration that describes the file
+        system (host / high-availability group / possibly credentials) either referenced from the
+        Flink config, or included in the classpath.
+
+        Example:
+        ::
+
+            >>> state_backend = EmbeddedRocksDBStateBackend()
+
+        :param enable_incremental_checkpointing: True if incremental checkpointing is enabled.
+        :param j_rocks_db_state_backend: For internal use, please keep none.
+        """
+        if j_rocks_db_state_backend is None:
+            gateway = get_gateway()
+            JTernaryBoolean = gateway.jvm.org.apache.flink.util.TernaryBoolean
+            JEmbeddedRocksDBStateBackend = gateway.jvm.org.apache.flink.contrib.streaming.state \
+                .EmbeddedRocksDBStateBackend
+
+            if enable_incremental_checkpointing not in (None, True, False):
+                raise TypeError("Unsupported input for 'enable_incremental_checkpointing': %s, "
+                                "the value of the parameter should be None or"
+                                "True or False.")
+
+            if enable_incremental_checkpointing is None:
+                j_enable_incremental_checkpointing = JTernaryBoolean.UNDEFINED
+            elif enable_incremental_checkpointing is True:
+                j_enable_incremental_checkpointing = JTernaryBoolean.TRUE
+            else:
+                j_enable_incremental_checkpointing = JTernaryBoolean.FALSE
+
+            j_rocks_db_state_backend = \
+                JEmbeddedRocksDBStateBackend(j_enable_incremental_checkpointing)
+
+        self._j_rocks_db_state_backend = j_rocks_db_state_backend
+        super(EmbeddedRocksDBStateBackend, self).__init__(j_rocks_db_state_backend)
+
+    def set_db_storage_paths(self, *paths):
+        """
+        Sets the directories in which the local RocksDB database puts its files (like SST and
+        metadata files). These directories do not need to be persistent, they can be ephemeral,
+        meaning that they are lost on a machine failure, because state in RocksDB is persisted
+        in checkpoints.
+
+        If nothing is configured, these directories default to the TaskManager's local
+        temporary file directories.
+
+        Each distinct state will be stored in one path, but when the state backend creates
+        multiple states, they will store their files on different paths.
+
+        Passing ``None`` to this function restores the default behavior, where the configured
+        temp directories will be used.
+
+        :param paths: The paths across which the local RocksDB database files will be spread. this
+                      parameter is optional.
+        """
+        if len(paths) < 1:
+            self._j_rocks_db_state_backend.setDbStoragePath(None)
+        else:
+            gateway = get_gateway()
+            j_path_array = gateway.new_array(gateway.jvm.String, len(paths))
+            for i in range(0, len(paths)):
+                j_path_array[i] = paths[i]
+            self._j_rocks_db_state_backend.setDbStoragePaths(j_path_array)
+
+    def get_db_storage_paths(self):
+        """
+        Gets the configured local DB storage paths, or null, if none were configured.
+
+        Under these directories on the TaskManager, RocksDB stores its SST files and
+        metadata files. These directories do not need to be persistent, they can be ephermeral,
+        meaning that they are lost on a machine failure, because state in RocksDB is persisted
+        in checkpoints.
+
+        If nothing is configured, these directories default to the TaskManager's local
+        temporary file directories.
+
+        :return: The list of configured local DB storage paths.
+        """
+        return list(self._j_rocks_db_state_backend.getDbStoragePaths())
+
+    def is_incremental_checkpoints_enabled(self):
+        """
+        Gets whether incremental checkpoints are enabled for this state backend.
+
+        :return: True if incremental checkpoints are enabled, false otherwise.
+        """
+        return self._j_rocks_db_state_backend.isIncrementalCheckpointsEnabled()
+
+    def set_predefined_options(self, options):
+        """
+        Sets the predefined options for RocksDB.
+
+        If user-configured options within ``RocksDBConfigurableOptions`` is set (through
+        flink-conf.yaml) or a user-defined options factory is set (via :func:`setOptions`),
+        then the options from the factory are applied on top of the here specified
+        predefined options and customized options.
+
+        Example:
+        ::
+
+            >>> state_backend.set_predefined_options(PredefinedOptions.SPINNING_DISK_OPTIMIZED)
+
+        :param options: The options to set (must not be null), see :class:`PredefinedOptions`.
+        """
+        gateway = get_gateway()
+        JPredefinedOptions = gateway.jvm.org.apache.flink.contrib.streaming.state.PredefinedOptions
+        if options == PredefinedOptions.DEFAULT:
+            self._j_rocks_db_state_backend.setPredefinedOptions(JPredefinedOptions.DEFAULT)
+        elif options == PredefinedOptions.SPINNING_DISK_OPTIMIZED:
+            self._j_rocks_db_state_backend.setPredefinedOptions(
+                JPredefinedOptions.SPINNING_DISK_OPTIMIZED)
+        elif options == PredefinedOptions.SPINNING_DISK_OPTIMIZED_HIGH_MEM:
+            self._j_rocks_db_state_backend.setPredefinedOptions(
+                JPredefinedOptions.SPINNING_DISK_OPTIMIZED_HIGH_MEM)
+        elif options == PredefinedOptions.FLASH_SSD_OPTIMIZED:
+            self._j_rocks_db_state_backend.setPredefinedOptions(
+                JPredefinedOptions.FLASH_SSD_OPTIMIZED)
+        else:
+            raise TypeError("Unsupported options: %s, the supported options are: "
+                            "PredefinedOptions.DEFAULT, PredefinedOptions.SPINNING_DISK_OPTIMIZED,"
+                            " PredefinedOptions.SPINNING_DISK_OPTIMIZED_HIGH_MEM and "
+                            "PredefinedOptions.FLASH_SSD_OPTIMIZED")
+
+    def get_predefined_options(self):

Review comment:
       add type hint

##########
File path: flink-python/pyflink/datastream/stream_execution_environment.py
##########
@@ -280,7 +276,38 @@ def set_state_backend(self, state_backend: StateBackend) -> 'StreamExecutionEnvi
             self._j_stream_execution_environment.setStateBackend(state_backend._j_state_backend)
         return self
 
-    def set_restart_strategy(self, restart_strategy_configuration: RestartStrategyConfiguration):
+    def set_default_savepoint_directory(self, savepoint_path):

Review comment:
       add type hints

##########
File path: flink-python/pyflink/datastream/state_backend.py
##########
@@ -116,8 +125,320 @@ def __init__(self, j_state_backend):
         self._j_state_backend = j_state_backend
 
 
+class HashMapStateBackend(StateBackend):
+    """
+    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 :func:`configure` method.
+    """
+
+    def __init__(self,
+                 using_asynchronous_snapshots=None,
+                 j_hashmap_state_backend=None):
+        """
+        Creates a new HashMapStateBackend, enabling optionally asynchronous operations.
+
+        Example:
+        ::
+            >>> state_backend = HashMapStateBackend()
+
+        :param using_asynchronous_snapshots: Flag to switch between synchronous and asynchronous
+                                             snapshot mode. If null, the value configured in the
+                                             runtime configuration will be used.
+        :param j_hashmap_state_backend: For internal use, please keep none.
+        """
+        if j_hashmap_state_backend is None:
+            gateway = get_gateway()
+            JTernaryBoolean = gateway.jvm.org.apache.flink.util.TernaryBoolean
+            JHashMapStateBackend = gateway.jvm.org.apache.flink.runtime.state.hashmap \
+                .HashMapStateBackend
+            if using_asynchronous_snapshots is None:
+                j_asynchronous_snapshots = JTernaryBoolean.UNDEFINED
+            elif using_asynchronous_snapshots is True:
+                j_asynchronous_snapshots = JTernaryBoolean.TRUE
+            elif using_asynchronous_snapshots is False:
+                j_asynchronous_snapshots = JTernaryBoolean.FALSE
+            else:
+                raise TypeError("Unsupported input for 'using_asynchronous_snapshots': %s, "
+                                "the value of the parameter should be None or"
+                                "True or False.")
+            j_hashmap_state_backend = JHashMapStateBackend(j_asynchronous_snapshots)
+
+        self._j_memory_state_backend = j_hashmap_state_backend
+        super(HashMapStateBackend, self).__init__(j_hashmap_state_backend)
+
+    def is_using_asynchronous_snapshots(self):
+        """
+        Gets whether the key/value data structures are asynchronously snapshotted.
+
+        If not explicitly configured, this is the default value of
+        ``org.apache.flink.configuration.CheckpointingOptions.ASYNC_SNAPSHOTS``.
+
+        :return: True if the key/value data structures are asynchronously snapshotted,
+                 false otherwise.
+        """
+        return self._j_memory_state_backend.isUsingAsynchronousSnapshots()
+
+    def __str__(self):
+        return self._j_memory_state_backend.toString()
+
+
+class EmbeddedRocksDBStateBackend(StateBackend):
+    """
+    A State Backend that stores its state in an embedded ``RocksDB``. This state backend can
+    store very large state that exceeds memory and spills to disk.
+
+    All key/value state (including windows) is stored in the key/value index of RocksDB.
+    For persistence against loss of machines, please configure a checkpoint storage
+    instance for the Job.
+
+    The behavior of the RocksDB instances can be parametrized by setting RocksDB Options
+    using the methods :func:`set_predefined_options` and :func:`set_options`.
+    """
+
+    def __init__(self,
+                 enable_incremental_checkpointing=None,
+                 j_rocks_db_state_backend=None):
+        """
+        Creates a new :class:`RocksDBStateBackend` that stores its checkpoint data in the given
+        state backend or the location of given URI.
+
+        If using state backend, typically, one would supply a filesystem or database state backend
+        here where the snapshots from RocksDB would be stored.
+
+        If using URI, a state backend that stores checkpoints in HDFS or S3 must specify the file
+        system host and port in the URI, or have the Hadoop configuration that describes the file
+        system (host / high-availability group / possibly credentials) either referenced from the
+        Flink config, or included in the classpath.
+
+        Example:
+        ::
+
+            >>> state_backend = EmbeddedRocksDBStateBackend()
+
+        :param enable_incremental_checkpointing: True if incremental checkpointing is enabled.
+        :param j_rocks_db_state_backend: For internal use, please keep none.
+        """
+        if j_rocks_db_state_backend is None:
+            gateway = get_gateway()
+            JTernaryBoolean = gateway.jvm.org.apache.flink.util.TernaryBoolean
+            JEmbeddedRocksDBStateBackend = gateway.jvm.org.apache.flink.contrib.streaming.state \
+                .EmbeddedRocksDBStateBackend
+
+            if enable_incremental_checkpointing not in (None, True, False):
+                raise TypeError("Unsupported input for 'enable_incremental_checkpointing': %s, "
+                                "the value of the parameter should be None or"
+                                "True or False.")
+
+            if enable_incremental_checkpointing is None:
+                j_enable_incremental_checkpointing = JTernaryBoolean.UNDEFINED
+            elif enable_incremental_checkpointing is True:
+                j_enable_incremental_checkpointing = JTernaryBoolean.TRUE
+            else:
+                j_enable_incremental_checkpointing = JTernaryBoolean.FALSE
+
+            j_rocks_db_state_backend = \
+                JEmbeddedRocksDBStateBackend(j_enable_incremental_checkpointing)
+
+        self._j_rocks_db_state_backend = j_rocks_db_state_backend
+        super(EmbeddedRocksDBStateBackend, self).__init__(j_rocks_db_state_backend)
+
+    def set_db_storage_paths(self, *paths):
+        """
+        Sets the directories in which the local RocksDB database puts its files (like SST and
+        metadata files). These directories do not need to be persistent, they can be ephemeral,
+        meaning that they are lost on a machine failure, because state in RocksDB is persisted
+        in checkpoints.
+
+        If nothing is configured, these directories default to the TaskManager's local
+        temporary file directories.
+
+        Each distinct state will be stored in one path, but when the state backend creates
+        multiple states, they will store their files on different paths.
+
+        Passing ``None`` to this function restores the default behavior, where the configured
+        temp directories will be used.
+
+        :param paths: The paths across which the local RocksDB database files will be spread. this
+                      parameter is optional.
+        """
+        if len(paths) < 1:
+            self._j_rocks_db_state_backend.setDbStoragePath(None)
+        else:
+            gateway = get_gateway()
+            j_path_array = gateway.new_array(gateway.jvm.String, len(paths))
+            for i in range(0, len(paths)):
+                j_path_array[i] = paths[i]
+            self._j_rocks_db_state_backend.setDbStoragePaths(j_path_array)
+
+    def get_db_storage_paths(self):
+        """
+        Gets the configured local DB storage paths, or null, if none were configured.
+
+        Under these directories on the TaskManager, RocksDB stores its SST files and
+        metadata files. These directories do not need to be persistent, they can be ephermeral,
+        meaning that they are lost on a machine failure, because state in RocksDB is persisted
+        in checkpoints.
+
+        If nothing is configured, these directories default to the TaskManager's local
+        temporary file directories.
+
+        :return: The list of configured local DB storage paths.
+        """
+        return list(self._j_rocks_db_state_backend.getDbStoragePaths())
+
+    def is_incremental_checkpoints_enabled(self):
+        """
+        Gets whether incremental checkpoints are enabled for this state backend.
+
+        :return: True if incremental checkpoints are enabled, false otherwise.
+        """
+        return self._j_rocks_db_state_backend.isIncrementalCheckpointsEnabled()
+
+    def set_predefined_options(self, options):
+        """
+        Sets the predefined options for RocksDB.
+
+        If user-configured options within ``RocksDBConfigurableOptions`` is set (through
+        flink-conf.yaml) or a user-defined options factory is set (via :func:`setOptions`),
+        then the options from the factory are applied on top of the here specified
+        predefined options and customized options.
+
+        Example:
+        ::
+
+            >>> state_backend.set_predefined_options(PredefinedOptions.SPINNING_DISK_OPTIMIZED)
+
+        :param options: The options to set (must not be null), see :class:`PredefinedOptions`.
+        """
+        gateway = get_gateway()
+        JPredefinedOptions = gateway.jvm.org.apache.flink.contrib.streaming.state.PredefinedOptions
+        if options == PredefinedOptions.DEFAULT:
+            self._j_rocks_db_state_backend.setPredefinedOptions(JPredefinedOptions.DEFAULT)
+        elif options == PredefinedOptions.SPINNING_DISK_OPTIMIZED:
+            self._j_rocks_db_state_backend.setPredefinedOptions(
+                JPredefinedOptions.SPINNING_DISK_OPTIMIZED)
+        elif options == PredefinedOptions.SPINNING_DISK_OPTIMIZED_HIGH_MEM:
+            self._j_rocks_db_state_backend.setPredefinedOptions(
+                JPredefinedOptions.SPINNING_DISK_OPTIMIZED_HIGH_MEM)
+        elif options == PredefinedOptions.FLASH_SSD_OPTIMIZED:
+            self._j_rocks_db_state_backend.setPredefinedOptions(
+                JPredefinedOptions.FLASH_SSD_OPTIMIZED)
+        else:
+            raise TypeError("Unsupported options: %s, the supported options are: "
+                            "PredefinedOptions.DEFAULT, PredefinedOptions.SPINNING_DISK_OPTIMIZED,"
+                            " PredefinedOptions.SPINNING_DISK_OPTIMIZED_HIGH_MEM and "
+                            "PredefinedOptions.FLASH_SSD_OPTIMIZED")
+
+    def get_predefined_options(self):
+        """
+        Gets the current predefined options for RocksDB.
+        The default options (if nothing was set via :func:`setPredefinedOptions`)
+        are :data:`PredefinedOptions.DEFAULT`.
+
+        If user-configured options within ``RocksDBConfigurableOptions`` is set (through
+        flink-conf.yaml) or a user-defined options factory is set (via :func:`setOptions`),
+        then the options from the factory are applied on top of the predefined and customized
+        options.
+
+        .. seealso:: :func:`set_predefined_options`
+
+        :return: Current predefined options.
+        """
+        j_predefined_options = self._j_rocks_db_state_backend.getPredefinedOptions()

Review comment:
       could be optimized as following:
   ```       
    j_predefined_options = self._j_rocks_db_state_backend.getPredefinedOptions()
   return PredefinedOptions._from_j_predefined_options(j_predefined_options)
   ```

##########
File path: flink-python/pyflink/datastream/stream_execution_environment.py
##########
@@ -280,7 +276,38 @@ def set_state_backend(self, state_backend: StateBackend) -> 'StreamExecutionEnvi
             self._j_stream_execution_environment.setStateBackend(state_backend._j_state_backend)
         return self
 
-    def set_restart_strategy(self, restart_strategy_configuration: RestartStrategyConfiguration):
+    def set_default_savepoint_directory(self, savepoint_path):
+        """
+        Sets the default savepoint directory, where savepoints will be written to
+        if none is explicitly provided when triggered.
+
+        .. seealso: :func:`get_default_savepoint_dir`
+
+        Example:
+        ::
+
+            >>> env.set_default_savepoint_directory("file://var/savepoints")
+
+        :param savepoint_path: The savepoint directory
+        :return: This object.
+        """
+
+        self._j_stream_execution_environment = \
+            self._j_stream_execution_environment.setDefaultSavepointDirectory(savepoint_path)
+        return self
+
+    def get_default_savepoint_directory(self):

Review comment:
       ditto

##########
File path: flink-python/pyflink/datastream/state_backend.py
##########
@@ -116,8 +125,320 @@ def __init__(self, j_state_backend):
         self._j_state_backend = j_state_backend
 
 
+class HashMapStateBackend(StateBackend):
+    """
+    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 :func:`configure` method.
+    """
+
+    def __init__(self,
+                 using_asynchronous_snapshots=None,
+                 j_hashmap_state_backend=None):
+        """
+        Creates a new HashMapStateBackend, enabling optionally asynchronous operations.
+
+        Example:
+        ::
+            >>> state_backend = HashMapStateBackend()
+
+        :param using_asynchronous_snapshots: Flag to switch between synchronous and asynchronous
+                                             snapshot mode. If null, the value configured in the
+                                             runtime configuration will be used.
+        :param j_hashmap_state_backend: For internal use, please keep none.
+        """
+        if j_hashmap_state_backend is None:
+            gateway = get_gateway()
+            JTernaryBoolean = gateway.jvm.org.apache.flink.util.TernaryBoolean
+            JHashMapStateBackend = gateway.jvm.org.apache.flink.runtime.state.hashmap \
+                .HashMapStateBackend
+            if using_asynchronous_snapshots is None:
+                j_asynchronous_snapshots = JTernaryBoolean.UNDEFINED
+            elif using_asynchronous_snapshots is True:
+                j_asynchronous_snapshots = JTernaryBoolean.TRUE
+            elif using_asynchronous_snapshots is False:
+                j_asynchronous_snapshots = JTernaryBoolean.FALSE
+            else:
+                raise TypeError("Unsupported input for 'using_asynchronous_snapshots': %s, "
+                                "the value of the parameter should be None or"
+                                "True or False.")
+            j_hashmap_state_backend = JHashMapStateBackend(j_asynchronous_snapshots)
+
+        self._j_memory_state_backend = j_hashmap_state_backend
+        super(HashMapStateBackend, self).__init__(j_hashmap_state_backend)
+
+    def is_using_asynchronous_snapshots(self):
+        """
+        Gets whether the key/value data structures are asynchronously snapshotted.
+
+        If not explicitly configured, this is the default value of
+        ``org.apache.flink.configuration.CheckpointingOptions.ASYNC_SNAPSHOTS``.
+
+        :return: True if the key/value data structures are asynchronously snapshotted,
+                 false otherwise.
+        """
+        return self._j_memory_state_backend.isUsingAsynchronousSnapshots()
+
+    def __str__(self):
+        return self._j_memory_state_backend.toString()
+
+
+class EmbeddedRocksDBStateBackend(StateBackend):
+    """
+    A State Backend that stores its state in an embedded ``RocksDB``. This state backend can
+    store very large state that exceeds memory and spills to disk.
+
+    All key/value state (including windows) is stored in the key/value index of RocksDB.
+    For persistence against loss of machines, please configure a checkpoint storage
+    instance for the Job.
+
+    The behavior of the RocksDB instances can be parametrized by setting RocksDB Options
+    using the methods :func:`set_predefined_options` and :func:`set_options`.
+    """
+
+    def __init__(self,
+                 enable_incremental_checkpointing=None,
+                 j_rocks_db_state_backend=None):
+        """
+        Creates a new :class:`RocksDBStateBackend` that stores its checkpoint data in the given
+        state backend or the location of given URI.
+
+        If using state backend, typically, one would supply a filesystem or database state backend
+        here where the snapshots from RocksDB would be stored.
+
+        If using URI, a state backend that stores checkpoints in HDFS or S3 must specify the file
+        system host and port in the URI, or have the Hadoop configuration that describes the file
+        system (host / high-availability group / possibly credentials) either referenced from the
+        Flink config, or included in the classpath.
+
+        Example:
+        ::
+
+            >>> state_backend = EmbeddedRocksDBStateBackend()
+
+        :param enable_incremental_checkpointing: True if incremental checkpointing is enabled.
+        :param j_rocks_db_state_backend: For internal use, please keep none.
+        """
+        if j_rocks_db_state_backend is None:
+            gateway = get_gateway()
+            JTernaryBoolean = gateway.jvm.org.apache.flink.util.TernaryBoolean
+            JEmbeddedRocksDBStateBackend = gateway.jvm.org.apache.flink.contrib.streaming.state \
+                .EmbeddedRocksDBStateBackend
+
+            if enable_incremental_checkpointing not in (None, True, False):
+                raise TypeError("Unsupported input for 'enable_incremental_checkpointing': %s, "
+                                "the value of the parameter should be None or"
+                                "True or False.")
+
+            if enable_incremental_checkpointing is None:
+                j_enable_incremental_checkpointing = JTernaryBoolean.UNDEFINED
+            elif enable_incremental_checkpointing is True:
+                j_enable_incremental_checkpointing = JTernaryBoolean.TRUE
+            else:
+                j_enable_incremental_checkpointing = JTernaryBoolean.FALSE
+
+            j_rocks_db_state_backend = \
+                JEmbeddedRocksDBStateBackend(j_enable_incremental_checkpointing)
+
+        self._j_rocks_db_state_backend = j_rocks_db_state_backend
+        super(EmbeddedRocksDBStateBackend, self).__init__(j_rocks_db_state_backend)
+
+    def set_db_storage_paths(self, *paths):
+        """
+        Sets the directories in which the local RocksDB database puts its files (like SST and
+        metadata files). These directories do not need to be persistent, they can be ephemeral,
+        meaning that they are lost on a machine failure, because state in RocksDB is persisted
+        in checkpoints.
+
+        If nothing is configured, these directories default to the TaskManager's local
+        temporary file directories.
+
+        Each distinct state will be stored in one path, but when the state backend creates
+        multiple states, they will store their files on different paths.
+
+        Passing ``None`` to this function restores the default behavior, where the configured
+        temp directories will be used.
+
+        :param paths: The paths across which the local RocksDB database files will be spread. this
+                      parameter is optional.
+        """
+        if len(paths) < 1:
+            self._j_rocks_db_state_backend.setDbStoragePath(None)
+        else:
+            gateway = get_gateway()
+            j_path_array = gateway.new_array(gateway.jvm.String, len(paths))
+            for i in range(0, len(paths)):
+                j_path_array[i] = paths[i]
+            self._j_rocks_db_state_backend.setDbStoragePaths(j_path_array)
+
+    def get_db_storage_paths(self):
+        """
+        Gets the configured local DB storage paths, or null, if none were configured.
+
+        Under these directories on the TaskManager, RocksDB stores its SST files and
+        metadata files. These directories do not need to be persistent, they can be ephermeral,
+        meaning that they are lost on a machine failure, because state in RocksDB is persisted
+        in checkpoints.
+
+        If nothing is configured, these directories default to the TaskManager's local
+        temporary file directories.
+
+        :return: The list of configured local DB storage paths.
+        """
+        return list(self._j_rocks_db_state_backend.getDbStoragePaths())
+
+    def is_incremental_checkpoints_enabled(self):
+        """
+        Gets whether incremental checkpoints are enabled for this state backend.
+
+        :return: True if incremental checkpoints are enabled, false otherwise.
+        """
+        return self._j_rocks_db_state_backend.isIncrementalCheckpointsEnabled()
+
+    def set_predefined_options(self, options):
+        """
+        Sets the predefined options for RocksDB.
+
+        If user-configured options within ``RocksDBConfigurableOptions`` is set (through
+        flink-conf.yaml) or a user-defined options factory is set (via :func:`setOptions`),
+        then the options from the factory are applied on top of the here specified
+        predefined options and customized options.
+
+        Example:
+        ::
+
+            >>> state_backend.set_predefined_options(PredefinedOptions.SPINNING_DISK_OPTIMIZED)
+
+        :param options: The options to set (must not be null), see :class:`PredefinedOptions`.
+        """
+        gateway = get_gateway()
+        JPredefinedOptions = gateway.jvm.org.apache.flink.contrib.streaming.state.PredefinedOptions
+        if options == PredefinedOptions.DEFAULT:
+            self._j_rocks_db_state_backend.setPredefinedOptions(JPredefinedOptions.DEFAULT)
+        elif options == PredefinedOptions.SPINNING_DISK_OPTIMIZED:
+            self._j_rocks_db_state_backend.setPredefinedOptions(
+                JPredefinedOptions.SPINNING_DISK_OPTIMIZED)
+        elif options == PredefinedOptions.SPINNING_DISK_OPTIMIZED_HIGH_MEM:
+            self._j_rocks_db_state_backend.setPredefinedOptions(
+                JPredefinedOptions.SPINNING_DISK_OPTIMIZED_HIGH_MEM)
+        elif options == PredefinedOptions.FLASH_SSD_OPTIMIZED:
+            self._j_rocks_db_state_backend.setPredefinedOptions(
+                JPredefinedOptions.FLASH_SSD_OPTIMIZED)
+        else:
+            raise TypeError("Unsupported options: %s, the supported options are: "
+                            "PredefinedOptions.DEFAULT, PredefinedOptions.SPINNING_DISK_OPTIMIZED,"
+                            " PredefinedOptions.SPINNING_DISK_OPTIMIZED_HIGH_MEM and "
+                            "PredefinedOptions.FLASH_SSD_OPTIMIZED")
+
+    def get_predefined_options(self):
+        """
+        Gets the current predefined options for RocksDB.
+        The default options (if nothing was set via :func:`setPredefinedOptions`)
+        are :data:`PredefinedOptions.DEFAULT`.
+
+        If user-configured options within ``RocksDBConfigurableOptions`` is set (through
+        flink-conf.yaml) or a user-defined options factory is set (via :func:`setOptions`),
+        then the options from the factory are applied on top of the predefined and customized
+        options.
+
+        .. seealso:: :func:`set_predefined_options`
+
+        :return: Current predefined options.
+        """
+        j_predefined_options = self._j_rocks_db_state_backend.getPredefinedOptions()
+        gateway = get_gateway()
+        JPredefinedOptions = gateway.jvm.org.apache.flink.contrib.streaming.state.PredefinedOptions
+        if j_predefined_options == JPredefinedOptions.DEFAULT:
+            return PredefinedOptions.DEFAULT
+        elif j_predefined_options == JPredefinedOptions.FLASH_SSD_OPTIMIZED:
+            return PredefinedOptions.FLASH_SSD_OPTIMIZED
+        elif j_predefined_options == JPredefinedOptions.SPINNING_DISK_OPTIMIZED:
+            return PredefinedOptions.SPINNING_DISK_OPTIMIZED
+        elif j_predefined_options == JPredefinedOptions.SPINNING_DISK_OPTIMIZED_HIGH_MEM:
+            return PredefinedOptions.SPINNING_DISK_OPTIMIZED_HIGH_MEM
+        else:
+            raise Exception("Unsupported java options: %s" % j_predefined_options)
+
+    def set_options(self, options_factory_class_name):
+        """
+        Sets ``org.rocksdb.Options`` for the RocksDB instances.
+        Because the options are not serializable and hold native code references,
+        they must be specified through a factory.
+
+        The options created by the factory here are applied on top of the pre-defined
+        options profile selected via :func:`set_predefined_options`.
+        If the pre-defined options profile is the default (:data:`PredefinedOptions.DEFAULT`),
+        then the factory fully controls the RocksDB options.
+
+        :param options_factory_class_name: The fully-qualified class name of the options
+                                           factory in Java that lazily creates the RocksDB options.
+                                           The options factory must have a default constructor.
+        """
+        gateway = get_gateway()
+        JOptionsFactory = gateway.jvm.org.apache.flink.contrib.streaming.state.RocksDBOptionsFactory
+        j_options_factory_clz = load_java_class(options_factory_class_name)
+        if not get_java_class(JOptionsFactory).isAssignableFrom(j_options_factory_clz):
+            raise ValueError("The input class does not implement RocksDBOptionsFactory.")
+        self._j_rocks_db_state_backend.setRocksDBOptions(j_options_factory_clz.newInstance())
+
+    def get_options(self):

Review comment:
       add typehint

##########
File path: flink-python/pyflink/datastream/state_backend.py
##########
@@ -116,8 +125,320 @@ def __init__(self, j_state_backend):
         self._j_state_backend = j_state_backend
 
 
+class HashMapStateBackend(StateBackend):
+    """
+    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 :func:`configure` method.
+    """
+
+    def __init__(self,
+                 using_asynchronous_snapshots=None,
+                 j_hashmap_state_backend=None):
+        """
+        Creates a new HashMapStateBackend, enabling optionally asynchronous operations.
+
+        Example:
+        ::
+            >>> state_backend = HashMapStateBackend()
+
+        :param using_asynchronous_snapshots: Flag to switch between synchronous and asynchronous
+                                             snapshot mode. If null, the value configured in the
+                                             runtime configuration will be used.
+        :param j_hashmap_state_backend: For internal use, please keep none.
+        """
+        if j_hashmap_state_backend is None:
+            gateway = get_gateway()
+            JTernaryBoolean = gateway.jvm.org.apache.flink.util.TernaryBoolean
+            JHashMapStateBackend = gateway.jvm.org.apache.flink.runtime.state.hashmap \
+                .HashMapStateBackend
+            if using_asynchronous_snapshots is None:
+                j_asynchronous_snapshots = JTernaryBoolean.UNDEFINED
+            elif using_asynchronous_snapshots is True:
+                j_asynchronous_snapshots = JTernaryBoolean.TRUE
+            elif using_asynchronous_snapshots is False:
+                j_asynchronous_snapshots = JTernaryBoolean.FALSE
+            else:
+                raise TypeError("Unsupported input for 'using_asynchronous_snapshots': %s, "
+                                "the value of the parameter should be None or"
+                                "True or False.")
+            j_hashmap_state_backend = JHashMapStateBackend(j_asynchronous_snapshots)
+
+        self._j_memory_state_backend = j_hashmap_state_backend
+        super(HashMapStateBackend, self).__init__(j_hashmap_state_backend)
+
+    def is_using_asynchronous_snapshots(self):
+        """
+        Gets whether the key/value data structures are asynchronously snapshotted.
+
+        If not explicitly configured, this is the default value of
+        ``org.apache.flink.configuration.CheckpointingOptions.ASYNC_SNAPSHOTS``.
+
+        :return: True if the key/value data structures are asynchronously snapshotted,
+                 false otherwise.
+        """
+        return self._j_memory_state_backend.isUsingAsynchronousSnapshots()
+
+    def __str__(self):
+        return self._j_memory_state_backend.toString()
+
+
+class EmbeddedRocksDBStateBackend(StateBackend):
+    """
+    A State Backend that stores its state in an embedded ``RocksDB``. This state backend can
+    store very large state that exceeds memory and spills to disk.
+
+    All key/value state (including windows) is stored in the key/value index of RocksDB.
+    For persistence against loss of machines, please configure a checkpoint storage
+    instance for the Job.
+
+    The behavior of the RocksDB instances can be parametrized by setting RocksDB Options
+    using the methods :func:`set_predefined_options` and :func:`set_options`.
+    """
+
+    def __init__(self,
+                 enable_incremental_checkpointing=None,
+                 j_rocks_db_state_backend=None):
+        """
+        Creates a new :class:`RocksDBStateBackend` that stores its checkpoint data in the given
+        state backend or the location of given URI.
+
+        If using state backend, typically, one would supply a filesystem or database state backend
+        here where the snapshots from RocksDB would be stored.
+
+        If using URI, a state backend that stores checkpoints in HDFS or S3 must specify the file
+        system host and port in the URI, or have the Hadoop configuration that describes the file
+        system (host / high-availability group / possibly credentials) either referenced from the
+        Flink config, or included in the classpath.
+
+        Example:
+        ::
+
+            >>> state_backend = EmbeddedRocksDBStateBackend()
+
+        :param enable_incremental_checkpointing: True if incremental checkpointing is enabled.
+        :param j_rocks_db_state_backend: For internal use, please keep none.
+        """
+        if j_rocks_db_state_backend is None:
+            gateway = get_gateway()
+            JTernaryBoolean = gateway.jvm.org.apache.flink.util.TernaryBoolean
+            JEmbeddedRocksDBStateBackend = gateway.jvm.org.apache.flink.contrib.streaming.state \
+                .EmbeddedRocksDBStateBackend
+
+            if enable_incremental_checkpointing not in (None, True, False):
+                raise TypeError("Unsupported input for 'enable_incremental_checkpointing': %s, "
+                                "the value of the parameter should be None or"
+                                "True or False.")
+
+            if enable_incremental_checkpointing is None:
+                j_enable_incremental_checkpointing = JTernaryBoolean.UNDEFINED
+            elif enable_incremental_checkpointing is True:
+                j_enable_incremental_checkpointing = JTernaryBoolean.TRUE
+            else:
+                j_enable_incremental_checkpointing = JTernaryBoolean.FALSE
+
+            j_rocks_db_state_backend = \
+                JEmbeddedRocksDBStateBackend(j_enable_incremental_checkpointing)
+
+        self._j_rocks_db_state_backend = j_rocks_db_state_backend
+        super(EmbeddedRocksDBStateBackend, self).__init__(j_rocks_db_state_backend)
+
+    def set_db_storage_paths(self, *paths):
+        """
+        Sets the directories in which the local RocksDB database puts its files (like SST and
+        metadata files). These directories do not need to be persistent, they can be ephemeral,
+        meaning that they are lost on a machine failure, because state in RocksDB is persisted
+        in checkpoints.
+
+        If nothing is configured, these directories default to the TaskManager's local
+        temporary file directories.
+
+        Each distinct state will be stored in one path, but when the state backend creates
+        multiple states, they will store their files on different paths.
+
+        Passing ``None`` to this function restores the default behavior, where the configured
+        temp directories will be used.
+
+        :param paths: The paths across which the local RocksDB database files will be spread. this
+                      parameter is optional.
+        """
+        if len(paths) < 1:
+            self._j_rocks_db_state_backend.setDbStoragePath(None)
+        else:
+            gateway = get_gateway()
+            j_path_array = gateway.new_array(gateway.jvm.String, len(paths))
+            for i in range(0, len(paths)):
+                j_path_array[i] = paths[i]
+            self._j_rocks_db_state_backend.setDbStoragePaths(j_path_array)
+
+    def get_db_storage_paths(self):
+        """
+        Gets the configured local DB storage paths, or null, if none were configured.
+
+        Under these directories on the TaskManager, RocksDB stores its SST files and
+        metadata files. These directories do not need to be persistent, they can be ephermeral,
+        meaning that they are lost on a machine failure, because state in RocksDB is persisted
+        in checkpoints.
+
+        If nothing is configured, these directories default to the TaskManager's local
+        temporary file directories.
+
+        :return: The list of configured local DB storage paths.
+        """
+        return list(self._j_rocks_db_state_backend.getDbStoragePaths())
+
+    def is_incremental_checkpoints_enabled(self):
+        """
+        Gets whether incremental checkpoints are enabled for this state backend.
+
+        :return: True if incremental checkpoints are enabled, false otherwise.
+        """
+        return self._j_rocks_db_state_backend.isIncrementalCheckpointsEnabled()
+
+    def set_predefined_options(self, options):
+        """
+        Sets the predefined options for RocksDB.
+
+        If user-configured options within ``RocksDBConfigurableOptions`` is set (through
+        flink-conf.yaml) or a user-defined options factory is set (via :func:`setOptions`),
+        then the options from the factory are applied on top of the here specified
+        predefined options and customized options.
+
+        Example:
+        ::
+
+            >>> state_backend.set_predefined_options(PredefinedOptions.SPINNING_DISK_OPTIMIZED)
+
+        :param options: The options to set (must not be null), see :class:`PredefinedOptions`.
+        """
+        gateway = get_gateway()
+        JPredefinedOptions = gateway.jvm.org.apache.flink.contrib.streaming.state.PredefinedOptions
+        if options == PredefinedOptions.DEFAULT:
+            self._j_rocks_db_state_backend.setPredefinedOptions(JPredefinedOptions.DEFAULT)
+        elif options == PredefinedOptions.SPINNING_DISK_OPTIMIZED:
+            self._j_rocks_db_state_backend.setPredefinedOptions(
+                JPredefinedOptions.SPINNING_DISK_OPTIMIZED)
+        elif options == PredefinedOptions.SPINNING_DISK_OPTIMIZED_HIGH_MEM:
+            self._j_rocks_db_state_backend.setPredefinedOptions(
+                JPredefinedOptions.SPINNING_DISK_OPTIMIZED_HIGH_MEM)
+        elif options == PredefinedOptions.FLASH_SSD_OPTIMIZED:
+            self._j_rocks_db_state_backend.setPredefinedOptions(
+                JPredefinedOptions.FLASH_SSD_OPTIMIZED)
+        else:
+            raise TypeError("Unsupported options: %s, the supported options are: "
+                            "PredefinedOptions.DEFAULT, PredefinedOptions.SPINNING_DISK_OPTIMIZED,"
+                            " PredefinedOptions.SPINNING_DISK_OPTIMIZED_HIGH_MEM and "
+                            "PredefinedOptions.FLASH_SSD_OPTIMIZED")
+
+    def get_predefined_options(self):
+        """
+        Gets the current predefined options for RocksDB.
+        The default options (if nothing was set via :func:`setPredefinedOptions`)
+        are :data:`PredefinedOptions.DEFAULT`.
+
+        If user-configured options within ``RocksDBConfigurableOptions`` is set (through
+        flink-conf.yaml) or a user-defined options factory is set (via :func:`setOptions`),
+        then the options from the factory are applied on top of the predefined and customized
+        options.
+
+        .. seealso:: :func:`set_predefined_options`
+
+        :return: Current predefined options.
+        """
+        j_predefined_options = self._j_rocks_db_state_backend.getPredefinedOptions()
+        gateway = get_gateway()
+        JPredefinedOptions = gateway.jvm.org.apache.flink.contrib.streaming.state.PredefinedOptions
+        if j_predefined_options == JPredefinedOptions.DEFAULT:
+            return PredefinedOptions.DEFAULT
+        elif j_predefined_options == JPredefinedOptions.FLASH_SSD_OPTIMIZED:
+            return PredefinedOptions.FLASH_SSD_OPTIMIZED
+        elif j_predefined_options == JPredefinedOptions.SPINNING_DISK_OPTIMIZED:
+            return PredefinedOptions.SPINNING_DISK_OPTIMIZED
+        elif j_predefined_options == JPredefinedOptions.SPINNING_DISK_OPTIMIZED_HIGH_MEM:
+            return PredefinedOptions.SPINNING_DISK_OPTIMIZED_HIGH_MEM
+        else:
+            raise Exception("Unsupported java options: %s" % j_predefined_options)
+
+    def set_options(self, options_factory_class_name):
+        """
+        Sets ``org.rocksdb.Options`` for the RocksDB instances.
+        Because the options are not serializable and hold native code references,
+        they must be specified through a factory.
+
+        The options created by the factory here are applied on top of the pre-defined
+        options profile selected via :func:`set_predefined_options`.
+        If the pre-defined options profile is the default (:data:`PredefinedOptions.DEFAULT`),
+        then the factory fully controls the RocksDB options.
+
+        :param options_factory_class_name: The fully-qualified class name of the options
+                                           factory in Java that lazily creates the RocksDB options.
+                                           The options factory must have a default constructor.
+        """
+        gateway = get_gateway()
+        JOptionsFactory = gateway.jvm.org.apache.flink.contrib.streaming.state.RocksDBOptionsFactory
+        j_options_factory_clz = load_java_class(options_factory_class_name)
+        if not get_java_class(JOptionsFactory).isAssignableFrom(j_options_factory_clz):
+            raise ValueError("The input class does not implement RocksDBOptionsFactory.")
+        self._j_rocks_db_state_backend.setRocksDBOptions(j_options_factory_clz.newInstance())
+
+    def get_options(self):
+        """
+        Gets the fully-qualified class name of the options factory in Java that lazily creates
+        the RocksDB options.
+
+        :return: The fully-qualified class name of the options factory in Java.
+        """
+        j_options_factory = self._j_rocks_db_state_backend.getRocksDBOptions()
+        if j_options_factory is not None:
+            return j_options_factory.getClass().getName()
+        else:
+            return None
+
+    def get_number_of_transfering_threads(self):
+        """
+        Gets the number of threads used to transfer files while snapshotting/restoring.
+
+        :return: The number of threads used to transfer files while snapshotting/restoring.
+        """
+        return self._j_rocks_db_state_backend.getNumberOfTransferingThreads()
+
+    def set_number_of_transfering_threads(self, number_of_transfering_threads):

Review comment:
       ditto




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org