public class SynchronizedGeneratorIdentity extends Object implements GeneratorIdentityHolder
| Constructor and Description |
|---|
SynchronizedGeneratorIdentity(io.etcd.jetcd.Client client,
List<Integer> clusterIds,
Supplier<Duration> claimDurationSupplier,
Supplier<Duration> acquisitionTimeoutSupplier) |
| Modifier and Type | Method and Description |
|---|---|
static SynchronizedGeneratorIdentity |
basedOn(String endpoints,
String namespace,
Long claimDuration)
Create a new
SynchronizedGeneratorIdentity instance. |
static SynchronizedGeneratorIdentity |
basedOn(String endpoints,
String namespace,
Supplier<Duration> claimDurationSupplier,
Supplier<Duration> acquisitionTimeoutSupplier)
Create a new
SynchronizedGeneratorIdentity instance. |
void |
close() |
int |
getClusterId() |
int |
getGeneratorId() |
void |
relinquishResourceClaim() |
public static SynchronizedGeneratorIdentity basedOn(String endpoints, String namespace, Supplier<Duration> claimDurationSupplier, Supplier<Duration> acquisitionTimeoutSupplier) throws IOException
SynchronizedGeneratorIdentity instance.
By using a Supplier instead of static longs for the claim duration and the acquisition timeout, these
values can be dynamically reconfigured at runtime.
endpoints - Addresses of the Etcd cluster (comma-separated).namespace - Namespace of the unique-id keys in Etcd.claimDurationSupplier - Provides the amount of time a claim to a generator-ID should be held.acquisitionTimeoutSupplier - Provides the amount of time the process of acquiring a generator-ID may take.
May be null to indicate that the process may wait indefinitely.SynchronizedGeneratorIdentity instance.IOExceptionpublic static SynchronizedGeneratorIdentity basedOn(String endpoints, String namespace, Long claimDuration) throws IOException
SynchronizedGeneratorIdentity instance.endpoints - Addresses of the Etcd cluster (comma-separated).namespace - Namespace of the unique-id keys in Etcd.claimDuration - How long a claim to a generator-ID should be held, in milliseconds.SynchronizedGeneratorIdentity instance.IOExceptionpublic int getClusterId()
throws GeneratorException
getClusterId in interface GeneratorIdentityHolderGeneratorExceptionpublic int getGeneratorId()
throws GeneratorException
getGeneratorId in interface GeneratorIdentityHolderGeneratorExceptionpublic void relinquishResourceClaim()
public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionCopyright © 2014–2021 Lable. All rights reserved.