Class ZooKeeperCheckpointIDCounter
- java.lang.Object
-
- org.apache.flink.runtime.checkpoint.ZooKeeperCheckpointIDCounter
-
- All Implemented Interfaces:
CheckpointIDCounter
public class ZooKeeperCheckpointIDCounter extends Object implements CheckpointIDCounter
CheckpointIDCounterinstances for JobManagers running inHighAvailabilityMode.ZOOKEEPER.Each counter creates a ZNode:
+----O /flink/checkpoint-counter/<job-id> 1 [persistent] . . . +----O /flink/checkpoint-counter/<job-id> N [persistent]
The checkpoints IDs are required to be ascending (per job). In order to guarantee this in case of job manager failures we use ZooKeeper to have a shared counter across job manager instances.
-
-
Field Summary
-
Fields inherited from interface org.apache.flink.runtime.checkpoint.CheckpointIDCounter
INITIAL_CHECKPOINT_ID
-
-
Constructor Summary
Constructors Constructor Description ZooKeeperCheckpointIDCounter(org.apache.flink.shaded.curator5.org.apache.curator.framework.CuratorFramework client, LastStateConnectionStateListener connectionStateListener)Creates aZooKeeperCheckpointIDCounterinstance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longget()Atomically gets the current checkpoint ID.longgetAndIncrement()Atomically increments the current checkpoint ID.voidsetCount(long newId)Sets the current checkpoint ID.CompletableFuture<Void>shutdown(org.apache.flink.api.common.JobStatus jobStatus)Shuts theCheckpointIDCounterservice.voidstart()Starts theCheckpointIDCounterservice down.
-
-
-
Constructor Detail
-
ZooKeeperCheckpointIDCounter
public ZooKeeperCheckpointIDCounter(org.apache.flink.shaded.curator5.org.apache.curator.framework.CuratorFramework client, LastStateConnectionStateListener connectionStateListener)Creates aZooKeeperCheckpointIDCounterinstance.- Parameters:
client- Curator ZooKeeper client
-
-
Method Detail
-
start
public void start() throws ExceptionDescription copied from interface:CheckpointIDCounterStarts theCheckpointIDCounterservice down.- Specified by:
startin interfaceCheckpointIDCounter- Throws:
Exception
-
shutdown
public CompletableFuture<Void> shutdown(org.apache.flink.api.common.JobStatus jobStatus)
Description copied from interface:CheckpointIDCounterShuts theCheckpointIDCounterservice.The job status is forwarded and used to decide whether state should actually be discarded or kept.
- Specified by:
shutdownin interfaceCheckpointIDCounter- Parameters:
jobStatus- Job state on shut down- Returns:
- The
CompletableFutureholding the result of the shutdown operation.
-
getAndIncrement
public long getAndIncrement() throws ExceptionDescription copied from interface:CheckpointIDCounterAtomically increments the current checkpoint ID.- Specified by:
getAndIncrementin interfaceCheckpointIDCounter- Returns:
- The previous checkpoint ID
- Throws:
Exception
-
get
public long get()
Description copied from interface:CheckpointIDCounterAtomically gets the current checkpoint ID.- Specified by:
getin interfaceCheckpointIDCounter- Returns:
- The current checkpoint ID
-
setCount
public void setCount(long newId) throws ExceptionDescription copied from interface:CheckpointIDCounterSets the current checkpoint ID.- Specified by:
setCountin interfaceCheckpointIDCounter- Parameters:
newId- The new ID- Throws:
Exception
-
-