Search in sources :

Example 1 with NotCompliantMBeanException

use of javax.management.NotCompliantMBeanException in project tomcat by apache.

the class BaseGenericObjectPool method jmxRegister.

/**
     * Registers the pool with the platform MBean server.
     * The registered name will be
     * <code>jmxNameBase + jmxNamePrefix + i</code> where i is the least
     * integer greater than or equal to 1 such that the name is not already
     * registered. Swallows MBeanRegistrationException, NotCompliantMBeanException
     * returning null.
     *
     * @param config Pool configuration
     * @param jmxNameBase default base JMX name for this pool
     * @param jmxNamePrefix name prefix
     * @return registered ObjectName, null if registration fails
     */
private ObjectName jmxRegister(final BaseObjectPoolConfig config, final String jmxNameBase, String jmxNamePrefix) {
    ObjectName objectName = null;
    final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
    int i = 1;
    boolean registered = false;
    String base = config.getJmxNameBase();
    if (base == null) {
        base = jmxNameBase;
    }
    while (!registered) {
        try {
            ObjectName objName;
            // only one so the names are cleaner.
            if (i == 1) {
                objName = new ObjectName(base + jmxNamePrefix);
            } else {
                objName = new ObjectName(base + jmxNamePrefix + i);
            }
            mbs.registerMBean(this, objName);
            objectName = objName;
            registered = true;
        } catch (final MalformedObjectNameException e) {
            if (BaseObjectPoolConfig.DEFAULT_JMX_NAME_PREFIX.equals(jmxNamePrefix) && jmxNameBase.equals(base)) {
                // Shouldn't happen. Skip registration if it does.
                registered = true;
            } else {
                // Must be an invalid name. Use the defaults instead.
                jmxNamePrefix = BaseObjectPoolConfig.DEFAULT_JMX_NAME_PREFIX;
                base = jmxNameBase;
            }
        } catch (final InstanceAlreadyExistsException e) {
            // Increment the index and try again
            i++;
        } catch (final MBeanRegistrationException e) {
            // Shouldn't happen. Skip registration if it does.
            registered = true;
        } catch (final NotCompliantMBeanException e) {
            // Shouldn't happen. Skip registration if it does.
            registered = true;
        }
    }
    return objectName;
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) MBeanRegistrationException(javax.management.MBeanRegistrationException) ObjectName(javax.management.ObjectName) MBeanServer(javax.management.MBeanServer)

Example 2 with NotCompliantMBeanException

use of javax.management.NotCompliantMBeanException in project hadoop by apache.

the class FsDatasetImpl method registerMBean.

/**
   * Register the FSDataset MBean using the name
   *        "hadoop:service=DataNode,name=FSDatasetState-<datanodeUuid>"
   */
void registerMBean(final String datanodeUuid) {
    // package naming for mbeans and their impl.
    try {
        StandardMBean bean = new StandardMBean(this, FSDatasetMBean.class);
        mbeanName = MBeans.register("DataNode", "FSDatasetState-" + datanodeUuid, bean);
    } catch (NotCompliantMBeanException e) {
        LOG.warn("Error registering FSDatasetState MBean", e);
    }
    LOG.info("Registered FSDatasetState MBean");
}
Also used : StandardMBean(javax.management.StandardMBean) NotCompliantMBeanException(javax.management.NotCompliantMBeanException)

Example 3 with NotCompliantMBeanException

use of javax.management.NotCompliantMBeanException in project aries by apache.

the class MBeanHolder method register.

void register(final MBeanServer server) {
    ObjectInstance instance;
    try {
        instance = server.registerMBean(mbean, requestedObjectName);
        registrations.put(server, instance.getObjectName());
    } catch (InstanceAlreadyExistsException e) {
        log.error("register: Failure registering MBean " + mbean, e);
    } catch (MBeanRegistrationException e) {
        log.error("register: Failure registering MBean " + mbean, e);
    } catch (NotCompliantMBeanException e) {
        log.error("register: Failure registering MBean " + mbean, e);
    }
}
Also used : NotCompliantMBeanException(javax.management.NotCompliantMBeanException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) ObjectInstance(javax.management.ObjectInstance) MBeanRegistrationException(javax.management.MBeanRegistrationException)

Example 4 with NotCompliantMBeanException

use of javax.management.NotCompliantMBeanException in project datanucleus-rdbms by datanucleus.

the class BasicDataSource method jmxRegister.

private void jmxRegister() {
    // Return immediately if this DataSource has already been registered
    if (registeredJmxName != null) {
        return;
    }
    // Return immediately if no JMX name has been specified
    String requestedName = getJmxName();
    if (requestedName == null) {
        return;
    }
    ObjectName oname;
    try {
        oname = new ObjectName(requestedName);
    } catch (MalformedObjectNameException e) {
        log.warn("The requested JMX name [" + requestedName + "] was not valid and will be ignored.");
        return;
    }
    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
    try {
        mbs.registerMBean(this, oname);
    } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e) {
        log.warn("Failed to complete JMX registration", e);
    }
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) MBeanRegistrationException(javax.management.MBeanRegistrationException) ObjectName(javax.management.ObjectName) MBeanServer(javax.management.MBeanServer)

Example 5 with NotCompliantMBeanException

use of javax.management.NotCompliantMBeanException in project SEPA by arces-wot.

the class SEPABeans method registerMBean.

public static void registerMBean(final String mBeanObjectName, final Object mBean) {
    try {
        final ObjectName name = new ObjectName(mBeanObjectName);
        mbs.registerMBean(mBean, name);
    } catch (MalformedObjectNameException badObjectName) {
        logger.error(badObjectName.getMessage());
    } catch (InstanceAlreadyExistsException duplicateMBeanInstance) {
        logger.error(duplicateMBeanInstance.getMessage());
    } catch (MBeanRegistrationException mbeanRegistrationProblem) {
        logger.error(mbeanRegistrationProblem.getMessage());
    } catch (NotCompliantMBeanException badMBean) {
        logger.error(badMBean.getMessage());
    }
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) MBeanRegistrationException(javax.management.MBeanRegistrationException) ObjectName(javax.management.ObjectName)

Aggregations

NotCompliantMBeanException (javax.management.NotCompliantMBeanException)105 ObjectName (javax.management.ObjectName)72 InstanceAlreadyExistsException (javax.management.InstanceAlreadyExistsException)70 MBeanRegistrationException (javax.management.MBeanRegistrationException)70 MalformedObjectNameException (javax.management.MalformedObjectNameException)58 MBeanServer (javax.management.MBeanServer)38 InstanceNotFoundException (javax.management.InstanceNotFoundException)23 StandardMBean (javax.management.StandardMBean)20 MBeanException (javax.management.MBeanException)8 ReflectionException (javax.management.ReflectionException)8 IOException (java.io.IOException)7 ObjectInstance (javax.management.ObjectInstance)5 AttributeNotFoundException (javax.management.AttributeNotFoundException)4 InvalidAttributeValueException (javax.management.InvalidAttributeValueException)4 ListenerNotFoundException (javax.management.ListenerNotFoundException)4 Logger (org.apache.aries.jmx.Logger)4 MalformedURLException (java.net.MalformedURLException)3 DynamicMBean (javax.management.DynamicMBean)3 IntrospectionException (javax.management.IntrospectionException)3 JMRuntimeException (javax.management.JMRuntimeException)3