com.hazelcast.client.proxy

## Class ClientFlakeIdGeneratorProxy

- java.lang.Object
- - com.hazelcast.client.spi.ClientProxy
  - - com.hazelcast.client.proxy.ClientFlakeIdGeneratorProxy

- All Implemented Interfaces:
    DistributedObject, IdGenerator, FlakeIdGenerator

      public class ClientFlakeIdGeneratorProxy
      extends ClientProxy
      implements FlakeIdGenerator

  Proxy implementation of `IdGenerator`.

- - ### Field Summary

    - ### Fields inherited from class com.hazelcast.client.spi.ClientProxy

      `name`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ClientFlakeIdGeneratorProxy(String serviceName, String objectName, ClientContext context)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `init(long id)` Tries to initialize this `IdGenerator` instance with the given ID.
    `long` | `newId()` Generates and returns a cluster-wide unique ID.
    `String` | `toString()`

    - ### Methods inherited from class com.hazelcast.client.spi.ClientProxy

      `deregisterListener, destroy, destroyLocally, destroyRemotely, equals, getClient, getConnectedServerVersion, getContext, getDistributedObjectName, getId, getName, getPartitionKey, getSerializationService, getServiceName, hashCode, invoke, invoke, invokeOnAddress, invokeOnPartition, invokeOnPartitionInterruptibly, onDestroy, onInitialize, onShutdown, postDestroy, preDestroy, registerListener, setContext, toData, toObject`

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

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface com.hazelcast.core.DistributedObject

      `destroy, getName, getPartitionKey, getServiceName`

- - ### Constructor Detail

    - #### ClientFlakeIdGeneratorProxy

          public ClientFlakeIdGeneratorProxy(String serviceName,
                                             String objectName,
                                             ClientContext context)

  - ### Method Detail

    - #### newId

          public long newId()

      Description copied from interface: `FlakeIdGenerator`
      Generates and returns a cluster-wide unique ID.

      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.

      Specified by:
        `newId` in interface `IdGenerator`
      Specified by:
        `newId` in interface `FlakeIdGenerator`
      Returns:
        new cluster-wide unique ID

    - #### init

          public boolean init(long id)

      Description copied from interface: `FlakeIdGenerator`
      Tries to initialize this `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.

      Specified by:
        `init` in interface `IdGenerator`
      Specified by:
        `init` in interface `FlakeIdGenerator`
      Returns:
        `true`, if the next ID will be larger than the supplied id

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright © 2019. All rights reserved.