public class PrioritySchedulerStatisticTracker extends PriorityScheduler implements StatisticPriorityScheduler
PriorityScheduler
which tracks run and usage statistics. This is
designed for testing and troubleshooting. It has a little more overhead from the normal
PriorityScheduler
.
It helps give insight in how long tasks are running, how well the thread pool is being utilized, as well as execution frequency.
Constructor and Description |
---|
PrioritySchedulerStatisticTracker(int poolSize)
Constructs a new thread pool, though no threads will be started till it accepts it's first
request.
|
PrioritySchedulerStatisticTracker(int poolSize,
boolean useDaemonThreads)
Constructs a new thread pool, though no threads will be started till it accepts it's first
request.
|
PrioritySchedulerStatisticTracker(int poolSize,
boolean useDaemonThreads,
int maxStatisticWindowSize)
Deprecated.
|
PrioritySchedulerStatisticTracker(int poolSize,
boolean useDaemonThreads,
int maxStatisticWindowSize,
boolean accurateTime)
Constructs a new thread pool, though no threads will be started till it accepts it's first
request.
|
PrioritySchedulerStatisticTracker(int poolSize,
int maxStatisticWindowSize)
Deprecated.
|
PrioritySchedulerStatisticTracker(int poolSize,
int maxStatisticWindowSize,
boolean accurateTime)
Constructs a new thread pool, though no threads will be started till it accepts it's first
request.
|
PrioritySchedulerStatisticTracker(int poolSize,
TaskPriority defaultPriority,
long maxWaitForLowPriorityInMs)
Constructs a new thread pool, though no threads will be started till it accepts it's first
request.
|
PrioritySchedulerStatisticTracker(int poolSize,
TaskPriority defaultPriority,
long maxWaitForLowPriorityInMs,
boolean useDaemonThreads)
Constructs a new thread pool, though no threads will be started till it accepts it's first
request.
|
PrioritySchedulerStatisticTracker(int poolSize,
TaskPriority defaultPriority,
long maxWaitForLowPriorityInMs,
boolean useDaemonThreads,
int maxStatisticWindowSize)
Deprecated.
|
PrioritySchedulerStatisticTracker(int poolSize,
TaskPriority defaultPriority,
long maxWaitForLowPriorityInMs,
boolean useDaemonThreads,
int maxStatisticWindowSize,
boolean accurateTime)
Constructs a new thread pool, though no threads will be started till it accepts it's first
request.
|
PrioritySchedulerStatisticTracker(int poolSize,
TaskPriority defaultPriority,
long maxWaitForLowPriorityInMs,
boolean stavableStartsThreads,
java.util.concurrent.ThreadFactory threadFactory)
Constructs a new thread pool, though no threads will be started till it accepts it's first
request.
|
PrioritySchedulerStatisticTracker(int poolSize,
TaskPriority defaultPriority,
long maxWaitForLowPriorityInMs,
boolean stavableStartsThreads,
java.util.concurrent.ThreadFactory threadFactory,
int maxStatisticWindowSize,
boolean accurateTime)
Constructs a new thread pool, though no threads will be started till it accepts it's first
request.
|
PrioritySchedulerStatisticTracker(int poolSize,
TaskPriority defaultPriority,
long maxWaitForLowPriorityInMs,
int maxStatisticWindowSize)
Deprecated.
|
PrioritySchedulerStatisticTracker(int poolSize,
TaskPriority defaultPriority,
long maxWaitForLowPriorityInMs,
int maxStatisticWindowSize,
boolean accurateTime)
Constructs a new thread pool, though no threads will be started till it accepts it's first
request.
|
PrioritySchedulerStatisticTracker(int poolSize,
TaskPriority defaultPriority,
long maxWaitForLowPriorityInMs,
java.util.concurrent.ThreadFactory threadFactory)
Constructs a new thread pool, though no threads will be started till it accepts it's first
request.
|
PrioritySchedulerStatisticTracker(int poolSize,
TaskPriority defaultPriority,
long maxWaitForLowPriorityInMs,
java.util.concurrent.ThreadFactory threadFactory,
int maxStatisticWindowSize)
Deprecated.
|
PrioritySchedulerStatisticTracker(int poolSize,
TaskPriority defaultPriority,
long maxWaitForLowPriorityInMs,
java.util.concurrent.ThreadFactory threadFactory,
int maxStatisticWindowSize,
boolean accurateTime)
Constructs a new thread pool, though no threads will be started till it accepts it's first
request.
|
Modifier and Type | Method and Description |
---|---|
double |
getAverageExecutionDelay()
This reports the rolling average delay from when a task was expected to run, till when the
executor actually started the task.
|
double |
getAverageExecutionDelay(TaskPriority priority)
Gets the average delay from when the task is ready, to when it is actually executed.
|
double |
getAverageExecutionDuration()
Get the average duration that tasks submitted through this executor have spent executing.
|
double |
getAverageExecutionDuration(TaskPriority priority)
Get the average duration that tasks submitted through this executor have spent executing.
|
java.util.Map<java.lang.Double,java.lang.Long> |
getExecutionDelayPercentiles(double... percentiles)
Gets percentile values for execution delays.
|
java.util.Map<java.lang.Double,java.lang.Long> |
getExecutionDelayPercentiles(TaskPriority priority,
double... percentiles)
Gets percentile values for execution delays.
|
java.util.List<java.lang.Long> |
getExecutionDelaySamples()
Get raw sample data for task execution delays.
|
java.util.List<java.lang.Long> |
getExecutionDelaySamples(TaskPriority priority)
Call to get a list of all currently recorded times for execution delays.
|
java.util.Map<java.lang.Double,java.lang.Long> |
getExecutionDurationPercentiles(double... percentiles)
Gets percentile values for execution duration.
|
java.util.Map<java.lang.Double,java.lang.Long> |
getExecutionDurationPercentiles(TaskPriority priority,
double... percentiles)
Gets percentile values for execution duration.
|
java.util.List<java.lang.Long> |
getExecutionDurationSamples()
Get raw sample data for task run durations.
|
java.util.List<java.lang.Long> |
getExecutionDurationSamples(TaskPriority priority)
Get raw sample data for task run durations.
|
java.util.List<Pair<java.lang.Runnable,java.lang.StackTraceElement[]>> |
getLongRunningTasks(long durationLimitMillis)
Call to get a list of runnables and stack traces from tasks which have been actively
executing for a longer duration than the one provided.
|
int |
getLongRunningTasksQty(long durationLimitMillis)
Call to return the number of tasks which have been running longer than the provided duration
in milliseconds.
|
long |
getTotalExecutionCount()
Call to get the total quantity of tasks this executor has handled.
|
long |
getTotalExecutionCount(TaskPriority priority)
Call to get the total quantity of tasks this executor has handled for a specific priority.
|
void |
resetCollectedStats()
Clears all collected rolling statistics.
|
void |
scheduleAtFixedRate(java.lang.Runnable task,
long initialDelay,
long period,
TaskPriority priority)
Schedule a fixed rate recurring task to run.
|
void |
scheduleWithFixedDelay(java.lang.Runnable task,
long initialDelay,
long recurringDelay,
TaskPriority priority)
Schedule a fixed delay recurring task to run.
|
java.util.List<java.lang.Runnable> |
shutdownNow()
Stops any new tasks from being able to be executed and removes workers from the pool.
|
adjustPoolSize, awaitTermination, awaitTermination, getActiveTaskCount, getCurrentPoolSize, getMaxPoolSize, getQueuedTaskCount, getQueuedTaskCount, isShutdown, prestartAllThreads, setPoolSize, shutdown
execute, getDefaultPriority, getMaxWaitForLowPriority, getWaitingForExecutionTaskCount, getWaitingForExecutionTaskCount, remove, remove, schedule, scheduleAtFixedRate, scheduleWithFixedDelay, setMaxWaitForLowPriority, submit, submit, submitScheduled, submitScheduled
schedule, submitScheduled, submitScheduled
execute, submit, submit
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getQueuedTaskCount
execute, getDefaultPriority, getMaxWaitForLowPriority, getQueuedTaskCount, getWaitingForExecutionTaskCount, schedule, submit, submit, submit, submitScheduled, submitScheduled, submitScheduled
getActiveTaskCount, getQueuedTaskCount, getWaitingForExecutionTaskCount, isShutdown, remove, remove
schedule, scheduleAtFixedRate, scheduleWithFixedDelay, submitScheduled, submitScheduled, submitScheduled
submit, submit, submit
public PrioritySchedulerStatisticTracker(int poolSize)
This defaults to inaccurate time. Meaning that durations and delays may under report (but NEVER OVER what they actually were). This has the least performance impact. If you want more accurate time consider using one of the constructors that accepts a boolean for accurate time.
poolSize
- Thread pool size that should be maintainedpublic PrioritySchedulerStatisticTracker(int poolSize, boolean useDaemonThreads)
This defaults to inaccurate time. Meaning that durations and delays may under report (but NEVER OVER what they actually were). This has the least performance impact. If you want more accurate time consider using one of the constructors that accepts a boolean for accurate time.
poolSize
- Thread pool size that should be maintaineduseDaemonThreads
- true
if newly created threads should be daemonpublic PrioritySchedulerStatisticTracker(int poolSize, TaskPriority defaultPriority, long maxWaitForLowPriorityInMs)
This defaults to inaccurate time. Meaning that durations and delays may under report (but NEVER OVER what they actually were). This has the least performance impact. If you want more accurate time consider using one of the constructors that accepts a boolean for accurate time.
poolSize
- Thread pool size that should be maintaineddefaultPriority
- priority to give tasks which do not specify itmaxWaitForLowPriorityInMs
- time low priority tasks wait for a workerpublic PrioritySchedulerStatisticTracker(int poolSize, TaskPriority defaultPriority, long maxWaitForLowPriorityInMs, boolean useDaemonThreads)
This defaults to inaccurate time. Meaning that durations and delays may under report (but NEVER OVER what they actually were). This has the least performance impact. If you want more accurate time consider using one of the constructors that accepts a boolean for accurate time.
poolSize
- Thread pool size that should be maintaineddefaultPriority
- priority to give tasks which do not specify itmaxWaitForLowPriorityInMs
- time low priority tasks wait for a workeruseDaemonThreads
- true
if newly created threads should be daemonpublic PrioritySchedulerStatisticTracker(int poolSize, TaskPriority defaultPriority, long maxWaitForLowPriorityInMs, java.util.concurrent.ThreadFactory threadFactory)
TaskPriority.Low
and higher priority tasks.
This defaults to inaccurate time. Meaning that durations and delays may under report (but NEVER OVER what they actually were). This has the least performance impact. If you want more accurate time consider using one of the constructors that accepts a boolean for accurate time.
poolSize
- Thread pool size that should be maintaineddefaultPriority
- priority to give tasks which do not specify itmaxWaitForLowPriorityInMs
- time low priority tasks wait for a workerthreadFactory
- thread factory for producing new threads within executorpublic PrioritySchedulerStatisticTracker(int poolSize, TaskPriority defaultPriority, long maxWaitForLowPriorityInMs, boolean stavableStartsThreads, java.util.concurrent.ThreadFactory threadFactory)
This defaults to inaccurate time. Meaning that durations and delays may under report (but NEVER OVER what they actually were). This has the least performance impact. If you want more accurate time consider using one of the constructors that accepts a boolean for accurate time.
poolSize
- Thread pool size that should be maintaineddefaultPriority
- priority to give tasks which do not specify itmaxWaitForLowPriorityInMs
- time low priority tasks wait for a workerstavableStartsThreads
- true
to have TaskPriority.Starvable tasks start new threadsthreadFactory
- thread factory for producing new threads within executor@Deprecated public PrioritySchedulerStatisticTracker(int poolSize, int maxStatisticWindowSize)
PrioritySchedulerStatisticTracker(int, int, boolean)
This defaults to inaccurate time. Meaning that durations and delays may under report (but NEVER OVER what they actually were). This has the least performance impact. If you want more accurate time consider using one of the constructors that accepts a boolean for accurate time.
poolSize
- Thread pool size that should be maintainedmaxStatisticWindowSize
- maximum number of samples to keep internally@Deprecated public PrioritySchedulerStatisticTracker(int poolSize, boolean useDaemonThreads, int maxStatisticWindowSize)
PrioritySchedulerStatisticTracker(int, boolean, int, boolean)
This defaults to inaccurate time. Meaning that durations and delays may under report (but NEVER OVER what they actually were). This has the least performance impact. If you want more accurate time consider using one of the constructors that accepts a boolean for accurate time.
poolSize
- Thread pool size that should be maintaineduseDaemonThreads
- true
if newly created threads should be daemonmaxStatisticWindowSize
- maximum number of samples to keep internally@Deprecated public PrioritySchedulerStatisticTracker(int poolSize, TaskPriority defaultPriority, long maxWaitForLowPriorityInMs, int maxStatisticWindowSize)
PrioritySchedulerStatisticTracker(int, TaskPriority, long, int, boolean)
This defaults to inaccurate time. Meaning that durations and delays may under report (but NEVER OVER what they actually were). This has the least performance impact. If you want more accurate time consider using one of the constructors that accepts a boolean for accurate time.
poolSize
- Thread pool size that should be maintaineddefaultPriority
- priority to give tasks which do not specify itmaxWaitForLowPriorityInMs
- time low priority tasks wait for a workermaxStatisticWindowSize
- maximum number of samples to keep internally@Deprecated public PrioritySchedulerStatisticTracker(int poolSize, TaskPriority defaultPriority, long maxWaitForLowPriorityInMs, boolean useDaemonThreads, int maxStatisticWindowSize)
PrioritySchedulerStatisticTracker(int, TaskPriority, long, boolean, int, boolean)
This defaults to inaccurate time. Meaning that durations and delays may under report (but NEVER OVER what they actually were). This has the least performance impact. If you want more accurate time consider using one of the constructors that accepts a boolean for accurate time.
poolSize
- Thread pool size that should be maintaineddefaultPriority
- priority to give tasks which do not specify itmaxWaitForLowPriorityInMs
- time low priority tasks wait for a workeruseDaemonThreads
- true
if newly created threads should be daemonmaxStatisticWindowSize
- maximum number of samples to keep internally@Deprecated public PrioritySchedulerStatisticTracker(int poolSize, TaskPriority defaultPriority, long maxWaitForLowPriorityInMs, java.util.concurrent.ThreadFactory threadFactory, int maxStatisticWindowSize)
PrioritySchedulerStatisticTracker(int, TaskPriority, long, ThreadFactory, int, boolean)
This defaults to inaccurate time. Meaning that durations and delays may under report (but NEVER OVER what they actually were). This has the least performance impact. If you want more accurate time consider using one of the constructors that accepts a boolean for accurate time.
poolSize
- Thread pool size that should be maintaineddefaultPriority
- priority to give tasks which do not specify itmaxWaitForLowPriorityInMs
- time low priority tasks wait for a workerthreadFactory
- thread factory for producing new threads within executormaxStatisticWindowSize
- maximum number of samples to keep internallypublic PrioritySchedulerStatisticTracker(int poolSize, int maxStatisticWindowSize, boolean accurateTime)
poolSize
- Thread pool size that should be maintainedmaxStatisticWindowSize
- maximum number of samples to keep internallyaccurateTime
- true
to ensure that delays and durations are not under reportedpublic PrioritySchedulerStatisticTracker(int poolSize, boolean useDaemonThreads, int maxStatisticWindowSize, boolean accurateTime)
poolSize
- Thread pool size that should be maintaineduseDaemonThreads
- true
if newly created threads should be daemonmaxStatisticWindowSize
- maximum number of samples to keep internallyaccurateTime
- true
to ensure that delays and durations are not under reportedpublic PrioritySchedulerStatisticTracker(int poolSize, TaskPriority defaultPriority, long maxWaitForLowPriorityInMs, int maxStatisticWindowSize, boolean accurateTime)
poolSize
- Thread pool size that should be maintaineddefaultPriority
- priority to give tasks which do not specify itmaxWaitForLowPriorityInMs
- time low priority tasks wait for a workermaxStatisticWindowSize
- maximum number of samples to keep internallyaccurateTime
- true
to ensure that delays and durations are not under reportedpublic PrioritySchedulerStatisticTracker(int poolSize, TaskPriority defaultPriority, long maxWaitForLowPriorityInMs, boolean useDaemonThreads, int maxStatisticWindowSize, boolean accurateTime)
TaskPriority.Low
and higher priority tasks.poolSize
- Thread pool size that should be maintaineddefaultPriority
- priority to give tasks which do not specify itmaxWaitForLowPriorityInMs
- time low priority tasks wait for a workeruseDaemonThreads
- true
if newly created threads should be daemonmaxStatisticWindowSize
- maximum number of samples to keep internallyaccurateTime
- true
to ensure that delays and durations are not under reportedpublic PrioritySchedulerStatisticTracker(int poolSize, TaskPriority defaultPriority, long maxWaitForLowPriorityInMs, java.util.concurrent.ThreadFactory threadFactory, int maxStatisticWindowSize, boolean accurateTime)
TaskPriority.Low
and higher priority tasks.poolSize
- Thread pool size that should be maintaineddefaultPriority
- priority to give tasks which do not specify itmaxWaitForLowPriorityInMs
- time low priority tasks wait for a workerthreadFactory
- thread factory for producing new threads within executormaxStatisticWindowSize
- maximum number of samples to keep internallyaccurateTime
- true
to ensure that delays and durations are not under reportedpublic PrioritySchedulerStatisticTracker(int poolSize, TaskPriority defaultPriority, long maxWaitForLowPriorityInMs, boolean stavableStartsThreads, java.util.concurrent.ThreadFactory threadFactory, int maxStatisticWindowSize, boolean accurateTime)
poolSize
- Thread pool size that should be maintaineddefaultPriority
- priority to give tasks which do not specify itmaxWaitForLowPriorityInMs
- time low priority tasks wait for a workerstavableStartsThreads
- true
to have TaskPriority.Starvable tasks start new threadsthreadFactory
- thread factory for producing new threads within executormaxStatisticWindowSize
- maximum number of samples to keep internallyaccurateTime
- true
to ensure that delays and durations are not under reportedpublic java.util.List<java.lang.Runnable> shutdownNow()
PriorityScheduler
This implementation refuses new submissions after this call. And will NOT interrupt any tasks which are currently running. However any tasks which are waiting in queue to be run (but have not started yet), will not be run. Those waiting tasks will be removed, and as workers finish with their current tasks the threads will be joined.
shutdownNow
in class PriorityScheduler
public void scheduleWithFixedDelay(java.lang.Runnable task, long initialDelay, long recurringDelay, TaskPriority priority)
PrioritySchedulerService
recurringDelay + runtime
for the provided task.
Unlike ScheduledExecutorService
if the task throws an exception,
subsequent executions are NOT suppressed or prevented. So if the task throws an exception on
every run, the task will continue to be executed at the provided recurring delay (possibly
throwing an exception on each execution).
scheduleWithFixedDelay
in interface PrioritySchedulerService
scheduleWithFixedDelay
in class PriorityScheduler
task
- runnable to be executedinitialDelay
- delay in milliseconds until first runrecurringDelay
- delay in milliseconds for running task after last finishpriority
- priority for task to get available thread to run onpublic void scheduleAtFixedRate(java.lang.Runnable task, long initialDelay, long period, TaskPriority priority)
PrioritySchedulerService
Unlike ScheduledExecutorService
if the task throws an exception,
subsequent executions are NOT suppressed or prevented. So if the task throws an exception on
every run, the task will continue to be executed at the provided recurring delay (possibly
throwing an exception on each execution).
scheduleAtFixedRate
in interface PrioritySchedulerService
scheduleAtFixedRate
in class PriorityScheduler
task
- runnable to be executedinitialDelay
- delay in milliseconds until first runperiod
- amount of time in milliseconds between the start of recurring executionspriority
- priority for task to get available thread to run onpublic java.util.List<java.lang.Long> getExecutionDelaySamples()
StatisticPriorityScheduler
StatisticsUtils
for additional statistics.
The returned result set includes all priorities. If you want durations for a specific
priority use StatisticPriorityScheduler.getExecutionDelaySamples(TaskPriority)
.
getExecutionDelaySamples
in interface StatisticExecutor
getExecutionDelaySamples
in interface StatisticPriorityScheduler
public java.util.List<java.lang.Long> getExecutionDelaySamples(TaskPriority priority)
StatisticPriorityScheduler
StatisticPriorityScheduler.getAverageExecutionDelay(TaskPriority)
. This call
allows for more complex statistics (ie looking for outliers, etc).getExecutionDelaySamples
in interface StatisticPriorityScheduler
priority
- Task priority to provide samples forpublic double getAverageExecutionDelay()
StatisticPriorityScheduler
-1
if no samples have been
collected yet. This call averages over all priority types, if you want the delay for a
specific priority use StatisticPriorityScheduler.getAverageExecutionDelay(TaskPriority)
.getAverageExecutionDelay
in interface StatisticExecutor
getAverageExecutionDelay
in interface StatisticPriorityScheduler
public double getAverageExecutionDelay(TaskPriority priority)
StatisticPriorityScheduler
getAverageExecutionDelay
in interface StatisticPriorityScheduler
priority
- Specific task priority which statistics should be calculated againstpublic java.util.Map<java.lang.Double,java.lang.Long> getExecutionDelayPercentiles(double... percentiles)
StatisticPriorityScheduler
The returned map's keys correspond exactly to the percentiles provided. Iterating over the returned map will iterate in order of the requested percentiles as well.
These percentiles are across all priorities combined into the same data set. If you want
percentiles for a specific priority use
StatisticPriorityScheduler.getExecutionDelayPercentiles(TaskPriority, double...)
.
getExecutionDelayPercentiles
in interface StatisticExecutor
getExecutionDelayPercentiles
in interface StatisticPriorityScheduler
percentiles
- Percentiles requested, any decimal values between 0 and 100 (inclusive)public java.util.Map<java.lang.Double,java.lang.Long> getExecutionDelayPercentiles(TaskPriority priority, double... percentiles)
StatisticPriorityScheduler
The returned map's keys correspond exactly to the percentiles provided. Iterating over the returned map will iterate in order of the requested percentiles as well.
getExecutionDelayPercentiles
in interface StatisticPriorityScheduler
priority
- Specific task priority which statistics should be calculated againstpercentiles
- Percentiles requested, any decimal values between 0 and 100 (inclusive)public java.util.List<java.lang.Long> getExecutionDurationSamples()
StatisticPriorityScheduler
StatisticsUtils
for additional statistics.
The returned result set includes all priorities. If you want durations for a specific
priority use StatisticPriorityScheduler.getExecutionDurationSamples(TaskPriority)
.
getExecutionDurationSamples
in interface StatisticExecutor
getExecutionDurationSamples
in interface StatisticPriorityScheduler
public java.util.List<java.lang.Long> getExecutionDurationSamples(TaskPriority priority)
StatisticPriorityScheduler
StatisticsUtils
for additional statistics.
These result set includes all priorities. If you want durations for a specific priority use
StatisticPriorityScheduler.getExecutionDurationSamples(TaskPriority)
.
getExecutionDurationSamples
in interface StatisticPriorityScheduler
priority
- Task priority to provide samples forpublic double getAverageExecutionDuration()
StatisticPriorityScheduler
This call averages over all priority types, if you want the duration for a specific priority
use StatisticPriorityScheduler.getAverageExecutionDuration(TaskPriority)
.
getAverageExecutionDuration
in interface StatisticExecutor
getAverageExecutionDuration
in interface StatisticPriorityScheduler
public double getAverageExecutionDuration(TaskPriority priority)
StatisticPriorityScheduler
getAverageExecutionDuration
in interface StatisticPriorityScheduler
priority
- Specific task priority which statistics should be calculated againstpublic java.util.Map<java.lang.Double,java.lang.Long> getExecutionDurationPercentiles(double... percentiles)
StatisticPriorityScheduler
The returned map's keys correspond exactly to the percentiles provided. Iterating over the returned map will iterate in order of the requested percentiles as well.
These percentiles are across all priorities combined into the same data set. If you want
percentiles for a specific priority use
StatisticPriorityScheduler.getExecutionDurationPercentiles(TaskPriority, double...)
.
getExecutionDurationPercentiles
in interface StatisticExecutor
getExecutionDurationPercentiles
in interface StatisticPriorityScheduler
percentiles
- Percentiles requested, any decimal values between 0 and 100 (inclusive)public java.util.Map<java.lang.Double,java.lang.Long> getExecutionDurationPercentiles(TaskPriority priority, double... percentiles)
StatisticPriorityScheduler
The returned map's keys correspond exactly to the percentiles provided. Iterating over the returned map will iterate in order of the requested percentiles as well.
getExecutionDurationPercentiles
in interface StatisticPriorityScheduler
priority
- Specific task priority which statistics should be calculated againstpercentiles
- Percentiles requested, any decimal values between 0 and 100 (inclusive)public java.util.List<Pair<java.lang.Runnable,java.lang.StackTraceElement[]>> getLongRunningTasks(long durationLimitMillis)
StatisticExecutor
If only the quantity of long running tasks is needed, please use
StatisticExecutor.getLongRunningTasksQty(long)
. Since it does not need to generate stack traces it is
a cheaper alternative.
The left side of the Pair
is the runnable task submitted. If the task was submitted
as a Callable
the Runnable will be of type:
ListenableFutureTask
. Casting and invoking
ListenableFutureTask.getContainedCallable()
will allow
you to get to your original Callable
.
The right side of the Pair
is a single sample of what that long running tasks stack
was. Because these tasks are running concurrently by the time this function returns the
provided tasks may have completed.
getLongRunningTasks
in interface StatisticExecutor
durationLimitMillis
- Limit for tasks execution, if task execution time is below this they will be ignoredpublic int getLongRunningTasksQty(long durationLimitMillis)
StatisticExecutor
getLongRunningTasksQty
in interface StatisticExecutor
durationLimitMillis
- threshold of time in milliseconds a task must have been executingpublic void resetCollectedStats()
StatisticExecutor
This does NOT reset the total execution counts.
resetCollectedStats
in interface StatisticExecutor
public long getTotalExecutionCount()
StatisticExecutor
getTotalExecutionCount
in interface StatisticExecutor
public long getTotalExecutionCount(TaskPriority priority)
StatisticPriorityScheduler
getTotalExecutionCount
in interface StatisticPriorityScheduler
priority
- Specific task priority which statistics should be calculated against