Custom JMX MBeans can be added to Geode members. They can be federated but not aggregated in the JMX manager. This means individual members MBean data can be retrieved from the JMX manager but the values from all the members cannot be combined in one bean.
The steps to create and register a new Geode JMX MBean are:
- Define MXBean interface
- Implement MXBean interface with MBean class
- Register the MBean
- Federate the MBean
Define MXBean interface
The MXBean interface provides the JMX bean's attributes and operations.
public interface CustomMXBean { public int getCustomInt(); public String getCustomString(); public String[] listCustomStrings(); }
Implement MXBean interface with MBean class
The MBean class provides the implementation of the MXBean.
public class CustomMBean implements CustomMXBean { public int getCustomInt() { return someInt; } public String getCustomString() { return someString; } public String[] listCustomStrings() { return new String[] {"someString1", "someString2"}; } }
Register the MBean
Registering the MBean causes the MBean to be available to JMX clients of the member. See below for code sample.
Federate the MBean
Federating the MBean causes the MBean to be registered in the JMX manager's MBeanServer which in turn causes the MBean to be available to JMX clients of the JMX manager. In addition, it causes the current values of the MBean's attributes to be periodically sent to the JMX manager.
Note: The JMX manager requires the custom MBean interface and class to be on its classpath.
// Get the ManagementService Cache cache = ...; ManagementService service = ManagementService.getManagementService(cache); // Create the MBean. The domain specified doesn't matter (as long as there is one). It will be replaced by the 'GemFire' domain. CustomMXBean bean = new CustomMBean(); ObjectName beanName = ObjectName.getInstance("GemFire:type=Member,name=Custom"); // Register the MBean. The GemFire ObjectName will be something like: GemFire:type=Member,name=Custom,member=192.168.2.13(68439)<v22>-8504 ObjectName gemfireBeanName = service.registerMBean(bean, beanName); // Federate the MBean. This causes its values to periodically be sent to the JMX manager. service.federate(gemfireBeanName, CustomMXBean.class, false);
In jconsole, the MBean will be available like: