Skip navigation links

Oracle® Coherence Java API Reference
Release 3.7.0.0

E18683-01


com.tangosol.net.management
Class MBeanHelper

java.lang.Object
  extended by com.tangosol.util.Base
      extended by com.tangosol.net.management.MBeanHelper

Direct Known Subclasses:
MBeanConnector

public abstract class MBeanHelper
extends Base

Helper class providing various functionality related to aggregation of attributes and methods exposed by Coherence JMX framework MBeans.

Since:
Coherence 3.3
Author:
gg 2007/01/02

Constructor Summary
MBeanHelper()
           

 

Method Summary
static double calculateAverage(javax.management.MBeanServer server, java.lang.String sPattern, java.lang.String sAttribute)
          Calculate the average of the attribute values across all the MBeans with a given name pattern.
static int compareKeyList(javax.management.ObjectName oname1, javax.management.ObjectName oname2)
          Compare two global MBean names forcing numeric comparison of the node ID while using string comparison on all other key properties.
static MBeanReference ensureSingletonMBean(java.lang.String sName)
          Ensure that there is an instance of a local MBean of the specified type registered with the default MBeansServer.
static javax.management.MBeanServer findMBeanServer()
          Find an MBeanServer that Coherence MBeans are registered with.
static javax.management.MBeanServer findMBeanServer(java.lang.String sDefaultDomain)
          Find an MBeanServer that has the specified default domain name.
static java.lang.String getDefaultDomain()
          Return the the default domain name as configured in the Coherence operational configuration descriptor ("default-domain-name" element).
static MBeanServerFinder getServerFinder()
          Return the the MBeanServerFinder as configured in the Coherence operational configuration descriptor ("server-factory" element).
static boolean hasDomain(java.lang.String sCanonical)
          Return true if the Canonical name is prefixed with the domain name.
static boolean isQuoteRequired(java.lang.String s)
          Determine if the string requires quotes.
static java.lang.String quote(java.lang.String s)
          Create an escape-sequence string that allows for special characters to be included in a JMX ObjectName.
static java.lang.String quoteCanonical(java.lang.String sCanonical)
          Return a quoted KeyPropertyString or a quoted canonical name.
static void registerQueryMBeans(java.lang.String sMBeanServerDomain, java.lang.String sQuery, java.lang.String sPrefix, Registry registry)
          Find all MBeans matching to the specified query at a local MBeanServer and register them with the specified Registry.
static java.lang.Object startHttpConnector(int nPort, javax.management.MBeanServer mbs)
          Start a com.sun.jdmk.comm.HtmlAdaptorServer, which is a part of the Sun JMX reference implementation.
static javax.management.remote.JMXConnectorServer startRmiConnector(java.lang.String sHost, int nRegPort, int nConPort, javax.management.MBeanServer mbs, java.util.Map mapEnv)
          Start a JMXConnectorServer.
static java.lang.String stripDomain(java.lang.String sCanonical)
          Remove the domain prefix from the canonical name if one exists.
static java.lang.String unquote(java.lang.String s)
          Convert a string returned from the quote(java.lang.String) method to the original string.

 

Constructor Detail

MBeanHelper

public MBeanHelper()

Method Detail

getDefaultDomain

public static java.lang.String getDefaultDomain()
Return the the default domain name as configured in the Coherence operational configuration descriptor ("default-domain-name" element).
Returns:
the default domain name

getServerFinder

public static MBeanServerFinder getServerFinder()
Return the the MBeanServerFinder as configured in the Coherence operational configuration descriptor ("server-factory" element).
Returns:
the MBeanServerFinder (null if none was configured)

findMBeanServer

public static javax.management.MBeanServer findMBeanServer()
Find an MBeanServer that Coherence MBeans are registered with.
Returns:
an existing or a new MBeanServer with the default domain name as configured in the Coherence operational configuration descriptor

findMBeanServer

public static javax.management.MBeanServer findMBeanServer(java.lang.String sDefaultDomain)
Find an MBeanServer that has the specified default domain name. If the domain name is not specified, any existing MBeanServer is choosen.
Parameters:
sDefaultDomain - the default domain name
Returns:
an existing or a new MBeanServer with the specified default domain name

registerQueryMBeans

public static void registerQueryMBeans(java.lang.String sMBeanServerDomain,
                                       java.lang.String sQuery,
                                       java.lang.String sPrefix,
                                       Registry registry)
Find all MBeans matching to the specified query at a local MBeanServer and register them with the specified Registry.

Note: the MBeanServer that the query runs against is not necesserily the one used by the Registry.

Parameters:
sMBeanServerDomain - the default domain of the MBeanServer where the query should be executed. If this value is empty or null the Coherence default domain is used
sQuery - a JMX query string that will be used to find the MBeans
sPrefix - a target location to prepend to converted MBean names
registry - a Registry to register the JMX query results with

