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();
}
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();
}
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);
}
}
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."));
}
}
}
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;
}
Aggregations