public class ZooKeeperCheckpointIDCounter extends Object implements CheckpointIDCounter
CheckpointIDCounter instances for JobManagers running in RecoveryMode.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.
| Constructor and Description |
|---|
ZooKeeperCheckpointIDCounter(org.apache.curator.framework.CuratorFramework client,
String counterPath)
Creates a
ZooKeeperCheckpointIDCounter instance. |
| Modifier and Type | Method and Description |
|---|---|
long |
getAndIncrement()
Atomically increments the current checkpoint ID.
|
void |
setCount(long newId)
Sets the current checkpoint ID.
|
void |
shutdown()
Shuts the
CheckpointIDCounter service down and frees all created
resources. |
void |
start()
Starts the
CheckpointIDCounter service. |
void |
suspend()
Suspends the counter.
|
public ZooKeeperCheckpointIDCounter(org.apache.curator.framework.CuratorFramework client,
String counterPath)
throws Exception
ZooKeeperCheckpointIDCounter instance.client - Curator ZooKeeper clientcounterPath - ZooKeeper path for the counter. It's sufficient to have a path per-job.Exceptionpublic void start()
throws Exception
CheckpointIDCounterCheckpointIDCounter service.start in interface CheckpointIDCounterExceptionpublic void shutdown()
throws Exception
CheckpointIDCounterCheckpointIDCounter service down and frees all created
resources.shutdown in interface CheckpointIDCounterExceptionpublic void suspend()
throws Exception
CheckpointIDCounterIf the implementation allows recovery, the counter state needs to be kept. Otherwise, this acts as shutdown.
suspend in interface CheckpointIDCounterExceptionpublic long getAndIncrement()
throws Exception
CheckpointIDCountergetAndIncrement in interface CheckpointIDCounterExceptionpublic void setCount(long newId)
throws Exception
CheckpointIDCountersetCount in interface CheckpointIDCounternewId - The new IDExceptionCopyright © 2014–2016 The Apache Software Foundation. All rights reserved.