public class LoggerThreadListener extends Object implements ThreadMonitor.ThreadListener
Constructor and Description |
---|
LoggerThreadListener(String threadIdPrefix,
org.slf4j.Logger logger,
javax.measure.Measurable<javax.measure.quantity.Duration> executionDurationThreshold)
Creates a new
ThreadMonitor.ThreadListener . |
Modifier and Type | Method and Description |
---|---|
void |
executing(Collection<ThreadMonitor.ThreadExecutionState> states)
Callback method to notify a snapshot of the active threads in
execution.
|
void |
failed(ThreadMonitor.ThreadExecutionState state,
Exception failure)
Callback method to notify a thread has failed and the exception was
not caught.
|
void |
finished(ThreadMonitor.ThreadExecutionState state)
Callback method to notify a thread has finished execution.
|
void |
overlapped(ThreadMonitor.ThreadExecutionState state,
javax.measure.Measurable<javax.measure.quantity.Duration> period)
Callback method to notify when a
Runnable is submitted to
be executed at a fixed rate but it took more time to execute than
its period. |
void |
started(ThreadMonitor.ThreadExecutionState state)
Callback method to notify a thread has started execution.
|
public LoggerThreadListener(String threadIdPrefix, org.slf4j.Logger logger, javax.measure.Measurable<javax.measure.quantity.Duration> executionDurationThreshold)
ThreadMonitor.ThreadListener
.threadIdPrefix
- a prefix for the thread Id used as a convenient
way of identifying logs associated to thread monitoring. For
example, using "th-" as threadIdPrefix
would produce
logs messages starting with "th-1" for the first executed
thread.logger
- logger used to write threads stateexecutionDurationThreshold
- when a thread takes more time in
execution state than executionDurationThreshold
a
warning log will be created.public void started(ThreadMonitor.ThreadExecutionState state)
ThreadMonitor.ThreadListener
Note: ThreadExecutionState's end time is updated by the executing thread, so by the moment the state is processed the thread might have finished execution.
started
in interface ThreadMonitor.ThreadListener
state
- thread execution statepublic void finished(ThreadMonitor.ThreadExecutionState state)
ThreadMonitor.ThreadListener
finished
in interface ThreadMonitor.ThreadListener
state
- thread execution statepublic void executing(Collection<ThreadMonitor.ThreadExecutionState> states)
ThreadMonitor.ThreadListener
Note: ThreadExecutionState's end time is updated by the executing thread, so by the moment the state is processed the thread might have finished execution.
executing
in interface ThreadMonitor.ThreadListener
states
- threads execution statespublic void overlapped(ThreadMonitor.ThreadExecutionState state, javax.measure.Measurable<javax.measure.quantity.Duration> period)
ThreadMonitor.ThreadListener
Runnable
is submitted to
be executed at a fixed rate but it took more time to execute than
its period.overlapped
in interface ThreadMonitor.ThreadListener
state
- thread execution stateperiod
- period the Runnable
was scheduled with.public void failed(ThreadMonitor.ThreadExecutionState state, Exception failure)
ThreadMonitor.ThreadListener
failed
in interface ThreadMonitor.ThreadListener
state
- thread execution statefailure
- failureCopyright © 2015. All Rights Reserved.