bitronix.tm.utils
Class UidGenerator

java.lang.Object
  extended by bitronix.tm.utils.UidGenerator

public class UidGenerator
extends Object

Helper that offers UID generation (GTRID, XID, sequences) needed by the transaction manager.

Generated UIDs are at most 64 bytes long and are made of 3 subparts: the current time in milliseconds since Epoch, a JVM transient atomic sequence number and the configured bitronix.tm.serverId.

The reliance on the system clock is critical to the uniqueness of the UID in the network so you have to make sure all servers of the network running this transaction manager have their clock reasonably in sync. An order of 1 second synchronicity is generally fine.

Author:
lorban

Constructor Summary
UidGenerator()
           
 
Method Summary
static Uid generateUid()
          Generate a UID, globally unique.
static BitronixXid generateXid(Uid gtrid)
          Generate a XID with the specified globalTransactionId.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UidGenerator

public UidGenerator()
Method Detail

generateUid

public static Uid generateUid()
Generate a UID, globally unique. This method relies on the configured serverId for network uniqueness.

Returns:
the generated UID.

generateXid

public static BitronixXid generateXid(Uid gtrid)
Generate a XID with the specified globalTransactionId.

Parameters:
gtrid - the GTRID to use to generate the Xid.
Returns:
the generated Xid.


Copyright © 2006-2013 Bitronix Software. All Rights Reserved.