calculateAverage

public static double calculateAverage(javax.management.MBeanServer server,
                                      java.lang.String sPattern,
                                      java.lang.String sAttribute)
Calculate the average of the attribute values across all the MBeans with a given name pattern. The attribute type should be a Number and will be treated as Java double values.
Parameters:
server - the MBeanServer
sPattern - the name pattern
sAttribute - the attribute name
Returns:
an average value

ensureSingletonMBean

public static MBeanReference ensureSingletonMBean(java.lang.String sName)
Ensure that there is an instance of a local MBean of the specified type registered with the default MBeansServer.
Parameters:
sName - an MBean name
Returns:
the MBeanReference for the registered MBean

startRmiConnector

public static javax.management.remote.JMXConnectorServer startRmiConnector(java.lang.String sHost,
                                                                           int nRegPort,
                                                                           int nConPort,
                                                                           javax.management.MBeanServer mbs,
                                                                           java.util.Map mapEnv)
Start a JMXConnectorServer. This method is used to expose the specified MBeanServer to external agents (such as JConsole) using RMI.

This method also allows for the RMI functionality to emulate the JConsole remote connection security.

For the list of relevant system properties please see:

Java 1.5 Agent Documentation, Java 1.6 Agent Documentation

Parameters:
sHost - host to bind to
nRegPort - port used for the JMX RMI registry
nConPort - port used for the JMX RMI connection
mbs - MBeanServer that contains Coherence MBeans
mapEnv - a set of attributes to control the new connector server's behavior
Returns:
a JMXConnectorServer that has been started
See Also:
JMXConnectorServerFactory

startHttpConnector

public static java.lang.Object startHttpConnector(int nPort,
                                                  javax.management.MBeanServer mbs)
Start a com.sun.jdmk.comm.HtmlAdaptorServer, which is a part of the Sun JMX reference implementation. It is being created via reflection to avoid a runtime dependency to this library.
Parameters:
nPort - port to bind the HTTP server to
mbs - MBeanServer that this HTTP server will expose
Returns:
an HtmlAdaptorServer that has been started

quote

public static java.lang.String quote(java.lang.String s)
Create an escape-sequence string that allows for special characters to be included in a JMX ObjectName.
Parameters:
s - the string to be quoted
Returns:
the quoted string
Since:
Coherence 3.4

unquote

public static java.lang.String unquote(java.lang.String s)
Convert a string returned from the quote(java.lang.String) method to the original string.
Parameters:
s - the string to be unquoted
Returns:
the unquoted string
Throws:
java.lang.IllegalArgumentException - if the passed string could not have been returned by the quote(java.lang.String) method; for instance if it does not begin and end with a quote (")
Since:
Coherence 3.4

isQuoteRequired

public static boolean isQuoteRequired(java.lang.String s)
Determine if the string requires quotes.
Parameters:
s - the string to be quoted
Returns:
true iff the quote(java.lang.String) method needs to be called
Since:
Coherence 3.4

quoteCanonical

public static java.lang.String quoteCanonical(java.lang.String sCanonical)
                                       throws javax.management.MalformedObjectNameException
Return a quoted KeyPropertyString or a quoted canonical name.
Parameters:
sCanonical - a string to be quoted
Returns:
a quoted and escape-sequence string
Throws:
javax.management.MalformedObjectNameException - if the name is invalid
Since:
Coherence 3.4

hasDomain

public static boolean hasDomain(java.lang.String sCanonical)
Return true if the Canonical name is prefixed with the domain name.
Parameters:
sCanonical - a canonical MBean name or key property list
Returns:
true iff the name contains the domain prefix
Since:
Coherence 3.6

stripDomain

public static java.lang.String stripDomain(java.lang.String sCanonical)
Remove the domain prefix from the canonical name if one exists.
Parameters:
sCanonical - a canonical MBean name or key property list
Returns:
the canonical name stripped of the domain prefix
Since:
Coherence 3.6

compareKeyList

public static int compareKeyList(javax.management.ObjectName oname1,
                                 javax.management.ObjectName oname2)
Compare two global MBean names forcing numeric comparison of the node ID while using string comparison on all other key properties. For example, the following order is enforced:
   Coherence:type=Node,nodeId=2 < Coherence:type=Node,nodeId=10
   Coherence:type=Cache,nodeId=20 < Coherence:type=Node,nodeId=1
 
If the key sets are different the lexicographical comparison is used.
Parameters:
oname1 - the first ObjectName to be compared
oname2 - the second ObjectName to be compared
Returns:
a negative integer, zero, or a positive integer as the first name is less than, equal to, or greater than the second one
Since:
Coherence 3.6

Skip navigation links

Oracle® Coherence Java API Reference
Release 3.7.0.0

E18683-01


Copyright © 2000, 2011, Oracle and/or its affiliates. All rights reserved.