Skip to end of metadata
Go to start of metadata

Java Management Extensions (JMX) is the Java-based standard for managing and monitoring services on the network. Coconut Cache has build-in support for JMX.

Overview

The management service is located in the org.coconut.cache.service.management package. It consists of the following 3 classes

Class

Description

CacheManagementConfiguration

This class is used to configure the management service prior cache initialization.

CacheManagementService

This class is used to control the management service at runtime.

CacheMXBean

The management interface for a Cache. Supports clearing of the cache and monitoring of the size and volume of the cache.

The following service also exports management interfaces:

Class

Description

CacheEvictionMXBean (org.coconut.cache.service.eviction)

Management interface for the eviction service.

CacheExpirationMXBean (org.coconut.cache.service.expiration)

Management interface for the expiration service.

CacheLoadingMXBean(org.coconut.cache.service.loading)

Management interface for the loading service.

CacheStatisticsMXBean(org.coconut.cache.service.statistics)

Management interface for the statistics service.

Using the management service

JMX management is disabled by default and must be enabled by calling CacheManagementConfiguration#setEnabled(true).

Example: Creating a new cache where JMX management is enabled and the default MXBeans are registered with the platform MBeanServer. (Full src)

A screenshot from JConsole after having connected to the JVM running the example.


The default domain that all the cache MBeans are registered under is org.coconut.cache. However, is is easy to register the beans under another domain, for example, if you are embedding the cache and want to expose it under your own domain name.

By default all MBeans are registered with the Platform MbeanServer. This can be changed by calling setMBeanServer().

Exposing custom services

It is easy to expose custom developed services via JMX.

Example: A CacheLoader (+ startup code) that exposes the number of loads as a MBean (Full src)

A screenshot from JConsole after having connected to the JVM running the example.

The following user provided objects will be registered as a MBean if they implement ManagedLifecycle

Class

Description

CacheEvictionConfiguration#setPolicy

The Replacement configuration of the cache.

CacheExpirationConfiguration#setExpirationFilter

The Expiration filter for the cache.

CacheLoadingConfiguration#setLoader

The cache loader.

CacheLoadingConfiguration#setExpirationFilter

The refresh filter for the cache.

CacheWorkerConfiguration#setWorkerManager

The cache's worker manager

Any object that is registered with CacheServiceManagerConfiguration#add(Object o and implements ManagedLifecycle can register MBeans.
Example: A service that clears the cache at regular intervals.

Advanced configuration

For greater control of how services are registered with MBeanServer you can override the default Registrant configured for the cache.
A registrant is basically just a Visitor that visits each object and registers it with the MBeanServer. It can be used, for example, to choose whether or not a component should be registered with MBeanServer or what ObjectName it should be registered with.

Example:

Labels
  • None