Search in sources :

Example 1 with IgniteStandardMXBean

use of org.apache.ignite.internal.mxbean.IgniteStandardMXBean in project ignite by apache.

the class IgniteUtils method registerMBean.

/**
     * Registers MBean with the server.
     *
     * @param <T> Type of mbean.
     * @param mbeanSrv MBean server.
     * @param igniteInstanceName Ignite instance name.
     * @param grp Name of the group.
     * @param name Name of mbean.
     * @param impl MBean implementation.
     * @param itf MBean interface.
     * @return JMX object name.
     * @throws JMException If MBean creation failed.
     */
public static <T> ObjectName registerMBean(MBeanServer mbeanSrv, @Nullable String igniteInstanceName, @Nullable String grp, String name, T impl, @Nullable Class<T> itf) throws JMException {
    assert mbeanSrv != null;
    assert name != null;
    assert itf != null;
    DynamicMBean mbean = new IgniteStandardMXBean(impl, itf);
    mbean.getMBeanInfo();
    return mbeanSrv.registerMBean(mbean, makeMBeanName(igniteInstanceName, grp, name)).getObjectName();
}
Also used : DynamicMBean(javax.management.DynamicMBean) IgniteStandardMXBean(org.apache.ignite.internal.mxbean.IgniteStandardMXBean)

Example 2 with IgniteStandardMXBean

use of org.apache.ignite.internal.mxbean.IgniteStandardMXBean in project ignite by apache.

the class IgniteUtils method registerCacheMBean.

/**
     * Registers MBean with the server.
     *
     * @param <T> Type of mbean.
     * @param mbeanSrv MBean server.
     * @param igniteInstanceName Ignite instance name.
     * @param cacheName Name of the cache.
     * @param name Name of mbean.
     * @param impl MBean implementation.
     * @param itf MBean interface.
     * @return JMX object name.
     * @throws JMException If MBean creation failed.
     */
public static <T> ObjectName registerCacheMBean(MBeanServer mbeanSrv, @Nullable String igniteInstanceName, @Nullable String cacheName, String name, T impl, Class<T> itf) throws JMException {
    assert mbeanSrv != null;
    assert name != null;
    assert itf != null;
    DynamicMBean mbean = new IgniteStandardMXBean(impl, itf);
    mbean.getMBeanInfo();
    return mbeanSrv.registerMBean(mbean, makeCacheMBeanName(igniteInstanceName, cacheName, name)).getObjectName();
}
Also used : DynamicMBean(javax.management.DynamicMBean) IgniteStandardMXBean(org.apache.ignite.internal.mxbean.IgniteStandardMXBean)

Example 3 with IgniteStandardMXBean

use of org.apache.ignite.internal.mxbean.IgniteStandardMXBean in project ignite by apache.

the class CacheManager method registerCacheObject.

/**
 * @param mxbean MXBean.
 * @param name Cache name.
 * @param beanType Bean type.
 */
private void registerCacheObject(Object mxbean, String name, String beanType) {
    MBeanServer mBeanSrv = ignite.configuration().getMBeanServer();
    ObjectName registeredObjName = getObjectName(name, beanType);
    try {
        if (mBeanSrv.queryNames(registeredObjName, null).isEmpty()) {
            IgniteStandardMXBean bean = beanType.equals(CACHE_CONFIGURATION) ? new IgniteStandardMXBean((CacheMXBean) mxbean, CacheMXBean.class) : new IgniteStandardMXBean((CacheStatisticsMXBean) mxbean, CacheStatisticsMXBean.class);
            mBeanSrv.registerMBean(bean, registeredObjName);
        }
    } catch (Exception e) {
        throw new CacheException("Failed to register MBean: " + registeredObjName, e);
    }
}
Also used : CacheStatisticsMXBean(javax.cache.management.CacheStatisticsMXBean) CacheException(javax.cache.CacheException) IgniteStandardMXBean(org.apache.ignite.internal.mxbean.IgniteStandardMXBean) CacheMXBean(javax.cache.management.CacheMXBean) CacheException(javax.cache.CacheException) MalformedURLException(java.net.MalformedURLException) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) MalformedObjectNameException(javax.management.MalformedObjectNameException) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName)

Example 4 with IgniteStandardMXBean

