GridGain™ 2.1.0
Java API Specification

org.gridgain.grid.spi.metrics
Class GridLocalMetricsAdapter

java.lang.Object
  extended by org.gridgain.grid.spi.metrics.GridLocalMetricsAdapter
All Implemented Interfaces:
Externalizable, Serializable, GridLocalMetrics

@Apache20LicenseCompatible
public class GridLocalMetricsAdapter
extends Object
implements GridLocalMetrics, Externalizable

Adapter for GridLocalMetrics interface.



See Also:

  Documentation
  Email Support
  Online Forums
  Issue Tracking

Author:   2005-2008 Copyright © GridGain Systems. All Rights Reserved. ver. 2.1.0

See Also:
Serialized Form
 

Constructor Summary
GridLocalMetricsAdapter()
          Empty constructor.
GridLocalMetricsAdapter(int availProcs, double load, long heapInit, long heapUsed, long heapCommitted, long heapMax, long nonHeapInit, long nonHeapUsed, long nonHeapCommitted, long nonHeapMax, long upTime, long startTime, int threadCnt, int peakThreadCnt, long startedThreadCnt, int daemonThreadCnt)
          Constructor to initialize all possible metrics.
 
Method Summary
 int getAvailableProcessors()
          Returns the number of processors available to the Java virtual machine.
 double getCurrentCpuLoad()
          Returns the system load average for the last minute.
 int getDaemonThreadCount()
          Returns the current number of live daemon threads.
 long getHeapMemoryCommitted()
          Returns the amount of heap memory in bytes that is committed for the Java virtual machine to use.
 long getHeapMemoryInitialized()
          Returns the amount of heap memory in bytes that the Java virtual machine initially requests from the operating system for memory management.
 long getHeapMemoryMaximum()
          Returns the maximum amount of heap memory in bytes that can be used for memory management.
 long getHeapMemoryUsed()
          Returns the current heap size that is used for object allocation.
 long getNonHeapMemoryCommitted()
          Returns the amount of non-heap memory in bytes that is committed for the Java virtual machine to use.
 long getNonHeapMemoryInitialized()
          Returns the amount of non-heap memory in bytes that the Java virtual machine initially requests from the operating system for memory management.
 long getNonHeapMemoryMaximum()
          Returns the maximum amount of non-heap memory in bytes that can be used for memory management.
 long getNonHeapMemoryUsed()
          Returns the current non-heap memory size that is used by Java VM.
 int getPeakThreadCount()
          Returns the peak live thread count since the Java virtual machine started or peak was reset.
 long getStartTime()
          Returns the start time of the Java virtual machine in milliseconds.
 int getThreadCount()
          Returns the current number of live threads including both daemon and non-daemon threads.
 long getTotalStartedThreadCount()
          Returns the total number of threads created and also started since the Java virtual machine started.
 long getUptime()
          Returns the uptime of the Java virtual machine in milliseconds.
 void readExternal(ObjectInput in)
          
 void setAvailableProcessors(int availProcs)
          Sets available processors.
 void setCurrentCpuLoad(double load)
          Sets CPU load average over last minute.
 void setDaemonThreadCount(int daemonThreadCnt)
          Sets daemon thread count.
 void setHeapMemoryCommitted(long heapCommitted)
          Sets committed heap memory.
 void setHeapMemoryInitialized(long heapInit)
          Sets heap initial memory.
 void setHeapMemoryMaximum(long heapMax)
          Sets maximum possible heap memory.
 void setHeapMemoryUsed(long heapUsed)
          Sets used heap memory.
 void setNonHeapMemoryCommitted(long nonHeapCommitted)
          Sets committed non-heap memory.
 void setNonHeapMemoryInitialized(long nonHeapInit)
          Sets initial non-heap memory.
 void setNonHeapMemoryMaximum(long nonHeapMax)
          Sets maximum possible non-heap memory.
 void setNonHeapMemoryUsed(long nonHeapUsed)
          Sets used non-heap memory.
 void setPeakThreadCount(int peakThreadCnt)
          Sets peak thread count.
 void setStartTime(long startTime)
          Sets VM start time.
 void setThreadCount(int threadCnt)
          Sets thread count.
 void setTotalStartedThreadCount(long startedThreadCnt)
          Sets started thread count.
 void setUpTime(long upTime)
          Sets VM up time.
 String toString()
          
 void writeExternal(ObjectOutput out)
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GridLocalMetricsAdapter

