Monitor.Omr
Class MemoryMonitor

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--Monitor.Omr.MemoryMonitor
All Implemented Interfaces:
java.lang.Runnable

public class MemoryMonitor
extends java.lang.Thread

Locally monitor the amount of free memory available. This class locally monitors the amount of free memory available in the host. The frequency in which this monitoring occurs is holded by a Frequency object. The value of the currently percentage of CPU usage is holded by a CurrentRange object. The monitoring performed by a MemoryMonitor object can be suspended and resumed. These operations are controlled by a SuspendMonitor object.


Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
MemoryMonitor(CurrentRange cr, Frequency fobj, SuspendMonitor smonitor)
           
 
Method Summary
 void run()
          Continuously check the amount of free memory available.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MemoryMonitor

public MemoryMonitor(CurrentRange cr,
                     Frequency fobj,
                     SuspendMonitor smonitor)
Method Detail

run

public void run()
Continuously check the amount of free memory available. This method contains an infinite loop that continuously reads the file /proc/meminfo and passes the second line of that file to the method extraiValores where the value of corresponding to the amount of free memory available is extracted. The thread then waits for t seconds and then repeats the loop. t is obtained using the method get of the Frequency object, responsible for holding the frequency in which the monitoring process must occur. The frequency is passed by the user, using the method change_frequency that belongs to the Rmo interface.

After getting the amount of free memory available, the loop always check if it must suspend the monitoring process by calling the method is_monitor_suspended that belongs to a SuspendMonitor object. This method will stop the monitoring thread if the user called the method suspend that belongs to the Rmo interface. The monitoring thread will be resumed when the user calls resume, also from the Rmo interface.

Overrides:
run in class java.lang.Thread