Search in sources :

Example 66 with Notification

use of javax.management.Notification in project cassandra by apache.

the class JMXProgressSupport method progress.

@Override
public void progress(String tag, ProgressEvent event) {
    Notification notification = new Notification("progress", tag, notificationSerialNumber.getAndIncrement(), System.currentTimeMillis(), event.getMessage());
    Map<String, Integer> userData = new HashMap<>();
    userData.put("type", event.getType().ordinal());
    userData.put("progressCount", event.getProgressCount());
    userData.put("total", event.getTotal());
    notification.setUserData(userData);
    broadcaster.sendNotification(notification);
}
Also used : HashMap(java.util.HashMap) Notification(javax.management.Notification)

Example 67 with Notification

use of javax.management.Notification in project cassandra by apache.

the class StreamEventJMXNotifier method onSuccess.

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);
}
Also used : Notification(javax.management.Notification)

Example 68 with Notification

use of javax.management.Notification in project tomcat by apache.

the class ConnectionPool method notify.

/**
     * Return true if the notification was sent successfully, false otherwise.
     * @param type The notification type
     * @param message The message
     * @return true if the notification succeeded
     */
public boolean notify(final String type, String message) {
    try {
        Notification n = new Notification(type, this, sequence.incrementAndGet(), System.currentTimeMillis(), "[" + type + "] " + message);
        sendNotification(n);
        for (NotificationListener listener : listeners) {
            listener.handleNotification(n, this);
        }
        return true;
    } catch (Exception x) {
        if (log.isDebugEnabled()) {
            log.debug("Notify failed. Type=" + type + "; Message=" + message, x);
        }
        return false;
    }
}
Also used : Notification(javax.management.Notification) NotificationListener(javax.management.NotificationListener)

Example 69 with Notification

use of javax.management.Notification in project tomcat by apache.

the class StandardWrapper method startInternal.

// ------------------------------------------------------ Lifecycle Methods
/**
     * Start this component and implement the requirements
     * of {@link org.apache.catalina.util.LifecycleBase#startInternal()}.
     *
     * @exception LifecycleException if this component detects a fatal error
     *  that prevents this component from being used
     */
@Override
protected synchronized void startInternal() throws LifecycleException {
    // Send j2ee.state.starting notification
    if (this.getObjectName() != null) {
        Notification notification = new Notification("j2ee.state.starting", this.getObjectName(), sequenceNumber++);
        broadcaster.sendNotification(notification);
    }
    // Start up this component
    super.startInternal();
    setAvailable(0L);
    // Send j2ee.state.running notification
    if (this.getObjectName() != null) {
        Notification notification = new Notification("j2ee.state.running", this.getObjectName(), sequenceNumber++);
        broadcaster.sendNotification(notification);
    }
}
Also used : Notification(javax.management.Notification)

Example 70 with Notification

use of javax.management.Notification in project groovy-core by groovy.

the class JmxEventEmitter method send.

/**
     * Called to broadcast message on MBeanServer event bus.  Internally, it calls
     * NotificationBroadCasterSupport.sendNotification() method to dispatch the event.
     *
     * @param data - a data object sent as part of the event parameter.
     * @return a sequence number associated with the emitted event.
     */
public long send(Object data) {
    long seq = NumberSequencer.getNextSequence();
    Notification note = new Notification(this.getEvent(), this, seq, System.currentTimeMillis(), "Event notification " + this.getEvent());
    note.setUserData(data);
    super.sendNotification(note);
    return seq;
}
Also used : Notification(javax.management.Notification)

Aggregations

Notification (javax.management.Notification)134 ObjectName (javax.management.ObjectName)47 NotificationListener (javax.management.NotificationListener)30 AttributeChangeNotification (javax.management.AttributeChangeNotification)22 HashMap (java.util.HashMap)16 MBeanServer (javax.management.MBeanServer)15 JMXConnector (javax.management.remote.JMXConnector)14 JMXServiceURL (javax.management.remote.JMXServiceURL)14 NotificationFilter (javax.management.NotificationFilter)13 MBeanServerConnection (javax.management.MBeanServerConnection)12 JMXConnectorServer (javax.management.remote.JMXConnectorServer)11 Test (org.junit.Test)11 IOException (java.io.IOException)10 MBeanServerNotification (javax.management.MBeanServerNotification)9 ArrayList (java.util.ArrayList)8 Attribute (javax.management.Attribute)8 ListenerNotFoundException (javax.management.ListenerNotFoundException)7 CompositeData (javax.management.openmbean.CompositeData)7 JMXConnectionNotification (javax.management.remote.JMXConnectionNotification)7 MalformedURLException (java.net.MalformedURLException)6