Existing MBean and JMX notifications in ProActive

37.1. Principles

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.

37.2. How to subscribe/unsubscribe to the notifications of a 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

37.2.1. Subscribe to the JMX notifications of a ProActive object

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.

37.2.2. Unsubscribe to the JMX notifications

JMXNotificationManager.getInstance().unsubscribe(ObjectName objectName, NotificationListener listener);

37.3. The ProActive JMX Notifications

37.3.1. How to send a JMX notification?

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.

37.3.2. example of notification listener

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);
		}
	}
}

37.3.3. The JMX notifications sent by the ProActive MBean

37.3.3.1. Notifications sent by the active object MBean.

[Note] 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

<title>Migration informations</title>

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

<title>Request informationss</title>

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

<title>Future information</title>

Type of notification

UserData

NotificationType.waitByNecessity

FutureNotificationData

NotificationType.receivedFutureResult

FutureNotificationData

37.3.3.2. Notifications sent by the ProActiveRuntime

Creation information

<title>Creation information</title>

Type of notification

UserData

NotificationType.bodyCreated

BodyNotificationData

NotificationType.nodeCreated

NodeNotificationData

NotificationType.runtimeRegistered

RuntimeNotificationData

Notification.runtimeAcquired

RuntimeNotificationData

Destruction informations

<title>Destruction informations</title>

Type of notification

UserData

NotificationType.bodyDestroyed

BodyNotificationData

NotificationType.nodeDestroyed

NodeNotificationData

NotificationType.runtimeDestroyed

null

Notification.runtimeUnregistered

RuntimeNotificationData