bb.util
Class MemoryMonitor.MonitorTask

java.lang.Object
  extended by java.util.TimerTask
      extended by bb.util.MemoryMonitor.MonitorTask
All Implemented Interfaces:
Runnable
Enclosing class:
MemoryMonitor

private class MemoryMonitor.MonitorTask
extends TimerTask

Class which detects memory issues and calls the appropriate fireXXX event notification method.

This class is not multithread safe: it expects to be run by only a single thread.


Field Summary
private  MemoryMeasurer measurer
          MemoryMeasurer used to measure the memory state.
private  double memoryLowTrigger
          If the ratio of the available memory to the maximum memory falls below this value, the low memory state is triggered.
 
Constructor Summary
private MemoryMonitor.MonitorTask(MemoryMeasurer measurer, double memoryLowTrigger)
          Constructor.
 
Method Summary
 void run()
          Detects any memory issues and calls the appropriate fireXXX event notification method.
 
Methods inherited from class java.util.TimerTask
cancel, scheduledExecutionTime
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

measurer

private final MemoryMeasurer measurer
MemoryMeasurer used to measure the memory state.

Contract: is never null.


memoryLowTrigger

private final double memoryLowTrigger
If the ratio of the available memory to the maximum memory falls below this value, the low memory state is triggered. Must be non-NaN, non-infinite, and in the range [0, 1].

Constructor Detail

MemoryMonitor.MonitorTask

private MemoryMonitor.MonitorTask(MemoryMeasurer measurer,
                                  double memoryLowTrigger)
                           throws IllegalArgumentException
Constructor.

Throws:
IllegalArgumentException - if measurer == null; memoryLowTrigger is NaN, infinite, or outside the range [0, 1]
Method Detail

run

public void run()
Detects any memory issues and calls the appropriate fireXXX event notification method.

If any Throwable is caught: it is logged by the logger2, fireOnMonitoringError is called, and then stopMonitoring is called.

Specified by:
run in interface Runnable
Specified by:
run in class TimerTask