Package fr.dyade.aaa.common
Class AverageLoadTask
- java.lang.Object
-
- java.util.TimerTask
-
- fr.dyade.aaa.common.AverageLoadTask
-
- All Implemented Interfaces:
Runnable
- Direct Known Subclasses:
Engine.EngineAverageLoadTask,Network.NetworkAverageLoadTask
public abstract class AverageLoadTask extends TimerTask
This class computes the load average of the server using Unix algorithm. This task needs to be scheduled every 5 seconds.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) longaverageLoad1load averages for the last minute.(package private) longaverageLoad15load averages for the past 15 minutes.(package private) longaverageLoad5load averages for the past 5 minutes.private static longEXP_11/exp(5sec/1min) as fixed-pointprivate static longEXP_151/exp(5sec/15min)private static longEXP_51/exp(5sec/5min)private static longFIXED_11.0 as fixed-pointprivate static longFSHIFTnumber of bits of precision
-
Constructor Summary
Constructors Constructor Description AverageLoadTask()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description (package private) longcomputeLoad(long load, long exp, long n)(package private) floatconvert(long average)protected abstract longcountActiveTasks()floatgetAverageLoad1()Returns the load averages for the last minute.floatgetAverageLoad15()Returns the load averages for the past 15 minutes.floatgetAverageLoad5()Returns the load averages for the past 5 minutes.voidreset()voidrun()protected voidstart(Timer timer)Starts the resulting task.-
Methods inherited from class java.util.TimerTask
cancel, scheduledExecutionTime
-
-
-
-
Field Detail
-
FSHIFT
private static final long FSHIFT
number of bits of precision- See Also:
- Constant Field Values
-
FIXED_1
private static final long FIXED_1
1.0 as fixed-point- See Also:
- Constant Field Values
-
EXP_1
private static final long EXP_1
1/exp(5sec/1min) as fixed-point- See Also:
- Constant Field Values
-
EXP_5
private static final long EXP_5
1/exp(5sec/5min)- See Also:
- Constant Field Values
-
EXP_15
private static final long EXP_15
1/exp(5sec/15min)- See Also:
- Constant Field Values
-
averageLoad1
long averageLoad1
load averages for the last minute.
-
averageLoad5
long averageLoad5
load averages for the past 5 minutes.
-
averageLoad15
long averageLoad15
load averages for the past 15 minutes.
-
-
Method Detail
-
getAverageLoad1
public float getAverageLoad1()
Returns the load averages for the last minute.- Returns:
- the load averages for the last minute.
-
getAverageLoad5
public float getAverageLoad5()
Returns the load averages for the past 5 minutes.- Returns:
- the load averages for the past 5 minutes.
-
getAverageLoad15
public float getAverageLoad15()
Returns the load averages for the past 15 minutes.- Returns:
- the load averages for the past 15 minutes.
-
convert
float convert(long average)
-
computeLoad
long computeLoad(long load, long exp, long n)
-
countActiveTasks
protected abstract long countActiveTasks()
-
run
public void run()
- Specified by:
runin interfaceRunnable- Specified by:
runin classTimerTask- See Also:
TimerTask.run()
-
reset
public void reset()
-
start
protected final void start(Timer timer)
Starts the resulting task.- Parameters:
timer- Timer to use to schedule the resulting task.
-
-