ATG Management using JMX

11 12 2007

Java Management Extensions (JMX) technology makes it possible for managing and monitoring applications. You can now use it to manage components in nucleus. This article goes into a little background about the JMX support in ATG.

The first thing you’ll need to know is that you’ll need to start the DAF.Management module to use any of the features described here. This modules includes some of the basic components needed to delivery management and monitoring using JMX and JMX-Remote. All the components support JMX can be found under the /atg/management context. Here’s a short list of some of the foundation components. 

/atg/management/MBeanServer

This component implements the javax.management.interface and provides the foundation for JMX support. It contains methods necessary for registering, creating and querying MBeans as well accessor methods for invoking operations on MBeans and accessing properties.

/atg/management/remote/JMXConnector

This component implements the javax.management.remote.JMXConnectorinterface. It provides the client side of a JMX remote connection.

/atg/management/remote/JMXConnectorServer

This component extends the javax.management.remote.JMXConnectorServer class. It provides the server side of the JMX remote connection.

To access ATGs MBean server remotely using your favorite management console (I use the open-source console MC4J) use the following JMX service URL replacing hostname and portas appropriate. Note the connection defaults to using RMI.

service:jmx:rmi://<hostname>/jndi/rmi://<hostname>:<port>/atg/management/remote/JMXConnectorServer

So that basically covers the foundations. But ATG contains some additional support to make instrumenting nucleus components. Let’s describe some of this support.

Say for example you’ve created a nucleus component that you’ve instrumented as an MBean and want to register it with ATG’s MBean server. To do this add your component to the /atg/management/Initial.initialServices property. For example say you instrumented the following component /acme/HelloWord the in order to register it with the MBean server just place the following property file in your config path.

# /atg/management/Initial
initialServices+=\
  /acme/HelloWorld

You’ll notice that ATG has already registered a number of its foundation components as MBeans. For example the /atg/dynamo/service/jdbc/JTDataSource and the /atg/dynamo/service/SMTPEmail components are already registered with the MBean server as well as a whole host of other ones.

If you don’t want to write a line of java code in order to instrument a nucleus component you’ve written but still want to register it with the MBean server then there’s an easy technique to support this which I’ll talk about briefly. What you’ll need to do is create an XML file that provided a model MBean info for your component. This XML should follow the mbeaninfo DTD and should be placed in the same directory as the nucleus components property file. The name of the file should take on the following form <componentName>MBeanInfo.xml. As an example the following xml instruments the /VMSystem component in nucleus.

VMSystemMBeanInfo.xml

<?xml version="1.0"?> 
<!DOCTYPE mbeanInfo 
PUBLIC "-//Art Technology Group, Inc.//DTD MBean Info//EN" 
          "http://www.atg.com/dtds/management/mbeaninfo_1.0.dtd"> 
<mbeanInfo type="model" className="atg.nucleus.VMSystem" description="This provides facilities for monitoring the status of the VM"> 
<attributeInfos> 
<attributeInfo name="freeMemory" description="Free memory available to JVM" type="long" readable="true" writable="false" is="false"> 
      <descriptor> 
 <fields> 
<field name="name">freeMemory</field> 
<field name="descriptorType">attribute</field> 
<field name="displayName">freeMemory</field> 
<field name="getMethod">getFreeMemory</field> 
 </fields> 
      </descriptor> 
</attributeInfo> 
<attributeInfo name="totalMemory" description="Total memory available to JVM" type="long" readable="true" writable="false" is="false"> 
      <descriptor> 
 <fields> 
<field name="name">totalMemory</field> 
<field name="descriptorType">attribute</field> 
<field name="displayName">totalMemory</field> 
<field name="getMethod">getTotalMemory</field> 
 </fields> 
      </descriptor> 
</attributeInfo> 
</attributeInfos> 
<operationInfos> 
<operationInfo name="stopVM" description="Calls System.exit(0) to immediately terminate the JVM. DANGEROUS!" type="void" impact="action"> 
      <descriptor> 
 <fields> 
<field name="name">stopVM</field> 
<field name="descriptorType">operation</field> 
   <field name="role">operation</field> 
 </fields> 
      </descriptor> 
