Example usage for javax.management Notification Notification

List of usage examples for javax.management Notification Notification

Introduction

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

Prototype

public Notification(String type, Object source, long sequenceNumber, long timeStamp, String message) 

Source Link

Document

Creates a Notification object.

Usage

From source file:com.heliosapm.script.AbstractDeployedScript.java

/**
 * {@inheritDoc}/*from w w  w . ja v a2s.  c  o  m*/
 * @see com.heliosapm.script.DeployedScript#setExecutable(java.lang.Object, long, long)
 */
@Override
public void setExecutable(final T executable, final long checksum, final long timestamp) {
    if (executable == null)
        throw new IllegalArgumentException("The passed executable was null");
    if (this.executable != null) {
        closeOldExecutable(this.executable);
    }
    if (this.checksum != checksum || this.lastModified != timestamp) {
        this.executable = executable;
        this.checksum = checksum;
        this.lastModified = timestamp;
        final long now = System.currentTimeMillis();
        lastModTime.set(now);
        final int v = version.incrementAndGet();
        initExcutable();
        final String message = String.format("[%s]: Recompiled Deployment v.%s, [%s]", new Date(now), v,
                sourceFile.getAbsolutePath());
        lastStatusMessage.set(message);
        sendNotification(
                new Notification(NOTIF_RECOMPILE, objectName, sequence.incrementAndGet(), now, message));
    }
}

From source file:org.apache.geode.management.internal.beans.ManagementAdapter.java

/**
 * Handles AsyncEventQueue Removal/*w  w  w  .j av  a  2  s  .  c o m*/
 *
 * @param queue The AsyncEventQueue being removed
 */
public void handleAsyncEventQueueRemoval(AsyncEventQueue queue) throws ManagementException {
    if (!isServiceInitialised("handleAsyncEventQueueRemoval")) {
        return;
    }

    ObjectName asycnEventQueueMBeanName = MBeanJMXAdapter.getAsyncEventQueueMBeanName(
            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);
}

From source file:org.apache.geode.management.internal.beans.ManagementAdapter.java

/**
 * Sends the alert with the Object source as member. This notification will get filtered out for
 * particular alert level//  w  w  w  . ja  v a2s  .c  o  m
 * 
 * @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);
    }
}

From source file:org.apache.geode.management.internal.beans.ManagementAdapter.java

/**
 * Assumption is its a cache server instance. For Gateway receiver there will be a separate method
 * //from w  ww  .  ja v a2s .c om
 * @param cacheServer cache server instance
 */
public void handleCacheServerStart(CacheServer cacheServer) {
    if (!isServiceInitialised("handleCacheServerStart")) {
        return;
    }

    CacheServerBridge cacheServerBridge = new CacheServerBridge(internalCache, cacheServer);
    cacheServerBridge.setMemberMBeanBridge(memberMBeanBridge);

    CacheServerMBean cacheServerMBean = new CacheServerMBean(cacheServerBridge);

    ObjectName cacheServerMBeanName = MBeanJMXAdapter.getClientServiceMBeanName(cacheServer.getPort(),
            internalCache.getDistributedSystem().getDistributedMember());

    ObjectName changedMBeanName = service.registerInternalMBean(cacheServerMBean, cacheServerMBeanName);

    ClientMembershipListener managementClientListener = new CacheServerMembershipListenerAdapter(
            cacheServerMBean, memberLevelNotifEmitter, changedMBeanName);
    ClientMembership.registerClientMembershipListener(managementClientListener);

    cacheServerBridge.setClientMembershipListener(managementClientListener);

    service.federate(changedMBeanName, CacheServerMXBean.class, true);

    Notification notification = new Notification(JMXNotificationType.CACHE_SERVER_STARTED, memberSource,
            SequenceNumber.next(), System.currentTimeMillis(), ManagementConstants.CACHE_SERVER_STARTED_PREFIX);

    memberLevelNotifEmitter.sendNotification(notification);

    memberMBeanBridge.setCacheServer(true);
}

From source file:org.apache.geode.management.internal.beans.ManagementAdapter.java

/**
 * Assumption is its a cache server instance. For Gateway receiver there will be a separate method
 * //from w w  w.j a v  a 2 s . com
 * @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);
}

From source file:org.apache.geode.management.internal.beans.ManagementAdapter.java

/**
 * Handles particular region destroy or close operation it will remove the corresponding MBean
 * /*from   w  w  w .  j a v a 2s. co m*/
 * @param region
 */