use of org.apache.ignite.internal.mxbean.IgniteStandardMXBean in project ignite by apache.

the class GridMBeanSelfTest method testCorrectMBeanInfo.

/**
 * Tests correct MBean interface.
 *
 * @throws Exception Thrown if test fails.
 */
@Test
public void testCorrectMBeanInfo() throws Exception {
    StandardMBean mbean = new IgniteStandardMXBean(new GridMBeanImplementation(), GridMBeanInterface.class);
    MBeanInfo info = mbean.getMBeanInfo();
    assert info.getDescription().equals("MBeanDescription.");
    assert info.getOperations().length == 2;
    for (MBeanOperationInfo opInfo : info.getOperations()) {
        if (opInfo.getDescription().equals("MBeanOperation."))
            assert opInfo.getSignature().length == 2;
        else {
            assert opInfo.getDescription().equals("MBeanSuperOperation.");
            assert opInfo.getSignature().length == 1;
        }
    }
    for (MBeanParameterInfo paramInfo : info.getOperations()[0].getSignature()) {
        if (paramInfo.getName().equals("ignored"))
            assert paramInfo.getDescription().equals("MBeanOperationParameter1.");
        else {
            assert paramInfo.getName().equals("someData");
            assert paramInfo.getDescription().equals("MBeanOperationParameter2.");
        }
    }
    assert info.getAttributes().length == 4 : "Expected 4 attributes but got " + info.getAttributes().length;
    for (MBeanAttributeInfo attrInfo : info.getAttributes()) {
        if (!attrInfo.isWritable()) {
            assert (attrInfo.getDescription().equals("MBeanReadonlyGetter.") || attrInfo.getDescription().equals("MBeanROGetter."));
        } else {
            assert (attrInfo.getDescription().equals("MBeanWritableGetter.") || attrInfo.getDescription().equals("MBeanWritableIsGetter."));
        }
    }
}
Also used : MBeanInfo(javax.management.MBeanInfo) StandardMBean(javax.management.StandardMBean) IgniteStandardMXBean(org.apache.ignite.internal.mxbean.IgniteStandardMXBean) MBeanOperationInfo(javax.management.MBeanOperationInfo) MBeanAttributeInfo(javax.management.MBeanAttributeInfo) MBeanParameterInfo(javax.management.MBeanParameterInfo) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 5 with IgniteStandardMXBean

use of org.apache.ignite.internal.mxbean.IgniteStandardMXBean in project ignite by apache.

the class GridMBeanSelfTest method testEmptyNameMBeanInfo.

/**
 * Tests correct MBean interface.
 *
 * @throws Exception Thrown if test fails.
 */
@Test
public void testEmptyNameMBeanInfo() throws Exception {
    try {
        StandardMBean mbean = new IgniteStandardMXBean(new GridMBeanImplementation(), GridMBeanInterfaceEmptyName.class);
        mbean.getMBeanInfo();
    } catch (AssertionError ignored) {
        return;
    }
    assert false;
}
Also used : StandardMBean(javax.management.StandardMBean) IgniteStandardMXBean(org.apache.ignite.internal.mxbean.IgniteStandardMXBean) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Aggregations

IgniteStandardMXBean (org.apache.ignite.internal.mxbean.IgniteStandardMXBean)9 StandardMBean (javax.management.StandardMBean)5 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)5 Test (org.junit.Test)5 DynamicMBean (javax.management.DynamicMBean)3 MalformedURLException (java.net.MalformedURLException)1 CacheException (javax.cache.CacheException)1 CacheMXBean (javax.cache.management.CacheMXBean)1 CacheStatisticsMXBean (javax.cache.management.CacheStatisticsMXBean)1 MBeanAttributeInfo (javax.management.MBeanAttributeInfo)1 MBeanInfo (javax.management.MBeanInfo)1 MBeanOperationInfo (javax.management.MBeanOperationInfo)1 MBeanParameterInfo (javax.management.MBeanParameterInfo)1 MBeanRegistrationException (javax.management.MBeanRegistrationException)1 MBeanServer (javax.management.MBeanServer)1 MalformedObjectNameException (javax.management.MalformedObjectNameException)1 ObjectName (javax.management.ObjectName)1 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 IgniteIllegalStateException (org.apache.ignite.IgniteIllegalStateException)1