How to Manage Coherence Using JMX

Skip to end of metadata
Go to start of metadata

Coherence includes facilities for managing and monitoring Coherence resources by using the Java Management Extensions (JMX) API. JMX is a Java standard for managing and monitoring Java applications and services. It defines a management architecture, design patterns, APIs, and services for building general solutions to manage Java-enabled resources. This section assumes familiarity with JMX terminology. If you are new to JMX, you should start with this article.

To manage Coherence using JMX:

JMX support
Coherence Enterprise Edition and higher support clustered JMX, allowing access to JMX statistics for the entire cluster from any member. Coherence Standard Edition provides only local JMX information.

Adding JMX libraries to the Coherence classpath

To manage a Coherence cluster using JMX, ensure that you have the necessary JMX 1.0 or later classes (javax.management.*) in the classpath of at least one Coherence cluster node, known as an MBeanServer host. The cluster nodes that are not MBeanServer hosts will be managed by the MBeanServer host(s) by using the Coherence Invocation service.

All compliant Java SE 5.0 JREs and Java EE application servers supply a JMX 1.0 or later implementation; therefore, if the MBeanServer host node is running within a Java SE 5.0 JVM or Java EE application server, no additional actions are necessary. For standalone applications running within a pre-Java SE 5.0 JVM, you can download the necessary JMX libraries here and add them to the classpath.

Configuring the Coherence Management Framework

In most cases, you can enable JMX management simply by setting the tangosol.coherence.management Java system property on all Coherence cluster nodes that are acting as MBeanServer hosts:

-Dtangosol.coherence.management=all

and the tangosol.coherence.management.remote Java system property on all cluster nodes:

-Dtangosol.coherence.management.remote=true

The use of dedicated JMX cluster members is a common pattern. This approach avoids loading JMX software into every single cluster member, while still providing fault-tolerance should a single JMX member run into issues. Setting tangosol.coherence.management to "all" on nodes that are not acting as MBeanServer hosts, will consume capacity (~3-5%) when the node starts and increase the time required for the node to join the cluster. Therefore, it is recommended to set the value to "none" or "local-only" for remotely managed nodes.

In general, the Coherence Management Framework is configured by the management-configuration operational configuration element in the Coherence Operational Configuration deployment descriptor (tangosol-coherence.xml). The following sub-elements control the behavior of the Management Framework:

Element Description
default-domain-name Specifies the name of the JMX domain used to register MBeans exposed by the Coherence Management Framework.
managed-nodes Specifies whether a cluster node's JVM has an in-process MBeanServer and if so, whether the node allows management of other nodes' managed objects. Valid values are none, local-only, remote-only and all. For example, if a node has an in-process MBeanServer and you would like this node to manage other nodes' MBeans, then set this attribute to all.
allow-remote-management Specifies whether this cluster node will register its MBeans in a remote MBeanServer(s).
read-only Specifies whether the MBeans exposed by this cluster node allow operations that modify run-time attributes.

For additional information on each of these attributes, please see the Operational Configuration Elements.

A note about Java 1.4
Starting with Coherence 3.4, Coherence monitors the Java Platform MBeans which makes it possible to see JVM statistics from across the cluster alongside the other statistics tracked by Coherence. This feature is on by default, as most customer deployments are on Java 1.5 and above. However the following exception may be thrown on Java 1.4 and Coherence 3.4:
The MBean query feature requires a local MBeanServer
   java.lang.NoClassDefFoundError: javax/management/MalformedObjectNameException

This feature can be disabled for 1.4 JVMs that don't have Platform MBeans available. Set the following system property:

  -Dtangosol.coherence.management.jvm.all=false

Accessing Coherence MBeans

After configuring the Coherence Management Framework and launching one or more Coherence cluster nodes (at least one being an MBeanServer host) you can view and manipulate the Coherence MBeans registered by all cluster nodes using standard JMX API calls. See the Javadoc for the ${xhtml} class for details on the various MBean types registered by Coherence clustered services.

Coherence ships with two examples that demonstrate accessing Coherence MBeans by using JMX. The first uses the HttpAdapter, shipped as part of the JMX reference implementation (jmxtools.jar). To run the example on a pre-Java SE 5.0 JVM, start the Coherence command line application using the following command on Windows (note that it is broken up into multiple lines here only for formatting purposes; this is a single command entered on one line):


java -cp jmxri.jar;jmxtools.jar;coherence.jar 
     -Dtangosol.coherence.management=all
     -Dtangosol.coherence.management.remote=true 
      com.tangosol.net.CacheFactory

On Unix:


java -cp jmxri.jar:jmxtools.jar:coherence.jar
     -Dtangosol.coherence.management=all
     -Dtangosol.coherence.management.remote=true 
      com.tangosol.net.CacheFactory

