org.apache.cassandra.utils
Class UUIDGen

java.lang.Object
  extended by org.apache.cassandra.utils.UUIDGen

public class UUIDGen
extends java.lang.Object

The goods are here: www.ietf.org/rfc/rfc4122.txt.


Method Summary
static byte[] decompose(java.util.UUID uuid)
          decomposes a uuid into raw bytes.
static long getAdjustedTimestamp(java.util.UUID uuid)
          Returns a milliseconds-since-epoch value for a type-1 UUID.
static byte[] getTimeUUIDBytes()
          Returns a 16 byte representation of a type 1 UUID (a time-based UUID), based on the current system time.
static byte[] getTimeUUIDBytes(long timeMillis)
          Converts a milliseconds-since-epoch timestamp into the 16 byte representation of a type 1 UUID (a time-based UUID).
static java.util.UUID getUUID(java.nio.ByteBuffer raw)
          creates a type 1 uuid from raw bytes.
static java.util.UUID makeType1UUIDFromHost(java.net.InetAddress addr)
          Creates a type 1 UUID (time-based UUID) that substitutes a hash of an IP address in place of the MAC (unavailable to Java).
static java.util.UUID read(java.io.DataInputStream dis)
          reads a uuid from an input stream.
static void write(java.util.UUID uuid, java.io.DataOutputStream dos)
          writes a uuid to an output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

makeType1UUIDFromHost

public static java.util.UUID makeType1UUIDFromHost(java.net.InetAddress addr)
Creates a type 1 UUID (time-based UUID) that substitutes a hash of an IP address in place of the MAC (unavailable to Java).

Parameters:
addr - the host address to use
Returns:
a UUID instance

getUUID

public static java.util.UUID getUUID(java.nio.ByteBuffer raw)
creates a type 1 uuid from raw bytes.


read

public static java.util.UUID read(java.io.DataInputStream dis)
                           throws java.io.IOException
reads a uuid from an input stream.

Throws:
java.io.IOException

write

public static void write(java.util.UUID uuid,
                         java.io.DataOutputStream dos)
                  throws java.io.IOException
writes a uuid to an output stream.

Throws:
java.io.IOException

decompose

public static byte[] decompose(java.util.UUID uuid)
decomposes a uuid into raw bytes.


getTimeUUIDBytes

public static byte[] getTimeUUIDBytes()
Returns a 16 byte representation of a type 1 UUID (a time-based UUID), based on the current system time.

Returns:
a type 1 UUID represented as a byte[]

getTimeUUIDBytes

public static byte[] getTimeUUIDBytes(long timeMillis)
Converts a milliseconds-since-epoch timestamp into the 16 byte representation of a type 1 UUID (a time-based UUID).

Warning: This method is not guaranteed to return unique UUIDs; Multiple invocations using identical timestamps will result in identical UUIDs.

Parameters:
timeMillis -
Returns:
a type 1 UUID represented as a byte[]

getAdjustedTimestamp

public static long getAdjustedTimestamp(java.util.UUID uuid)
Returns a milliseconds-since-epoch value for a type-1 UUID.

Parameters:
uuid - a type-1 (time-based) UUID
Returns:
the number of milliseconds since the unix epoch
Throws:
InvalidArgumentException - if the UUID is not version 1


Copyright © 2011 The Apache Software Foundation