/** * @see #createCacheManagerEnforceJmxDomain(String) */ public static EmbeddedCacheManager createCacheManagerEnforceJmxDomain(String jmxDomain) { return createCacheManagerEnforceJmxDomain(jmxDomain, true, true, true); }
/** * @see #createCacheManagerEnforceJmxDomain(String) */ public static EmbeddedCacheManager createCacheManagerEnforceJmxDomain(String jmxDomain, boolean exposeGlobalJmx, boolean exposeCacheJmx, boolean allowDuplicates) { return createCacheManagerEnforceJmxDomain(jmxDomain, null, exposeGlobalJmx, exposeCacheJmx, allowDuplicates); }
public void testDuplicateJmxDomainOnlyCacheExposesJmxStatistics() throws Exception { Exceptions.expectException(EmbeddedCacheManagerStartupException.class, JmxDomainConflictException.class, () -> createCacheManagerEnforceJmxDomain(JMX_DOMAIN, false, true, false)); }
public void testAvoidLeakOfCacheMBeanWhenCacheStatisticsDisabled(Method m) { final String jmxDomain = "jmx_" + m.getName(); withCacheManager(new CacheManagerCallable( createCacheManagerEnforceJmxDomain(jmxDomain, false, false, true)) { @Override public void call() throws Exception { cm.getCache(); ObjectName cacheObjectName = getCacheObjectName(jmxDomain); assertTrue(cacheObjectName + " should be registered", server.isRegistered(cacheObjectName)); TestingUtil.killCacheManagers(cm); assertFalse(cacheObjectName + " should NOT be registered", server.isRegistered(cacheObjectName)); } }); }
@Override protected EmbeddedCacheManager createCacheManager() throws Exception { cacheManager = TestCacheManagerFactory.createCacheManagerEnforceJmxDomain(JMX_DOMAIN, true, false, true); name = getCacheManagerObjectName(JMX_DOMAIN); server = PerThreadMBeanServerLookup.getThreadMBeanServer(); server.invoke(name, "startCache", new Object[]{}, new String[]{}); return cacheManager; }
@Override protected void createCacheManagers() throws Exception { cacheManager = createCacheManagerEnforceJmxDomain(JMX_DOMAIN); registerCacheManager(cacheManager); // Create the default cache and register its JMX beans cacheManager.getCache(); server = PerThreadMBeanServerLookup.getThreadMBeanServer(); }
public void testCustomCacheManagerName(Method m) throws Exception { final String otherJmxDomain = getMethodSpecificJmxDomain(m, JMX_DOMAIN); CacheContainer otherContainer = TestCacheManagerFactory.createCacheManagerEnforceJmxDomain(otherJmxDomain, "Hibernate2LC", true, false, true); ObjectName otherName = getCacheManagerObjectName(otherJmxDomain, "Hibernate2LC"); try { assertEquals("0", server.getAttribute(otherName, "CreatedCacheCount")); } finally { otherContainer.stop(); } }
public void testJmxRegistrationAtStartupAndStop(Method m) throws Exception { final String otherJmxDomain = getMethodSpecificJmxDomain(m, JMX_DOMAIN); CacheContainer otherContainer = TestCacheManagerFactory.createCacheManagerEnforceJmxDomain(otherJmxDomain, true, false, true); ObjectName otherName = getCacheManagerObjectName(otherJmxDomain); try { assertEquals("0", server.getAttribute(otherName, "CreatedCacheCount")); } finally { otherContainer.stop(); } Exceptions.expectException(InstanceNotFoundException.class, () -> server.getAttribute(otherName, "CreatedCacheCount")); }
public void testManagerStopRemovesCacheMBean(Method m) throws Exception { final String otherJmxDomain = getMethodSpecificJmxDomain(m, JMX_DOMAIN); ObjectName defaultOn = getCacheObjectName(otherJmxDomain); ObjectName galderOn = getCacheObjectName(otherJmxDomain, "galder(local)"); ObjectName managerON = getCacheManagerObjectName(otherJmxDomain); EmbeddedCacheManager otherContainer = createCacheManagerEnforceJmxDomain(otherJmxDomain); otherContainer.defineConfiguration("galder", new ConfigurationBuilder().build()); registerCacheManager(otherContainer); 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")); assert ComponentStatus.RUNNING.toString().equals(server.getAttribute(galderOn, "CacheStatus")); otherContainer.stop(); try { log.info(server.getMBeanInfo(managerON)); assert false : "Failure expected, " + managerON + " shouldn't be registered in mbean server"; } catch (InstanceNotFoundException e) { } try { log.info(server.getMBeanInfo(defaultOn)); assert false : "Failure expected, " + defaultOn + " shouldn't be registered in mbean server"; } catch (InstanceNotFoundException e) { } try { log.info(server.getMBeanInfo(galderOn)); assert false : "Failure expected, " + galderOn + " shouldn't be registered in mbean server"; } catch (InstanceNotFoundException e) { } }
@Override protected EmbeddedCacheManager createCacheManager() throws Exception { EmbeddedCacheManager cm = TestCacheManagerFactory.createCacheManagerEnforceJmxDomain(TEST_JMX_DOMAIN); ConfigurationBuilder builder = getDefaultStandaloneCacheConfig(true); builder.indexing().index(Index.ALL) .addProperty("default.directory_provider", "local-heap") .addProperty("error_handler", "org.infinispan.query.helper.StaticTestingErrorHandler") .addProperty("lucene_version", "LUCENE_CURRENT"); cm.defineConfiguration(CACHE_NAME, builder.build()); return cm; }
@Override protected EmbeddedCacheManager createCacheManager() throws Exception { cacheManager = TestCacheManagerFactory.createCacheManagerEnforceJmxDomain(JMX_DOMAIN); ConfigurationBuilder configuration = getDefaultStandaloneCacheConfig(false); configuration .jmxStatistics().enable() .persistence() .passivation(false) .addStore(DummyInMemoryStoreConfigurationBuilder.class); cacheManager.defineConfiguration("test", configuration.build()); cache = cacheManager.getCache("test"); loaderInterceptorObjName = getCacheObjectName(JMX_DOMAIN, "test(local)", "CacheLoader"); storeInterceptorObjName = getCacheObjectName(JMX_DOMAIN, "test(local)", "CacheStore"); threadMBeanServer = PerThreadMBeanServerLookup.getThreadMBeanServer(); store = (AdvancedLoadWriteStore) TestingUtil.getFirstLoader(cache); return cacheManager; }
@Override protected EmbeddedCacheManager createCacheManager() throws Exception { cacheManager = TestCacheManagerFactory.createCacheManagerEnforceJmxDomain(JMX_DOMAIN); ConfigurationBuilder configuration = getDefaultStandaloneCacheConfig(true); configuration .jmxStatistics().enable() .locking() .concurrencyLevel(CONCURRENCY_LEVEL) .useLockStriping(true) .transaction() .transactionManagerLookup(new EmbeddedTransactionManagerLookup()); cacheManager.defineConfiguration("test", configuration.build()); cache = cacheManager.getCache("test"); lockManagerObjName = getCacheObjectName(JMX_DOMAIN, "test(local)", "LockManager"); threadMBeanServer = PerThreadMBeanServerLookup.getThreadMBeanServer(); return cacheManager; }
@Override protected EmbeddedCacheManager createCacheManager() throws Exception { cacheManager = TestCacheManagerFactory.createCacheManagerEnforceJmxDomain(JMX_DOMAIN); ConfigurationBuilder configuration = getDefaultStandaloneCacheConfig(false); configuration.memory().size(1) .persistence() .passivation(true) .addStore(DummyInMemoryStoreConfigurationBuilder.class); configuration.jmxStatistics().enable(); cacheManager.defineConfiguration("test", configuration.build()); cache = cacheManager.getCache("test"); advanced = cache.getAdvancedCache(); mgmtInterceptor = getCacheObjectName(JMX_DOMAIN, "test(local)", "Statistics"); loader = (AdvancedLoadWriteStore) TestingUtil.getFirstLoader(cache); server = PerThreadMBeanServerLookup.getThreadMBeanServer(); return cacheManager; }