Search in sources :

Example 16 with MBeanRegistrationException

use of javax.management.MBeanRegistrationException in project uPortal by Jasig.

the class RequestCacheAspect method getCacheStatistics.

protected final CacheStatistics getCacheStatistics(ProceedingJoinPoint pjp, RequestCache requestCache) {
    final Signature signature = pjp.getSignature();
    final String signatureString = signature.toString();
    CacheStatistics cacheStatistics = this.methodStats.get(signatureString);
    if (cacheStatistics == null) {
        final CacheStatistics newStats = new CacheStatistics();
        cacheStatistics = ConcurrentMapUtils.putIfAbsent(this.methodStats, signatureString, newStats);
        if (this.mBeanExportOperations != null && cacheStatistics == newStats) {
            final String nameString = "uPortal:section=Cache,RequestCache=RequestCache,name=" + EhcacheHibernateMbeanNames.mbeanSafe(signatureString);
            try {
                final ObjectName name = new ObjectName(nameString);
                registerMbean(cacheStatistics, name);
            } catch (MalformedObjectNameException e) {
                logger.warn("Failed to create ObjectName {} the corresponding CacheStatistics will not be registered with JMX", nameString, e);
            } catch (NullPointerException e) {
                logger.warn("Failed to create ObjectName {} the corresponding CacheStatistics will not be registered with JMX", nameString, e);
            } catch (InstanceAlreadyExistsException e) {
                logger.warn("ObjectName {} is already registered, the corresponding CacheStatistics will not be registered with JMX", nameString, e);
            } catch (MBeanRegistrationException e) {
                logger.warn("Failed to register ObjectName {} the corresponding CacheStatistics will not be registered with JMX", nameString, e);
            } catch (NotCompliantMBeanException e) {
                logger.warn("Failed to register ObjectName {} the corresponding CacheStatistics will not be registered with JMX", nameString, e);
            }
        }
    }
    return cacheStatistics;
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) Signature(org.aspectj.lang.Signature) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) MBeanRegistrationException(javax.management.MBeanRegistrationException) ObjectName(javax.management.ObjectName)

Example 17 with MBeanRegistrationException

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

the class DefaultMBeanServerInterceptor method unregisterMBean.

public void unregisterMBean(ObjectName name) throws InstanceNotFoundException, MBeanRegistrationException {
    if (name == null) {
        final RuntimeException wrapped = new IllegalArgumentException("Object name cannot be null");
        throw new RuntimeOperationsException(wrapped, "Exception occurred trying to unregister the MBean");
    }
    name = nonDefaultDomain(name);
    synchronized (beingUnregistered) {
        while (beingUnregistered.contains(name)) {
            try {
                beingUnregistered.wait();
            } catch (InterruptedException e) {
                throw new MBeanRegistrationException(e, e.toString());
            // pretend the exception came from preDeregister;
            // in another execution sequence it could have
            }
        }
        beingUnregistered.add(name);
    }
    try {
        exclusiveUnregisterMBean(name);
    } finally {
        synchronized (beingUnregistered) {
            beingUnregistered.remove(name);
            beingUnregistered.notifyAll();
        }
    }
}
Also used : JMRuntimeException(javax.management.JMRuntimeException) MBeanRegistrationException(javax.management.MBeanRegistrationException) RuntimeOperationsException(javax.management.RuntimeOperationsException)

Example 18 with MBeanRegistrationException

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

the class ManagementFactoryHelper method addMBean.

/**
     * Registers a given MBean if not registered in the MBeanServer;
     * otherwise, just return.
     */
private static void addMBean(MBeanServer mbs, Object mbean, String mbeanName) {
    try {
        final ObjectName objName = Util.newObjectName(mbeanName);
        // inner class requires these fields to be final
        final MBeanServer mbs0 = mbs;
        final Object mbean0 = mbean;
        AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {

            public Void run() throws MBeanRegistrationException, NotCompliantMBeanException {
                try {
                    mbs0.registerMBean(mbean0, objName);
                    return null;
                } catch (InstanceAlreadyExistsException e) {
                // if an instance with the object name exists in
                // the MBeanServer ignore the exception
                }
                return null;
            }
        });
    } catch (PrivilegedActionException e) {
        throw Util.newException(e.getException());
    }
}
Also used : PrivilegedActionException(java.security.PrivilegedActionException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) MBeanRegistrationException(javax.management.MBeanRegistrationException) ObjectName(javax.management.ObjectName) MBeanServer(javax.management.MBeanServer)

