Search in sources :

Example 6 with MBeanRegistrationException

use of javax.management.MBeanRegistrationException in project quasar by puniverse.

the class JMXActorMonitor method unregisterMBean.

public void unregisterMBean() {
    try {
        if (registered) {
            ManagementFactory.getPlatformMBeanServer().unregisterMBean(new ObjectName(name));
            MonitoringServices.getInstance().removePerfNotificationListener(this);
        }
        this.registered = false;
    } catch (InstanceNotFoundException | MBeanRegistrationException | MalformedObjectNameException ex) {
        ex.printStackTrace();
    }
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) InstanceNotFoundException(javax.management.InstanceNotFoundException) MBeanRegistrationException(javax.management.MBeanRegistrationException) ObjectName(javax.management.ObjectName)

Example 7 with MBeanRegistrationException

use of javax.management.MBeanRegistrationException in project quasar by puniverse.

the class JMXFibersMonitor method unregister.

@SuppressWarnings({ "CallToPrintStackTrace", "CallToThreadDumpStack" })
@Override
public void unregister() {
    try {
        if (registered) {
            MonitoringServices.getInstance().removePerfNotificationListener(this);
            ManagementFactory.getPlatformMBeanServer().unregisterMBean(new ObjectName(mbeanName));
        }
        this.registered = false;
    } catch (InstanceNotFoundException ex) {
        ex.printStackTrace();
    } catch (MBeanRegistrationException ex) {
        ex.printStackTrace();
    } catch (MalformedObjectNameException ex) {
        throw new AssertionError(ex);
    }
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) InstanceNotFoundException(javax.management.InstanceNotFoundException) MBeanRegistrationException(javax.management.MBeanRegistrationException) ObjectName(javax.management.ObjectName)

Example 8 with MBeanRegistrationException

use of javax.management.MBeanRegistrationException in project quasar by puniverse.

the class SimpleMBean method registerMBean.

protected void registerMBean() {
    try {
        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
        ObjectName mxbeanName = new ObjectName(name);
        mbs.registerMBean(this, mxbeanName);
        this.registered = true;
    } catch (InstanceAlreadyExistsException ex) {
        throw new RuntimeException(ex);
    } catch (MBeanRegistrationException ex) {
        ex.printStackTrace();
    } catch (NotCompliantMBeanException ex) {
        throw new AssertionError(ex);
    } catch (MalformedObjectNameException ex) {
        throw new AssertionError(ex);
    }
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) MBeanRegistrationException(javax.management.MBeanRegistrationException) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName)

Example 9 with MBeanRegistrationException

use of javax.management.MBeanRegistrationException in project redisson by redisson.

the class JCacheManager method enableManagement.

@Override
public void enableManagement(String cacheName, boolean enabled) {
    checkNotClosed();
    if (cacheName == null) {
        throw new NullPointerException();
    }
    JCache<?, ?> cache = caches.get(cacheName);
    if (cache == null) {
        throw new NullPointerException();
    }
    if (enabled) {
        JCacheManagementMXBean statBean = managementBeans.get(cache);
        if (statBean == null) {
            statBean = new JCacheManagementMXBean(cache);
            JCacheManagementMXBean oldBean = managementBeans.putIfAbsent(cache, statBean);
            if (oldBean != null) {
                statBean = oldBean;
            }
        }
        try {
            ObjectName objectName = queryNames("Configuration", cache);
            if (mBeanServer.queryNames(objectName, null).isEmpty()) {
                mBeanServer.registerMBean(statBean, objectName);
            }
        } catch (MalformedObjectNameException e) {
            throw new CacheException(e);
        } catch (InstanceAlreadyExistsException e) {
            throw new CacheException(e);
        } catch (MBeanRegistrationException e) {
            throw new CacheException(e);
        } catch (NotCompliantMBeanException e) {
            throw new CacheException(e);
        }
    } else {
        unregisterManagementBean(cache);
    }
    cache.getConfiguration(JCacheConfiguration.class).setManagementEnabled(enabled);
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) JCacheConfiguration(org.redisson.jcache.configuration.JCacheConfiguration) CacheException(javax.cache.CacheException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) JCacheManagementMXBean(org.redisson.jcache.bean.JCacheManagementMXBean) MBeanRegistrationException(javax.management.MBeanRegistrationException) ObjectName(javax.management.ObjectName)

Example 10 with MBeanRegistrationException

use of javax.management.MBeanRegistrationException in project ACS by ACS-Community.

the class RemoteThreadsClient method getMBean.

/**
	 * Returns an object representing the MBean registered on the remote JVM agent. If the
	 * MBean has not been registered, then it is registered and then retreived.
	 * @return A {@link RemoteThreadsMBean} object representing the MBean registered
	 * on the remote JVM agent.
	 * @throws RemoteThreadsException If:
	 * <ul>
	 * 	<li>The MBean can't be registered on the remote JVM agent</li>
	 * 	<li>A local reference for this MBean can't be get</li>
	 * </ul>
	 */
public RemoteThreadsMBean getMBean() throws RemoteThreadsException {
    if (rtmb == null) {
        try {
            ObjectName remoteThreadsName = new ObjectName("alma.acs.monitoring:type=RemoteThreads");
            if (!remote.isRegistered(remoteThreadsName))
                remote.createMBean("alma.acs.monitoring.RemoteThreads", remoteThreadsName);
            rtmb = JMX.newMBeanProxy(remote, remoteThreadsName, RemoteThreadsMBean.class);
        } catch (MalformedObjectNameException e) {
        // shouldn't get never get here
        } catch (MBeanRegistrationException e) {
            throw new RemoteThreadsException("Can't register the MBean in the remote server", e);
        } catch (Exception e) {
            throw new RemoteThreadsException("Can't get a reference to the remote MBean", e);
        }
    }
    return rtmb;
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) MBeanRegistrationException(javax.management.MBeanRegistrationException) AgentInitializationException(com.sun.tools.attach.AgentInitializationException) AttachNotSupportedException(com.sun.tools.attach.AttachNotSupportedException) MalformedURLException(java.net.MalformedURLException) AgentLoadException(com.sun.tools.attach.AgentLoadException) IOException(java.io.IOException) MalformedObjectNameException(javax.management.MalformedObjectNameException) 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