com.thinkaurelius.titan.diskstorage.idmanagement

## Class ConsistentKeyIDAuthority

- java.lang.Object
- - com.thinkaurelius.titan.diskstorage.idmanagement.AbstractIDAuthority
  - - com.thinkaurelius.titan.diskstorage.idmanagement.ConsistentKeyIDAuthority

- All Implemented Interfaces:
    IDAuthority, BackendOperation.TransactionalProvider

      public class ConsistentKeyIDAuthority
      extends AbstractIDAuthority
      implements BackendOperation.TransactionalProvider

  `IDAuthority` implementation assuming that the backing store supports consistent key operations.

  ID blocks are allocated by first applying for an id block, waiting for a specified period of time and then checking that the application was the first received for that particular id block. If so, the application is considered successful. If not, some other process won the application and a new application is tried.

  The partition id is used as the key and since key operations are considered consistent, this protocol guarantees unique id block assignments.

  Author:
    Matthias Broecheler (me@matthiasb.com)

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected int` | `randomUniqueIDLimit`

    - ### Fields inherited from class com.thinkaurelius.titan.diskstorage.idmanagement.AbstractIDAuthority

      `BASE_ID, idApplicationWaitMS, metricsPrefix, uid, uidBytes`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ConsistentKeyIDAuthority(KeyColumnValueStore idStore, StoreManager manager, Configuration config)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` Closes the IDAuthority and any underlying storage backend.
    `IDBlock` | `getIDBlock(int partition, int idNamespace, Duration timeout)` Returns a block of new ids in the form of `IDBlock`.
    `List<KeyRange>` | `getLocalIDPartition()` Returns the lower and upper limits of the key range assigned to this local machine as an array with two entries.
    `StoreTransaction` | `openTx()`

    - ### Methods inherited from class com.thinkaurelius.titan.diskstorage.idmanagement.AbstractIDAuthority

      `getBlockSize, getIdUpperBound, getPartitionKey, getUniqueID, setIDBlockSizer`

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

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

- - ### Field Detail

    - #### randomUniqueIDLimit

          protected final int randomUniqueIDLimit

  - ### Constructor Detail

    - #### ConsistentKeyIDAuthority

          public ConsistentKeyIDAuthority(KeyColumnValueStore idStore,
                                  StoreManager manager,
                                  Configuration config)
                                   throws BackendException

      Throws:
        `BackendException`

  - ### Method Detail

    - #### getLocalIDPartition

          public List<KeyRange> getLocalIDPartition()
                                             throws BackendException

      Description copied from interface: `IDAuthority`
      Returns the lower and upper limits of the key range assigned to this local machine as an array with two entries.
      Specified by:
        `getLocalIDPartition` in interface `IDAuthority`
      Returns:
      Throws:
        `BackendException`

    - #### close

          public void close()
                     throws BackendException

      Description copied from interface: `IDAuthority`
      Closes the IDAuthority and any underlying storage backend.
      Specified by:
        `close` in interface `IDAuthority`
      Specified by:
        `close` in interface `BackendOperation.TransactionalProvider`
      Throws:
        `BackendException`

    - #### openTx

          public StoreTransaction openTx()
                                  throws BackendException

      Specified by:
        `openTx` in interface `BackendOperation.TransactionalProvider`
      Throws:
        `BackendException`

    - #### getIDBlock

          public IDBlock getIDBlock(int partition,
                           int idNamespace,
                           Duration timeout)
                             throws BackendException

      Description copied from interface: `IDAuthority`
      Returns a block of new ids in the form of `IDBlock`. It is guaranteed that the block of ids for the particular partition id is uniquely assigned, that is, the block of ids has not been previously and will not subsequently be assigned again when invoking this method on the local or any remote machine that is connected to the underlying storage backend.

      In other words, this method has to ensure that ids are uniquely assigned per partition.

      It is furthermore guaranteed that any id of the returned IDBlock is smaller than the upper bound for the given partition as read from the `IDBlockSizer` set on this IDAuthority and that the number of ids returned is equal to the block size of the IDBlockSizer.
      Specified by:
        `getIDBlock` in interface `IDAuthority`
      Parameters:
        `partition` - Partition for which to request an id block
        `idNamespace` - namespace for ids within a partition
        `timeout` - When a call to this method is unable to return a id block before this timeout elapses, the implementation must give up and throw a `StorageException` ASAP
      Returns:
        a range of ids for the `partition` parameter
      Throws:
        `BackendException`

Copyright © 2012–2014. All rights reserved.