Dashboard > GridGain User Guide > Table Of Contents > GridGain Book > Local Metrics SPI > GridJdkLocalMetricsSpi
GridJdkLocalMetricsSpi
Added by morpheus, last edited by morpheus on Feb 18, 2008  (view change)
Labels: 
(None)


Click on Javadoc link to open Javadoc documentation.

Package

org.gridgain.grid.spi.metrics.jdk Javadoc

Available starting with GridGain

Description

Grid JDK local metrics SPI provides JDK MXBean based local VM metrics. Note that average CPU load cannot be obtained from JDK 1.5 and on some operating systems (including Windows Vista) even from JDK 1.6 (although JDK 1.6 supposedly added support for it).

For cases when CPU load cannot be obtained from JDK, GridGain ships with Hyperic SIGAR metrics. Hyperic metrics are used by default regardless of JDK version, as they are always guaranteed to provide correct CPU metrics.

Hyperic SIGAR and GPL

Hyperic SIGAR is licensed under GPL (unlike LGPL license for GridGain); so if GPL license cannot be used for your business, you should remove Hyperic libraries from GRIDGAIN_HOME/libs folder.

If CPU load cannot be obtained either from JDK or Hyperic, then getCurrentCpuLoad() method will always return -1.

Configuration

The following configuration parameters can be used to configure GridJdkLocalMetricsSpi

Setter Method Description Optional Default
setPreferSigar(boolean) Javadoc Configuration parameter indicating if Hyperic Sigar should be used regardless of JDK version. Hyperic Sigar is used to provide CPU load. Starting with JDK 1.6, method OperatingSystemMXBean.getSystemLoadAverage() method was added. However, even in 1.6 and higher this method does not always provide CPU load on some operating systems (or provides incorrect value) - in such cases Hyperic Sigar will be used automatically. Yes Default value is true.


For more information about using Spring framework for configuration click here.

Examples

GridJdkLocalMetricsSpi is used by default and should be explicitly configured only if some SPI configuration parameters need to be overridden. Example below disables preference of Hyperic SIGAR.

GridConfigurationAdapter cfg = new GridConfigurationAdapter();

GridJdkLocalMetricsSpi metricsSpi = new GridJdkLocalMetricsSpi();

// Disable preference of Hyperic SIGAR.
// JDK 1.6 CPU metrics will be given preference.
metricsSpi.setPreferSigar(false);

// Configure your own metrics SPI.
cfg.setMetricsSpi(metricsSpi);

GridFactory.start(cfg);

or from Spring configuration file

<bean id="grid.custom.cfg" class="org.gridgain.grid.GridConfigurationAdapter" singleton="true">
        ...
        <property name="metricsSpi">
            <bean class="org.gridgain.grid.spi.metrics.jdk.GridJdkLocalMetricsSpi">
                <!--
                   Disable preference of Hyperic SIGAR.
                   JDK 1.6 CPU metrics will be given preference.
                -->
                <property name="preferSigar" value="false"/>
            </bean>
        </property>
        ...
</bean>

Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.2.10 Build:#528 Nov 29, 2006) - Bug/feature request - Contact Administrators