public class IdGeneratorProxy extends AbstractDistributedObject<IdGeneratorService> implements IdGenerator
PARTITIONING_STRATEGY
Constructor and Description |
---|
IdGeneratorProxy(IAtomicLong blockGenerator,
String name,
NodeEngine nodeEngine,
IdGeneratorService service) |
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.
|
protected void |
postDestroy() |
destroy, equals, getDistributedObjectName, getNameAsPartitionAwareData, getNodeEngine, getOperationService, getPartitionId, getPartitionKey, getService, hashCode, invalidate, invokeOnPartition, preDestroy, throwNotActiveException, toData, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
destroy, getPartitionKey
public IdGeneratorProxy(IAtomicLong blockGenerator, String name, NodeEngine nodeEngine, IdGeneratorService service)
public boolean init(long id)
IdGenerator
The first generated ID will be 1 greater than ID.
init
in interface IdGenerator
true
if initialization succeeded, false
if ID is less than 0.public long newId()
IdGenerator
Generated 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 IdGenerator
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<IdGeneratorService>
protected void postDestroy()
postDestroy
in class AbstractDistributedObject<IdGeneratorService>
Copyright © 2018 Hazelcast, Inc.. All Rights Reserved.