Class ComponentIdGenerator

java.lang.Object
org.apache.nifi.util.ComponentIdGenerator

public class ComponentIdGenerator extends Object
IMPORTANT: This component is not part of public API! ====================================================

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.

  • Field Details

    • logger

      private static final org.slf4j.Logger logger
    • lock

      public static final Object lock
    • lastTime

      private static long lastTime
    • clockSequence

      private static long clockSequence
    • randomGenerator

      private static final SecureRandom randomGenerator
  • Constructor Details

    • ComponentIdGenerator

      public ComponentIdGenerator()
  • Method Details

    • generateId

      public static final UUID generateId()
      Will generate unique time based UUID where the next UUID is always greater then the previous.
    • generateId

      public static final UUID generateId(long currentTime)
    • generateId

      public static final UUID generateId(long msb, long lsb, boolean ensureUnique)