public void testHealthCheckAPI() throws Exception { //given //we need this to start a cache with a custom name cacheManagers.get(0).getCache("test").put("1", "1"); final MBeanServer mBeanServer = PerThreadMBeanServerLookup.getThreadMBeanServer(); //when String domain0 = manager(0).getCacheManagerConfiguration().globalJmxStatistics().domain(); ObjectName healthAPI0 = TestingUtil.getCacheManagerObjectName(domain0, "DefaultCacheManager", HealthJMXExposer.OBJECT_NAME); Object numberOfCpus = mBeanServer.getAttribute(healthAPI0, "NumberOfCpus"); Object totalMemoryKb = mBeanServer.getAttribute(healthAPI0, "TotalMemoryKb"); Object freeMemoryKb = mBeanServer.getAttribute(healthAPI0, "FreeMemoryKb"); Object clusterHealth = mBeanServer.getAttribute(healthAPI0, "ClusterHealth"); Object clusterName = mBeanServer.getAttribute(healthAPI0, "ClusterName"); Object numberOfNodes = mBeanServer.getAttribute(healthAPI0, "NumberOfNodes"); Object cacheHealth = mBeanServer.getAttribute(healthAPI0, "CacheHealth"); //then assertTrue((int) numberOfCpus > 0); assertTrue((long) totalMemoryKb > 0); assertTrue((long) freeMemoryKb > 0); assertEquals((String) clusterHealth, HealthStatus.HEALTHY.toString()); assertEquals((String) clusterName, "ISPN"); assertEquals((int) numberOfNodes, 1); assertEquals(((String[]) cacheHealth)[0], "test"); assertEquals(((String[]) cacheHealth)[1], HealthStatus.HEALTHY.toString()); } }
@Override public void cacheManagerStarted(GlobalComponentRegistry gcr) { GlobalConfiguration globalCfg = gcr.getGlobalConfiguration(); MBeanServer mbeanServer = JmxUtil.lookupMBeanServer(globalCfg); String groupName = getGroupName(globalCfg); String jmxDomain = globalCfg.globalJmxStatistics().domain(); Interpreter interpreter = new Interpreter(); gcr.registerComponent(interpreter, Interpreter.class); // Pick up metadata from the component metadata repository ManageableComponentMetadata meta = gcr.getComponentMetadataRepo().findComponentMetadata(Interpreter.class) .toManageableComponentMetadata(); // And use this metadata when registering the transport as a dynamic MBean try { ResourceDMBean mbean = new ResourceDMBean(interpreter, meta); interpreterObjName = new ObjectName(String.format("%s:%s,component=Interpreter", jmxDomain, groupName)); JmxUtil.registerMBean(mbean, interpreterObjName, mbeanServer); } catch (Exception e) { interpreterObjName = null; log.jmxRegistrationFailed(); } }
private ObjectName counterObjectName(int managerIndex) { final String domain = manager(managerIndex).getCacheManagerConfiguration().globalJmxStatistics().domain(); return TestingUtil.getCacheManagerObjectName(domain, "DefaultCacheManager", EmbeddedCounterManager.OBJECT_NAME); } }
@Override public void cacheManagerStarted(GlobalComponentRegistry gcr) { // This works because the interpreter is not yet used internally, otherwise it would have to be in cacheManagerStarting GlobalJmxStatisticsConfiguration globalCfg = gcr.getGlobalConfiguration().globalJmxStatistics(); MBeanServer mbeanServer = JmxUtil.lookupMBeanServer(globalCfg.mbeanServerLookup(), globalCfg.properties()); String groupName = getGroupName(globalCfg.cacheManagerName()); Interpreter interpreter = new Interpreter(); gcr.registerComponent(interpreter, Interpreter.class); // Pick up metadata from the component metadata repository ManageableComponentMetadata meta = gcr.getComponentMetadataRepo().findComponentMetadata(Interpreter.class) .toManageableComponentMetadata(); // And use this metadata when registering the transport as a dynamic MBean try { ResourceDMBean mbean = new ResourceDMBean(interpreter, meta); interpreterObjName = new ObjectName(String.format("%s:%s,component=Interpreter", globalCfg.domain(), groupName)); JmxUtil.registerMBean(mbean, interpreterObjName, mbeanServer); } catch (Exception e) { interpreterObjName = null; log.jmxRegistrationFailed(); } }
public void testConfigurationProperties() throws Exception { GlobalConfigurationBuilder globalConfiguration = GlobalConfigurationBuilder.defaultClusteredBuilder(); globalConfiguration.transport().siteId("TESTVALUE1"); globalConfiguration.transport().rackId("TESTVALUE2"); globalConfiguration.transport().machineId("TESTVALUE3"); globalConfiguration.globalJmxStatistics().enable().mBeanServerLookup(new PerThreadMBeanServerLookup()); cm = TestCacheManagerFactory.createClusteredCacheManager(globalConfiguration, new ConfigurationBuilder()); String jmxDomain = cm.getCacheManagerConfiguration().globalJmxStatistics().domain(); ConfigurationBuilder localCache = config(); localCache.memory().storageType(StorageType.BINARY); cm.defineConfiguration("local_cache1", localCache.build()); localCache.memory().storageType(StorageType.OBJECT); cm.defineConfiguration("local_cache2", localCache.build()); cm.getCache("local_cache1"); cm.getCache("local_cache2"); MBeanServer mBeanServer = PerThreadMBeanServerLookup.getThreadMBeanServer(); Properties props1 = (Properties) mBeanServer.getAttribute(getCacheObjectName(jmxDomain, "local_cache1(local)", "Cache"), "configurationAsProperties"); Properties props2 = (Properties) mBeanServer.getAttribute(getCacheObjectName(jmxDomain, "local_cache2(local)", "Cache"), "configurationAsProperties"); Properties propsGlobal = (Properties) mBeanServer.getAttribute(getCacheManagerObjectName(jmxDomain), "globalConfigurationAsProperties"); assert "BINARY".equals(props1.getProperty("memory.storageType")); assert "OBJECT".equals(props2.getProperty("memory.storageType")); log.tracef("propsGlobal=%s", propsGlobal); assert "TESTVALUE1".equals(propsGlobal.getProperty("transport.siteId")); assert "TESTVALUE2".equals(propsGlobal.getProperty("transport.rackId")); assert "TESTVALUE3".equals(propsGlobal.getProperty("transport.machineId")); }
public void testRecoveryManagerInJmx() throws Exception { assert cache.getCacheConfiguration().transaction().transactionMode().isTransactional(); String jmxDomain = cacheManager.getCacheManagerConfiguration().globalJmxStatistics().domain(); assert !existsObject(getCacheObjectName(jmxDomain, cache.getName(), "RecoveryManager")); }
public void testNoRecoveryManager() throws Exception { assert cache.getCacheConfiguration().transaction().transactionMode().isTransactional(); String jmxDomain = cacheManager.getCacheManagerConfiguration().globalJmxStatistics().domain(); assert !existsObject(getCacheObjectName(jmxDomain, cache.getName(), "RecoveryManager")); }
public void testAvailabilityChange() throws Exception { final MBeanServer mBeanServer = PerThreadMBeanServerLookup.getThreadMBeanServer(); String domain0 = manager(1).getCacheManagerConfiguration().globalJmxStatistics().domain(); final ObjectName cacheName0 = TestingUtil.getCacheObjectName(domain0, CacheContainer.DEFAULT_CACHE_NAME + "(dist_sync)"); String domain1 = manager(1).getCacheManagerConfiguration().globalJmxStatistics().domain(); final ObjectName cacheName1 = TestingUtil.getCacheObjectName(domain1, CacheContainer.DEFAULT_CACHE_NAME + "(dist_sync)");
String jmxDomain = JmxUtil.buildJmxDomain(jmxConfig.domain(), mbeanServer, queryGroupName);
String domain0 = manager(1).getCacheManagerConfiguration().globalJmxStatistics().domain(); ObjectName ltmName0 = TestingUtil.getCacheManagerObjectName(domain0, "DefaultCacheManager", "LocalTopologyManager"); String domain1 = manager(1).getCacheManagerConfiguration().globalJmxStatistics().domain(); ObjectName ltmName1 = TestingUtil.getCacheManagerObjectName(domain1, "DefaultCacheManager", "LocalTopologyManager");
public void testDifferentDomain() throws Exception { GlobalConfigurationBuilder globalConfiguration = GlobalConfigurationBuilder.defaultClusteredBuilder(); globalConfiguration.globalJmxStatistics().enable().mBeanServerLookup(new PerThreadMBeanServerLookup()); cm = TestCacheManagerFactory.createClusteredCacheManager(globalConfiguration, new ConfigurationBuilder()); String jmxDomain = cm.getCacheManagerConfiguration().globalJmxStatistics().domain(); ConfigurationBuilder localCache = config();//local by default cm.defineConfiguration("local_cache", localCache.build()); cm.getCache("local_cache"); assert existsObject(getCacheObjectName(jmxDomain, "local_cache(local)", "Statistics")); }
public void testMultipleManagersOnSameServerWithCloneFails() throws Exception { GlobalConfigurationBuilder globalConfiguration = GlobalConfigurationBuilder.defaultClusteredBuilder(); globalConfiguration.globalJmxStatistics().enable().mBeanServerLookup(new PerThreadMBeanServerLookup()); cm = TestCacheManagerFactory.createClusteredCacheManager(globalConfiguration, new ConfigurationBuilder()); String jmxDomain = cm.getCacheManagerConfiguration().globalJmxStatistics().domain(); ConfigurationBuilder localCache = config();//local by default localCache.jmxStatistics().enable(); cm.defineConfiguration("local_cache", localCache.build()); cm.getCache("local_cache"); assert existsObject(getCacheObjectName(jmxDomain, "local_cache(local)", "Statistics")); expectException(EmbeddedCacheManagerStartupException.class, JmxDomainConflictException.class, () -> TestCacheManagerFactory.createClusteredCacheManagerEnforceJmxDomain(jmxDomain, false)); }
String domain0 = manager(1).getCacheManagerConfiguration().globalJmxStatistics().domain(); ObjectName ltmName0 = TestingUtil.getCacheManagerObjectName(domain0, "DefaultCacheManager", "LocalTopologyManager"); String domain1 = manager(1).getCacheManagerConfiguration().globalJmxStatistics().domain(); ObjectName ltmName1 = TestingUtil.getCacheManagerObjectName(domain1, "DefaultCacheManager", "LocalTopologyManager"); String domain2 = manager(2).getCacheManagerConfiguration().globalJmxStatistics().domain(); ObjectName ltmName2 = TestingUtil.getCacheManagerObjectName(domain2, "DefaultCacheManager", "LocalTopologyManager"); String domain3 = manager(2).getCacheManagerConfiguration().globalJmxStatistics().domain(); ObjectName ltmName3 = TestingUtil.getCacheManagerObjectName(domain3, "DefaultCacheManager", "LocalTopologyManager"); mBeanServer.setAttribute(ltmName2, new Attribute(REBALANCING_ENABLED, true));
public void testUnregisterJmxInfoOnStop() throws Exception { GlobalConfigurationBuilder globalConfiguration = GlobalConfigurationBuilder.defaultClusteredBuilder(); globalConfiguration.globalJmxStatistics().enable().mBeanServerLookup(new PerThreadMBeanServerLookup()); cm = TestCacheManagerFactory.createClusteredCacheManager(globalConfiguration, new ConfigurationBuilder()); String jmxDomain = cm.getCacheManagerConfiguration().globalJmxStatistics().domain(); ConfigurationBuilder localCache = config();//local by default localCache.jmxStatistics().enable(); cm.defineConfiguration("local_cache", localCache.build()); cm.getCache("local_cache"); assert existsObject(getCacheObjectName(jmxDomain, "local_cache(local)", "Statistics")); TestingUtil.killCacheManagers(cm); assert !existsObject(getCacheObjectName(jmxDomain, "local_cache(local)", "Statistics")); assert !existsDomains(jmxDomain); }
public void testMultipleManagersOnSameServer() throws Exception { GlobalConfigurationBuilder globalConfiguration = GlobalConfigurationBuilder.defaultClusteredBuilder(); globalConfiguration.globalJmxStatistics().enable().mBeanServerLookup(new PerThreadMBeanServerLookup()); cm = TestCacheManagerFactory.createClusteredCacheManager(globalConfiguration, new ConfigurationBuilder()); String jmxDomain = cm.getCacheManagerConfiguration().globalJmxStatistics().domain(); ConfigurationBuilder localCache = config();//local by default localCache.jmxStatistics().enable(); cm.defineConfiguration("local_cache", localCache.build()); cm.getCache("local_cache"); assert existsObject(getCacheObjectName(jmxDomain, "local_cache(local)", "Statistics")); GlobalConfigurationBuilder globalConfiguration2 = GlobalConfigurationBuilder.defaultClusteredBuilder(); globalConfiguration2.globalJmxStatistics().enable().mBeanServerLookup(new PerThreadMBeanServerLookup()); cm2 = TestCacheManagerFactory.createClusteredCacheManager(globalConfiguration2, new ConfigurationBuilder()); String jmxDomain2 = cm2.getCacheManagerConfiguration().globalJmxStatistics().domain(); ConfigurationBuilder localCache2 = config();//local by default localCache2.jmxStatistics().enable(); cm2.defineConfiguration("local_cache", localCache.build()); cm2.getCache("local_cache"); assert existsObject(getCacheObjectName(jmxDomain2, "local_cache(local)", "Statistics")); GlobalConfigurationBuilder globalConfiguration3 = GlobalConfigurationBuilder.defaultClusteredBuilder(); globalConfiguration3.globalJmxStatistics().enable().mBeanServerLookup(new PerThreadMBeanServerLookup()); cm3 = TestCacheManagerFactory.createClusteredCacheManager(globalConfiguration3, new ConfigurationBuilder()); String jmxDomain3 = cm3.getCacheManagerConfiguration().globalJmxStatistics().domain(); ConfigurationBuilder localCache3 = config();//local by default localCache3.jmxStatistics().enable(); cm3.defineConfiguration("local_cache", localCache.build()); cm3.getCache("local_cache"); assert existsObject(getCacheObjectName(jmxDomain3, "local_cache(local)", "Statistics")); }
public void testOnlyPerCacheJmxStatsEnabled() throws Exception { GlobalConfigurationBuilder globalConfiguration = GlobalConfigurationBuilder.defaultClusteredBuilder(); globalConfiguration.globalJmxStatistics().enable().mBeanServerLookup(new PerThreadMBeanServerLookup()); cm = TestCacheManagerFactory.createClusteredCacheManager(globalConfiguration, new ConfigurationBuilder()); String jmxDomain = cm.getCacheManagerConfiguration().globalJmxStatistics().domain(); ConfigurationBuilder localCache = config();//local by default localCache.jmxStatistics().enable(); cm.defineConfiguration("local_cache", localCache.build()); ConfigurationBuilder remote1 = config();//local by default remote1.jmxStatistics().enable(); remote1.clustering().cacheMode(CacheMode.REPL_SYNC); cm.defineConfiguration("remote1", remote1.build()); cm.getCache("local_cache"); cm.getCache("remote1"); assert existsObject(getCacheObjectName(jmxDomain, "local_cache(local)", "Statistics")); // Since ISPN-2290 assert existsObject(getCacheManagerObjectName(jmxDomain)); assert existsObject(getCacheObjectName(jmxDomain, "remote1(repl_sync)", "RpcManager")); }
String jmxDomain = cm.getCacheManagerConfiguration().globalJmxStatistics().domain(); assert existsObject(getCacheObjectName(jmxDomain, "local_cache(local)", "Statistics")); assert existsObject(getCacheObjectName(jmxDomain, "local_cache(local)", "Cache")); cm2.defineConfiguration("remote_cache", remoteCache.build()); cm2.getCache("remote_cache"); String jmxDomain2 = cm2.getCacheManagerConfiguration().globalJmxStatistics().domain(); assert existsObject(getCacheObjectName(jmxDomain2, "remote_cache(repl_sync)", "Cache")); assert existsObject(getCacheObjectName(jmxDomain2, "remote_cache(repl_sync)", "Statistics"));
public void testOnlyGlobalJmxStatsEnabled() throws Exception { GlobalConfigurationBuilder globalConfiguration = GlobalConfigurationBuilder.defaultClusteredBuilder(); globalConfiguration.globalJmxStatistics().enable().mBeanServerLookup(new PerThreadMBeanServerLookup()); cm = TestCacheManagerFactory.createClusteredCacheManager(globalConfiguration, new ConfigurationBuilder()); String jmxDomain = cm.getCacheManagerConfiguration().globalJmxStatistics().domain(); ConfigurationBuilder localCache = config();//local by default localCache.jmxStatistics().disable(); cm.defineConfiguration("local_cache", localCache.build()); ConfigurationBuilder remote1 = config();//local by default remote1.jmxStatistics().disable(); remote1.clustering().cacheMode(CacheMode.REPL_SYNC); cm.defineConfiguration("remote1", remote1.build()); cm.getCache("local_cache"); cm.getCache("remote1"); assert existsObject(getCacheManagerObjectName(jmxDomain)); // Statistics MBean is always enabled now assert existsObject(getCacheObjectName(jmxDomain, "local_cache(local)", "Statistics")); assert existsObject(getCacheObjectName(jmxDomain, "remote1(repl_sync)", "Statistics")); // Since ISPN-2290 assert existsObject(getCacheObjectName(jmxDomain, "remote1(repl_sync)", "LockManager")); assert existsObject(getCacheObjectName(jmxDomain, "local_cache(local)", "LockManager")); }
assertTrue(gc.globalJmxStatistics().enabled()); assertTrue(gc.globalJmxStatistics().allowDuplicateDomains()); assertEquals("funky_domain", gc.globalJmxStatistics().domain()); assertTrue(gc.globalJmxStatistics().mbeanServerLookup() instanceof PerThreadMBeanServerLookup);
globalConfiguration.globalJmxStatistics().enable().mBeanServerLookup(new PerThreadMBeanServerLookup()); cm = TestCacheManagerFactory.createClusteredCacheManager(globalConfiguration, new ConfigurationBuilder()); String jmxDomain = cm.getCacheManagerConfiguration().globalJmxStatistics().domain();