Package org.hippoecm.hst.diagnosis
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 customHDC
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(); }
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
HDC()
Protected constructor which might be called by a child class.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
cleanUp()
Cleans up the HDC tasks and its context.protected void
doCleanUp()
Cleans up the HDC tasks and its context.protected Task
doCreateTask(String name)
Internally create a task instance by the name.protected Task
doGetCurrentTask()
Internally returns the task instance in the current thread context if available.protected Task
doGetRootTask()
Internally returns the root task instance if available.protected boolean
doIsStarted()
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
doStart(String name)
Internally starts the root task by the name.static Task
getCurrentTask()
Returns the task in the current thread context.static Task
getRootTask()
Returns the root task.static boolean
isStarted()
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.
-
-
-
Field Detail
-
NOOP_TASK
public static final Task NOOP_TASK
-
-
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 bydoStart(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.
-
-