Bug 745844 (EDG-48) - Infinispan MBeans need registering in JBoss MBean Server
Summary: Infinispan MBeans need registering in JBoss MBean Server
Keywords:
Status: CLOSED NEXTRELEASE
Alias: EDG-48
Product: JBoss Data Grid 5
Classification: JBoss
Component: Infinispan
Version: unspecified
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: ---
: EAP 5.1.0 EDG TP
Assignee: Default User
QA Contact:
URL: http://jira.jboss.org/jira/browse/EDG-48
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-01-25 14:14 UTC by Galder Zamarreño
Modified: 2011-10-11 17:05 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-03-03 16:17:16 UTC
Type: Bug


Attachments (Terms of Use)
Configuration_changes_for_JBoss_mbean_server_lookup.patch (922 bytes, text/plain)
2011-02-07 10:51 UTC, Galder Zamarreño
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker EDG-48 0 Major Closed Infinispan MBeans need registering in JBoss MBean Server 2018-03-09 13:11:37 UTC

Description Galder Zamarreño 2011-01-25 14:14:36 UTC
project_key: EDG

On Mon, 2011-01-24 at 09:54 +0100, Galder Zamarreño wrote:
On Jan 20, 2011, at 8:55 PM, Richard Achmatowicz wrote:

Hi Galder

Run into a couple of problems with the datagrid.sar deployment and JMX:
1. Infinispan is creating its own MBeanServer to register MBeans in, instead of using the JBoss MBeanServer

This is configurable via mBeanServerLookup attribute of globalJmxStatistics. By default it uses java.lang.management.ManagementFactory.getPlatformMBeanServer().

So, maybe it needs to retrieve the JBoss MBeanServer? I've just checked the AS6 configurations and they didn't have to modify this, at least not in XML (not sure if they do something programmatically, maybe Paul/Scott can confirm this):
https://svn.jboss.org/repos/jbossas/tags/6.0.0.Final/cluster/src/resources/infinispan/infinispan-configs.xml

To clarify, in AS6, an mbean server lookup is added programatically by
the CacheContainerFactory.  The factory serves a few purposes:
* To inject the JBoss mbean server
* To allow Infinispan to fetch its channel from the AS's JChannelFactory
* To wrap the DefaultCacheManager impl with a decorator that implements
a workaround ISPN-658
See here:
https://svn.jboss.org/repos/jbossas/projects/cluster/ha-server-ispn/tags/1.0.0.Final/src/main/java/org/jboss/ha/ispn/DefaultCacheContainerFactory.java

And here is this object's configuration:
 <bean name="CacheContainerFactory" class="org.jboss.ha.ispn.DefaultCacheContainerFactory">
   <constructor>
     <parameter><inject bean="JChannelFactory"/></parameter>
     <parameter><inject bean="JMXKernel" property="mbeanServer"/></parameter>
   </constructor>
 </bean>

So, perhaps EDG may want to leverage this?  This library
(ha-server-ispn, has no dependencies other than infinispan)

So, it would seem like AS6 uses the default platform MBeanServer whereas EAP5 uses the JBoss MBeanServer. IOW, for the datagrid profile, an implementation of org.infinispan.jmx.MBeanServerLookup is needed that does this:

import org.jboss.mx.util.MBeanServerLocator;

public class JBossMBeanServerLookup implements MBeanServerLookup {

  public MBeanServer getMBeanServer(Properties properties) {
     return MBeanServerLocator.locateJBoss();
  }

}

I'm not sure though where we'd put that code... I don't think it you can do it in cluster/ or any of the existing modules cos that would add infinispan as dependency to the default server profiles, which would bring a different JGroups as well, not good. The alternatives are:

- create a new maven module where you put this code in and make sure it gets shipped with the rest jars
- or, create a new maven module in infinispan where we add this code and its dependency, and add a dependency for that in EDG.

The first of the two options is the one that makes more sense since this is integration code and should live in AS/EDG.

2. DefaltCacheManager.start() seems to get called twice in startup, which causes "Could not register object with name" messages to appear in the console

Known issue in 4.2.0: https://issues.jboss.org/browse/ISPN-853


Any ideas? If this is not an quick answer, want me to set up a JIRA?
Details below.

I wanted to use JMX to talk to some of the Infinispan MBeans, so I set globalJmxStatistics=true in the global configuration.
Beacuse the JMX console is not enabled in EDG, I tried to use twiddle to interact with the MBeans but found none:

./twiddle.sh -s 192.168.0.100:1099 query '*:*'
// no MBeans listed in domain infinispan

