Java Code Examples for javax.management.Notification#setUserData()

The following examples show how to use javax.management.Notification#setUserData() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
void createGCNotification(long timestamp,
                          String gcName,
                          String gcAction,
                          String gcCause,
                          GcInfo gcInfo)  {

    if (!hasListeners()) {
        return;
    }

    Notification notif = new Notification(GarbageCollectionNotificationInfo.GARBAGE_COLLECTION_NOTIFICATION,
                                          getObjectName(),
                                          getNextSeqNumber(),
                                          timestamp,
                                          gcName);
    GarbageCollectionNotificationInfo info =
        new GarbageCollectionNotificationInfo(gcName,
                                              gcAction,
                                              gcCause,
                                              gcInfo);

    CompositeData cd =
        GarbageCollectionNotifInfoCompositeData.toCompositeData(info);
    notif.setUserData(cd);
    sendNotification(notif);
}
 
Example 2
void createGCNotification(long timestamp,
                          String gcName,
                          String gcAction,
                          String gcCause,
                          GcInfo gcInfo)  {

    if (!hasListeners()) {
        return;
    }

    Notification notif = new Notification(GarbageCollectionNotificationInfo.GARBAGE_COLLECTION_NOTIFICATION,
                                          getObjectName(),
                                          getNextSeqNumber(),
                                          timestamp,
                                          gcName);
    GarbageCollectionNotificationInfo info =
        new GarbageCollectionNotificationInfo(gcName,
                                              gcAction,
                                              gcCause,
                                              gcInfo);

    CompositeData cd =
        GarbageCollectionNotifInfoCompositeData.toCompositeData(info);
    notif.setUserData(cd);
    sendNotification(notif);
}
 
Example 3
static void createNotification(String notifType,
                               String poolName,
                               MemoryUsage usage,
                               long count) {
    MemoryImpl mbean = (MemoryImpl) ManagementFactory.getMemoryMXBean();
    if (!mbean.hasListeners()) {
        // if no listener is registered.
        return;
    }
    long timestamp = System.currentTimeMillis();
    String msg = getNotifMsg(notifType);
    Notification notif = new Notification(notifType,
                                          mbean.getObjectName(),
                                          getNextSeqNumber(),
                                          timestamp,
                                          msg);
    MemoryNotificationInfo info =
        new MemoryNotificationInfo(poolName,
                                   usage,
                                   count);
    CompositeData cd =
        MemoryNotifInfoCompositeData.toCompositeData(info);
    notif.setUserData(cd);
    mbean.sendNotification(notif);
}
 
Example 4
void createGCNotification(long timestamp,
                          String gcName,
                          String gcAction,
                          String gcCause,
                          GcInfo gcInfo)  {

    if (!hasListeners()) {
        return;
    }

    Notification notif = new Notification(GarbageCollectionNotificationInfo.GARBAGE_COLLECTION_NOTIFICATION,
                                          getObjectName(),
                                          getNextSeqNumber(),
                                          timestamp,
                                          gcName);
    GarbageCollectionNotificationInfo info =
        new GarbageCollectionNotificationInfo(gcName,
                                              gcAction,
                                              gcCause,
                                              gcInfo);

    CompositeData cd =
        GarbageCollectionNotifInfoCompositeData.toCompositeData(info);
    notif.setUserData(cd);
    sendNotification(notif);
}
 
Example 5
/**
 * Implementation should handle loss of region by extracting the details from 
 * the given event object and sending the
 * {@link SystemMemberJmx#NOTIF_REGION_LOST} notification to the connected 
 * JMX Clients. Region Path is set as User Data in Notification. Additionally, 
 * it also clears the ManagedResources created for the region that is lost. 
 * 
 * @param event
 *          event object corresponding to the loss of a region
 */
public void handleRegionLoss(SystemMemberRegionEvent event) {
  SystemMemberCacheJmxImpl cacheResource = this.managedSystemMemberCache;
  
  if (cacheResource != null) {
    ManagedResource cleanedUp = 
              cacheResource.cleanupRegionResources(event.getRegionPath());
    
    if (cleanedUp != null) {
      MBeanUtil.unregisterMBean(cleanedUp);
    }
  }
  
  LogWriterI18n logWriterI18n = 
    this.getDistributedSystem().getLogWriter().convertToLogWriterI18n();
  
  Notification notification = new Notification(NOTIF_REGION_LOST, 
                                  this.modelMBean, 
                                  Helper.getNextNotificationSequenceNumber(),
                                  Helper.getRegionEventDetails(event));
  
  notification.setUserData(event.getRegionPath());

  Helper.sendNotification(logWriterI18n, this, notification);
}
 
