public class ThreadPoolExecutorStatisticsTask extends Object implements Runnable
ThreadPoolExecutor
including the moving average of its queue length, queuing times, etc.Modifier and Type | Field and Description |
---|---|
static double |
DEFAULT_WEIGHT
The recommended default weight.
|
Constructor and Description |
---|
ThreadPoolExecutorStatisticsTask(String serviceName,
ThreadPoolExecutor service)
Ctor variant when the
ThreadPoolExecutor does not have hooks for
an AbstractTask and therefore does not update
TaskCounters s. |
ThreadPoolExecutorStatisticsTask(String serviceName,
ThreadPoolExecutor service,
TaskCounters taskCounters)
Ctor variant when the
ThreadPoolExecutor has hooks for an
AbstractTask and updates the given TaskCounters s. |
ThreadPoolExecutorStatisticsTask(String serviceName,
ThreadPoolExecutor service,
TaskCounters taskCounters,
double w)
Core impl.
|
Modifier and Type | Method and Description |
---|---|
CounterSet |
getCounters()
Adds counters for all innate variables defined for a
ThreadPoolExecutor and for each of the variables computed by this
class. |
double |
getMovingAverage(double avg,
double q,
double w)
Compute a moving average:
(1 - w) * avg + w * q |
long |
getSampleCount()
#of samples taken so far.
|
double |
getWeight()
The weight used to compute the moving average.
|
void |
run()
This should be invoked once per second to sample various counters in
order to turn their values into moving averages.
|
public static final double DEFAULT_WEIGHT
public ThreadPoolExecutorStatisticsTask(String serviceName, ThreadPoolExecutor service)
ThreadPoolExecutor
does not have hooks for
an AbstractTask
and therefore does not update
TaskCounters
s.serviceName
- The label for the service.service
- The service to be monitored.public ThreadPoolExecutorStatisticsTask(String serviceName, ThreadPoolExecutor service, TaskCounters taskCounters)
ThreadPoolExecutor
has hooks for an
AbstractTask
and updates the given TaskCounters
s.serviceName
- The label for the service.service
- The service to be monitored.taskCounters
- The per-task counters used to compute the latency data for
tasks run on that service.public ThreadPoolExecutorStatisticsTask(String serviceName, ThreadPoolExecutor service, TaskCounters taskCounters, double w)
serviceName
- The label for the service.service
- The service to be monitored.taskCounters
- The per-task counters used to compute the latency data for
tasks run on that service.w
- The weight to be used by
getMovingAverage(double, double, double)
public double getWeight()
public long getSampleCount()
public double getMovingAverage(double avg, double q, double w)
(1 - w) * avg + w * q
avg
- The previous average and initially zero (0.0).q
- The current value (e.g., the instantaneous measurement of the
#of active tasks plus the length of the queue).w
- The weight for the moving average in (0:1). Values around .2
seem appropriate.public void run()
Note: don't throw anything from here or it will cause the scheduled task executing this to no longer be run!
public CounterSet getCounters()
ThreadPoolExecutor
and for each of the variables computed by this
class. Note that some variables (e.g., the lock waiting time) are only
available when the service specified to the ctor is a
WriteExecutorService
.counterSet
- The counters will be added to this CounterSet
.Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.