Example usage for javax.management Notification getTimeStamp

List of usage examples for javax.management Notification getTimeStamp

Introduction

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

Prototype

public long getTimeStamp() 

Source Link

Document

Get the notification timestamp.

Usage

From source file:de.iew.spring.integration.JmxTestServiceNotificationListener.java

private String formatNotification(Notification notification) {
    StringBuilder sb = new StringBuilder();
    sb.append("recieved notification class: ").append(notification.getType());
    sb.append(", method: ").append(notification.getSource());
    sb.append(", sequence: ").append(notification.getSequenceNumber());
    sb.append(",  timestamp: ").append(notification.getTimeStamp());
    sb.append(",  data: ");

    Object userData = notification.getUserData();
    String formattedUserData;/*from w  w  w.j a  va  2  s .c  om*/
    if (userData == null) {
        formattedUserData = "";
    } else if (userData instanceof String) {
        formattedUserData = StringUtils.arrayToCommaDelimitedString((Object[]) notification.getUserData());
    } else {
        formattedUserData = userData.toString();
    }
    sb.append(formattedUserData);

    return sb.toString();
}

From source file:org.wso2.carbon.registry.subscription.test.util.JMXClient.java

public void handleNotification(Notification ntfyObj, Object handback) {
    log.info("***************************************************");
    log.info("* Notification received at " + new Date().toString());
    log.info("* type      = " + ntfyObj.getType());
    log.info("* message   = " + ntfyObj.getMessage());

    if (ntfyObj.getMessage().contains(path)) {
        setSuccess(true);// w  w w. j a v  a 2s  . co m
    }

    log.info("* seqNum    = " + ntfyObj.getSequenceNumber());
    log.info("* source    = " + ntfyObj.getSource());
    log.info("* seqNum    = " + Long.toString(ntfyObj.getSequenceNumber()));
    log.info("* timeStamp = " + new Date(ntfyObj.getTimeStamp()));
    log.info("* userData  = " + ntfyObj.getUserData());
    log.info("***************************************************");
}

From source file:org.hyperic.hq.product.jmx.MxNotificationListener.java

public synchronized void handleNotification(Notification notification, Object handback) {

    String msg;/*www  .  j av  a 2s  .  c o m*/
    boolean isAttrChange = notification instanceof AttributeChangeNotification;

    if (log.isDebugEnabled()) {
        log.debug(this.plugin.getName() + " received notification: " + notification);
    }

    if (isAttrChange && this.isConfigTrackEnabled) {
        AttributeChangeNotification change = (AttributeChangeNotification) notification;

        msg = "Attribute: " + change.getAttributeName() + " changed from " + change.getOldValue() + " to "
                + change.getNewValue();
    } else if (this.isLogTrackEnabled) {
        msg = notification.getMessage();
    } else {
        return;
    }

    if (msg == null) {
        Object data = notification.getUserData();
        if (data != null) {
            msg = data.toString();
        } else {
            msg = notification.getType();
        }
    }

    long time = notification.getTimeStamp();

    // Default level to INFO
    int level = LogTrackPlugin.LOGLEVEL_INFO;

    // Check notification.getType() for Error, Warn, Info, Debug (case insensitive)
    String typeString = notification.getType();
    if (typeString != null) {
        if (typeString.equalsIgnoreCase(LogTrackPlugin.LOGLEVEL_ERROR_LABEL)) {
            level = LogTrackPlugin.LOGLEVEL_ERROR;
        } else if (typeString.equalsIgnoreCase(LogTrackPlugin.LOGLEVEL_WARN_LABEL)) {
            level = LogTrackPlugin.LOGLEVEL_WARN;
        } else if (typeString.equalsIgnoreCase(LogTrackPlugin.LOGLEVEL_DEBUG_LABEL)) {
            level = LogTrackPlugin.LOGLEVEL_DEBUG;
        }
    }

    String source = notification.getSource().toString();

    if (isAttrChange) {
        TrackEvent event = new TrackEvent(this.plugin.getName(), time, level, source, msg);
        this.plugin.getManager().reportEvent(event);
    } else {
        //apply filters to msg
        this.plugin.reportEvent(time, level, source, msg);
    }
}

From source file:org.apache.cassandra.tools.NodeProbe.java

public void handleNotification(Notification notification, Object handback) {
    if ("repair".equals(notification.getType())) {
        int[] status = (int[]) notification.getUserData();
        assert status.length == 2;
        if (cmd == status[0]) {
            String message = String.format("[%s] %s", format.format(notification.getTimeStamp()),
                    notification.getMessage());
            out.println(message);//from w w w . ja v a  2  s  .  c o  m
            // repair status is int array with [0] = cmd number, [1] = status
            if (status[1] == ActiveRepairService.Status.SESSION_FAILED.ordinal())
                success = false;
            else if (status[1] == ActiveRepairService.Status.FINISHED.ordinal())
                condition.signalAll();
        }
    } else if (JMXConnectionNotification.NOTIFS_LOST.equals(notification.getType())) {
        String message = String.format(
                "[%s] Lost notification. You should check server log for repair status of keyspace %s",
                format.format(notification.getTimeStamp()), keyspace);
        out.println(message);
    } else if (JMXConnectionNotification.FAILED.equals(notification.getType())
            || JMXConnectionNotification.CLOSED.equals(notification.getType())) {
        String message = String
                .format("JMX connection closed. You should check server log for repair status of keyspace %s"
                        + "(Subsequent keyspaces are not going to be repaired).", keyspace);
        error = new IOException(message);
        condition.signalAll();
    }
}

