Package org.hippoecm.hst.diagnosis
Class HDC
java.lang.Object
org.hippoecm.hst.diagnosis.HDC
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
-
Constructor Summary
ModifierConstructorDescriptionprotected
HDC()
Protected constructor which might be called by a child class. -
Method Summary
Modifier and TypeMethodDescriptionstatic void
cleanUp()
Cleans up the HDC tasks and its context.protected void
Cleans up the HDC tasks and its context.protected Task
doCreateTask
(String name) 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 the root task with the name.
-
Field Details
-
NOOP_TASK
-
-
Constructor Details
-
HDC
protected HDC()Protected constructor which might be called by a child class.
-
-
Method Details
-
start
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
Returns the root task. Null otherwise.- Returns:
- the root task if exists. Null, otherwise.
-
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
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
Internally starts the root task by the name.- Parameters:
name
- root task name- Returns:
- the root task instance
-
doCreateTask
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
Internally returns the root task instance if available. Null otherwise.- Returns:
- the root task instance if available. Null otherwise
-
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
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.
-