public interface IdGenerator extends DistributedObject
IAtomicLong.incrementAndGet()
could be used to provide the same functionality.
The big difference is that the incrementAndGet requires one or more remote calls for every invocation and therefor
is a performance and scalability bottleneck. The IdGenerator uses an IAtomicLong under the hood, but instead of
doing remote call for every call to newId()
, it does it less frequently. It checks out a chunk, e.g. 1..1000 and
as long as it has not yet consumed all the id's in its chunk, then no remote call is done.
It can be that id's generated by different cluster members get out of order because each member will get its own chunk. It
could be that member 1 has chunk 1..1000 and member 2 has 1001..2000. So therefor member 2 will automatically have id's that
are out of order with the id's generated by member 1.Modifier and Type | Method and Description |
---|---|
boolean |
init(long id)
Try to initialize this IdGenerator instance with given id.
|
long |
newId()
Generates and returns cluster-wide unique id.
|
destroy, getId, getName, getPartitionKey, getServiceName
boolean init(long id)
long newId()
Copyright © 2014 Hazelcast, Inc.. All Rights Reserved.