Example 6
static void createNotification(String notifType,
                               String poolName,
                               MemoryUsage usage,
                               long count) {
    MemoryImpl mbean = (MemoryImpl) ManagementFactory.getMemoryMXBean();
    if (!mbean.hasListeners()) {
        // if no listener is registered.
        return;
    }
    long timestamp = System.currentTimeMillis();
    String msg = getNotifMsg(notifType);
    Notification notif = new Notification(notifType,
                                          mbean.getObjectName(),
                                          getNextSeqNumber(),
                                          timestamp,
                                          msg);
    MemoryNotificationInfo info =
        new MemoryNotificationInfo(poolName,
                                   usage,
                                   count);
    CompositeData cd =
        MemoryNotifInfoCompositeData.toCompositeData(info);
    notif.setUserData(cd);
    mbean.sendNotification(notif);
}
 
Example 7
void createGCNotification(long timestamp,
                          String gcName,
                          String gcAction,
                          String gcCause,
                          GcInfo gcInfo)  {

    if (!hasListeners()) {
        return;
    }

    Notification notif = new Notification(GarbageCollectionNotificationInfo.GARBAGE_COLLECTION_NOTIFICATION,
                                          getObjectName(),
                                          getNextSeqNumber(),
                                          timestamp,
                                          gcName);
    GarbageCollectionNotificationInfo info =
        new GarbageCollectionNotificationInfo(gcName,
                                              gcAction,
                                              gcCause,
                                              gcInfo);

    CompositeData cd =
        GarbageCollectionNotifInfoCompositeData.toCompositeData(info);
    notif.setUserData(cd);
    sendNotification(notif);
}
 
Example 8
/**
 * Implementation should handle loss of region by extracting the details from 
 * the given event object and sending the
 * {@link SystemMemberJmx#NOTIF_REGION_LOST} notification to the connected 
 * JMX Clients. Region Path is set as User Data in Notification. Additionally, 
 * it also clears the ManagedResources created for the region that is lost. 
 * 
 * @param event
 *          event object corresponding to the loss of a region
 */
public void handleRegionLoss(SystemMemberRegionEvent event) {
  SystemMemberCacheJmxImpl cacheResource = this.managedSystemMemberCache;
  
  if (cacheResource != null) {
    ManagedResource cleanedUp = 
              cacheResource.cleanupRegionResources(event.getRegionPath());
    
    if (cleanedUp != null) {
      MBeanUtil.unregisterMBean(cleanedUp);
    }
  }
  
  LogWriterI18n logWriterI18n = 
    this.getDistributedSystem().getLogWriter().convertToLogWriterI18n();
  
  Notification notification = new Notification(NOTIF_REGION_LOST, this.modelMBean, 
      Helper.getNextNotificationSequenceNumber(),
      Helper.getRegionEventDetails(event));
  
  notification.setUserData(event.getRegionPath());

  Helper.sendNotification(logWriterI18n, this, notification);
}
 
Example 9
static void createNotification(String notifType,
                               String poolName,
                               MemoryUsage usage,
                               long count) {
    MemoryImpl mbean = (MemoryImpl) ManagementFactory.getMemoryMXBean();
    if (!mbean.hasListeners()) {
        // if no listener is registered.
        return;
    }
    long timestamp = System.currentTimeMillis();
    String msg = getNotifMsg(notifType);
    Notification notif = new Notification(notifType,
                                          mbean.getObjectName(),
                                          getNextSeqNumber(),
                                          timestamp,
                                          msg);
    MemoryNotificationInfo info =
        new MemoryNotificationInfo(poolName,
                                   usage,
                                   count);
    CompositeData cd =
        MemoryNotifInfoCompositeData.toCompositeData(info);
    notif.setUserData(cd);
    mbean.sendNotification(notif);
}
 
Example 10
void createGCNotification(long timestamp,
                          String gcName,
                          String gcAction,
                          String gcCause,
                          GcInfo gcInfo)  {

    if (!hasListeners()) {
        return;
    }

    Notification notif = new Notification(GarbageCollectionNotificationInfo.GARBAGE_COLLECTION_NOTIFICATION,
                                          getObjectName(),
                                          getNextSeqNumber(),
                                          timestamp,
                                          gcName);
    GarbageCollectionNotificationInfo info =
        new GarbageCollectionNotificationInfo(gcName,
                                              gcAction,
                                              gcCause,
                                              gcInfo);

    CompositeData cd =
        GarbageCollectionNotifInfoCompositeData.toCompositeData(info);
    notif.setUserData(cd);
    sendNotification(notif);
}
 
Example 11
static void createNotification(String notifType,
                               String poolName,
                               MemoryUsage usage,
                               long count) {
    MemoryImpl mbean = (MemoryImpl) ManagementFactory.getMemoryMXBean();
    if (!mbean.hasListeners()) {
        // if no listener is registered.
        return;
    }
    long timestamp = System.currentTimeMillis();
    String msg = getNotifMsg(notifType);
    Notification notif = new Notification(notifType,
                                          mbean.getObjectName(),
                                          getNextSeqNumber(),
                                          timestamp,
                                          msg);
    MemoryNotificationInfo info =
        new MemoryNotificationInfo(poolName,
                                   usage,
                                   count);
    CompositeData cd =
        MemoryNotifInfoCompositeData.toCompositeData(info);
    notif.setUserData(cd);
    mbean.sendNotification(notif);
}
 
