An extended ProActive JMX Connector

36.1. Overview of JMX - Java Management eXtention

JMX Java Management Extensions is a Java technology providing tools and APIs for managing and monitoring Java applications and their resources. Resources are represented by objects called MBeans (for Managed Bean).

This figure shows the JMX 3 levels architecture and the integration of the ProActive JMX Connector.

Figure 36.1.  This figure shows the JMX 3 levels architecture and the integration of the ProActive JMX Connector.


JMX defines a 3 layers management architecture :

  • The instrumentation level contains MBeans and their manageable resources. A Mbean is a Java Object implementing a specific interface and pattern. They contain and define the manageable attributes, the management operations that can be performed onto resources and the notifications that can be emitted by the resources.

  • The Agent Level The agent acts as a MBeans containers (the MBeanServer) and controls them. This level represents the main part in the JMX specification : because it give access to the managed resources to the clients, the agent is the architecture central point.

  • The Distributed Level The distributed Level enables the remote management of Java applications. In order to access remotely to managed application, JMX specification defines two type of remote access : protocol adaptors and protocol connectors. Connectors allow a manager to perform method calls onto a distant agent's MBeanServer (for example RMI). Adaptors are components that ensure binding between a specific protocol (for example for SNMP or Http) and thre managed resources. Indeed, they enable Mbeans to be accessed by existing approches.

36.2. Asynchronous ProActive JMX connector

The JMX technology defines a connector based on RMI. The RMI connector allows the manager to connect to an MBean in a MBeanServer from a remote location and performs operations on it.

We defined a ProActive Connector according to the JMX Remote API JSR 160 that enables asynchronous remote access to a JMX Agent thanks to ProActive. This connector is based on a call via an active object. When invoking the standard API specification methods, the access to the managed application is synchronous, because the JMX remote API provides non-reifiable methods. For example, the method invoke that allow to invoke a Mbean's method throws exceptions :

				public Object invoke(ObjectName name, String
				operationName, Object[] params, String[] signature)
				throws InstanceNotFoundException, MBeanException,
				ReflectionException, IOException;
			

We extended the API in order to provide asynchronous acces thanks to additionnal reifiable methods. The additional invoke method looks like :

				public GenericTypeWrapper invokeAsynchronous(ObjectName
				name, String operationName, Object[] params, String[]
				signature) (method names connector ( non reifiable
				methods ).
			

Thus, all requests sent to the MBean are put in the active object requests queue and a future object is returned to the client.

36.3. How to use the connector ?

The ProActive connector allows you yo connect to an MBean in an MBean server to a remote location, and perform operations on it, exactly as if the operations were being performed locally.

To perform such a call, you have first to enable the server connector on the application you wish to manage. This is simply done by adding one line of code in the application to be managed :

				org.objectweb.proactive.jmx.server.ServerConnector
				connector = new
				org.objectweb.proactive.jmx.server.ServerConnector ();
			

Once the connector server part launched, any ProActive JMX connector client can connect to it and manage the application thanks to the ClientConnector class.

				org.objectweb.proactive.jmx.client.ClientConnector
				clientConnector = new
				org.objectweb.proactive.jmx.client.ClientConnector
				(String serverUrl);
			

To perform remote operations on a given MBean, you have to get the reference of the current MBeanServerConnection, which is actually a ProActiveConnection :

				ProActiveConnection connection =
				clientConnector.getConnection(); //invoke the
				performAction method on the MBean named beanName with
				the parameter param1 wich type is typeParam1 ObjectName
				beanName = new ObjectName ("myDomain:name=beanName");
				GenericTypeWrapper return =
				connection.invokeAsynchronous( beanName,
				"performAction", new Object[] { param1 } , new String []
				{typeOfParam1});
			

[Note] Note

To know all available methods on a MBeanServerConnection, have a look at the

36.4. Notifications JMX via ProActive

The JMX specification defines a notification mechanism,based on java events, that allows alerts to be sent to client management applications. To use JMX Notifications, one has to use a listener object that is registered within the MBean server. On the server side, the MBean has to implement the NotificationBroadcaster interface. As we work in a distributed environment, listeners are located remotely and thus, have to be joined remotely. Hence, the listener must be a serializable active object and added as a NotificationListener :

				/*creates an active listener MyNotificationListener */
				MyNotificationListener listener =
				(MyNotificationListener)PAActiveObject.newActive(MyNotificationListener.class.getName(),
				new Object[] { connection}); /*adds the listener to the
				Mbean server where we are connected to*/
				connection.addNotificationListener( beanName, listener,
				null, handback);
			

36.5. Example : a simple textual JMX Console

The example available in the ProActive examples directory, is a simple textual tool to connect to a remote MBeanServer and list available domains and mbeans registered in this server.

To launch the connector server side, execute the jmx/connector script. To connect this server, execute the jmx/simpleJmx script and specify the machine name where is hosted the Mbean server. For example:

				--- JMC Test client
				connector---------------------------------------------
				Enter the url of the JMX MBean Server : localhost
			

The console shows the domains list, for example :

				Registered Domains : 
				[ 0 ] java.util.logging 
				[ 1 ] JMImplementation 
				[ 2 ] java.lang
			

By choosing a specific domain, the console will show the Mbeans registered in this domain.

The console shows the domains list, for example :

					[ 0 ] java.lang:type=Memory 
					[ 1 ] java.lang:type=GarbageCollector,name=Copy 
					[ 2 ] java.lang:type=MemoryPool,name=Tenured Gen 
					[ 3 ] java.lang:type=MemoryPool,name=Eden Space 
					[ 4 ] java.lang:type=MemoryPool,name=Code Cache 
					[ 5 ] java.lang:type=Threading 
					[ 6 ] java.lang:type=OperatingSystem 
					... 
					Type the mbean	number to see its properties :
				

If you wish to get informations about Memory, choose 0, and the console will show the whole information about this MBean.