</operationInfo> 
<operationInfo name="getFreeMemory" description="Free memory available to JVM" type="long" impact="info"> 
      <descriptor> 
 <fields> 
   <field name="name">getFreeMemory</field> 
<field name="descriptorType">operation</field> 
   <field name="role">getter</field> 
 </fields> 
      </descriptor> 
</operationInfo> 
<operationInfo name="getTotalMemory" description="Total memory available to JVM" type="long" impact="info"> 
      <descriptor> 
 <fields> 
<field name="name">getTotalMemory</field> 
<field name="descriptorType">operation</field> 
   <field name="role">getter</field> 
 </fields> 
      </descriptor> 
</operationInfo> 
<operationInfo name="gc" description="Performs a JVM GC request" type="void" impact="action"> 
      <descriptor> 
 <fields> 
<field name="name">gc</field> 
<field name="descriptorType">operation</field> 
   <field name="role">operation</field> 
 </fields> 
      </descriptor> 
</operationInfo> 
<operationInfo name="runFinalization" description="Runs outstanding object finalizers" type="void" impact="action"> 
      <descriptor> 
 <fields> 
<field name="name">runFinalization</field> 
<field name="descriptorType">operation</field> 
   <field name="role">operation</field> 
 </fields> 
      </descriptor> 
</operationInfo> 
</operationInfos> 
  <descriptor> 
    <fields> 
<field name="name">atg.nucleus.VMSystem</field> 
<field name="descriptorType">mbean</field> 
<field name="displayName">VMSystem</field> 
    </fields> 
  </descriptor> 
</mbeanInfo>

The final thing you’ll need to do is register it with the MBean server as described above and poof you’re done. For more information on JMX technology see the following:

Advertisements

Actions

Information

8 responses

4 08 2008
Vivek

Hello:
This worked perfectly fine except when I try to access my MBean from JConsole, I am seeing all my attributes as “unavailable” and when I try to access them, I see the following on my Dynamo logs. I am not sure what am I doing wrong here.

18:43:36,171 ERROR [STDERR] Aug 4, 2008 6:43:36 PM RequiredModelMBean getAttributes(String[])

SEVERE: Failed to get “failedRequests”: javax.management.MBeanException: Operation getFailedRequests not in ModelMBeanInfo

18:43:36,171 ERROR [STDERR] Aug 4, 2008 6:43:36 PM RequiredModelMBean getAttributes(String[])

SEVERE: Failed to get “requestFrequency”: javax.management.MBeanException: Operation getRequestFequency not in ModelMBeanInfo

18:43:36,171 ERROR [STDERR] Aug 4, 2008 6:43:36 PM RequiredModelMBean getAttributes(String[])

4 08 2008
drakcira

Check your components MBeanInfo.xml file. From the sounds of the error message it doesn’t sound like you’ve exposed those methods in the file correctly.

