Search in sources :

Example 41 with Notification

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

the class ManagementAdapter method handleAsyncEventQueueRemoval.

/**
   * Handles AsyncEventQueue Removal
   *
   * @param queue The AsyncEventQueue being removed
   */
public void handleAsyncEventQueueRemoval(AsyncEventQueue queue) throws ManagementException {
    if (!isServiceInitialised("handleAsyncEventQueueRemoval")) {
        return;
    }
    ObjectName asycnEventQueueMBeanName = MBeanJMXAdapter.getAsycnEventQueueMBeanName(internalCache.getDistributedSystem().getDistributedMember(), queue.getId());
    AsyncEventQueueMBean bean;
    try {
        bean = (AsyncEventQueueMBean) service.getLocalAsyncEventQueueMXBean(queue.getId());
        if (bean == null) {
            return;
        }
    } catch (ManagementException e) {
        // If no bean found its a NO-OP
        if (logger.isDebugEnabled()) {
            logger.debug(e.getMessage(), e);
        }
        return;
    }
    bean.stopMonitor();
    service.unregisterMBean(asycnEventQueueMBeanName);
    Notification notification = new Notification(JMXNotificationType.ASYNC_EVENT_QUEUE_CLOSED, memberSource, SequenceNumber.next(), System.currentTimeMillis(), ManagementConstants.ASYNC_EVENT_QUEUE_CLOSED_PREFIX + queue.getId());
    memberLevelNotifEmitter.sendNotification(notification);
}
Also used : ManagementException(org.apache.geode.management.ManagementException) Notification(javax.management.Notification) ObjectName(javax.management.ObjectName)

Example 42 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 43 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 44 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 45 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)

Aggregations

Notification (javax.management.Notification)204 ObjectName (javax.management.ObjectName)68 NotificationListener (javax.management.NotificationListener)35 AttributeChangeNotification (javax.management.AttributeChangeNotification)29 CompositeData (javax.management.openmbean.CompositeData)25 IOException (java.io.IOException)23 Test (org.junit.Test)20 HashMap (java.util.HashMap)19 MalformedObjectNameException (javax.management.MalformedObjectNameException)19 Test (org.testng.annotations.Test)18 ListenerNotFoundException (javax.management.ListenerNotFoundException)17 ArrayList (java.util.ArrayList)16 MBeanServer (javax.management.MBeanServer)16 NotificationFilter (javax.management.NotificationFilter)15 NotificationEmitter (javax.management.NotificationEmitter)14 JMXConnector (javax.management.remote.JMXConnector)14 JMXServiceURL (javax.management.remote.JMXServiceURL)14 MBeanServerConnection (javax.management.MBeanServerConnection)12 MalformedURLException (java.net.MalformedURLException)11 JMXConnectorServer (javax.management.remote.JMXConnectorServer)11