public GridLocalMetricsAdapter()
Empty constructor.


GridLocalMetricsAdapter

public GridLocalMetricsAdapter(int availProcs,
                               double load,
                               long heapInit,
                               long heapUsed,
                               long heapCommitted,
                               long heapMax,
                               long nonHeapInit,
                               long nonHeapUsed,
                               long nonHeapCommitted,
                               long nonHeapMax,
                               long upTime,
                               long startTime,
                               int threadCnt,
                               int peakThreadCnt,
                               long startedThreadCnt,
                               int daemonThreadCnt)
Constructor to initialize all possible metrics.

Parameters:
availProcs - Number of available processors.
load - Average system load for the last minute.
heapInit - Heap initial memory.
heapUsed - Heap used memory.
heapCommitted - Heap committed memory.
heapMax - Heap maximum memory.
nonHeapInit - Non-heap initial memory.
nonHeapUsed - Non-heap used memory.
nonHeapCommitted - Non-heap committed memory.
nonHeapMax - Non-heap maximum memory.
upTime - VM uptime.
startTime - VM start time.
threadCnt - Current active thread count.
peakThreadCnt - Peak thread count.
startedThreadCnt - Started thread count.
daemonThreadCnt - Daemon thread count.
Method Detail

getAvailableProcessors

public int getAvailableProcessors()
Returns the number of processors available to the Java virtual machine. This method is equivalent to the Runtime.availableProcessors() method.

This value may change during a particular invocation of the virtual machine.

Specified by:
getAvailableProcessors in interface GridLocalMetrics
Returns:
The number of processors available to the virtual machine; never smaller than one.

getCurrentCpuLoad

public double getCurrentCpuLoad()
Returns the system load average for the last minute. The system load average is the sum of the number of runnable entities queued to the available processors and the number of runnable entities running on the available processors averaged over a period of time. The way in which the load average is calculated is operating system specific but is typically a damped time-dependent average.

If the load average is not available, a negative value is returned.

This method is designed to provide a hint about the system load and may be queried frequently. The load average may be unavailable on some platform where it is expensive to implement this method.

If you are running JDK 1.6 or above and GridJdkLocalMetricsSpi.setPreferSigar(boolean) is set to false (default is true), then this method is equivalent to OperatingSystemMXBean.getSystemLoadAverage() method. Otherwise, for JDK 1.5 Hyperic Sigar monitoring will be used.

Note that Hyperic Sigar is licensed under GPL. If this license is not suitable for your business, remove hyperic libs from your classpath. In case if this method will not detect JDK 1.6 and will not find Hyperic Sigar libraries in the classpath, -1 will be returned.

Specified by:
getCurrentCpuLoad in interface GridLocalMetrics
Returns:
The system load average; or a negative value if not available.

getHeapMemoryInitialized

public long getHeapMemoryInitialized()
Returns the amount of heap memory in bytes that the Java virtual machine initially requests from the operating system for memory management. This method returns -1 if the initial memory size is undefined.

This value represents a setting of the heap memory for Java VM and is not a sum of all initial heap values for all memory pools.

Specified by:
getHeapMemoryInitialized in interface GridLocalMetrics
Returns:
The initial size of memory in bytes; -1 if undefined.

getHeapMemoryUsed

public long getHeapMemoryUsed()
Returns the current heap size that is used for object allocation. The heap consists of one or more memory pools. This value is the sum of used heap memory values of all heap memory pools.

