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 is with this article: "Getting Started with Java Management Extensions (JMX): Developing Management and Monitoring Solutions".
To manage Coherence using JMX:
Add JMX libraries to the Coherence classpath (if necessary)
Access Coherence MBeans to view and manipulate them using a JMX client of your choice
Note:
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.
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 from the JMX download Web site and add them to the classpath.
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 and the tangosol.coherence.management.remote
Java system property on all cluster nodes:
-Dtangosol.coherence.management=all -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.
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 subelements control the behavior of the Management Framework:
Table 22-1 Elements that Control the Behavior of the Management Framework
Element | Description |
---|---|
allow-remote-management |
Specifies whether this cluster node will register its MBeans in a remote |
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 |
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, see Appendix H, "Operational Configuration Elements."
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 com.tangosol.net.management.Registry
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
When the Coherence command line application has started, enter jmx
8082
and press return. 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:
Figure 22-1 Viewing the HttpAdapter Web Application in a Browser
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
When 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:
Figure 22-2 Using the JConsole Utility to Display and Manipulate Coherence MBeans
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.
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.
Table 22-2 describes optional properties that can be used for JMX RMI configuration:
Table 22-2 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 |
tangosol.coherence.management.remote.registryport |
The port used for the JMX RMI registry. Default is |
tangosol.coherence.management.remote.connectionport |
The port used for the JMX RMI connection. Default is |
Table 22-3 describes optional properties that can be used for HTTP configuration. (NOTE: This flag requires Sun's JMX RI in the classpath):
Table 22-3 Optional Properties that can be used for Http Configuration
Property | Description |
---|---|
tangosol.coherence.management.remote.httpport |
The port used for the HTTP connection. Default is |
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
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
Table 22-4 describes valid values for this property.
Table 22-4 Values for the tangosol.coherence.management.refresh.policy Property
Setting | Description |
---|---|
refresh-ahead |
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. |
refresh-expired (default) |
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. |