It appears that Infinspan is creating its own MBeanServer when DefaultCacheManager is deployed, and not referencing the existing JBoss MBeanServer.
Here is some debugging output from the EDG console on startup. I added some logging statements to a few components:

14:38:32,334 INFO  [DefaultCacheManager] start() called (which calls CacheManagerJmxRegistration)
14:38:32,334 INFO  [CacheManagerJmxRegistration] MBean server = org.jboss.mx.server.MBeanServerImpl@21453d72[ defaultDomain='jboss' ]
14:38:32,336 INFO  [CacheManagerJmxRegistration] domains = [Ljava.lang.String;@476127f4
14:38:32,336 INFO  [CacheManagerJmxRegistration] in start()
14:38:32,425 INFO  [ComponentsJmxRegistration] mBeanServer = org.jboss.mx.server.MBeanServerImpl@b354f7e[ defaultDomain='null' ], jmxDomain = infinispan, groupName = type=CacheManager,name="DefaultCacheManager"
14:38:32,442 INFO  [ComponentsJmxRegistration] Trying to register org.infinispan.jmx.ResourceDMBean@4fa6cb2d under infinispan:type=CacheManager,name="DefaultCacheManager",component=CacheManager
14:38:32,442 INFO  [ComponentsJmxRegistration] Pre-existing object names:
14:38:32,442 INFO  [ComponentsJmxRegistration] on = java.lang:type=MemoryPool,name=PS Eden Space
14:38:32,443 INFO  [ComponentsJmxRegistration] on = java.lang:type=Memory
14:38:32,443 INFO  [ComponentsJmxRegistration] on = java.lang:type=MemoryPool,name=PS Survivor Space
14:38:32,443 INFO  [ComponentsJmxRegistration] on = java.lang:type=MemoryPool,name=Code Cache
14:38:32,443 INFO  [ComponentsJmxRegistration] on = java.lang:type=GarbageCollector,name=PS MarkSweep
14:38:32,443 INFO  [ComponentsJmxRegistration] on = java.lang:type=Runtime
14:38:32,443 INFO  [ComponentsJmxRegistration] on = java.lang:type=ClassLoading
14:38:32,443 INFO  [ComponentsJmxRegistration] on = JMImplementation:type=MBeanRegistry
14:38:32,443 INFO  [ComponentsJmxRegistration] on = JMImplementation:service=LoaderRepository,name=Default
14:38:32,443 INFO  [ComponentsJmxRegistration] on = java.lang:type=Threading
14:38:32,443 INFO  [ComponentsJmxRegistration] on = java.util.logging:type=Logging
14:38:32,443 INFO  [ComponentsJmxRegistration] on = java.lang:type=Compilation
14:38:32,443 INFO  [ComponentsJmxRegistration] on = com.sun.management:type=HotSpotDiagnostic
14:38:32,443 INFO  [ComponentsJmxRegistration] on = java.lang:type=MemoryPool,name=PS Perm Gen
14:38:32,443 INFO  [ComponentsJmxRegistration] on = java.lang:type=OperatingSystem
14:38:32,443 INFO  [ComponentsJmxRegistration] on = java.lang:type=GarbageCollector,name=PS Scavenge
14:38:32,443 INFO  [ComponentsJmxRegistration] on = java.lang:type=MemoryPool,name=PS Old Gen
14:38:32,444 INFO  [ComponentsJmxRegistration] on = JMImplementation:type=MBeanServerDelegate
14:38:32,444 INFO  [ComponentsJmxRegistration] on = java.lang:type=MemoryManager,name=CodeCacheManager
14:38:32,444 INFO  [DefaultCacheManager] start() called (which calls CacheManagerJmxRegistration)
14:38:32,445 INFO  [CacheManagerJmxRegistration] MBean server = org.jboss.mx.server.MBeanServerImpl@21453d72[ defaultDomain='jboss' ]
14:38:32,445 INFO  [CacheManagerJmxRegistration] domains = [Ljava.lang.String;@3d1cd90
14:38:32,445 INFO  [CacheManagerJmxRegistration] MBean server = org.jboss.mx.server.MBeanServerImpl@b354f7e[ defaultDomain='null' ]
14:38:32,445 INFO  [CacheManagerJmxRegistration] domains = [Ljava.lang.String;@430eaae5
14:38:32,445 INFO  [CacheManagerJmxRegistration] in start()
14:38:32,445 INFO  [ComponentsJmxRegistration] mBeanServer = org.jboss.mx.server.MBeanServerImpl@b354f7e[ defaultDomain='null' ], jmxDomain = infinispan, groupName = type=CacheManager,name="DefaultCacheManager"
14:38:32,454 INFO  [ComponentsJmxRegistration] Trying to register org.infinispan.jmx.ResourceDMBean@77f5c2c7 under infinispan:type=CacheManager,name="DefaultCacheManager",component=CacheManager
14:38:32,455 INFO  [ComponentsJmxRegistration] Pre-existing object names:
14:38:32,455 INFO  [ComponentsJmxRegistration] on = java.lang:type=MemoryPool,name=PS Eden Space
14:38:32,455 INFO  [ComponentsJmxRegistration] on = java.lang:type=Memory
14:38:32,455 INFO  [ComponentsJmxRegistration] on = java.lang:type=MemoryPool,name=PS Survivor Space
14:38:32,455 INFO  [ComponentsJmxRegistration] on = java.lang:type=MemoryPool,name=Code Cache
14:38:32,455 INFO  [ComponentsJmxRegistration] on = java.lang:type=GarbageCollector,name=PS MarkSweep
14:38:32,455 INFO  [ComponentsJmxRegistration] on = java.lang:type=Runtime
14:38:32,455 INFO  [ComponentsJmxRegistration] on = java.lang:type=ClassLoading
14:38:32,459 INFO  [ComponentsJmxRegistration] on = JMImplementation:type=MBeanRegistry
14:38:32,459 INFO  [ComponentsJmxRegistration] on = JMImplementation:service=LoaderRepository,name=Default
14:38:32,459 INFO  [ComponentsJmxRegistration] on = java.lang:type=Threading
14:38:32,459 INFO  [ComponentsJmxRegistration] on = infinispan:type=CacheManager,name="DefaultCacheManager",component=CacheManager
14:38:32,459 INFO  [ComponentsJmxRegistration] on = java.util.logging:type=Logging
14:38:32,459 INFO  [ComponentsJmxRegistration] on = java.lang:type=Compilation
14:38:32,460 INFO  [ComponentsJmxRegistration] on = com.sun.management:type=HotSpotDiagnostic
14:38:32,460 INFO  [ComponentsJmxRegistration] on = java.lang:type=MemoryPool,name=PS Perm Gen
14:38:32,460 INFO  [ComponentsJmxRegistration] on = java.lang:type=OperatingSystem
14:38:32,460 INFO  [ComponentsJmxRegistration] on = java.lang:type=GarbageCollector,name=PS Scavenge
14:38:32,460 INFO  [ComponentsJmxRegistration] on = java.lang:type=MemoryPool,name=PS Old Gen
14:38:32,460 INFO  [ComponentsJmxRegistration] on = JMImplementation:type=MBeanServerDelegate
14:38:32,460 INFO  [ComponentsJmxRegistration] on = java.lang:type=MemoryManager,name=CodeCacheManager
14:38:32,460 INFO  [ComponentsJmxRegistration] Could not register object with name(ra): infinispan:type=CacheManager,name="DefaultCacheManager",component=CacheManager
14:38:32,953 INFO  [JGroupsTransport] Starting JGroups Channel

It also seems that DefaultCacheManager.start() is getting called twice, and the first registration of CacheManager succeeds, but the second attempt fails.




--
Galder Zamarreño
Sr. Software Engineer
Infinispan, JBoss Cache

Comment 1 Galder Zamarreño 2011-02-01 17:25:46 UTC
Link: Added: This issue depends ISPN-910


Comment 2 Galder Zamarreño 2011-02-01 17:34:36 UTC
Richard, once next 4.2.1 CR or Final release is out, make sure you update infinispan-configuration.xml to be:

<globalJmxStatistics enabled="true" mBeanServerLookup="org.infinispan.jmx.JBossMBeanServerLookup"/>

Also, make sure all caches have JMX statistics are enabled via:

<jmxStatistics enabled="true"/>

Comment 3 Galder Zamarreño 2011-02-07 10:51:17 UTC
Please find attached a patch for the Infinispan configuration file that should be applied once Infinispan has been upgraded to get around this issue.

Comment 4 Galder Zamarreño 2011-02-07 10:51:17 UTC
Attachment: Added: Configuration_changes_for_JBoss_mbean_server_lookup.patch


Comment 5 Galder Zamarreño 2011-02-14 18:34:19 UTC
Richard, 4.2.1.CR2 should be released this week.

Comment 6 Galder Zamarreño 2011-02-22 15:24:32 UTC
Richard, CR3 is out. So, can you update EDG to CR3 and apply the patch I attached to this JIRA?

Comment 7 Richard Achmatowicz 2011-02-22 15:35:01 UTC
OK. I'll do it today.
Thanks for the fix, Galder!

Comment 8 Richard Achmatowicz 2011-02-22 17:22:11 UTC
Made the changes to the testsuite server configurations datagrid-0, datagrid-1 and everything seems OK:

[nrla@lenovo bin]$ ./twiddle.sh -s 192.168.0.100:1099 query '*:*' | grep infinispan:type=
infinispan:type=Cache,name="sampleReplicatedCache(repl_async)",manager="DefaultCacheManager",component=LockManager
infinispan:type=Cache,name="samplePersistedCache(dist_sync)",manager="DefaultCacheManager",component=CacheStore
infinispan:type=Cache,name="samplePersistedCache(dist_sync)",manager="DefaultCacheManager",component=Cache
infinispan:type=Cache,name="sampleReplicatedCache(repl_async)",manager="DefaultCacheManager",component=Statistics
infinispan:type=Cache,name="___defaultcache(dist_sync)",manager="DefaultCacheManager",component=LockManager
infinispan:type=Cache,name="samplePersistedCache(dist_sync)",manager="DefaultCacheManager",component=Statistics
infinispan:type=Cache,name="samplePersistedCache(dist_sync)",manager="DefaultCacheManager",component=LockManager
infinispan:type=Cache,name="samplePersistedCache(dist_sync)",manager="DefaultCacheManager",component=CacheLoader
infinispan:type=Cache,name="___defaultcache(dist_sync)",manager="DefaultCacheManager",component=RpcManager
infinispan:type=Cache,name="___hotRodTopologyCache(repl_sync)",manager="DefaultCacheManager",component=Statistics
infinispan:type=Cache,name="samplePersistedCache(dist_sync)",manager="DefaultCacheManager",component=Transactions
infinispan:type=CacheManager,name="DefaultCacheManager",component=CacheManager
infinispan:type=Cache,name="___hotRodTopologyCache(repl_sync)",manager="DefaultCacheManager",component=LockManager
infinispan:type=Cache,name="sampleReplicatedCache(repl_async)",manager="DefaultCacheManager",component=RpcManager
infinispan:type=Cache,name="sampleReplicatedCache(repl_async)",manager="DefaultCacheManager",component=Transactions
infinispan:type=Cache,name="samplePersistedCache(dist_sync)",manager="DefaultCacheManager",component=RpcManager
infinispan:type=Cache,name="___hotRodTopologyCache(repl_sync)",manager="DefaultCacheManager",component=Cache
infinispan:type=Cache,name="___defaultcache(dist_sync)",manager="DefaultCacheManager",component=DistributionManager
infinispan:type=Cache,name="___defaultcache(dist_sync)",manager="DefaultCacheManager",component=Statistics
infinispan:type=Cache,name="___hotRodTopologyCache(repl_sync)",manager="DefaultCacheManager",component=RpcManager
infinispan:type=Cache,name="___hotRodTopologyCache(repl_sync)",manager="DefaultCacheManager",component=Transactions
infinispan:type=Cache,name="samplePersistedCache(dist_sync)",manager="DefaultCacheManager",component=DistributionManager
infinispan:type=Cache,name="sampleReplicatedCache(repl_async)",manager="DefaultCacheManager",component=Cache
infinispan:type=Cache,name="___defaultcache(dist_sync)",manager="DefaultCacheManager",component=Cache
infinispan:type=Cache,name="___defaultcache(dist_sync)",manager="DefaultCacheManager",component=Transactions

I also modified the configuration in extras/datagrid but left the original default values for whether or not JMX should be on, as JMX off was the original default:

<globalJmxStatistics enabled="false" jmxDomain="infinispan" mBeanServerLookup="org.infinispan.jmx.JBossMBeanServerLookup"/>
<jmxStatistics enabled="false"/>

Is this OK with you?

Comment 9 Galder Zamarreño 2011-02-22 17:38:24 UTC
Personally, I'd leave JMX should be on by default. That way you can quickly glance at stats information.

JMX is on for Infinispan caches in AS6: http://anonsvn.jboss.org/repos/jbossas/trunk/cluster/src/resources/infinispan/infinispan-configs.xml

Comment 10 Richard Achmatowicz 2011-02-22 17:57:55 UTC
OK, i'll set it on by default. 

Comment 11 Galder Zamarreño 2011-03-03 10:49:00 UTC
Richard, this should be solved by now? Ready to be closed?

Comment 12 Richard Achmatowicz 2011-03-03 16:17:00 UTC
Yes, looks that way. I got swapped out.


Note You need to log in before you can comment on or make changes to this bug.