com.hazelcast.concurrent.idgen

## Class IdGeneratorImpl

- java.lang.Object
- - com.hazelcast.concurrent.idgen.IdGeneratorImpl

- All Implemented Interfaces:
    DistributedObject, IdGenerator

      public class IdGeneratorImpl
      extends Object
      implements IdGenerator

  Generates blocks with the help of an `IAtomicLong`.

  For each block, ID generation is simply a volatile increment.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `BLOCK_SIZE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `IdGeneratorImpl(IAtomicLong blockGenerator)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    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.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### BLOCK_SIZE

          public static final int BLOCK_SIZE

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### IdGeneratorImpl

          public IdGeneratorImpl(IAtomicLong blockGenerator)

  - ### Method Detail

    - #### init

          public boolean init(long id)

      Description copied from interface: `IdGenerator`
      Tries to initialize this `IdGenerator` instance with the given ID.

      The next generated ID will be 1 greater than the supplied ID.

      Specified by:
        `init` in interface `IdGenerator`
      Returns:
        `true` if initialization succeeded, `false` otherwise.

    - #### newId

          public long newId()

      Description copied from interface: `IdGenerator`
      Generates and returns a cluster-wide unique ID.
      Specified by:
        `newId` in interface `IdGenerator`
      Returns:
        new cluster-wide unique ID

    - #### getPartitionKey

          public String getPartitionKey()

      Description copied from interface: `DistributedObject`
      Returns the key of the partition that this DistributedObject is assigned to. The returned value only has meaning for a non-partitioned data structure like an `IAtomicLong`. For a partitioned data structure like an `IMap`, the returned value will not be null, but otherwise undefined.
      Specified by:
        `getPartitionKey` in interface `DistributedObject`
      Returns:
        the partition key.

    - #### getName

          public String getName()

      Description copied from interface: `DistributedObject`
      Returns the unique name for this DistributedObject. The returned value will never be null. The suggested way for getting name is retrieving it through `DistributedObjectUtil.getName(DistributedObject)` because this might be also a `PrefixedDistributedObject`.
      Specified by:
        `getName` in interface `DistributedObject`
      Returns:
        the unique name for this object.

    - #### getServiceName

          public String getServiceName()

      Description copied from interface: `DistributedObject`
      Returns the service name for this object.
      Specified by:
        `getServiceName` in interface `DistributedObject`
      Returns:
        the service name for this object.

    - #### destroy

          public void destroy()

      Description copied from interface: `DistributedObject`
      Destroys this object cluster-wide. Clears and releases all resources for this object.
      Specified by:
        `destroy` in interface `DistributedObject`

Copyright © 2019. All rights reserved.