The amount of used memory in the returned is the amount of memory occupied by both live objects and garbage objects that have not been collected, if any.

Specified by:
getHeapMemoryUsed in interface GridLocalMetrics
Returns:
Amount of heap memory used.

getHeapMemoryCommitted

public long getHeapMemoryCommitted()
Returns the amount of heap memory in bytes that is committed for the Java virtual machine to use. This amount of memory is guaranteed for the Java virtual machine to use. The heap consists of one or more memory pools. This value is the sum of committed heap memory values of all heap memory pools.

Specified by:
getHeapMemoryCommitted in interface GridLocalMetrics
Returns:
The amount of committed memory in bytes.

getHeapMemoryMaximum

public long getHeapMemoryMaximum()
Returns the maximum amount of heap memory in bytes that can be used for memory management. This method returns -1 if the maximum memory size is undefined.

This amount of memory is not guaranteed to be available for memory management if it is greater than the amount of committed memory. The Java virtual machine may fail to allocate memory even if the amount of used memory does not exceed this maximum size.

This value represents a setting of the heap memory for Java VM and is not a sum of all initial heap values for all memory pools.

Specified by:
getHeapMemoryMaximum in interface GridLocalMetrics
Returns:
The maximum amount of memory in bytes; -1 if undefined.

getNonHeapMemoryInitialized

public long getNonHeapMemoryInitialized()
Returns the amount of non-heap memory in bytes that the Java virtual machine initially requests from the operating system for memory management. This method returns -1 if the initial memory size is undefined.

This value represents a setting of non-heap memory for Java VM and is not a sum of all initial heap values for all memory pools.

Specified by:
getNonHeapMemoryInitialized in interface GridLocalMetrics
Returns:
The initial size of memory in bytes; -1 if undefined.

getNonHeapMemoryUsed

public long getNonHeapMemoryUsed()
Returns the current non-heap memory size that is used by Java VM. The non-heap memory consists of one or more memory pools. This value is the sum of used non-heap memory values of all non-heap memory pools.

Specified by:
getNonHeapMemoryUsed in interface GridLocalMetrics
Returns:
Amount of none-heap memory used.

getNonHeapMemoryCommitted

public long getNonHeapMemoryCommitted()
Returns the amount of non-heap memory in bytes that is committed for the Java virtual machine to use. This amount of memory is guaranteed for the Java virtual machine to use. The non-heap memory consists of one or more memory pools. This value is the sum of committed non-heap memory values of all non-heap memory pools.

Specified by:
getNonHeapMemoryCommitted in interface GridLocalMetrics
Returns:
The amount of committed memory in bytes.

getNonHeapMemoryMaximum

public long getNonHeapMemoryMaximum()
Returns the maximum amount of non-heap memory in bytes that can be used for memory management. This method returns -1 if the maximum memory size is undefined.

This amount of memory is not guaranteed to be available for memory management if it is greater than the amount of committed memory. The Java virtual machine may fail to allocate memory even if the amount of used memory does not exceed this maximum size.

This value represents a setting of the non-heap memory for Java VM and is not a sum of all initial non-heap values for all memory pools.

Specified by:
getNonHeapMemoryMaximum in interface GridLocalMetrics
Returns:
The maximum amount of memory in bytes; -1 if undefined.

getUptime

public long getUptime()
Returns the uptime of the Java virtual machine in milliseconds.

Specified by:
getUptime in interface GridLocalMetrics
Returns:
Uptime of the Java virtual machine in milliseconds.

getStartTime

public long getStartTime()
Returns the start time of the Java virtual machine in milliseconds. This method returns the approximate time when the Java virtual machine started.

Specified by:
getStartTime in interface GridLocalMetrics
Returns:
Start time of the Java virtual machine in milliseconds.

getThreadCount

public int getThreadCount()
Returns the current number of live threads including both daemon and non-daemon threads.

