org.apache.cassandra.utils

## Class CounterId

- java.lang.Object
- - org.apache.cassandra.utils.CounterId

- All Implemented Interfaces:
    java.lang.Comparable<CounterId>

      public class CounterId
      extends java.lang.Object
      implements java.lang.Comparable<CounterId>

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `CounterId.CounterIdRecord`
    `static class` | `CounterId.OneShotRenewer`

  - ### Field Summary

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

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.nio.ByteBuffer` | `bytes()`
    `int` | `compareTo(CounterId o)`
    `boolean` | `equals(java.lang.Object o)`
    `static CounterId` | `fromInt(int n)` Function for test purposes, do not use otherwise.
    `static CounterId` | `generate()`
    `static CounterId` | `getLocalId()`
    `static java.util.List<CounterId.CounterIdRecord>` | `getOldLocalCounterIds()` Return the list of old local counter id of this node.
    `int` | `hashCode()`
    `boolean` | `isLocalId()`
    `static void` | `renewLocalId()` Renew the local counter id.
    `static void` | `renewLocalId(long now)`
    `java.lang.String` | `toString()`
    `static CounterId` | `wrap(java.nio.ByteBuffer id)`
    `static CounterId` | `wrap(java.nio.ByteBuffer bb, int offset)`

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

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

- - ### Field Detail

    - #### LENGTH

          public static final int LENGTH

      See Also:
        Constant Field Values

  - ### Method Detail

    - #### getLocalId

          public static CounterId getLocalId()

    - #### renewLocalId

          public static void renewLocalId()

      Renew the local counter id. To use only when this strictly necessary, as using this will make all counter context grow with time.

    - #### renewLocalId

          public static void renewLocalId(long now)

    - #### getOldLocalCounterIds

          public static java.util.List<CounterId.CounterIdRecord> getOldLocalCounterIds()

      Return the list of old local counter id of this node. It is guaranteed that the returned list is sorted by growing counter id (and hence the first item will be the oldest counter id for this host)

    - #### fromInt

          public static CounterId fromInt(int n)

      Function for test purposes, do not use otherwise. Pack an int in a valid CounterId so that the resulting ids respects the numerical ordering. Used for creating handcrafted but easy to understand contexts in unit tests (see CounterContextTest).

    - #### wrap

          public static CounterId wrap(java.nio.ByteBuffer id)

    - #### wrap

          public static CounterId wrap(java.nio.ByteBuffer bb,
                       int offset)

    - #### generate

          public static CounterId generate()

    - #### bytes

          public java.nio.ByteBuffer bytes()

    - #### isLocalId

          public boolean isLocalId()

    - #### compareTo

          public int compareTo(CounterId o)

      Specified by:
        `compareTo` in interface `java.lang.Comparable<CounterId>`

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

    - #### equals

          public boolean equals(java.lang.Object o)

      Overrides:
        `equals` in class `java.lang.Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `java.lang.Object`

Copyright © 2014 The Apache Software Foundation