Example usage for javax.management Notification setUserData

List of usage examples for javax.management Notification setUserData

Introduction

In this page you can find the example usage for javax.management Notification setUserData.

Prototype

public void setUserData(Object userData) 

Source Link

Document

Set the user data.

Usage

From source file:com.heliosapm.jmx.cache.CacheStatistics.java

/**
 * {@inheritDoc}/*from   www.  j  a v a  2  s .co  m*/
 * @see com.google.common.cache.RemovalListener#onRemoval(com.google.common.cache.RemovalNotification)
 */
@Override
public void onRemoval(RemovalNotification<Object, Object> removal) {
    final Notification notif = new Notification("cache.removal", objectName, sequence.incrementAndGet(),
            System.currentTimeMillis(), "Cache entry [" + removal.toString() + "] removed from cache ["
                    + cacheName + "]. Cause:" + removal.getCause().name());
    final JSONObject json = new JSONObject();
    json.put("event", "cache.removal");
    json.put("cacheName", cacheName);
    json.put("key", removal.getKey());
    json.put("value", removal.getValue());
    json.put("cause", removal.getCause().name());
    notif.setUserData(json.toString());
    sendNotification(notif);
}

From source file:org.helios.netty.jmx.MetricCollector.java

/**
 * Executes the collection//from  ww w.  j  a  v  a  2s  .c  om
 * {@inheritDoc}
 * @see java.lang.Runnable#run()
 */
public void run() {
    try {
        updateMetricNames();
        long channelCount = SharedChannelGroup.getInstance().size();
        //log.info("\n\tChanne,l Count:" + channelCount);
        submitMetric("netty.channels.count", channelCount);
        Notification notif = new Notification(MetricProvider.METRIC_NOTIFICATION, OBJECT_NAME,
                tick.incrementAndGet(), System.currentTimeMillis());
        final JSONObject json = new JSONObject();
        final JSONObject envelope = new JSONObject();
        envelope.put("metrics", json);
        notif.setUserData(json);
        pushRemoteMetrics(json);
        json.put("ts", System.currentTimeMillis());
        json.put("heap", processMemoryUsage(memMxBean.getHeapMemoryUsage()));
        json.put("non-heap", processMemoryUsage(memMxBean.getNonHeapMemoryUsage()));
        json.put("thread-states*", new JSONObject(getThreadStates()));
        if (haveNioMXBean) {
            json.put("direct-nio", new JSONObject(getNio()));
        }
        sendNotification(notif);
        SharedChannelGroup.getInstance().write(envelope);
    } catch (Exception e) {
        e.printStackTrace(System.err);
    } finally {
        scheduler.schedule(this, period, TimeUnit.MILLISECONDS);
    }
}

From source file:org.apache.geode.management.internal.beans.ManagementAdapter.java

/**
 * Sends the alert with the Object source as member. This notification will get filtered out for
 * particular alert level/*from   w  w  w .  java2s .  c  o  m*/
 * 
 * @param details
 */
public void handleSystemNotification(AlertDetails details) {
    if (!isServiceInitialised("handleSystemNotification")) {
        return;
    }
    if (service.isManager()) {
        String systemSource = "DistributedSystem("
                + service.getDistributedSystemMXBean().getDistributedSystemId() + ")";
        Map<String, String> userData = prepareUserData(details);

        Notification notification = new Notification(JMXNotificationType.SYSTEM_ALERT, systemSource,
                SequenceNumber.next(), details.getMsgTime().getTime(), details.getMsg());

        notification.setUserData(userData);
        service.handleNotification(notification);
    }
}

From source file:com.heliosapm.script.AbstractDeployedScript.java

/**
 * Sends a configuration change notification when the configuration of the deployment changes
 * @param jsonConfig The new configuration represented in JSON which is included as the user data in the sent notification
 * @param timestamp The timestamp//from   w  ww  .  ja  va 2  s  .  c  om
 */
protected void sendConfigurationChangeNotification(final String jsonConfig, final long timestamp) {
    final String msg = String.format("[%s] Configuration change", new Date(timestamp));
    // last event msg      
    final Notification notif = new Notification(NOTIF_CONFIG_CHANGE, objectName, sequence.incrementAndGet(),
            timestamp, msg);
    notif.setUserData(jsonConfig);
    sendNotification(notif);
}

From source file:com.heliosapm.script.AbstractDeployedScript.java

/**
 * Adds a new notification type for this deployment
 * @param infos The notification infos to add
 *///from w w w  .  j  av  a  2  s. c  o m
protected void registerNotifications(final MBeanNotificationInfo... infos) {
    if (infos == null || infos.length == 0)
        return;
    if (instanceNotificationInfos.isEmpty()) {
        Collections.addAll(instanceNotificationInfos, notificationInfos);
    }
    int added = 0;
    for (MBeanNotificationInfo info : infos) {
        if (info == null)
            continue;
        if (instanceNotificationInfos.add(info)) {
            added++;
        }
    }
    if (added > 0) {
        final Notification notif = new Notification(JMXHelper.MBEAN_INFO_CHANGED, objectName,
                sequence.incrementAndGet(), System.currentTimeMillis(), "Updated MBeanInfo");
        notif.setUserData(JMXHelper.getMBeanInfo(objectName));
        sendNotification(notif);
    }
}