Package org.hippoecm.hst.diagnosis
Interface Task
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
DefaultTaskImpl
A unit of execution.
A task may start a subtask, and may contain multiple child subtasks.
Each task may have attributes map of necessary data needed for diagnostics.
By the way, the root task should be given by the container.
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
close()
getAttribute
(String key) Retrieve the attribute value by the attribute name.Returns attribute map which is unmodifiable.Enumerates the attribute namesReturns the child tasks collectionlong
Returns the task execution duration time in millisecondsgetName()
returns the task nameboolean
Returns true if the task was started but not stopped.removeAttribute
(String key) Removes the attribute by the attribute name.void
setAttribute
(String key, Object value) Set an attribute for the task.startSubtask
(String name) Starts and returns a child subtask with the name.void
stop()
Stops the task
-
Method Details
-
getName
String getName()returns the task name- Returns:
-
getAttributeMap
Returns attribute map which is unmodifiable. So, do not try to put or remove items directly from the returned map.- Returns:
-
getAttributeNames
Enumeration<String> getAttributeNames()Enumerates the attribute names -
setAttribute
Set an attribute for the task. The objectvalue
should have a proper #toString method as by default, the #toString method is used for displaying the object in the diagnostics.- Parameters:
key
- attribute namevalue
- attribute value
-
getAttribute
Retrieve the attribute value by the attribute name. When not found,null
is returned -
removeAttribute
Removes the attribute by the attribute name. When an Object was removed forkey
, this object is returned. Otherwisenull
is returned. -
getParentTask
Task getParentTask()- Returns:
- Returns the parent task and
null
if this is the root task
-
startSubtask
Starts and returns a child subtask with the name.- Parameters:
name
-- Returns:
-
stop
void stop()Stops the task -
getChildTasks
Collection<Task> getChildTasks()Returns the child tasks collection- Returns:
-
isRunning
boolean isRunning()Returns true if the task was started but not stopped.- Returns:
-
getDurationTimeMillis
long getDurationTimeMillis()Returns the task execution duration time in milliseconds- Returns:
-
close
default void close()- Specified by:
close
in interfaceAutoCloseable
-