5 08 2008
Vivek

                <attributeInfo name="requestFrequency"
                        description="Frequency of requests received per second by the component"
                        type="long" readable="true" writable="false" is="false">

                        <descriptor>
                                <fields>
                                        <field name="name">requestFrequency</field>
                                        <field name="descriptorType">attribute</field>

                                        <field name="displayName">requestFrequency</field>
                                        <field name="getMethod">getRequestFequency</field>
                                </fields>
                        </descriptor>

                </attributeInfo>

                <attributeInfo name="timePerRequest"
                        description="Average Time taken by the component to handle a single request"
                        type="long" readable="true" writable="false" is="false">

                        <descriptor>
                                <fields>
                                        <field name="name">timePerRequest</field>
                                        <field name="descriptorType">attribute</field>

                                        <field name="displayName">timePerRequest</field>
                                        <field name="getMethod">getTimePerRequest</field>
                                </fields>
                        </descriptor>

                </attributeInfo>

                <attributeInfo name="totalRequests"
                        description="Total number of requests handled by the component since last call to reset()"
                        type="long" readable="true" writable="false" is="false">

                        <descriptor>
                                <fields>
                                        <field name="name">totalRequests</field>
                                        <field name="descriptorType">attribute</field>

                                        <field name="displayName">totalRequests</field>
                                        <field name="getMethod">getTotalRequests</field>
                                </fields>
                        </descriptor>

                </attributeInfo>
                
                <attributeInfo name="failedConnections"
                        description="Number of connections that failed compared to total connections made to the external system"
                        type="long" readable="true" writable="false" is="false">

                        <descriptor>
                                <fields>
                                        <field name="name">failedConnections</field>
                                        <field name="descriptorType">attribute</field>

                                        <field name="displayName">failedConnections</field>
                                        <field name="getMethod">getFailedConnections</field>
                                </fields>
                        </descriptor>

                </attributeInfo>

                <attributeInfo name="connectionFrequency"
                        description="Frequency of connection made per second by this component"
                        type="long" readable="true" writable="false" is="false">

                        <descriptor>
                                <fields>
                                        <field name="name">connectionFrequency</field>
                                        <field name="descriptorType">attribute</field>

                                        <field name="displayName">connectionFrequency</field>
                                        <field name="getMethod">connectionFequency</field>
                                </fields>
                        </descriptor>

                </attributeInfo>

5 08 2008
drakcira

From the looks of the xml you posted all you seem to have added are attributes. It seems you haven’t exposed any operations. You need to add operationInfo elements to your mBeanInfo.xml file for each of the public methods you intend on exposing in the mBean.

25 03 2011
David Harvey

As drakcira points out, you need to add operations corresponding to the attributes if you do the JMX integration this way. However there are a couple of bugs in the way ATG deals with this XML

1) Operations defined with more than one argument in the …MBeanInfo.xml aren’t handled properly – you end up with only one argument.

2) Notifications defined in the XML don’t appear at all in a JMX client (e.g. JConsole)

Solved both of these problems by using the alternative way of defining an MBean to the JMX server: for a component ‘X’, define an interface ‘XMbean’, add getter/setter pairs for things you want to expose as attributes, methods for operations. Have X implement the MBean interface, then declare your component to ATG in the management initial services as described above.

To add notifications, have your component implement javax.management.NotificationEmitter. You can delegate most of the methods to an instance of javax.management.NotificationBroadcastSupport, which saves having to manage your own collections of listeners.

Introspection, and the JBoss MBean server, take care of the rest.

3 04 2013
download ftl

You need to be a part of a contest for one of the highest quality sites on the web. I most certainly will highly recommend this site!

24 06 2013
Gordon

I am wondering if you this running on a more recent install of ATG? Under JBoss EAP 5.1.2 and ATG 10.1.2 as soon as I add the DAF.Management module into the module path I am getting an issue with ClassLoaders. It prevents all of the ATG based modules from running in any usable way. Has anyone experienced this before?

14:09:29,275 ERROR [AbstractKernelController] Error installing to Instantiated: name=jboss.jacc:id=”vfsfile:/opt/jboss/versions/EnterprisePlatform-5.1.2/jboss-eap-5.1/jboss-as/server/app1/depl
oy/Estore.ear/atg_admin.war/”,parent=”Estore.ear”,service=jacc state=Described mode=Manual requiredState=Configured
javax.management.InstanceNotFoundException: jboss.classloader:id=”vfsfile:/opt/jboss/versions/EnterprisePlatform-5.1.2/jboss-eap-5.1/jboss-as/server/app1/deploy/Estore.ear/a
tg_admin.war/”
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBean(DefaultMBeanServerInterceptor.java:1094)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getClassLoader(DefaultMBeanServerInterceptor.java:1458)
at com.sun.jmx.mbeanserver.JmxMBeanServer.getClassLoader(JmxMBeanServer.java:1289)
at org.jboss.system.server.jmx.LazyMBeanServer.getClassLoader(LazyMBeanServer.java:448)
at org.jboss.system.ServiceCreator.installPlainMBean(ServiceCreator.java:205)

5 08 2013
dermawand review

Your way of telling everything in this article is genuinely good, all be
able to without difficulty know it, Thanks
a lot.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: