Apache Ignite Documentation

GridGain Developer Hub - Apache Ignitetm

Welcome to the Apache Ignite developer hub run by GridGain. Here you'll find comprehensive guides and documentation to help you start working with Apache Ignite as quickly as possible, as well as support if you get stuck.

 

GridGain also provides Community Edition which is a distribution of Apache Ignite made available by GridGain. It is the fastest and easiest way to get started with Apache Ignite. The Community Edition is generally more stable than the Apache Ignite release available from the Apache Ignite website and may contain extra bug fixes and features that have not made it yet into the release on the Apache website.

 

Let's jump right in!

 

Documentation     Ask a Question     Download

 

Javadoc     Scaladoc     Examples

Cache Metrics

Apache Ignite allows to keep an eye on the distributed cache specific statistics available via the CacheMetrics interface.

The CacheMetrics interface has a variety of metrics, such as - the total number of put and get operations processed by a cache, average put or get time, total number of evictions, current write-behind cache store buffer size, and more.

Enabling Cache Metrics

To enable cache metrics, set CacheConfiguration.setStatisticsEnabled(boolean) to true for every cache you want to collect the metrics for. The example below shows how to do this for a cache named test-cache:

<bean class="org.apache.ignite.configuration.IgniteConfiguration">
  <property name="cacheConfiguration">
    <list>
      <bean class="org.apache.ignite.configuration.CacheConfiguration">
        <property name="name" value="test-cache"/>
      
        <!-- Enable statistics for the cache. -->
        <property name="statisticsEnabled" value="true"/>
      </bean>
    </list>
  </property>
</bean>
IgniteConfiguration cfg = new IgniteConfiguration();

CacheConfiguration cacheCfg = new CacheConfiguration("test-cache");
        
// Enable statistics for the cache.
cacheCfg.setStatisticsEnabled(true);

// Start the node.
Ignition.start(cfg);

Getting Cache Metrics

There are several ways to get the latest metrics snapshot of a specific cache:

  • IgniteCache.metrics() - gets the metrics snapshot of the whole cluster where the cache is deployed.
  • IgniteCache.metrics(ClusterGroup grp) - gets the metrics snapshot for Apache Ignite nodes that belong to the given cluster group.
  • IgniteCache.localMetrics() - gets the local node's metrics snapshot for the cache.
IgniteCache<Integer, Person> cache = ignite.getOrCreateCache("myCache");

// Get cache metrics 
CacheMetrics cm = cache.metrics();

System.out.println("Avg put time: " + cm.getAveragePutTime());

System.out.println("Avg get time: " + cm.getAverageGetTime());

For a complete list of metrics available, refer to CacheMetrics javadoc.

Using JMX Bean

You can also get access to cache metrics via the CacheMetricsMXBean interface. You can connect to the bean from any JMX-compliant tool or API. If you need to work with the bean from your application, use IgniteCache.mxBean() or IgniteCache.localMxBean() to get a bean reference.

Use the CacheMetricsMXBean.enableStatistics() method exposed by a special JMX bean to activate collecting cache metrics.

For a complete list of metrics available, refer to CacheMetricsMXBean javadoc.

Cache Size Calculation

To learn how to calculate cache size, see Memory Usage Calculation.

Cache Metrics


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.