public interface ReliableIdGenerator extends DistributedObject
long primitive values
and are k-ordered (roughly ordered). IDs are in the range from Long.MIN_VALUE to
Long.MAX_VALUE. This type of generator is generally known as Flake ID generator.
The IDs contain timestamp component and a node ID component, which is assigned when the member
joins the cluster. This allows the IDs to be ordered and unique without any coordination between
members, which makes the generator safe even in split-brain scenario (for caveats,
see here).
Timestamp component is in milliseconds since 1.1.2017, 0:00 UTC, and has 42 bits. This caps the useful lifespan of the generator to little less than 140 years. The sequence component is 6 bits. If more than 64 IDs are requested in single millisecond, IDs will gracefully overflow to next millisecond and uniqueness is guaranteed in this case.
newId() method goes to a random
member and gets a batch of IDs, which will then be returned locally for limited time. The pre-fetch
size and the validity time can be configured for each client and member, see here for member config and ClientConfig.addReliableIdGeneratorConfig() for client config.
| Modifier and Type | Method and Description |
|---|---|
long |
newId()
Generates and returns a cluster-wide unique ID.
|
destroy, getName, getPartitionKey, getServiceNamelong newId()
The call is typically local on member. A batch of IDs is pre-fetched and then used for preconfigured time locally.
Note: Values returned from this method may be not strictly ordered.
NodeIdOutOfRangeException - if node ID for all members in the cluster is out of valid range.
See "Node ID overflow" in class documentation for more details.UnsupportedOperationException - if the cluster version is below 3.10Copyright © 2018. All Rights Reserved.