Example 12
Source Project: gemfirexd-oss   File: ManagementAdapter.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Sends the alert with the Object source as member. This notification will
 * get filtered out for particular alert level
 * 
 * @param details
 */
public void handleSystemNotification(AlertDetails details) {
  if (!isServiceInitialised("handleSystemNotification")) {
    return;
  }

  if (service.isManager()) {
    String systemSource = "DistributedSystem(" + service.getDistributedSystemMXBean().getDistributedSystemId() + ")";

    Notification notification = new Notification(ResourceNotification.SYSTEM_ALERT, systemSource, SequenceNumber
        .next(), details.getMsgTime().getTime(), details.toString());
    InternalDistributedMember sender = details.getSender();
    String nameOrId = memberSource; // TODO Rishi/Abhishek - what if sender is
                                    // null?
    if (sender != null) {
      nameOrId = sender.getName();
      nameOrId = nameOrId != null && !nameOrId.trim().isEmpty() ? nameOrId : sender.getId();
    }
    notification.setUserData(nameOrId);
    service.handleNotification(notification);
  }

}
 
Example 13
/**
 * Implementation handles creation of region by extracting the details from 
 * the given event object and sending the
 * {@link SystemMemberJmx#NOTIF_REGION_CREATED} notification to the connected 
 * JMX Clients. Region Path is set as User Data in Notification. 
 * 
 * @param event
 *          event object corresponding to the creation of a region
 */
public void handleRegionCreate(SystemMemberRegionEvent event) {
  LogWriterI18n logWriterI18n = 
    this.getDistributedSystem().getLogWriter().convertToLogWriterI18n();
  
  Notification notification = new Notification(NOTIF_REGION_CREATED, this.modelMBean, 
      Helper.getNextNotificationSequenceNumber(),
      Helper.getRegionEventDetails(event));
  
  notification.setUserData(event.getRegionPath());

  Helper.sendNotification(logWriterI18n, this, notification);
}
 
Example 14
/**
 * sendNotification
 * 
 * @param eventType
 * @param data
 * @param msg
 */
public void sendNotification(String eventType, Object data, String msg) {
    Notification notif = new Notification(eventType, this, sequenceNumber
            .incrementAndGet(), System.currentTimeMillis(), msg);
    if (data != null) {
        notif.setUserData(data);
    }
    emitter.sendNotification(notif);
}
 
Example 15
public void onSuccess(StreamState result)
{
    Notification notif = new Notification(StreamEvent.class.getCanonicalName() + ".success",
                                          StreamManagerMBean.OBJECT_NAME,
                                          seq.getAndIncrement());
    notif.setUserData(StreamStateCompositeData.toCompositeData(result));
    sendNotification(notif);
}
 
Example 16
private void createDiagnosticFrameworkNotification() {

        if (!hasListeners()) {
            return;
        }
        ObjectName on = null;
        try {
            on = ObjectName.getInstance(PlatformMBeanProviderImpl.DIAGNOSTIC_COMMAND_MBEAN_NAME);
        } catch (MalformedObjectNameException e) { }
        Notification notif = new Notification("jmx.mbean.info.changed",
                                              on,
                                              getNextSeqNumber());
        notif.setUserData(getMBeanInfo());
        sendNotification(notif);
    }
 
Example 17
public void onFailure(Throwable t)
{
    Notification notif = new Notification(StreamEvent.class.getCanonicalName() + ".failure",
                                          StreamManagerMBean.OBJECT_NAME,
                                          seq.getAndIncrement());
    notif.setUserData(t.fillInStackTrace().toString());
    sendNotification(notif);
}
 
Example 18
public void sendNotification(long runId, String type, String message, Object userData) {
	Notification notification = new Notification(type, MBEAN_NAME, 0); // CLO-13065: the sequence number will be set by JmxNotificationSender
	notification.setUserData(new JMXNotificationMessage(runId, userData));
	sendNotification(notification);
}
 
Example 19
Source Project: kieker   File: KiekerJmxMonitoringLog.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * Consumes the given record by sending a notification.
 * 
 * @param record
 *            The record to consume.
 * 
 * @return Always true.
 */
public final boolean newMonitoringRecord(final IMonitoringRecord record) {
	final Notification notification = new Notification(MESSAGE_TYPE, this.kiekerMonitoringLogName, 0L, 0L);
	notification.setUserData(record);
	super.sendNotification(notification);
	return true;
}
 
Example 20
/**
 * Sends JMX notification to subscribers.
 *
 * @param type Message type
 * @param message Message itself
 * @param userObject Arbitrary object to attach to notification
 */
public void sendNotification(String type, String message, Object userObject)
{
    Notification jmxNotification = new Notification(type, jmxObjectName, notificationSerialNumber.incrementAndGet(), message);
    jmxNotification.setUserData(userObject);
    sendNotification(jmxNotification);
}