[infinispan-commits] Infinispan SVN: r1316 - in trunk/core/src: test/java/org/infinispan/jmx and 2 other directories.
infinispan-commits at lists.jboss.org
infinispan-commits at lists.jboss.org
Tue Dec 22 11:16:50 EST 2009
Author: galder.zamarreno at jboss.com
Date: 2009-12-22 11:16:49 -0500 (Tue, 22 Dec 2009)
New Revision: 1316
Modified:
trunk/core/src/main/java/org/infinispan/jmx/ComponentsJmxRegistration.java
trunk/core/src/test/java/org/infinispan/jmx/CacheMBeanTest.java
trunk/core/src/test/java/org/infinispan/jmx/CacheManagerMBeanTest.java
trunk/core/src/test/java/org/infinispan/manager/CacheManagerComponentRegistryTest.java
trunk/core/src/test/java/org/infinispan/test/fwk/TestCacheManagerFactory.java
Log:
[ISPN-309] (Default session_factory_name causes MalformedObjectNameException while registering mbeans) Fixed.
Modified: trunk/core/src/main/java/org/infinispan/jmx/ComponentsJmxRegistration.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/jmx/ComponentsJmxRegistration.java 2009-12-21 19:10:54 UTC (rev 1315)
+++ trunk/core/src/main/java/org/infinispan/jmx/ComponentsJmxRegistration.java 2009-12-22 16:16:49 UTC (rev 1316)
@@ -67,7 +67,8 @@
public ComponentsJmxRegistration(MBeanServer mBeanServer, Set<AbstractComponentRegistry.Component> components, String groupName) {
this.mBeanServer = mBeanServer;
this.components = components;
- this.groupName = groupName;
+ // Replace any malforming characters out of the group name
+ this.groupName = groupName.replace(':', '_').replace('=','_');
}
public void setJmxDomain(String jmxDomain) {
Modified: trunk/core/src/test/java/org/infinispan/jmx/CacheMBeanTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/jmx/CacheMBeanTest.java 2009-12-21 19:10:54 UTC (rev 1315)
+++ trunk/core/src/test/java/org/infinispan/jmx/CacheMBeanTest.java 2009-12-22 16:16:49 UTC (rev 1316)
@@ -29,8 +29,6 @@
import javax.management.ObjectName;
import org.infinispan.CacheException;
-import org.infinispan.config.Configuration;
-import org.infinispan.config.GlobalConfiguration;
import org.infinispan.lifecycle.ComponentStatus;
import org.infinispan.manager.CacheManager;
import org.infinispan.manager.DefaultCacheManager;
@@ -48,13 +46,7 @@
@Override
protected CacheManager createCacheManager() throws Exception {
- GlobalConfiguration globalConfiguration = GlobalConfiguration.getNonClusteredDefault();
- globalConfiguration.setJmxDomain(JMX_DOMAIN);
- globalConfiguration.setMBeanServerLookup(PerThreadMBeanServerLookup.class.getName());
- globalConfiguration.setExposeGlobalJmxStatistics(true);
- Configuration configuration = new Configuration();
- configuration.setExposeJmxStatistics(true);
- cacheManager = TestCacheManagerFactory.createCacheManager(globalConfiguration, configuration);
+ cacheManager = TestCacheManagerFactory.createJmxEnabledCacheManager(JMX_DOMAIN);
server = PerThreadMBeanServerLookup.getThreadMBeanServer();
return cacheManager;
}
@@ -89,17 +81,11 @@
}
public void testManagerStopRemovesCacheMBean(Method m) throws Exception {
- GlobalConfiguration globalConfiguration = GlobalConfiguration.getNonClusteredDefault();
final String otherJmxDomain = JMX_DOMAIN + '.' + m.getName();
- globalConfiguration.setJmxDomain(otherJmxDomain);
- globalConfiguration.setMBeanServerLookup(PerThreadMBeanServerLookup.class.getName());
- globalConfiguration.setExposeGlobalJmxStatistics(true);
- Configuration configuration = new Configuration();
- configuration.setExposeJmxStatistics(true);
ObjectName defaultOn = new ObjectName(otherJmxDomain + ":cache-name=" + DefaultCacheManager.DEFAULT_CACHE_NAME + "(local),jmx-resource=Cache");
ObjectName galderOn = new ObjectName(otherJmxDomain + ":cache-name=galder(local),jmx-resource=Cache");
ObjectName managerON = new ObjectName(otherJmxDomain + ":cache-name=[global],jmx-resource=CacheManager");
- CacheManager otherManager = TestCacheManagerFactory.createCacheManager(globalConfiguration, configuration);
+ CacheManager otherManager = TestCacheManagerFactory.createJmxEnabledCacheManager(otherJmxDomain);
server.invoke(managerON, "startCache", new Object[]{}, new String[]{});
server.invoke(managerON, "startCache", new Object[]{"galder"}, new String[]{String.class.getName()});
assert ComponentStatus.RUNNING.toString().equals(server.getAttribute(defaultOn, "CacheStatus"));
@@ -124,18 +110,18 @@
public void testDuplicateJmxDomainOnlyCacheExposesJmxStatistics() throws Exception {
- GlobalConfiguration globalConfiguration = GlobalConfiguration.getNonClusteredDefault();
- final String otherJmxDomain = JMX_DOMAIN;
- globalConfiguration.setJmxDomain(otherJmxDomain);
- globalConfiguration.setMBeanServerLookup(PerThreadMBeanServerLookup.class.getName());
- Configuration configuration = new Configuration();
- configuration.setExposeJmxStatistics(true);
- CacheManager otherManager = TestCacheManagerFactory.createCacheManager(globalConfiguration, configuration);
+ CacheManager otherManager = TestCacheManagerFactory.createJmxEnabledCacheManager(JMX_DOMAIN, false, true);
try {
otherManager.getCache();
- assert false : "Failure expected, " + otherJmxDomain + " is a duplicate!";
+ assert false : "Failure expected, " + JMX_DOMAIN + " is a duplicate!";
} catch (CacheException e) {
assert e.getCause().getCause() instanceof JmxDomainConflictException;
}
}
+
+ public void testMalformedCacheName(Method m) throws Exception {
+ final String otherJmxDomain = JMX_DOMAIN + '.' + m.getName();
+ CacheManager otherManager = TestCacheManagerFactory.createJmxEnabledCacheManager(otherJmxDomain);
+ otherManager.getCache("persistence.unit:unitName=#helloworld.MyRegion");
+ }
}
Modified: trunk/core/src/test/java/org/infinispan/jmx/CacheManagerMBeanTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/jmx/CacheManagerMBeanTest.java 2009-12-21 19:10:54 UTC (rev 1315)
+++ trunk/core/src/test/java/org/infinispan/jmx/CacheManagerMBeanTest.java 2009-12-22 16:16:49 UTC (rev 1316)
@@ -3,7 +3,6 @@
import java.lang.reflect.Method;
import org.infinispan.config.Configuration;
-import org.infinispan.config.GlobalConfiguration;
import org.infinispan.manager.CacheManager;
import org.infinispan.test.SingleCacheManagerTest;
import org.infinispan.test.fwk.TestCacheManagerFactory;
@@ -30,11 +29,7 @@
private ObjectName name;
protected CacheManager createCacheManager() throws Exception {
- GlobalConfiguration globalConfiguration = GlobalConfiguration.getNonClusteredDefault();
- globalConfiguration.setJmxDomain(JMX_DOMAIN);
- globalConfiguration.setMBeanServerLookup(PerThreadMBeanServerLookup.class.getName());
- globalConfiguration.setExposeGlobalJmxStatistics(true);
- cacheManager = TestCacheManagerFactory.createCacheManager(globalConfiguration);
+ cacheManager = TestCacheManagerFactory.createJmxEnabledCacheManager(JMX_DOMAIN, true, false);
name = new ObjectName(JMX_DOMAIN + ":cache-name=[global],jmx-resource=CacheManager");
server = PerThreadMBeanServerLookup.getThreadMBeanServer();
server.invoke(name, "startCache", new Object[]{}, new String[]{});
@@ -82,12 +77,8 @@
}
public void testJmxRegistrationAtStartupAndStop(Method method) throws Exception {
- GlobalConfiguration globalConfiguration = GlobalConfiguration.getNonClusteredDefault();
final String otherJmxDomain = JMX_DOMAIN + '.' + method.getName();
- globalConfiguration.setJmxDomain(otherJmxDomain);
- globalConfiguration.setMBeanServerLookup(PerThreadMBeanServerLookup.class.getName());
- globalConfiguration.setExposeGlobalJmxStatistics(true);
- CacheManager otherManager = TestCacheManagerFactory.createCacheManager(globalConfiguration);
+ CacheManager otherManager = TestCacheManagerFactory.createJmxEnabledCacheManager(otherJmxDomain, true, false);
ObjectName otherName = new ObjectName(otherJmxDomain + ":cache-name=[global],jmx-resource=CacheManager");
try {
assert server.getAttribute(otherName, "CreatedCacheCount").equals("0");
Modified: trunk/core/src/test/java/org/infinispan/manager/CacheManagerComponentRegistryTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/manager/CacheManagerComponentRegistryTest.java 2009-12-21 19:10:54 UTC (rev 1315)
+++ trunk/core/src/test/java/org/infinispan/manager/CacheManagerComponentRegistryTest.java 2009-12-22 16:16:49 UTC (rev 1316)
@@ -24,7 +24,7 @@
*/
@Test(groups = "functional", testName = "manager.CacheManagerComponentRegistryTest")
public class CacheManagerComponentRegistryTest extends AbstractInfinispanTest {
- DefaultCacheManager cm;
+ CacheManager cm;
@AfterMethod(alwaysRun = true)
public void tearDown() {
Modified: trunk/core/src/test/java/org/infinispan/test/fwk/TestCacheManagerFactory.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/test/fwk/TestCacheManagerFactory.java 2009-12-21 19:10:54 UTC (rev 1315)
+++ trunk/core/src/test/java/org/infinispan/test/fwk/TestCacheManagerFactory.java 2009-12-22 16:16:49 UTC (rev 1316)
@@ -2,6 +2,7 @@
import org.infinispan.config.Configuration;
import org.infinispan.config.GlobalConfiguration;
+import org.infinispan.jmx.PerThreadMBeanServerLookup;
import org.infinispan.manager.CacheManager;
import org.infinispan.manager.DefaultCacheManager;
import org.infinispan.remoting.transport.jgroups.JGroupsTransport;
@@ -115,13 +116,27 @@
return newDefaultCacheManager(globalConfiguration, defaultCacheConfig);
}
- public static DefaultCacheManager createCacheManager(GlobalConfiguration configuration, Configuration defaultCfg) {
+ public static CacheManager createCacheManager(GlobalConfiguration configuration, Configuration defaultCfg) {
minimizeThreads(configuration);
amendMarshaller(configuration);
amendTransport(configuration);
return newDefaultCacheManager(configuration, defaultCfg);
}
+ public static CacheManager createJmxEnabledCacheManager(String jmxDomain) {
+ return createJmxEnabledCacheManager(jmxDomain, true, true);
+ }
+
+ public static CacheManager createJmxEnabledCacheManager(String jmxDomain, boolean exposeGlobalJmx, boolean exposeCacheJmx) {
+ GlobalConfiguration globalConfiguration = GlobalConfiguration.getNonClusteredDefault();
+ globalConfiguration.setJmxDomain(jmxDomain);
+ globalConfiguration.setMBeanServerLookup(PerThreadMBeanServerLookup.class.getName());
+ globalConfiguration.setExposeGlobalJmxStatistics(exposeGlobalJmx);
+ Configuration configuration = new Configuration();
+ configuration.setExposeJmxStatistics(exposeCacheJmx);
+ return createCacheManager(globalConfiguration, configuration);
+ }
+
private static void amendTransport(GlobalConfiguration configuration) {
if (configuration.getTransportClass() != null) { //this is local
Properties newTransportProps = new Properties();
More information about the infinispan-commits
mailing list