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
Source File: GarbageCollectorImpl.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
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
Source File: GarbageCollectorImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
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
Source File: MemoryImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
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
Source File: GarbageCollectorImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
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
Source File: CacheServerJmxImpl.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * 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
Source File: MemoryImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
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
Source File: GarbageCollectorImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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
Source File: SystemMemberJmxImpl.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * 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
Source File: ManagementAdapter.java    From gemfirexd-oss with 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 10
Source File: MemoryImpl.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
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 11
Source File: GarbageCollectorImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
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 12
Source File: MemoryImpl.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
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 13
Source File: SystemMemberJmxImpl.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * 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
Source File: StreamEventJMXNotifier.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
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 15
Source File: DiagnosticCommandImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
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 16
Source File: StreamEventJMXNotifier.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
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 17
Source File: QuartzSchedulerMBeanImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 18
Source File: CloverJMX.java    From CloverETL-Engine with GNU Lesser General Public License v2.1 4 votes vote down vote up
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 File: StorageService.java    From stratio-cassandra with Apache License 2.0 3 votes vote down vote up
/**
 * 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);
}
 
Example 20
Source File: KiekerJmxMonitoringLog.java    From kieker with 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;
}