Class SequentialNumber

java.lang.Object
org.apache.hadoop.util.SequentialNumber
All Implemented Interfaces:
IdGenerator

@Private public abstract class SequentialNumber extends Object implements IdGenerator
Sequential number generator. This class is thread safe.
  • Constructor Details

    • SequentialNumber

      protected SequentialNumber(long initialValue)
      Create a new instance with the given initial value.
      Parameters:
      initialValue - initialValue.
  • Method Details

    • getCurrentValue

      public long getCurrentValue()
      Returns:
      the current value.
    • setCurrentValue

      public void setCurrentValue(long value)
      Set current value.
      Parameters:
      value - value.
    • setIfGreater

      public boolean setIfGreater(long value)
    • nextValue

      public long nextValue()
      Increment and then return the next value.
      Specified by:
      nextValue in interface IdGenerator
      Returns:
      long value.
    • skipTo

      public void skipTo(long newValue) throws IllegalStateException
      Skip to the new value.
      Parameters:
      newValue - newValue.
      Throws:
      IllegalStateException - Cannot skip to less than the current value.
    • equals

      public boolean equals(Object that)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object