Class HDC

java.lang.Object
org.hippoecm.hst.diagnosis.HDC

public class HDC extends Object
Hierarchical Diagnostic Context.

This provides static methods to start, get and clean up diagnostic tasks.

This also allows to customize HDC by setting a system property, org.hippoecm.hst.diagnosis to a specific implementation class name. A custom HDC implementation may override the instance methods (#doXXX) to extend the functionality.

For example, suppose you want to extend HDC to report the duration of each task to an external performance measuring system. Then one example implementation could look like the following:

 public class CustomExternalApmIntegratedHDC extends HDC {

    // Suppose externalAPM is your external application performance monitoring system
    // at your hand to integrate with.
    private ExternalAPM externalAPM = ...;

    public CustomExternalApmIntegratedHDC() {
        super();
    }
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Task
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    HDC()
    Protected constructor which might be called by a child class.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    Cleans up the HDC tasks and its context.
    protected void
    Cleans up the HDC tasks and its context.
    protected Task
    Internally create a task instance by the name.
    protected Task
    Internally returns the task instance in the current thread context if available.
    protected Task
    Internally returns the root task instance if available.
    protected boolean
    Internally check whether or not the root task was started.
    protected void
    doSetCurrentTask(Task currentTask)
    Internally sets the task instance in the current thread context.
    protected Task
    Internally starts the root task by the name.
    static Task
    Returns the task in the current thread context.
    static Task
    Returns the root task.
    static boolean
    Returns true if the root task was started.
    static void
    setCurrentTask(Task currentTask)
    Sets a task in the current thread context.
    static Task
    start(String name)
    Start the root task with the name.

    Methods inherited from class java.lang.Object

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

    • NOOP_TASK

      public static final Task NOOP_TASK
  • Constructor Details

    • HDC

      protected HDC()
      Protected constructor which might be called by a child class.
  • Method Details

    • start

      public static Task start(String name)
      Start the root task with the name.
      Parameters:
      name - root task name
      Returns:
      root task instance
    • isStarted

      public static boolean isStarted()
      Returns true if the root task was started.
      Returns:
      true if the root task was started
    • getRootTask

      public static Task getRootTask()
      Returns the root task. Null otherwise.
      Returns:
      the root task if exists. Null, otherwise.
    • getCurrentTask

      public static Task getCurrentTask()
      Returns the task in the current thread context. Null if not available.
      Returns:
      the task in the current thread context. Null if not available.
    • setCurrentTask

      public static void setCurrentTask(Task currentTask)
      Sets a task in the current thread context.
      Parameters:
      currentTask - current task instance
    • cleanUp

      public static void cleanUp()
      Cleans up the HDC tasks and its context.
    • doStart

      protected Task doStart(String name)
      Internally starts the root task by the name.
      Parameters:
      name - root task name
      Returns:
      the root task instance
    • doCreateTask

      protected Task doCreateTask(String name)
      Internally create a task instance by the name. This method is invoked by doStart(String), so a child class may override this method if it needs to override the default task implementation, DefaultTaskImpl, for instance.
      Parameters:
      name - task name
      Returns:
      internally created task instance
    • doIsStarted

      protected boolean doIsStarted()
      Internally check whether or not the root task was started.
      Returns:
      returns if the root task was started
    • doGetRootTask

      protected Task doGetRootTask()
      Internally returns the root task instance if available. Null otherwise.
      Returns:
      the root task instance if available. Null otherwise
    • doGetCurrentTask

      protected Task doGetCurrentTask()
      Internally returns the task instance in the current thread context if available. Null otherwise.
      Returns:
      the task instance in the current thread context if available. Null otherwise
    • doSetCurrentTask

      protected void doSetCurrentTask(Task currentTask)
      Internally sets the task instance in the current thread context.
      Parameters:
      currentTask - current task instance
    • doCleanUp

      protected void doCleanUp()
      Cleans up the HDC tasks and its context.