Each ProActive object has an MBean.
ProActiveRuntimeWrapperMBean for a ProActiveRuntimeImpl
NodeWrapperMBean for a NocalNode
BodyWrapperMBean for AbstractBody
It is possible to receive the JMX notification emitted by the MBean, or to invoke a method on the MBean.
Utility classes are provided in order to make easy the subscription of JMX notifications. If you subscribe to a MBean of a remote MBean server, this one sends you the notifications of the wanted MBean. However, in case of an active object, if the object migrates it is necessary to unsubscribe the listener from the MBean Server and to open a new connection to the new MBean Server and subscribe to this one. If you don't do those steps you will not continue to receive the notifications. In order to resolve this problem, we provide some classes which do this work: JMXNotificationManager and JMXNotificationListener
JMXNotification.getInstance().subscribe(ObjectName objectName, NotificationListener listener, String runtimeUrl);
objectName is the identifier of the MBean.
The FactoryName class gives you some methods in order to get the objectName:
FactoryName.createActiveObjectName(UniqueID id);
FactoryName.createNodeObjectName(String runtimeUrl,String nodeName);
FactoryName.createRuntimeObjectName(String url);
FactoryName.createVirtualNodeObjectName(String vnName,String jobID);
listener is a JMX notification listener.(It needs to implement the NotificationListener interface.)
runtimeUrl The url of the runtime, where to find the MBean.
The classes ProActiveRuntimeImpl, LocalNode, AbstractBody contain a MBean and the getMBean() method.
On the MBean, you can call 2 different methods:
sendNotification(String type);
sendNotification(String type, Object userData);
type is the type of the notification. The NotificationType class gets a lot of existing notification types.
userData is the object to send to the listener. The package org.objectweb.proactive.core.jmx.notification contains some existing notification.
import javax.management.Notification; import javax.management.NotificationListener; import org.objectweb.proactive.core.UniqueID; import org.objectweb.proactive.core.jmx.notification.BodyNotificationData; import org.objectweb.proactive.core.jmx.notification.NotificationType; public class MyListener implements NotificationListener{ public void handleNotification(Notification notification, Object handback){ // Get the type of the notification String type = notification.getType(); // Get the data of the notification Object data = notification.getUserData(); if(type.equals(NotificationType.bodyCreated)){ BodyNotificationData notificationData = (BodyNotificationData) data; UniqueID id = notificationData.getId(); System.out.println("Active Object created with id:"+id); } } }
Warning | |
---|---|
For performance reasons, the MBean of an active object (BodyWrapperMBean) sends a set of notifications. Type of the notification: Notification.setOfNotifications User Data: ConcurrentLinkedQueue<Notification> |
Migration informations
Type of notification |
UserData |
NotificationType.migrationAboutToStart |
String (Url of the destination node) |
NotificationType.migratedBodyRestarted |
null |
NotificationType.migrationFinished |
String (Url of the destination runtime |
Notification.migrationExceptionThrown |
MigrationException |
Request informations
Type of notification |
UserData |
NotificationType.requestSent |
RequestNotificationData |
NotificationType.requestReceived |
RequestNotificationData |
NotificationType.replySent |
null |
Notification.replyReceived |
null |
NotificationType.servingStarted |
Integer (Request queue Size) |
NotificationType.voidRequestServed |
Integer (Request queue Size) |
NotificationType.waitForRequest |
null |
Future information
Type of notification |
UserData |
NotificationType.waitByNecessity |
FutureNotificationData |
NotificationType.receivedFutureResult |
FutureNotificationData |
Creation information
Type of notification |
UserData |
NotificationType.bodyCreated |
BodyNotificationData |
NotificationType.nodeCreated |
NodeNotificationData |
NotificationType.runtimeRegistered |
RuntimeNotificationData |
Notification.runtimeAcquired |
RuntimeNotificationData |
Destruction informations
Type of notification |
UserData |
NotificationType.bodyDestroyed |
BodyNotificationData |
NotificationType.nodeDestroyed |
NodeNotificationData |
NotificationType.runtimeDestroyed |
null |
Notification.runtimeUnregistered |
RuntimeNotificationData |
© 1997-2008 INRIA Sophia Antipolis All Rights Reserved