Class ZooKeeperStateHandleStore<T extends Serializable>

java.lang.Object
org.apache.flink.runtime.zookeeper.ZooKeeperStateHandleStore<T>
Type Parameters:
T - Type of state
All Implemented Interfaces:
StateHandleStore<T,IntegerResourceVersion>

public class ZooKeeperStateHandleStore<T extends Serializable> extends Object implements StateHandleStore<T,IntegerResourceVersion>
Class which stores state via the provided RetrievableStateStorageHelper and writes the returned state handle to ZooKeeper. The ZooKeeper node can be locked by creating an ephemeral child in the lock sub-path. The implementation only allows the deletion of the ZooKeeper node if the lock sub-path has no children. That way we protect concurrent accesses from different ZooKeeperStateHandleStore instances.

Added state is persisted via RetrievableStateHandles, which in turn are written to ZooKeeper. This level of indirection is necessary to keep the amount of data in ZooKeeper small. ZooKeeper is build for data in the KB range whereas state can grow to multiple MBs.

State modifications require some care, because it is possible that certain failures bring the state handle backend and ZooKeeper out of sync.

ZooKeeper holds the ground truth about state handles, i.e. the following holds:

 State handle in ZooKeeper and not marked for deletion => State handle exists
 
 State handle in ZooKeeper and marked for deletion => State handle might or might not be deleted, yet
 
 State handle not in ZooKeeper => State handle does not exist
 

There can be lingering state handles when failures happen during operation. They need to be cleaned up manually (see FLINK-2513 about a possible way to overcome this).

  • Constructor Details

    • ZooKeeperStateHandleStore

      public ZooKeeperStateHandleStore(org.apache.flink.shaded.curator5.org.apache.curator.framework.CuratorFramework client, RetrievableStateStorageHelper<T> storage)
      Parameters:
      client - The Curator ZooKeeper client. Important: It is expected that the client's namespace ensures that the root path is exclusive for all state handles managed by this instance, e.g. client.usingNamespace("/stateHandles")
      storage - to persist the actual state and whose returned state handle is then written to ZooKeeper
  • Method Details