Interface StatisticExecutor
-
- All Superinterfaces:
java.util.concurrent.Executor
,SubmitterExecutor
- All Known Subinterfaces:
StatisticPriorityScheduler
- All Known Implementing Classes:
ExecutorStatisticWrapper
,NoThreadSchedulerStatisticTracker
,PrioritySchedulerStatisticTracker
,SingleThreadSchedulerStatisticTracker
public interface StatisticExecutor extends SubmitterExecutor
Interface for some basic statistic elements provided by any statistic executor/scheduler or any executor/scheduler wrappers.- Since:
- 4.5.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method 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
getAverageExecutionDuration()
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.List<java.lang.Long>
getExecutionDelaySamples()
Get raw sample data for task execution delays.java.util.Map<java.lang.Double,java.lang.Long>
getExecutionDurationPercentiles(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<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.int
getQueuedTaskCount()
Returns how many tasks are either waiting to be executed, or are scheduled to be executed at a future point.long
getTotalExecutionCount()
Call to get the total quantity of tasks this executor has handled.void
resetCollectedStats()
Clears all collected rolling statistics.-
Methods inherited from interface org.threadly.concurrent.SubmitterExecutor
submit, submit, submit
-
-
-
-
Method Detail
-
getQueuedTaskCount
int getQueuedTaskCount()
Returns how many tasks are either waiting to be executed, or are scheduled to be executed at a future point.- Returns:
- Number of tasks still waiting to be executed.
-
getExecutionDelaySamples
java.util.List<java.lang.Long> getExecutionDelaySamples()
Get raw sample data for task execution delays. This raw data can be used for more advanced statistics which are not provided in this library. These can also be fed into utilities inStatisticsUtils
for additional statistics.- Returns:
- A list of delay times in milliseconds before a task was executed
-
getAverageExecutionDelay
double getAverageExecutionDelay()
This reports the rolling average delay from when a task was expected to run, till when the executor actually started the task. This will return-1
if no samples have been collected yet.- Returns:
- Average delay till execution in milliseconds
-
getExecutionDelayPercentiles
java.util.Map<java.lang.Double,java.lang.Long> getExecutionDelayPercentiles(double... percentiles)
Gets percentile values for execution delays. This function accepts any decimal percentile between zero and one hundred.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.
- Parameters:
percentiles
- Percentiles requested, any decimal values between 0 and 100 (inclusive)- Returns:
- Map with keys being the percentiles requested, value being the execution delay in milliseconds
-
getExecutionDurationSamples
java.util.List<java.lang.Long> getExecutionDurationSamples()
Get raw sample data for task run durations. This raw data can be used for more advanced statistics which are not provided in this library. These can also be fed into utilities inStatisticsUtils
for additional statistics.- Returns:
- A list of task durations in milliseconds
-
getAverageExecutionDuration
double getAverageExecutionDuration()
Get the average duration that tasks submitted through this executor have spent executing. This only reports samples from tasks which have completed (in-progress tasks are not considered).- Returns:
- Average task execution duration in milliseconds
-
getExecutionDurationPercentiles
java.util.Map<java.lang.Double,java.lang.Long> getExecutionDurationPercentiles(double... percentiles)
Gets percentile values for execution duration. This function accepts any decimal percentile between zero and one hundred.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.
- Parameters:
percentiles
- Percentiles requested, any decimal values between 0 and 100 (inclusive)- Returns:
- Map with keys being the percentiles requested, value being the execution duration in milliseconds
-
getLongRunningTasks
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. Time in queue waiting for execution is not considered as part of the execution duration.If only the quantity of long running tasks is needed, please use
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 aCallable
the Runnable will be of type:ListenableFutureTask
. Casting and invokingListenableFutureTask.getContainedCallable()
will allow you to get to your originalCallable
.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.- Parameters:
durationLimitMillis
- Limit for tasks execution, if task execution time is below this they will be ignored- Returns:
- List of long running runnables with their corresponding stack traces
-
getLongRunningTasksQty
int getLongRunningTasksQty(long durationLimitMillis)
Call to return the number of tasks which have been running longer than the provided duration in milliseconds. While iterating over running tasks, it may be possible that some previously examine tasks have completed before this ran. There is no attempt to lock tasks from starting or stopping during this check.- Parameters:
durationLimitMillis
- threshold of time in milliseconds a task must have been executing- Returns:
- total quantity of tasks which have or are running longer than the provided time length
-
getTotalExecutionCount
long getTotalExecutionCount()
Call to get the total quantity of tasks this executor has handled.- Returns:
- total quantity of tasks run
-
resetCollectedStats
void resetCollectedStats()
Clears all collected rolling statistics. These are the statistics used for averages and are limited by window sizes.This does NOT reset the total execution counts.
-
-