public class ComponentIdGenerator extends Object
This component generates type-one UUID. It is used for generating ID of all NiFi components. Giving the 128-bit UUID structure which consists of Least Significant Bits (LSB) and Most Significant Bits (MSB) this component provides support for generating and maintaining INCEPTION ID of the component (MSB) as well as its INSTANCE ID (LSB).
It is also important to understand that while this component does seed itself
from current time which could be extracted from the resulting UUID via call
to UUID.timestamp()
operation, one should not be relying on such time
as the exact time when such ID was generated since in the event the same time
is passed to one of the generateId()
operation it will be
incremented by 1 since the goal of this component to only ensure uniqueness
and type-one semantics where each UUID generated by this component is
comparable and each subsequent ID is > then previous ID.
For more details on how it is interacted with please see org.apache.nifi.web.util.SnippetUtils as well as org.apache.nifi.web.util.SnippetUtilsTest which contain additional documentation on its usage as well as ID generation contracts defined in NiFi.
Modifier and Type | Field and Description |
---|---|
private static long |
clockSequence |
private static long |
lastTime |
static Object |
lock |
private static org.slf4j.Logger |
logger |
private static SecureRandom |
randomGenerator |
Constructor and Description |
---|
ComponentIdGenerator() |
Modifier and Type | Method and Description |
---|---|
static UUID |
generateId()
Will generate unique time based UUID where the next UUID is always
greater then the previous.
|
static UUID |
generateId(long currentTime) |
static UUID |
generateId(long msb,
long lsb,
boolean ensureUnique) |
private static final org.slf4j.Logger logger
public static final Object lock
private static long lastTime
private static long clockSequence
private static final SecureRandom randomGenerator
public static final UUID generateId()
public static final UUID generateId(long currentTime)
public static final UUID generateId(long msb, long lsb, boolean ensureUnique)
Copyright © 2018 Apache NiFi Project. All rights reserved.