public class IdGeneratorImpl extends Object implements IdGenerator
IAtomicLong.
For each block, ID generation is simply a volatile increment.
| Modifier and Type | Field and Description |
|---|---|
static int |
BLOCK_SIZE |
| Constructor and Description |
|---|
IdGeneratorImpl(IAtomicLong blockGenerator) |
| Modifier and Type | Method and Description |
|---|---|
void |
destroy()
Destroys this object cluster-wide.
|
String |
getName()
Returns the unique name for this DistributedObject.
|
String |
getPartitionKey()
Returns the key of the partition that this DistributedObject is assigned to.
|
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.
|
public static final int BLOCK_SIZE
public IdGeneratorImpl(IAtomicLong blockGenerator)
public boolean init(long id)
IdGeneratorThe first generated ID will be 1 greater than ID.
init in interface IdGeneratortrue if initialization succeeded, false if ID is less than 0.public long newId()
IdGeneratorGenerated IDs are guaranteed to be unique for the entire cluster as long as the cluster is live. If the cluster restarts, then ID generation will start from 0.
newId in interface IdGeneratorpublic String getPartitionKey()
DistributedObjectIAtomicLong. For a partitioned data structure like an IMap,
the returned value will not be null, but otherwise undefined.getPartitionKey in interface DistributedObjectpublic String getName()
DistributedObjectDistributedObjectUtil.getName(DistributedObject)
because this might be also a PrefixedDistributedObject.getName in interface DistributedObjectpublic String getServiceName()
DistributedObjectgetServiceName in interface DistributedObjectpublic void destroy()
DistributedObjectdestroy in interface DistributedObjectCopyright © 2018 Hazelcast, Inc.. All Rights Reserved.