Class UuidUtil
- java.lang.Object
-
- org.apache.logging.log4j.core.util.UuidUtil
-
public final class UuidUtil extends java.lang.Object
Generates a unique ID. The generated UUID will be unique for approximately 8,925 years so long as less than 10,000 IDs are generated per millisecond on the same device (as identified by its MAC address).
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
ASSIGNED_SEQUENCES
private static java.util.concurrent.atomic.AtomicInteger
COUNT
private static long
HIGH_MASK
private static int
HUNDRED_NANOS_PER_MILLI
private static long
INITIAL_UUID_SEQNO
private static long
LEAST
private static Logger
LOGGER
private static long
LOW_MASK
private static long
MID_MASK
private static int
NODE_SIZE
private static long
NUM_100NS_INTERVALS_SINCE_UUID_EPOCH
private static int
SEQUENCE_MASK
private static int
SHIFT_2
private static int
SHIFT_4
private static int
SHIFT_6
private static long
TYPE1
static java.lang.String
UUID_SEQUENCE
System property that may be used to seed the UUID generation with an integer value.private static byte
VARIANT
-
Constructor Summary
Constructors Modifier Constructor Description private
UuidUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.UUID
getTimeBasedUuid()
Generates Type 1 UUID.(package private) static long
initialize(byte[] mac)
Initializes this class
-
-
-
Field Detail
-
UUID_SEQUENCE
public static final java.lang.String UUID_SEQUENCE
System property that may be used to seed the UUID generation with an integer value.- See Also:
- Constant Field Values
-
LOGGER
private static final Logger LOGGER
-
ASSIGNED_SEQUENCES
private static final java.lang.String ASSIGNED_SEQUENCES
- See Also:
- Constant Field Values
-
COUNT
private static final java.util.concurrent.atomic.AtomicInteger COUNT
-
TYPE1
private static final long TYPE1
- See Also:
- Constant Field Values
-
VARIANT
private static final byte VARIANT
- See Also:
- Constant Field Values
-
SEQUENCE_MASK
private static final int SEQUENCE_MASK
- See Also:
- Constant Field Values
-
NUM_100NS_INTERVALS_SINCE_UUID_EPOCH
private static final long NUM_100NS_INTERVALS_SINCE_UUID_EPOCH
- See Also:
- Constant Field Values
-
INITIAL_UUID_SEQNO
private static final long INITIAL_UUID_SEQNO
-
LOW_MASK
private static final long LOW_MASK
- See Also:
- Constant Field Values
-
MID_MASK
private static final long MID_MASK
- See Also:
- Constant Field Values
-
HIGH_MASK
private static final long HIGH_MASK
- See Also:
- Constant Field Values
-
NODE_SIZE
private static final int NODE_SIZE
- See Also:
- Constant Field Values
-
SHIFT_2
private static final int SHIFT_2
- See Also:
- Constant Field Values
-
SHIFT_4
private static final int SHIFT_4
- See Also:
- Constant Field Values
-
SHIFT_6
private static final int SHIFT_6
- See Also:
- Constant Field Values
-
HUNDRED_NANOS_PER_MILLI
private static final int HUNDRED_NANOS_PER_MILLI
- See Also:
- Constant Field Values
-
LEAST
private static final long LEAST
-
-
Method Detail
-
initialize
static long initialize(byte[] mac)
Initializes this class- Parameters:
mac
- MAC address- Returns:
- Least
-
getTimeBasedUuid
public static java.util.UUID getTimeBasedUuid()
Generates Type 1 UUID. The time contains the number of 100NS intervals that have occurred since 00:00:00.00 UTC, 10 October 1582. Each UUID on a particular machine is unique to the 100NS interval until they rollover around 3400 A.D.- Digits 1-12 are the lower 48 bits of the number of 100 ns increments since the start of the UUID epoch.
- Digit 13 is the version (with a value of 1).
- Digits 14-16 are a sequence number that is incremented each time a UUID is generated.
- Digit 17 is the variant (with a value of binary 10) and 10 bits of the sequence number
- Digit 18 is final 16 bits of the sequence number.
- Digits 19-32 represent the system the application is running on.
- Returns:
- universally unique identifiers (UUID)
-
-