Class 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 Detail

      • NOOP_TASK

        public static final Task NOOP_TASK
    • Constructor Detail

      • HDC

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

      • 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.