Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Geode uses Java MBeans, specifically MXBeans, to expose management controls and monitoring features.

To provide cluster level management and monitoring, Geode uses a federated Open MBean strategy. The Java classes interact with a single MBeanServer that aggregates MBeans from other local and remote members. This strategy provides a consolidated, single-agent view of the distributed system.

The implementation is based on JMX  (industry-standard and friendly to generic JMX clients), this allows use of any JMX compliant tools (third party or custom build) to manage and monitor Geode cluster. For example, JConsole.

Create and Register a New Geode JMX MBean

...

Code Block
languagejava
titleMemberMBeanBridge fetchJVMMetrics
public JVMMetrics fetchJVMMetrics() {
	long gcCount = getGCStatistic(StatsKey.VM_GC_STATS_COLLECTIONS).longValue();
	long gcTimeMillis = getGCStatistic(StatsKey.VM_GC_STATS_COLLECTION_TIME).longValue();
	long initMemory = memoryMXBean.getHeapMemoryUsage().getInit();
	long committedMemory = memoryMXBean.getHeapMemoryUsage().getCommitted();
	long usedMemory = getVMStatistic(StatsKey.VM_USED_MEMORY).longValue();
	long maxMemory = memoryMXBean.getHeapMemoryUsage().getMax();
	int totalThreads = getVMStatistic(StatsKey.VM_STATS_NUM_THREADS).intValue();
	return new JVMMetrics(gcCount, gcTimeMillis, initMemory, committedMemory,
	  usedMemory, maxMemory, totalThreads);
}

...

The JVMMetrics class is defined like:

...

Note: The JVMMetrics (and other data beans) are returned to the JMX client as CompositeData objects.

Handle MBean Lifecycle

...

Modify ManagementListener and ManagementAdapter

 

When a Cache is created, it creates a ManagementListener that listens for ResourceEvents (in the GemFireCacheImpl constructor). Each ResourceEvent triggers an MBean to be instantiated, registered and federated. For example, when a Region is created, the REGION_CREATE ResourceEvent is sent like: 

Code Block
languagejava
titleCreate Region
public Region createVMRegion(String name, RegionAttributes p_attrs, InternalRegionArguments internalRegionArgs) {
  ...
  system.handleResourceEvent(ResourceEvent.REGION_CREATE, rgn);
}

...

In the ManagementListener, the REGION_CREATE ResourceEvent causes the RegionMBean to be instantiated and registered like: 

Code Block
languagejava
titleHandle ResourceEvent
In ManagementListener:
 
public void handleEvent(ResourceEvent event, Object resource) {
 ...
 case REGION_CREATE:
   adapter.handleRegionCreation(createdRegion);
   break;
 ...
}
 
In ManagementAdapter:
 
public <K, V> void handleRegionCreation(Region<K, V> region) {
 ...
 RegionMBeanBridge<K, V> bridge = RegionMBeanBridge.getInstance(region);
 RegionMXBean regionMBean = new RegionMBean<K, V>(bridge);
 ObjectName regionMBeanName = MBeanJMXAdapter.getRegionMBeanName(cacheImpl
     .getDistributedSystem().getDistributedMember(), region.getFullPath());
 ObjectName changedMBeanName = service.registerInternalMBean(regionMBean, regionMBeanName);
 service.federate(changedMBeanName, RegionMXBean.class, true);
 ...
}

...

When the FederationComponent is initially created, the ManagementCacheListener afterCreate method is invoked. This causes a proxy representation of the MBean to be registered in the MBeanServer using MBeanJMXAdapter registerMBeanProxy.

Some examples are:

  • GemFire:service=CacheService,name=LuceneService,type=Member,member=192.168.2.13(69570)<ec><v1>-1025

  • GemFire:type=Member,member=192.168.2.13(69570)<ec><v1>-1025

  • GemFire:service=LockService,name=gatewayEventIdIndexMetaData_lockService,type=Member,member=192.168.2.13(69570)<ec><v1>-1025

  • GemFire:service=DiskStore,name=DEFAULT,type=Member,member=192.168.2.13(69570)<ec><v1>-1025

  • GemFire:service=CacheServer,port=58176,type=Member,member=192.168.2.13(69570)<ec><v1>-1025

  • GemFire:service=AsyncEventQueue,queue=full_index#_data,type=Member,member=192.168.2.13(69570)<ec><v1>-1025

  • GemFire:service=Region,name=/data,type=Member,member=192.168.2.13(69570)<ec><v1>-1025

 

Aggregation

 Depending on the MBean, an AggregateHandler is invoked to aggregate the data.

 When the ManagementCacheListener afterUpdate method is invoked, it retrieves the proxy and updates the state of the MBean.

 More details to come.

...

 

What is registered for each ObjectName by the registerMBeanProxy method is a each MBean by the registerMBeanProxy method is a MBeanProxyInvocationHandler. This object handles requests from JMX clients. MBean state is retrieved When a request is received, it is handled in one of two ways, either by operation or by attribute.

All operations are forwarded to the appropriate member using the MBeanProxyInvocationHandler delegateToFunctionService method. This method executes the ManagementFunction in the member. The ManagementFunction uses the local MBeanServer to invoke the operation on the MBean represented by the ObjectName.

All requests for attributes are handled by the MBeanProxyInvocationHandler delegateToObjectState method. This method gets the FederationComponent from the local monitoring region and retrieves the value of the requested attribute. All requests for operations are handled by the MBeanProxyInvocationHandler delegateToFunctionService method. This method executes the ManagementFunction to forward the operation to the appropriate member. The ManagementFunction executes in the member and uses the MBeanServer to invoke the operation on the MBean.

Aggregation

 Depending on the MBean, an AggregateHandler is invoked to aggregate the data in the JMX manager.

 When the ManagementCacheListener afterUpdate method is invoked, it retrieves the proxy and updates the state of the MBean.

 More details to come.

 All attributes are retrieved in the JMX manager using the MBeanProxyInvocationHandler delegateToObjectState method. This method gets the FederationComponent from the local monitoring region and retrieves value of the requested attribute.