Class HelixMarkerFactory

java.lang.Object
com.helixframework.logging.HelixMarkerFactory

public final class HelixMarkerFactory extends Object
A factory class for creating and managing Marker instances. The HelixMarkerFactory provides an efficient mechanism to handle composite markers with caching capabilities, ensuring reusability and immutability where needed. This class is implemented as a singleton to centralize access and management of markers. It allows creating both cached and detached marker instances, ensuring thread-safe operations through the use of a ConcurrentMap. The internal caching mechanism optimizes marker retrieval and ensures consistency across different usages.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Clears all entries from the marker cache.
    boolean
    detachMarker(String... names)
    Detaches a Marker associated with the specified names from the marker cache.
    boolean
    Detaches a Marker associated with the specified set of names from the marker cache.
    boolean
    exists(String... names)
    Checks if a Marker exists in the marker cache for the given names.
    boolean
    exists(Set<String> names)
    Checks if an entry corresponding to the specified set of names exists in the marker cache.
    org.slf4j.Marker
    Retrieves a detached Marker instance corresponding to the specified names.
    org.slf4j.Marker
    Retrieves a detached Marker instance corresponding to the specified set of names.
    Provides a globally accessible instance of the HelixMarkerFactory class.
    org.slf4j.Marker
    getMarker(String... names)
    Retrieves a Marker instance corresponding to the specified names.
    org.slf4j.Marker
    Retrieves a Marker instance corresponding to the specified list of names.
    org.slf4j.Marker
    getMarker(org.slf4j.Marker... markers)
    Retrieves a Marker instance corresponding to the specified array of Marker objects.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getInstance

      public static HelixMarkerFactory getInstance()
      Provides a globally accessible instance of the HelixMarkerFactory class.
      Returns:
      the singleton instance of HelixMarkerFactory
    • getMarker

      public org.slf4j.Marker getMarker(String... names)
      Retrieves a Marker instance corresponding to the specified names. The method accepts a variable number of String parameters representing marker names and delegates the operation to getMarker(List).
      Parameters:
      names - the names of the markers to retrieve; must not be null or contain nulls
      Returns:
      a Marker representing the composite structure of the specified marker names
      Throws:
      IllegalArgumentException - if the names parameter is null, empty, or contains null elements
    • getMarker

      public org.slf4j.Marker getMarker(List<String> names)
      Retrieves a Marker instance corresponding to the specified list of names. The method validates the provided list of names, processes them into a canonical form, and either retrieves a cached Marker or builds a composite Marker structure.
      Parameters:
      names - the list of marker names to be processed; must not be null, empty, or contain null elements
      Returns:
      a Marker representing the composite structure of the specified marker names
      Throws:
      IllegalArgumentException - if the names parameter is null, empty, or contains null elements
    • getMarker

      public org.slf4j.Marker getMarker(org.slf4j.Marker... markers)
      Retrieves a Marker instance corresponding to the specified array of Marker objects. The method validates the input array, ensuring it is non-null, non-empty, and does not contain null elements. It then extracts the names of the markers and retrieves a composite Marker structure based on those names.
      Parameters:
      markers - the array of Marker objects to be processed; must not be null, empty, or contain null elements
      Returns:
      a Marker representing the composite structure of the specified Marker objects
      Throws:
      IllegalArgumentException - if the markers parameter is null, empty, or contains null elements
    • exists

      public boolean exists(String... names)
      Checks if a Marker exists in the marker cache for the given names. This method uses the specified names to create a canonical key and verifies whether it is present in the marker cache.
      Parameters:
      names - the variable-length array of marker names to check; may be empty or null
      Returns:
      true if the marker cache contains an entry for the canonical key derived from the specified names; false otherwise
    • exists

      public boolean exists(Set<String> names)
      Checks if an entry corresponding to the specified set of names exists in the marker cache. This method uses the set of names to construct a canonical key and verifies its presence in the cache.
      Parameters:
      names - the set of marker names to check; may be null or empty
      Returns:
      true if the marker cache contains an entry corresponding to the derived canonical key; false otherwise
    • detachMarker

      public boolean detachMarker(String... names)
      Detaches a Marker associated with the specified names from the marker cache. This method generates a canonical key from the provided names and attempts to remove the corresponding Marker entry from the cache.
      Parameters:
      names - the variable-length array of marker names to identify the Marker to be detached; may be null or empty
      Returns:
      true if a Marker corresponding to the specified names was successfully removed from the cache; false otherwise
    • detachMarker

      public boolean detachMarker(Set<String> names)
      Detaches a Marker associated with the specified set of names from the marker cache. This method constructs a canonical key using the provided set of names and attempts to remove the corresponding entry from the cache.
      Parameters:
      names - the set of marker names used to identify the Marker to detach; may be null or empty
      Returns:
      true if a Marker corresponding to the specified names was successfully removed from the cache; false otherwise
    • clear

      public void clear()
      Clears all entries from the marker cache. This method removes any cached marker instances, effectively resetting the state of the marker cache within the factory. After invoking this method, previously cached markers are no longer retrievable, and a new instance will be created if requested.
    • getDetachedMarker

      public org.slf4j.Marker getDetachedMarker(String... names)
      Retrieves a detached Marker instance corresponding to the specified names. The method validates the input names, processes them into a canonical key, and constructs a composite Marker structure that is immutable.
      Parameters:
      names - the variable-length array of marker names to be processed; must not be null, empty, or contain null elements
      Returns:
      an immutable Marker representing the composite structure of the specified names
      Throws:
      IllegalArgumentException - if the names parameter is null, empty, or contains null elements
    • getDetachedMarker

      public org.slf4j.Marker getDetachedMarker(Set<String> names)
      Retrieves a detached Marker instance corresponding to the specified set of names. The method validates the provided set of names, processes them into a canonical key, and constructs a composite Marker structure that is immutable.
      Parameters:
      names - the set of marker names to be processed; must not be null, empty, or contain null elements
      Returns:
      an immutable Marker representing the composite structure of the specified names
      Throws:
      IllegalArgumentException - if the names parameter is null, empty, or contains null elements