org.jppf.client.utils
Class GridMonitor

java.lang.Object
  extended by org.jppf.client.utils.GridMonitor

public class GridMonitor
extends Object

This class monitors each of the nodes and their memory usage during execution.

example use:

 JPPFClient client = ...;
 // take memory usage snapshots at approximately 1 second intervals
 GridMonitor monitor = new GridMonitor(client, 1000L);
 monitor.startMonitoring();
 JPPFJob job = ...;
 List<JPPFTask> results = client.submit(job);
 monitor.stopMonitoring();
 // store snapshots in the specified directory
 // there will be one .csv file per node
 monitor.storeData("./GridMonitoring");
 monitor.close();
 

Author:
Laurent Cohen

Nested Class Summary
 class GridMonitor.DataUpdateTask
          This task is run at regular intervals by a timer and takes a snapshot of the heap memory usage for each node.
static class GridMonitor.JPPFManagement
          Container class that holds references to JMX-related objects for one node.
static class GridMonitor.NodeData
          Instances of this class represent a snapshot of the heap memory usage of a node at a given time.
 
Constructor Summary
GridMonitor(JPPFClient jppfClient)
          Initialize this grid monitor with the specified JPPF client and the default (1 second) snpashot interval.
GridMonitor(JPPFClient jppfClient, long snapshotInterval)
          Initialize this grid monitor with the specified JPPF client and snpashot interval.
GridMonitor(String driverHost, int managementPort)
          Initialize this grid monitor with the specified parameters.
GridMonitor(String driverHost, int managementPort, long snapshotInterval)
          Initialize this grid monitor with the specified parameters.
 
Method Summary
 void close()
          Close this monitpr and release the resources it uses.
 GridMonitor.JPPFManagement getDriver()
          Get the object that holds the JMX connection to the driver.
 String getInfo(GridMonitor.JPPFManagement mgt)
          Compute a string that provides information about a driver or node, including the PID
 GridMonitor.JPPFManagement[] getNodes()
          Get the objects that hold the JMX connection to the nodes.
 void startMonitoring()
          Start this monitor and associated resources.
 void stopMonitoring()
          Stop monitoring the nodes.
 void storeData(String folder)
          Store all data snapshots to file.
 void testPIDs()
          This method demonstrates how the APIs in this class can be used to find the Process ID for the driver and nodes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GridMonitor

public GridMonitor(String driverHost,
                   int managementPort)
            throws Exception
Initialize this grid monitor with the specified parameters.

Parameters:
driverHost - the host of the driver.
managementPort - management port used by the driver.
Throws:
Exception - if any error occurs.

GridMonitor

public GridMonitor(String driverHost,
                   int managementPort,
                   long snapshotInterval)
            throws Exception
Initialize this grid monitor with the specified parameters.

Parameters:
driverHost - the host of the driver.
managementPort - management port used by the driver.
snapshotInterval - the interval at which memory usage snapshots are taken.
Throws:
Exception - if any error occurs.

GridMonitor

public GridMonitor(JPPFClient jppfClient)
            throws Exception
Initialize this grid monitor with the specified JPPF client and the default (1 second) snpashot interval.

Parameters:
jppfClient - the JPPF client from which to get the JMX connections.
Throws:
Exception - if any error occurs during initialization.

GridMonitor

public GridMonitor(JPPFClient jppfClient,
                   long snapshotInterval)
            throws Exception
Initialize this grid monitor with the specified JPPF client and snpashot interval.

Parameters:
jppfClient - the JPPF client from which to get the JMX connections.
snapshotInterval - the interval at which memory usage snapshots are taken.
Throws:
Exception - if any error occurs during initialization.
Method Detail

startMonitoring

public void startMonitoring()
Start this monitor and associated resources.


stopMonitoring

public void stopMonitoring()
Stop monitoring the nodes.


close

public void close()
           throws Exception
Close this monitpr and release the resources it uses.

Throws:
Exception - if any error occurs.

storeData

public void storeData(String folder)
Store all data snapshots to file. One CSV file is created for each node.

Parameters:
folder - path to the folder where the files are created. This folder is created if needed.

getDriver

public GridMonitor.JPPFManagement getDriver()
Get the object that holds the JMX connection to the driver.

Returns:
the JPPFManagement instance for the driver.

getNodes

public GridMonitor.JPPFManagement[] getNodes()
Get the objects that hold the JMX connection to the nodes.

Returns:
an array of JPPFManagement instances for the nodes.

testPIDs

public void testPIDs()
This method demonstrates how the APIs in this class can be used to find the Process ID for the driver and nodes.


getInfo

public String getInfo(GridMonitor.JPPFManagement mgt)
Compute a string that provides information about a driver or node, including the PID

Parameters:
mgt - the driver or node to process.
Returns:
a string that contains the host name or IP, jmx port number and PID for the node or driver.


Copyright © 2005-2010 JPPF Team.