public class SynchronizedUniqueIDGeneratorFactory extends Object
IDGenerator capable of generating unique identifiers in a distributed environment with multiple
services generating them. To do this, the GeneratorIdentityHolder it uses acquires a temporary claim on a
generator ID negotiated via a ZooKeeper quorum.
Because claimed generator IDs are automatically returned to the pool after a set time
(ExpiringResourceClaim.DEFAULT_CLAIM_HOLD), there is no guarantee that IDs generated by the same
IDGenerator instance share the same generator ID.
| Constructor and Description |
|---|
SynchronizedUniqueIDGeneratorFactory() |
| Modifier and Type | Method and Description |
|---|---|
static IDGenerator |
generatorFor(org.lable.oss.dynamicconfig.zookeeper.MonitoringZookeeperConnection zooKeeperConnection,
String znode,
Clock clock,
Mode mode)
Get the synchronized ID generator instance.
|
static IDGenerator |
generatorFor(org.lable.oss.dynamicconfig.zookeeper.MonitoringZookeeperConnection zooKeeperConnection,
String znode,
Mode mode)
Get the synchronized ID generator instance.
|
static IDGenerator |
generatorFor(SynchronizedGeneratorIdentity synchronizedGeneratorIdentity,
Clock clock,
Mode mode)
Get the synchronized ID generator instance.
|
public SynchronizedUniqueIDGeneratorFactory()
public static IDGenerator generatorFor(org.lable.oss.dynamicconfig.zookeeper.MonitoringZookeeperConnection zooKeeperConnection, String znode, Clock clock, Mode mode) throws IOException
zooKeeperConnection - Connection to the ZooKeeper quorum.znode - Base-path of the resource pool in ZooKeeper.clock - Clock implementation.mode - Generator mode.IOException - Thrown when something went wrong trying to find the cluster ID or trying to claim a
generator ID.public static IDGenerator generatorFor(org.lable.oss.dynamicconfig.zookeeper.MonitoringZookeeperConnection zooKeeperConnection, String znode, Mode mode) throws IOException
zooKeeperConnection - Connection to the ZooKeeper quorum.znode - Base-path of the resource pool in ZooKeeper.mode - Generator mode.IOException - Thrown when something went wrong trying to find the cluster ID or trying to claim a
generator ID.public static IDGenerator generatorFor(SynchronizedGeneratorIdentity synchronizedGeneratorIdentity, Clock clock, Mode mode) throws IOException
synchronizedGeneratorIdentity - An instance of SynchronizedGeneratorIdentity to (re)use for
acquiring the generator ID.clock - Clock implementation.mode - Generator mode.IOException - Thrown when something went wrong trying to find the cluster ID or trying to claim a
generator ID.Copyright © 2014–2020 Lable. All rights reserved.