Specified by:
getThreadCount in interface GridLocalMetrics
Returns:
the current number of live threads.

getPeakThreadCount

public int getPeakThreadCount()
Returns the peak live thread count since the Java virtual machine started or peak was reset.

Specified by:
getPeakThreadCount in interface GridLocalMetrics
Returns:
The peak live thread count.

getTotalStartedThreadCount

public long getTotalStartedThreadCount()
Returns the total number of threads created and also started since the Java virtual machine started.

Specified by:
getTotalStartedThreadCount in interface GridLocalMetrics
Returns:
The total number of threads started.

getDaemonThreadCount

public int getDaemonThreadCount()
Returns the current number of live daemon threads.

Specified by:
getDaemonThreadCount in interface GridLocalMetrics
Returns:
The current number of live daemon threads.

setAvailableProcessors

public void setAvailableProcessors(int availProcs)
Sets available processors.

Parameters:
availProcs - Available processors.

setCurrentCpuLoad

public void setCurrentCpuLoad(double load)
Sets CPU load average over last minute.

Parameters:
load - CPU load average over last minute.

setHeapMemoryInitialized

public void setHeapMemoryInitialized(long heapInit)
Sets heap initial memory.

Parameters:
heapInit - Heap initial memory.

setHeapMemoryUsed

public void setHeapMemoryUsed(long heapUsed)
Sets used heap memory.

Parameters:
heapUsed - Used heap memory.

setHeapMemoryCommitted

public void setHeapMemoryCommitted(long heapCommitted)
Sets committed heap memory.

Parameters:
heapCommitted - Committed heap memory.

setHeapMemoryMaximum

public void setHeapMemoryMaximum(long heapMax)
Sets maximum possible heap memory.

Parameters:
heapMax - Maximum possible heap memory.

setNonHeapMemoryInitialized

public void setNonHeapMemoryInitialized(long nonHeapInit)
Sets initial non-heap memory.

Parameters:
nonHeapInit - Initial non-heap memory.

setNonHeapMemoryUsed

public void setNonHeapMemoryUsed(long nonHeapUsed)
Sets used non-heap memory.

Parameters:
nonHeapUsed - Used non-heap memory.

setNonHeapMemoryCommitted

public void setNonHeapMemoryCommitted(long nonHeapCommitted)
Sets committed non-heap memory.

Parameters:
nonHeapCommitted - Committed non-heap memory.

setNonHeapMemoryMaximum

public void setNonHeapMemoryMaximum(long nonHeapMax)
Sets maximum possible non-heap memory.

Parameters:
nonHeapMax - Maximum possible non-heap memory.

setUpTime

public void setUpTime(long upTime)
Sets VM up time.

Parameters:
upTime - VN up time.

setStartTime

public void setStartTime(long startTime)
Sets VM start time.

Parameters:
startTime - VM start time.

setThreadCount

public void setThreadCount(int threadCnt)
Sets thread count.

Parameters:
threadCnt - Thread count.

setPeakThreadCount

public void setPeakThreadCount(int peakThreadCnt)
Sets peak thread count.

Parameters:
peakThreadCnt - Peak thread count.

setTotalStartedThreadCount

public void setTotalStartedThreadCount(long startedThreadCnt)
Sets started thread count.

Parameters:
startedThreadCnt - Started thread count.

setDaemonThreadCount

public void setDaemonThreadCount(int daemonThreadCnt)
Sets daemon thread count.

Parameters:
daemonThreadCnt - Daemon thread count.

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException

Specified by:
writeExternal in interface Externalizable
Throws:
IOException

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException

Specified by:
readExternal in interface Externalizable
Throws:
IOException
ClassNotFoundException

toString

public String toString()

Overrides:
toString in class Object

GridGain™ 2.1.0
Java API Specification

GridGain™ - Grid Computing Made Simple, ver. 2.1.0.19122008
2005-2008 Copyright © GridGain Systems. All Rights Reserved.