Example 19 with MBeanRegistrationException

use of javax.management.MBeanRegistrationException in project cdap by caskdata.

the class OperationalStatsService method shutDown.

@Override
protected void shutDown() throws Exception {
    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
    for (Map.Entry<OperationalExtensionId, OperationalStats> entry : operationalStatsLoader.getAll().entrySet()) {
        OperationalStats operationalStats = entry.getValue();
        ObjectName objectName = getObjectName(operationalStats);
        if (objectName == null) {
            LOG.warn("Found an operational extension with null service name and stat type while unregistering - {}. " + "Ignoring this extension.", operationalStats.getClass().getName());
            continue;
        }
        try {
            mbs.unregisterMBean(objectName);
        } catch (InstanceNotFoundException e) {
            LOG.warn("MBean {} not found while un-registering. Ignoring.", objectName);
        } catch (MBeanRegistrationException e) {
            LOG.warn("Error while un-registering MBean {}.", e);
        }
        operationalStats.destroy();
    }
    LOG.info("Successfully shutdown operational stats service.");
}
Also used : InstanceNotFoundException(javax.management.InstanceNotFoundException) Map(java.util.Map) MBeanRegistrationException(javax.management.MBeanRegistrationException) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName)

Example 20 with MBeanRegistrationException

use of javax.management.MBeanRegistrationException in project ddf by codice.

the class QueryMonitor method registerMbean.

private void registerMbean() {
    try {
        objectName = new ObjectName(QueryMonitor.class.getName() + ":service=querymonitor");
        mBeanServer = ManagementFactory.getPlatformMBeanServer();
    } catch (MalformedObjectNameException e) {
        LOGGER.info("Unable to create Query Monitor Configuration MBean.", e);
    }
    if (mBeanServer == null) {
        return;
    }
    try {
        try {
            mBeanServer.registerMBean(this, objectName);
            LOGGER.debug("Registered Query Monitor Configuration MBean under object name: {}", objectName.toString());
        } catch (InstanceAlreadyExistsException e) {
            // Try to remove and re-register
            mBeanServer.unregisterMBean(objectName);
            mBeanServer.registerMBean(this, objectName);
            LOGGER.debug("Re-registered Query Monitor Configuration MBean");
        }
    } catch (MBeanRegistrationException | InstanceNotFoundException | InstanceAlreadyExistsException | NotCompliantMBeanException e) {
        LOGGER.info("Could not register MBean [{}].", objectName.toString(), e);
    }
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) InstanceNotFoundException(javax.management.InstanceNotFoundException) MBeanRegistrationException(javax.management.MBeanRegistrationException) ObjectName(javax.management.ObjectName)

Aggregations

MBeanRegistrationException (javax.management.MBeanRegistrationException)48 ObjectName (javax.management.ObjectName)39 MalformedObjectNameException (javax.management.MalformedObjectNameException)35 InstanceAlreadyExistsException (javax.management.InstanceAlreadyExistsException)31 NotCompliantMBeanException (javax.management.NotCompliantMBeanException)29 InstanceNotFoundException (javax.management.InstanceNotFoundException)21 MBeanServer (javax.management.MBeanServer)20 StandardMBean (javax.management.StandardMBean)8 IOException (java.io.IOException)7 RuntimeOperationsException (javax.management.RuntimeOperationsException)5 MalformedURLException (java.net.MalformedURLException)4 JMRuntimeException (javax.management.JMRuntimeException)3 MBeanException (javax.management.MBeanException)3 ObjectInstance (javax.management.ObjectInstance)3 PrivilegedActionException (java.security.PrivilegedActionException)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 ReflectionException (javax.management.ReflectionException)2 Test (org.junit.Test)2 Logger (ch.qos.logback.classic.Logger)1