41 How to Manage Custom MBeans Within the Cluster

In addition to managing Coherence with JMX, Coherence provides the ability to manage and monitor custom MBeans (that is, application-level MBeans) within the Coherence JMX Management and Monitoring framework. This enables you to manage or monitor any application-level MBean from any JVM, node, or end-point within the cluster.

In addition to the standard Coherence managed object types, any dynamic or standard MBean type may be registered using the com.tangosol.net.management.Registry interface.

Custom MBean Configuration

Coherence can be configured to load platform and standard MBeans on connection to the cluster. This allows administrators and support personnel to update and view system and application information from all nodes in a cluster from a single location. This feature also eliminates the need for JMX programs to connect to multiple sources to gather information.

How to Add a Standard MBean to Coherence

The following instructions describe how to add a standard MBean to Coherence:

  1. Create a standard MBean.

  2. Add a standard MBean Class or JAR to the Coherence classpath (including central management node).

  3. Create a custom MBean XML configuration file (see "Creating an MBean XML Configuration File").

  4. Modify node startup scripts to reference custom-mbean.xml (see "Enabling a Custom MBean Configuration File".

How to Programmatically Add a Standard MBean to Coherence

Example 41-1 illustrates sample code that programmatically adds a standard MBean to Coherence.

Example 41-1 Adding a Standard MBean to Coherence Programatically

Registry    registry = CacheFactory.ensureCluster().getManagement();
Custom      bean     = new Custom();
String      sName    = registry.ensureGlobalName("type=Custom");

registry.register(sName, bean);

Using Static MBean Names

Example 41-1 uses the ensureGlobalName method when adding a custom MBean to Coherence. The method is used to add the nodeId=... portion to the end of the MBean's ObjectName. This is required in order to have unique names on the centralized MBean server. If an application requires static MBean names, use a MBean query to add MBeans from a local MBean server to the Coherence management system. This will create the MBeans on the managed node with the static name and then add the ,nodeId=... portion to the name of the MBean when aggregating on the managing node.

To use static MBean names:

  1. Register the MBeans on the local MBean server of the managed node using the registerMBean or createMBean methods prior to joining the cluster. See the MBeanServer interface JavaDocs for information on using these methods:


  2. Use the MBeanHelper.findMBeanServer() method to obtain the same MBean server that Coherence is using.

  3. Configure the custom-mbeans.xml file to query the newly registered MBeans. See "Configuring JMX MBeans".


Refer to the Sun documentation below to ensure an environment is set up properly to access the local MBean server.


How to Add a the Results of a JMX Query to Coherence

The following instructions describe how to add the results of a JMX query to Coherence.

  1. Create a custom MBean XML file (see "Creating an MBean XML Configuration File").

  2. Configure node startup script to include JMX MBean Server

  3. Configure a node startup script to reference custom-mbean.xml (see "Enabling a Custom MBean Configuration File").

Figure 41-1 illustrates an example of running a JMX Query in JConsole.

Figure 41-1 JMX Query Run in JConsole

This figure is described in the text