Search in sources :

Example 51 with Notification

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

the class ManagementAdapter method handleGatewaySenderCreation.

/**
   * Handles GatewaySender creation
   * 
   * @param sender the specific gateway sender
   * @throws ManagementException
   */
public void handleGatewaySenderCreation(GatewaySender sender) throws ManagementException {
    if (!isServiceInitialised("handleGatewaySenderCreation")) {
        return;
    }
    GatewaySenderMBeanBridge bridge = new GatewaySenderMBeanBridge(sender);
    GatewaySenderMXBean senderMBean = new GatewaySenderMBean(bridge);
    ObjectName senderObjectName = MBeanJMXAdapter.getGatewaySenderMBeanName(internalCache.getDistributedSystem().getDistributedMember(), sender.getId());
    ObjectName changedMBeanName = service.registerInternalMBean(senderMBean, senderObjectName);
    service.federate(changedMBeanName, GatewaySenderMXBean.class, true);
    Notification notification = new Notification(JMXNotificationType.GATEWAY_SENDER_CREATED, memberSource, SequenceNumber.next(), System.currentTimeMillis(), ManagementConstants.GATEWAY_SENDER_CREATED_PREFIX);
    memberLevelNotifEmitter.sendNotification(notification);
}
Also used : GatewaySenderMXBean(org.apache.geode.management.GatewaySenderMXBean) Notification(javax.management.Notification) ObjectName(javax.management.ObjectName)

Example 52 with Notification

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

the class ManagementAdapter method handleCacheServerStop.

/**
   * Assumption is its a cache server instance. For Gateway receiver there will be a separate method
   * 
   * @param server cache server instance
   */
public void handleCacheServerStop(CacheServer server) {
    if (!isServiceInitialised("handleCacheServerStop")) {
        return;
    }
    CacheServerMBean mbean = (CacheServerMBean) service.getLocalCacheServerMXBean(server.getPort());
    ClientMembershipListener listener = mbean.getBridge().getClientMembershipListener();
    if (listener != null) {
        ClientMembership.unregisterClientMembershipListener(listener);
    }
    mbean.stopMonitor();
    ObjectName cacheServerMBeanName = MBeanJMXAdapter.getClientServiceMBeanName(server.getPort(), internalCache.getDistributedSystem().getDistributedMember());
    service.unregisterMBean(cacheServerMBeanName);
    Notification notification = new Notification(JMXNotificationType.CACHE_SERVER_STOPPED, memberSource, SequenceNumber.next(), System.currentTimeMillis(), ManagementConstants.CACHE_SERVER_STOPPED_PREFIX);
    memberLevelNotifEmitter.sendNotification(notification);
    memberMBeanBridge.setCacheServer(false);
}
Also used : ClientMembershipListener(org.apache.geode.management.membership.ClientMembershipListener) Notification(javax.management.Notification) ObjectName(javax.management.ObjectName)

Example 53 with Notification

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

the class ManagementAdapter method handleSystemNotification.

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

Example 54 with Notification

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

the class ManagementAdapter method handleLocatorStart.

/**
   * Handles management side call backs for a locator creation and start. Assumption is a cache will
   * be created before hand.
   * 
   * There is no corresponding handleStopLocator() method. Locator will close the cache whenever its
   * stopped and it should also shutdown all the management services by closing the cache.
   * 
   * @param locator instance of locator which is getting started
   * @throws ManagementException
   */
public void handleLocatorStart(Locator locator) throws ManagementException {
    if (!isServiceInitialised("handleLocatorCreation")) {
        return;
    }
    ObjectName locatorMBeanName = MBeanJMXAdapter.getLocatorMBeanName(internalCache.getDistributedSystem().getDistributedMember());
    LocatorMBeanBridge bridge = new LocatorMBeanBridge(locator);
    LocatorMBean locatorMBean = new LocatorMBean(bridge);
    ObjectName changedMBeanName = service.registerInternalMBean((LocatorMXBean) locatorMBean, locatorMBeanName);
    service.federate(changedMBeanName, LocatorMXBean.class, true);
    Notification notification = new Notification(JMXNotificationType.LOCATOR_STARTED, memberSource, SequenceNumber.next(), System.currentTimeMillis(), ManagementConstants.LOCATOR_STARTED_PREFIX);
    memberLevelNotifEmitter.sendNotification(notification);
}
Also used : Notification(javax.management.Notification) ObjectName(javax.management.ObjectName)

Example 55 with Notification

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

the class ManagementAdapter method handleGatewaySenderPaused.

public void handleGatewaySenderPaused(GatewaySender sender) throws ManagementException {
    if (!isServiceInitialised("handleGatewaySenderPaused")) {
        return;
    }
    Notification notification = new Notification(JMXNotificationType.GATEWAY_SENDER_PAUSED, memberSource, SequenceNumber.next(), System.currentTimeMillis(), ManagementConstants.GATEWAY_SENDER_PAUSED_PREFIX + sender.getId());
    memberLevelNotifEmitter.sendNotification(notification);
}
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