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 an Etcd cluster.
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(io.etcd.jetcd.Client etcd,
Clock clock,
Mode mode)
Get the synchronized ID generator instance.
|
static IDGenerator |
generatorFor(io.etcd.jetcd.Client etcd,
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(io.etcd.jetcd.Client etcd, Clock clock, Mode mode) throws IOException
etcd - Connection to the Etcd cluster.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(io.etcd.jetcd.Client etcd, Mode mode) throws IOException
etcd - Connection to the Etcd cluster.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)
synchronizedGeneratorIdentity - An instance of SynchronizedGeneratorIdentity to (re)use for
acquiring the generator ID.clock - Clock implementation.mode - Generator mode.Copyright © 2014–2021 Lable. All rights reserved.