Class LoggingRegistry

java.lang.Object
org.pentaho.di.core.logging.LoggingRegistry

public class LoggingRegistry extends Object
This class keeps track of all LoggingObjects that implement the LoggingObjectInterface which register with the LoggingRegistry. It is a static singleton, and manages the in memory LoggingObjects as well as LoggingObjects that have FileWriter Buffers. The class provides a central and thread safe place to register, remove and find LoggingObjects held in memory. It uses a purgeTimer task to attempt to remove older registry objects as the internal map reaches the maxSize which is defined by the Kettle Property "KETTLE_MAX_LOGGING_REGISTRY_SIZE".
  • Method Details

    • getInstance

      public static LoggingRegistry getInstance()
    • registerLoggingSource

      public String registerLoggingSource(Object object)
      Register Method for objects that implement the LoggingObjectInterface which adds them to the LoggingRegistry. Note, this defaults the object to be purged by the registry.
      Parameters:
      object - the object to register.
      Returns:
      the LogChanelID which is a String UUID key.
    • registerLoggingSource

      public String registerLoggingSource(Object object, boolean isPurgeable)
      Register Method for objects that implement the LoggingObjectInterface which adds them to the LoggingRegistry, Includes a flag to identify loggingObjects that should not be removed from the registry i.e. Singleton classes or "General" that stick around the life of the application.
      Parameters:
      object - the object to register.
      isPurgeable - true will flag the object to be purged if needed.
      Returns:
      the LogChanelID which is a String UUID key.
    • findExistingLoggingSource

      public LoggingObjectInterface findExistingLoggingSource(LoggingObjectInterface loggingObject)
      Finds an Existing LoggingObjectInterface in the registry using the LoggingObject's equals method.
      Parameters:
      loggingObject - the object to search for.
      Returns:
      the LoggingObjectInterface if found, null otherwise.
    • getLoggingObject

      public LoggingObjectInterface getLoggingObject(String logChannelId)
      Returns a LoggingObjectInterface based on a LogChannelID which is the key for the LoggingRegistry.
      Parameters:
      logChannelId - the logChannelID to search for.
      Returns:
      the LoggingObjectInterface if found, null otherwise.
    • getMap

      Deprecated.
      This is unsafe call and references to this method will be removed.
    • updateFromProperties

      public void updateFromProperties()
      Updates Class variables from the systemProperties / kettle.properties.
    • schedulePurgeTimer

      public void schedulePurgeTimer()
      Schedule the Purge Timer.
    • getLogChannelChildren

      public List<String> getLogChannelChildren(String parentLogChannelId)
      Searches for a LogChannel and returns a list of children IDs.
      Parameters:
      parentLogChannelId - The ID of the parent to search for.
      Returns:
      a list of LogChannelID's that are the children of the parent object (parent also included on the list).
    • getLastModificationTime

      public Date getLastModificationTime()
      Returns:
      Last Modification Time of the registry.
    • dump

      public String dump(boolean includeGeneral)
      Returns the contents of the Registry map as a string.
      Parameters:
      includeGeneral - Flag when true includes LoggingObjects of type GENERAL.
      Returns:
      String containing logging object.
    • removeIncludingChildren

      public void removeIncludingChildren(String logChannelId)
      Removes a LoggingObject entry and all its children, based on a LogChannelID.
      Parameters:
      logChannelId - LogChannelID of the parent object to remove.
    • removeOrphans

      public void removeOrphans()
      Cleans up internal map of children that do not have parent in the main registry map.
    • registerLogChannelFileWriterBuffer

      public void registerLogChannelFileWriterBuffer(LogChannelFileWriterBuffer fileWriterBuffer)
      Registers a LogChannelFileWriterBuffer with the registry. Existing Buffer must have a logChannelID set.
      Parameters:
      fileWriterBuffer - Object to register.
    • getLogChannelFileWriterBuffer

      public LogChannelFileWriterBuffer getLogChannelFileWriterBuffer(String id)
      Searches and returns LogChannelFileWriterBuffer object based on buffer's LogChannelID.
      Parameters:
      id - LogChannelID to search for.
      Returns:
      Buffer Object, null if can't be determined.
    • getLogChannelFileWriterBufferIds

      protected Set<String> getLogChannelFileWriterBufferIds()
      Returns a Set of LogChannelIds associated with a FileWriterBuffer which includes a parent and its children.
      Returns:
      A set of LogChannelIds to avoid duplicates.
    • removeLogChannelFileWriterBuffer

      public void removeLogChannelFileWriterBuffer(String id)
      Removes a LogChannelFileWriterBuffer by LogChannelId.
      Parameters:
      id - LogChannelId of the object to remove.
    • reset

      public void reset()
      Resets all internal memory objects and counters.