public class ZooKeeperCheckpointIDCounter extends Object implements CheckpointIDCounter
CheckpointIDCounter
instances for JobManagers running in HighAvailabilityMode.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,
LastStateConnectionStateListener connectionStateListener)
Creates a
ZooKeeperCheckpointIDCounter instance. |
Modifier and Type | Method and Description |
---|---|
long |
get()
Atomically gets the current checkpoint ID.
|
long |
getAndIncrement()
Atomically increments the current checkpoint ID.
|
void |
setCount(long newId)
Sets the current checkpoint ID.
|
void |
shutdown(JobStatus jobStatus)
Shuts the
CheckpointIDCounter service. |
void |
start()
Starts the
CheckpointIDCounter service down. |
public ZooKeeperCheckpointIDCounter(org.apache.curator.framework.CuratorFramework client, String counterPath, LastStateConnectionStateListener connectionStateListener)
ZooKeeperCheckpointIDCounter
instance.client
- Curator ZooKeeper clientcounterPath
- ZooKeeper path for the counter. It's sufficient to have a path per-job.public void start() throws Exception
CheckpointIDCounter
CheckpointIDCounter
service down.start
in interface CheckpointIDCounter
Exception
public void shutdown(JobStatus jobStatus) throws Exception
CheckpointIDCounter
CheckpointIDCounter
service.
The job status is forwarded and used to decide whether state should actually be discarded or kept.
shutdown
in interface CheckpointIDCounter
jobStatus
- Job state on shut downException
public long getAndIncrement() throws Exception
CheckpointIDCounter
getAndIncrement
in interface CheckpointIDCounter
Exception
public long get()
CheckpointIDCounter
get
in interface CheckpointIDCounter
public void setCount(long newId) throws Exception
CheckpointIDCounter
setCount
in interface CheckpointIDCounter
newId
- The new IDException
Copyright © 2014–2020 The Apache Software Foundation. All rights reserved.