Search in sources :

Example 36 with StandardMBean

use of javax.management.StandardMBean 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 37 with StandardMBean

use of javax.management.StandardMBean 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)

Example 38 with StandardMBean

use of javax.management.StandardMBean in project ignite by apache.

the class GridMBeanSelfTest method testEmptyDescriptionMBeanInfo.

/**
 * Tests correct MBean interface.
 *
 * @throws Exception Thrown if test fails.
 */
@Test
public void testEmptyDescriptionMBeanInfo() throws Exception {
    try {
        StandardMBean mbean = new IgniteStandardMXBean(new GridMBeanImplementation(), GridMBeanInterfaceEmptyDescription.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)

Example 39 with StandardMBean

use of javax.management.StandardMBean in project drools by kiegroup.

the class MBeanUtils method registerMBean.

public static synchronized <T> void registerMBean(T mbean, Class<T> mbeanInterface, ObjectName name) {
    try {
        MBeanServer mbs = getMBeanServer();
        if (!mbs.isRegistered(name)) {
            final StandardMBean adapter = new StandardMBean(mbean, mbeanInterface);
            mbs.registerMBean(adapter, name);
        }
    } catch (Exception e) {
        logger.error("Unable to register mbean " + name + " into the platform MBean Server", e);
    }
}
Also used : StandardMBean(javax.management.StandardMBean) MBeanServer(javax.management.MBeanServer)

Example 40 with StandardMBean

use of javax.management.StandardMBean in project drools by kiegroup.

the class KnowledgeBaseMonitoring method startInternalMBeans.

public void startInternalMBeans() {
    for (EntryPointNode epn : kbase.getRete().getEntryPointNodes().values()) {
        for (ObjectTypeNode otn : epn.getObjectTypeNodes().values()) {
            ObjectTypeNodeMonitor otnm = new ObjectTypeNodeMonitor(otn);
            try {
                final StandardMBean adapter = new StandardMBean(otnm, ObjectTypeNodeMonitorMBean.class);
                ObjectName name = DroolsManagementAgent.createObjectName(this.name.toString() + ",group=EntryPoints,EntryPoint=" + otnm.getNameSufix() + ",ObjectType=" + ((ClassObjectType) otn.getObjectType()).getClassName());
                DroolsManagementAgent.getInstance().registerMBean(kbase, adapter, name);
            } catch (NotCompliantMBeanException e) {
                logger.error("Unable to register ObjectTypeNodeMonitor mbean for OTN " + otn.getObjectType() + " into the platform MBean Server", e);
            }
        }
    }
    final KieBaseConfigurationMonitor kbcm = new KieBaseConfigurationMonitor(kbase.getConfiguration());
    try {
        final StandardMBean adapter = new StandardMBean(kbcm, KieBaseConfigurationMonitorMBean.class);
        ObjectName name = DroolsManagementAgent.createObjectName(this.name.toString() + ",group=Configuration");
        DroolsManagementAgent.getInstance().registerMBean(kbase, adapter, name);
    } catch (NotCompliantMBeanException e) {
        logger.error("Unable to register KBaseConfigurationMonitor mbean into the platform MBean Server", e);
    }
}
Also used : EntryPointNode(org.drools.core.reteoo.EntryPointNode) ClassObjectType(org.drools.core.base.ClassObjectType) StandardMBean(javax.management.StandardMBean) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) ObjectTypeNode(org.drools.core.reteoo.ObjectTypeNode) ObjectName(javax.management.ObjectName)

Aggregations

StandardMBean (javax.management.StandardMBean)70 ObjectName (javax.management.ObjectName)32 NotCompliantMBeanException (javax.management.NotCompliantMBeanException)21 MBeanServer (javax.management.MBeanServer)17 MalformedObjectNameException (javax.management.MalformedObjectNameException)16 InstanceAlreadyExistsException (javax.management.InstanceAlreadyExistsException)12 MBeanRegistrationException (javax.management.MBeanRegistrationException)9 Test (org.junit.Test)9 JMException (javax.management.JMException)7 IOException (java.io.IOException)6 Logger (org.apache.aries.jmx.Logger)6 InstanceNotFoundException (javax.management.InstanceNotFoundException)5 Activate (org.apache.felix.scr.annotations.Activate)5 IgniteStandardMXBean (org.apache.ignite.internal.mxbean.IgniteStandardMXBean)5 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)5 MBeanInfo (javax.management.MBeanInfo)4 OpenDataException (javax.management.openmbean.OpenDataException)4 MBeanAttributeInfo (javax.management.MBeanAttributeInfo)3 CompositeType (javax.management.openmbean.CompositeType)3 OpenType (javax.management.openmbean.OpenType)3