public class FlakeIdGeneratorProxy extends AbstractDistributedObject<FlakeIdGeneratorService> implements FlakeIdGenerator
Modifier and Type | Class and Description |
---|---|
static class |
FlakeIdGeneratorProxy.IdBatchAndWaitTime |
Modifier and Type | Field and Description |
---|---|
static int |
BITS_NODE_ID |
static int |
BITS_SEQUENCE |
static int |
BITS_TIMESTAMP |
static long |
INCREMENT
The difference between two IDs from a sequence on single member
|
PARTITIONING_STRATEGY
Modifier and Type | Method and Description |
---|---|
String |
getName()
Returns the unique name for this DistributedObject.
|
String |
getServiceName()
Returns the service name for this object.
|
boolean |
init(long id)
Tries to initialize this
IdGenerator instance with the given ID. |
long |
newId()
Generates and returns a cluster-wide unique ID.
|
FlakeIdGeneratorProxy.IdBatchAndWaitTime |
newIdBatch(int batchSize) |
destroy, equals, getDistributedObjectName, getNameAsPartitionAwareData, getNodeEngine, getOperationService, getPartitionId, getPartitionKey, getService, hashCode, invalidate, invokeOnPartition, isClusterVersionEqualTo, isClusterVersionGreaterOrEqual, isClusterVersionGreaterThan, isClusterVersionLessOrEqual, isClusterVersionLessThan, isClusterVersionUnknown, isClusterVersionUnknownOrGreaterOrEqual, isClusterVersionUnknownOrGreaterThan, isClusterVersionUnknownOrLessOrEqual, isClusterVersionUnknownOrLessThan, postDestroy, preDestroy, throwNotActiveException, toData, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
destroy, getPartitionKey
public static final int BITS_TIMESTAMP
public static final int BITS_SEQUENCE
public static final int BITS_NODE_ID
public static final long INCREMENT
public long newId()
FlakeIdGenerator
Operation on member is always local, if the member has valid node ID, otherwise it's remote. On
client, this 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 see ClientConfig.addFlakeIdGeneratorConfig()
for client config.
Note: Values returned from this method may be not strictly ordered.
newId
in interface IdGenerator
newId
in interface FlakeIdGenerator
public boolean init(long id)
FlakeIdGenerator
IdGenerator
instance with the given ID.
The next generated ID will be 1 greater than the supplied ID.
Note for Flake ID Generator: This method does nothing and will simply tell if the next ID will be larger than the given ID. You don't need to call this method on cluster restart - uniqueness is preserved thanks to the timestamp component of the ID.
init
in interface IdGenerator
init
in interface FlakeIdGenerator
true
, if the next ID will be larger than the supplied idpublic FlakeIdGeneratorProxy.IdBatchAndWaitTime newIdBatch(int batchSize)
public String getName()
DistributedObject
DistributedObjectUtil.getName(DistributedObject)
because this might be also a PrefixedDistributedObject
.getName
in interface DistributedObject
public String getServiceName()
DistributedObject
getServiceName
in interface DistributedObject
getServiceName
in class AbstractDistributedObject<FlakeIdGeneratorService>
Copyright © 2022 Hazelcast, Inc.. All Rights Reserved.