public void handleRegionRemoval(Region region) throws ManagementException {
    if (!isServiceInitialised("handleRegionRemoval")) {
        return;
    }
    /*
     * Moved region remove operation to a guarded block. If a region is getting created it wont
     * allow it to destroy any region.
     */

    synchronized (regionOpLock) {
        ObjectName regionMBeanName = MBeanJMXAdapter.getRegionMBeanName(
                internalCache.getDistributedSystem().getDistributedMember(), region.getFullPath());
        RegionMBean bean;
        try {
            bean = (RegionMBean) service.getLocalRegionMBean(region.getFullPath());
        } catch (ManagementException e) {
            // If no bean found its a NO-OP
            // Mostly for situation like DiskAccessException while creating region
            // which does a compensatory close region
            if (logger.isDebugEnabled()) {
                logger.debug(e.getMessage(), e);
            }
            return;
        }

        if (bean != null) {
            bean.stopMonitor();
        }
        service.unregisterMBean(regionMBeanName);

        Notification notification = new Notification(JMXNotificationType.REGION_CLOSED, memberSource,
                SequenceNumber.next(), System.currentTimeMillis(),
                ManagementConstants.REGION_CLOSED_PREFIX + region.getFullPath());
        memberLevelNotifEmitter.sendNotification(notification);
        memberMBeanBridge.removeRegion(region);
    }
}

From source file:org.apache.geode.management.internal.beans.ManagementAdapter.java

/**
 * Handles DiskStore Removal/*from   w w  w.  j a va 2s.c  o m*/
 * 
 * @param disk
 */
public void handleDiskRemoval(DiskStore disk) throws ManagementException {
    if (!isServiceInitialised("handleDiskRemoval")) {
        return;
    }

    ObjectName diskStoreMBeanName = MBeanJMXAdapter
            .getDiskStoreMBeanName(internalCache.getDistributedSystem().getDistributedMember(), disk.getName());

    DiskStoreMBean bean;
    try {
        bean = (DiskStoreMBean) service.getLocalDiskStoreMBean(disk.getName());
        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(diskStoreMBeanName);

    Notification notification = new Notification(JMXNotificationType.DISK_STORE_CLOSED, memberSource,
            SequenceNumber.next(), System.currentTimeMillis(),
            ManagementConstants.DISK_STORE_CLOSED_PREFIX + disk.getName());
    memberLevelNotifEmitter.sendNotification(notification);
    memberMBeanBridge.removeDiskStore(disk);
}

From source file:org.apache.geode.management.internal.beans.ManagementAdapter.java

/**
 * Handles Lock Service Removal//ww w .j  av  a  2  s. c  om
 * 
 * @param lockService lock service instance
 */
public void handleLockServiceRemoval(DLockService lockService) throws ManagementException {
    if (!isServiceInitialised("handleLockServiceRemoval")) {
        return;
    }

    ObjectName lockServiceMBeanName = MBeanJMXAdapter.getLockServiceMBeanName(
            internalCache.getDistributedSystem().getDistributedMember(), lockService.getName());

    LockServiceMXBean bean = service.getLocalLockServiceMBean(lockService.getName());

    service.unregisterMBean(lockServiceMBeanName);

    Notification notification = new Notification(JMXNotificationType.LOCK_SERVICE_CLOSED, memberSource,
            SequenceNumber.next(), System.currentTimeMillis(),
            ManagementConstants.LOCK_SERVICE_CLOSED_PREFIX + lockService.getName());
    memberLevelNotifEmitter.sendNotification(notification);
}

From source file:org.apache.geode.management.internal.beans.ManagementAdapter.java

/**
 * Handles management side call backs for a locator creation and start. Assumption is a cache will
 * be created before hand./*from w  w  w. j a v  a  2  s  .c  om*/
 * 
 * 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(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);

}

From source file:org.apache.geode.management.internal.beans.ManagementAdapter.java

public void handleGatewaySenderStart(GatewaySender sender) throws ManagementException {
    if (!isServiceInitialised("handleGatewaySenderStart")) {
        return;//from ww  w  . j  a va2  s  .  com
    }
    if ((sender.getRemoteDSId() < 0)) {
        return;
    }
    GatewaySenderMBean bean = (GatewaySenderMBean) service.getLocalGatewaySenderMXBean(sender.getId());

    bean.getBridge().setDispatcher();

    Notification notification = new Notification(JMXNotificationType.GATEWAY_SENDER_STARTED, memberSource,
            SequenceNumber.next(), System.currentTimeMillis(),
            ManagementConstants.GATEWAY_SENDER_STARTED_PREFIX + sender.getId());

    memberLevelNotifEmitter.sendNotification(notification);
}