Once the Coherence command line application has started, type jmx 8082 and press Enter. This starts the HttpAdapter on http://localhost:8082 in the cluster node's JVM and makes the cluster node an MBeanServer host. You can now use the HttpAdapter web application to view and manipulate Coherence MBeans registered by all cluster nodes:

Alternatively, you can run this example with the Sun Java SE 5.0 JVM and use the JConsole utility included with the Sun Java SE 5.0 JDK to view and manipulate Coherence MBeans. To do so, start the Coherence command line application using the following command (note that it is broken up into multiple lines here only for formatting purposes; this is a single command entered on one line):


java -Dcom.sun.management.jmxremote
     -Dtangosol.coherence.management=all
     -Dtangosol.coherence.management.remote=true 
     -jar coherence.jar

Once the Coherence command line application has started, launch the JConsole utility (located in the bin directory of the Sun Java SE 5.0 JDK distribution) and open a new connection to the JVM running the Coherence command line application:

!

The second example is a JSP page (JmxCacheExplorer.jsp) that displays basic information on each running Coherence cache using JMX API calls. You can find this example in the examples/jsp/explore directory under the root of your Coherence installation.

Additional JMX examples may be found on the Coherence Forums.

Using Coherence MBeanConnector to Access MBeans

Coherence ships with a program to launch a cluster node as a dedicated MBeanServer host. This program provides access to Coherence MBeans by using the JMX Remote API using RMI or the HTTP server provided by Sun's JMX RI. The RMI and HTTP ports are user-configurable, allowing for access through a firewall. The server is started using the following command (note that it is broken up into multiple lines here only for formatting purposes; this is a single command entered on one line):


java -Dtangosol.coherence.management=all
     -cp coherence.jar com.tangosol.net.management.MBeanConnector [-http -rmi]

To allow access by using JMX RMI, include the -rmi flag. To allow access by using HTTP and a web browser, include the -http flag. Both flags may be included; however at least one must present for the node to start.

The following table describes optional properties that can be used for JMX RMI configuration:

Property Description
tangosol.coherence.management.remote.host The host that the JMX server will bind to. Default is localhost. (NOTE: on Redhat Linux this may have to be changed to the host name or IP address)
tangosol.coherence.management.remote.registryport The port used for the JMX RMI registry. Default is 9000.
tangosol.coherence.management.remote.connectionport The port used for the JMX RMI connection. Default is 3000.

The following table describes optional properties that can be used for HTTP configuration. (NOTE: This flag requires Sun's JMX RI in the classpath):

Property Description
tangosol.coherence.management.remote.httpport The port used for the HTTP connection. Default is 8888.

To connect by using JConsole with default settings use the following command:


jconsole service:jmx:rmi://localhost:3000/jndi/rmi://localhost:9000/server

To connect by using HTTP with default settings use the following URL:


http://localhost:8888

Configuring Management Refresh Methodology

The current release of Coherence offers several ways to reduce the latency of management information. Refresh policy was introduced in Coherence 3.3 to allow for optimization of the retrieval of information from remotely managed nodes. Two new settings were added to help integrators and administrators configure the refresh policy.

The tangosol.coherence.management.refresh.expiry property specifies the minimum time interval between the remote retrieval of management information from remote nodes.


-Dtangosol.coherence.management.refresh.expiry

The value of this element must be in the following format:

[\d]+[[.][\d]+]?[MS|ms|S|s|M|m|H|h|D|d]?

where the first non-digits (from left to right) indicate the unit of time duration:

  • MS or ms (milliseconds)
  • S or s (seconds)
  • M or m (minutes)
  • H or h (hours)
  • D or d (days)

If the value does not contain a unit, a unit of milliseconds is assumed.

The tangosol.coherence.management.refresh.policy property defines the refresh policy for the MBean.


-Dtangosol.coherence.management.refresh.policy   

Valid values for this property are:

Setting Description
refresh-expired This setting has the same functionality as in pre-3.4 Coherence releases. Each MBean will be refreshed from the remote node when it is accessed and the expiry delay has passed from the last refresh. This setting is best used when MBeans are accessed in a random pattern.
refresh-ahead (default) MBeans are refreshed before they are requested based on prior usage patterns after the expiry delay has passed. This setting can reduce latency of the management information with a minor increase in network consumption. This setting is best when MBeans are accessed in a repetitive/programmatic pattern.
refresh-behind Each MBean will be refreshed after the data is accessed. This method ensures optimal response time. However, the information returned will be offset by the last refresh time.
Labels:
jmx jmx Delete
mbeans mbeans Delete
reporter reporter Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.