Search in sources :

Example 56 with Notification

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

the class ManagementAdapter method handleRegionCreation.

/**
   * Handles Region Creation. This is the call back which will create the specified RegionMXBean and
   * will send a notification on behalf of Member Mbean
   * 
   * @param region the region for which the call back is invoked
   */
public <K, V> void handleRegionCreation(Region<K, V> region) throws ManagementException {
    if (!isServiceInitialised("handleRegionCreation")) {
        return;
    }
    synchronized (regionOpLock) {
        LocalRegion localRegion = (LocalRegion) region;
        if (localRegion.isDestroyed()) {
            return;
        }
        // Bridge is responsible for extracting data from GemFire Layer
        RegionMBeanBridge<K, V> bridge = RegionMBeanBridge.getInstance(region);
        RegionMXBean regionMBean = new RegionMBean<>(bridge);
        ObjectName regionMBeanName = MBeanJMXAdapter.getRegionMBeanName(internalCache.getDistributedSystem().getDistributedMember(), region.getFullPath());
        ObjectName changedMBeanName = service.registerInternalMBean(regionMBean, regionMBeanName);
        service.federate(changedMBeanName, RegionMXBean.class, true);
        Notification notification = new Notification(JMXNotificationType.REGION_CREATED, memberSource, SequenceNumber.next(), System.currentTimeMillis(), ManagementConstants.REGION_CREATED_PREFIX + region.getFullPath());
        memberLevelNotifEmitter.sendNotification(notification);
        memberMBeanBridge.addRegion(region);
    }
}
Also used : RegionMXBean(org.apache.geode.management.RegionMXBean) LocalRegion(org.apache.geode.internal.cache.LocalRegion) Notification(javax.management.Notification) ObjectName(javax.management.ObjectName)

Example 57 with Notification

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

the class DistributedSystemDUnitTest method addAlertListener.

private void addAlertListener(final VM managerVM) {
    managerVM.invoke("addAlertListener", () -> {
        AlertNotificationListener listener = AlertNotificationListener.getInstance();
        listener.resetCount();
        NotificationFilter notificationFilter = (Notification notification) -> notification.getType().equals(JMXNotificationType.SYSTEM_ALERT);
        getPlatformMBeanServer().addNotificationListener(getDistributedSystemName(), listener, notificationFilter, null);
    });
}
Also used : NotificationFilter(javax.management.NotificationFilter) Notification(javax.management.Notification)

Example 58 with Notification

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

the class FeaturesServiceMBeanImpl method getFeaturesListener.

public FeaturesListener getFeaturesListener() {
    return new FeaturesListener() {

        public void featureEvent(FeatureEvent event) {
            if (!event.isReplay()) {
                Notification notification = new Notification(FEATURE_EVENT_TYPE, objectName, sequenceNumber++);
                notification.setUserData(new JmxFeatureEvent(event).asCompositeData());
                sendNotification(notification);
            }
        }

        public void repositoryEvent(RepositoryEvent event) {
            if (!event.isReplay()) {
                Notification notification = new Notification(REPOSITORY_EVENT_TYPE, objectName, sequenceNumber++);
                notification.setUserData(new JmxRepositoryEvent(event).asCompositeData());
                sendNotification(notification);
            }
        }
    };
}
Also used : FeaturesListener(org.apache.karaf.features.FeaturesListener) FeatureEvent(org.apache.karaf.features.FeatureEvent) JmxFeatureEvent(org.apache.karaf.features.management.codec.JmxFeatureEvent) RepositoryEvent(org.apache.karaf.features.RepositoryEvent) JmxRepositoryEvent(org.apache.karaf.features.management.codec.JmxRepositoryEvent) Notification(javax.management.Notification) JmxFeatureEvent(org.apache.karaf.features.management.codec.JmxFeatureEvent) JmxRepositoryEvent(org.apache.karaf.features.management.codec.JmxRepositoryEvent)

Example 59 with Notification

use of javax.management.Notification in project logging-log4j2 by apache.

the class LoggerContextAdmin method propertyChange.

@Override
public void propertyChange(final PropertyChangeEvent evt) {
    if (!LoggerContext.PROPERTY_CONFIG.equals(evt.getPropertyName())) {
        return;
    }
    final Notification notif = new Notification(NOTIF_TYPE_RECONFIGURED, getObjectName(), nextSeqNo(), now(), null);
    sendNotification(notif);
}
Also used : Notification(javax.management.Notification)

Example 60 with Notification

use of javax.management.Notification in project jdk8u_jdk by JetBrains.

the class RequiredModelMBean method sendNotification.

public void sendNotification(String ntfyText) throws MBeanException, RuntimeOperationsException {
    if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
        MODELMBEAN_LOGGER.logp(Level.FINER, RequiredModelMBean.class.getName(), "sendNotification(String)", "Entry");
    }
    if (ntfyText == null)
        throw new RuntimeOperationsException(new IllegalArgumentException("notification message must not " + "be null"), "Exception occurred trying to send a text notification " + "from a ModelMBean");
    Notification myNtfyObj = new Notification("jmx.modelmbean.generic", this, 1, ntfyText);
    sendNotification(myNtfyObj);
    if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
        MODELMBEAN_LOGGER.logp(Level.FINER, RequiredModelMBean.class.getName(), "sendNotification(String)", "Notification sent");
        MODELMBEAN_LOGGER.logp(Level.FINER, RequiredModelMBean.class.getName(), "sendNotification(String)", "Exit");
    }
}
Also used : AttributeChangeNotification(javax.management.AttributeChangeNotification) Notification(javax.management.Notification) RuntimeOperationsException(javax.management.RuntimeOperationsException)

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