com.fasterxml.uuid
Class UUIDTimer

java.lang.Object
  extended by com.fasterxml.uuid.UUIDTimer

public final class UUIDTimer
extends Object

UUIDTimer produces the time stamps required for time-based UUIDs. It works as outlined in the UUID specification, with following implementation:

Some additional assumptions about calculating the timestamp:

Note about synchronization: main synchronization point (as of version 3.1.1 and above) is getTimestamp(), so caller need not synchronize access explicitly.


Field Summary
protected  Random _random
          Random number generator used to generate additional information to further reduce probability of collisions.
protected  TimestampSynchronizer _syncer
          Object used to reliably ensure that no multiple JVMs generate UUIDs, and also that the time stamp value used for generating time-based UUIDs is monotonically increasing even if system clock moves backwards over a reboot (usually due to some system level problem).
 
Constructor Summary
UUIDTimer(Random rnd, TimestampSynchronizer sync)
           
 
Method Summary
protected  void getAndSetTimestamp(byte[] uuidBytes)
           
 int getClockSequence()
           
 long getTimestamp()
          Method that constructs timestamp unique and suitable to use for constructing UUIDs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_syncer

protected final TimestampSynchronizer _syncer
Object used to reliably ensure that no multiple JVMs generate UUIDs, and also that the time stamp value used for generating time-based UUIDs is monotonically increasing even if system clock moves backwards over a reboot (usually due to some system level problem).

See TimestampSynchronizer for details.


_random

protected final Random _random
Random number generator used to generate additional information to further reduce probability of collisions.

Constructor Detail

UUIDTimer

public UUIDTimer(Random rnd,
                 TimestampSynchronizer sync)
          throws IOException
Throws:
IOException
Method Detail

getClockSequence

public int getClockSequence()

getTimestamp

public final long getTimestamp()
Method that constructs timestamp unique and suitable to use for constructing UUIDs. Default implementation just calls #getTimestampSynchronized, which is fully synchronized; sub-classes may choose to implemented alternate strategies

Returns:
64-bit timestamp to use for constructing UUID

getAndSetTimestamp

protected final void getAndSetTimestamp(byte[] uuidBytes)


Copyright © 2011 FasterXML.com. All Rights Reserved.