From source file:com.pivotal.gemfire.tools.pulse.internal.data.JMXDataUpdater.java

/**
 * System Notification Listener//from   www.  java  2  s .co  m
 */
@Override
public void handleNotification(Notification notification, Object handback) {
    String type = notification.getType();

    if (PulseConstants.NOTIFICATION_TYPE_SYSTEM_ALERT.equals(type)) {
        Cluster.Alert alert = new Cluster.Alert();
        Long timeStamp = notification.getTimeStamp();
        Date date = new Date(timeStamp);
        alert.setTimestamp(date);
        String notificationSource = (String) notification.getUserData();
        alert.setMemberName(notificationSource);
        String alertDescription = notification.getMessage();
        if (alertDescription.startsWith("[error")) {
            alert.setSeverity(Cluster.Alert.ERROR);
        } else if (alertDescription.startsWith("[warning")) {
            alert.setSeverity(Cluster.Alert.WARNING);
        } else if (alertDescription.startsWith("[severe")) {
            alert.setSeverity(Cluster.Alert.SEVERE);
        } else {
            alert.setSeverity(Cluster.Alert.INFO);
        }
        alert.setDescription(notification.getMessage());
        alert.setAcknowledged(false);
        alert.setId(Cluster.Alert.nextID());
        cluster.addAlert(alert);
    } else {
        Cluster.Alert alert = new Cluster.Alert();
        Long timeStamp = notification.getTimeStamp();
        Date date = new Date(timeStamp);
        alert.setTimestamp(date);
        String notificationSource = (String) notification.getSource();
        alert.setMemberName(notificationSource);
        String alertDescription = notification.getMessage();
        alert.setDescription(alertDescription);

        alert.setSeverity(Cluster.Alert.INFO);

        alert.setAcknowledged(false);
        alert.setId(Cluster.Alert.nextID());
        cluster.addAlert(alert);
    }
}

From source file:edu.nwpu.gemfire.monitor.data.JMXDataUpdater.java

/**
 * System Notification Listener//from   ww w  .j  a  va 2s.  c  om
 */
@Override
public void handleNotification(Notification notification, Object handback) {
    String type = notification.getType();

    if (PulseConstants.NOTIFICATION_TYPE_SYSTEM_ALERT.equals(type)) {
        Cluster.Alert alert = new Cluster.Alert();
        Long timeStamp = notification.getTimeStamp();
        Date date = new Date(timeStamp);
        alert.setTimestamp(date);
        String notificationSource = (String) notification.getUserData();
        alert.setMemberName(notificationSource);
        String alertDescription = notification.getMessage();
        if (alertDescription.startsWith("[error")) {
            alert.setSeverity(Cluster.Alert.ERROR);
        } else if (alertDescription.startsWith("[warning")) {
            alert.setSeverity(Cluster.Alert.WARNING);
        } else if (alertDescription.startsWith("[severe")) {
            alert.setSeverity(Cluster.Alert.SEVERE);
        } else {
            alert.setSeverity(Cluster.Alert.INFO);
        }
        alert.setDescription(notification.getMessage());
        alert.setAcknowledged(false);
        alert.setId(Cluster.Alert.nextID());
        cluster.addAlert(alert);
    } else {
        Cluster.Alert alert = new Cluster.Alert();
        Long timeStamp = notification.getTimeStamp();
        Date date = new Date(timeStamp);
        alert.setTimestamp(date);
        String notificationSource = (String) notification.getSource();
        alert.setMemberName(notificationSource);
        String alertDescription = notification.getMessage();
        alert.setDescription(alertDescription);

        alert.setSeverity(Cluster.Alert.INFO);

        alert.setAcknowledged(false);
        alert.setId(Cluster.Alert.nextID());
        cluster.addAlert(alert);

        if (PulseConstants.NOTIFICATION_TYPE_REGION_DESTROYED.equals(type)) {
            // Remove deleted region from member's regions list
            String msg = notification.getMessage();
            String deletedRegion = msg.substring(msg.indexOf("Name ") + "Name ".length());
            String memberName = notificationSource;
            Cluster.Member member = cluster.getMembersHMap().get(memberName);

            if (member.getMemberRegions().get(deletedRegion) != null) {
                member.getMemberRegions().remove(deletedRegion);
                member.setTotalRegionCount(member.getMemberRegions().size());
            }
        }
    }
}