@Override public void accept(ConfigurationBuilder builder) { TransactionConfiguration tx = this.transaction.get(); builder.memory().read(this.memory.get()); builder.expiration().read(this.expiration.get()); builder.locking().read(this.locking.get()); builder.persistence().read(this.persistence.get()); builder.transaction().read(tx); builder.jmxStatistics().enabled(this.statisticsEnabled).available(this.statisticsEnabled); try { // Configure invocation batching based on transaction configuration builder.invocationBatching().enable(tx.transactionMode().isTransactional() && (tx.transactionManagerLookup().getTransactionManager() != ContextTransactionManager.getInstance())); } catch (Exception e) { throw new CacheException(e); } }
protected ConfigurationBuilder getConfiguration() { ConfigurationBuilder c = getDefaultClusteredCacheConfig(CacheMode.REPL_SYNC, true); c.jmxStatistics().enable(); return c; }
@Override protected EmbeddedCacheManager createCacheManager() throws Exception { ConfigurationBuilder c = hotRodCacheConfiguration( getDefaultStandaloneCacheConfig(false)); c.jmxStatistics().enable(); return TestCacheManagerFactory.createCacheManager(c); }
@Override protected void createCacheManagers() throws Throwable { ConfigurationBuilder builder = getDefaultClusteredCacheConfig( CacheMode.REPL_SYNC, false); builder.jmxStatistics().enable(); EmbeddedCacheManager cm1 = TestCacheManagerFactory .createClusteredCacheManagerEnforceJmxDomain(JMX_1, builder); EmbeddedCacheManager cm2 = TestCacheManagerFactory .createClusteredCacheManagerEnforceJmxDomain(JMX_2, builder); registerCacheManager(cm1, cm2); }
@Override protected void createCacheManagers() throws Throwable { indexDir = Files.createTempDirectory("test-").toFile(); createIndex(indexDir, INDEX_NAME, TERMS_NUMBER, false); ConfigurationBuilder c = getDefaultClusteredCacheConfig(CacheMode.DIST_SYNC, false); c.clustering().hash().numOwners(1); c.jmxStatistics().enable(); c.persistence() .addStore(LuceneLoaderConfigurationBuilder.class) .preload(true) .location(indexDir.getAbsolutePath()); createCluster(c, CLUSTER_SIZE); waitForClusterToForm(); }
@Override protected EmbeddedCacheManager createCacheManager() throws Exception { ConfigurationBuilder c = getDefaultStandaloneCacheConfig(true); c.jmxStatistics().enable().dataContainer().invocationBatching().enable(); return TestCacheManagerFactory.createCacheManager(c); }
@Override protected ConfigurationBuilder createCacheConfig() { ConfigurationBuilder config = hotRodCacheConfiguration( getDefaultClusteredCacheConfig(CacheMode.DIST_SYNC, false)); config.jmxStatistics().enable(); config.clustering().hash().numOwners(1); return config; }
@Override public EmbeddedCacheManager createTestCacheManager() { ConfigurationBuilder cfg = hotRodCacheConfiguration(); cfg.jmxStatistics().enable(); EmbeddedCacheManager cm = TestCacheManagerFactory.createClusteredCacheManagerEnforceJmxDomain(jmxDomain(), cfg); cm.defineConfiguration(cacheName, cm.getDefaultCacheConfiguration()); return cm; }
protected void configure(ConfigurationBuilder cfg) { cfg .jmxStatistics() .enable() .clustering() .hash() .numOwners(NUM_OWNERS) .memory() .storageType(storageType) .evictionType(EvictionType.COUNT) .size(MAX_SIZE); }
@Override protected EmbeddedCacheManager createCacheManager() throws Exception { ConfigurationBuilder c = getDefaultStandaloneCacheConfig(false); c.jmxStatistics().enable(); cacheManager = TestCacheManagerFactory.createCacheManager(c); memcachedServer = MemcachedTestingUtil.startMemcachedTextServer(cacheManager); port = memcachedServer.getPort(); memcachedClient = MemcachedTestingUtil.createMemcachedClient(60000, port); GlobalComponentRegistry gcr = TestingUtil.extractGlobalComponentRegistry(cacheManager); interpreter = gcr.getComponent(Interpreter.class); return cacheManager; }
@Override protected EmbeddedCacheManager createCacheManager() throws Exception { ConfigurationBuilder c = getDefaultStandaloneCacheConfig(false); c.jmxStatistics().enable(); cacheManager = TestCacheManagerFactory.createCacheManager(c); memcachedServer = MemcachedTestingUtil.startMemcachedTextServer(cacheManager); port = memcachedServer.getPort(); memcachedClient = MemcachedTestingUtil.createMemcachedClient(60000, port); GlobalComponentRegistry gcr = TestingUtil.extractGlobalComponentRegistry(cacheManager); interpreter = gcr.getComponent(Interpreter.class); return cacheManager; }
@Override protected EmbeddedCacheManager createCacheManager() throws Exception { GlobalConfigurationBuilder gcb = new GlobalConfigurationBuilder(); gcb.defaultCacheName("default"); ConfigurationBuilder c = getDefaultStandaloneCacheConfig(true); c.jmxStatistics().enable().dataContainer().invocationBatching().enable().locking().isolationLevel(IsolationLevel.READ_COMMITTED); EmbeddedCacheManager cm = TestCacheManagerFactory.createCacheManager(gcb, c); return cm; }
private static ConfigurationBuilder createConfiguration(String storeName, boolean shared, boolean transactional, boolean passivation) { ConfigurationBuilder builder = getDefaultClusteredCacheConfig(CacheMode.LOCAL, transactional); builder.jmxStatistics().enable(); builder.persistence() .passivation(passivation) .addStore(DummyInMemoryStoreConfigurationBuilder.class) .storeName(storeName + (shared ? "-shared" : "-private")) .fetchPersistentState(false) .purgeOnStartup(true) .shared(shared); builder.locking().isolationLevel(IsolationLevel.READ_COMMITTED); return builder; }
private ConfigurationBuilder createConfiguration(String storeName, boolean shared, boolean transactional, boolean passivation, int storePrefix) { ConfigurationBuilder builder = getDefaultClusteredCacheConfig(cacheMode, transactional); builder.jmxStatistics().enable(); builder.persistence() .passivation(passivation) .addStore(DummyInMemoryStoreConfigurationBuilder.class) .storeName(storeName + (shared ? "-shared" : storePrefix)) .fetchPersistentState(false) .purgeOnStartup(true) .shared(shared); builder.locking().isolationLevel(IsolationLevel.READ_COMMITTED); return builder; }
public void testStatistics() { Configuration cfg = new ConfigurationBuilder().simpleCache(true).jmxStatistics().enabled(true).build(); String name = "statsCache"; cacheManager.defineConfiguration(name, cfg); Cache<Object, Object> cache = cacheManager.getCache(name); assertEquals(0L, cache.getAdvancedCache().getStats().getStores()); cache.put("key", "value"); assertEquals(1L, cache.getAdvancedCache().getStats().getStores()); } }
@Override protected EmbeddedCacheManager createCacheManager() throws Exception { GlobalConfigurationBuilder gcb = new GlobalConfigurationBuilder(); gcb.globalJmxStatistics().jmxDomain(JMX_DOMAIN).mBeanServerLookup(new PerThreadMBeanServerLookup()).enable(); ConfigurationBuilder dcc = TestCacheManagerFactory.getDefaultCacheConfiguration(true); dcc.transaction().autoCommit(false); dcc.memory().size(1000); dcc.jmxStatistics().enable(); server = PerThreadMBeanServerLookup.getThreadMBeanServer(); return new DefaultCacheManager(gcb.build(), dcc.build()); }
@Override protected EmbeddedCacheManager createCacheManager() throws Exception { GlobalConfigurationBuilder gcb = new GlobalConfigurationBuilder(); gcb.globalJmxStatistics().jmxDomain(JMX_DOMAIN).mBeanServerLookup(new PerThreadMBeanServerLookup()).enable(); ConfigurationBuilder dcc = TestCacheManagerFactory.getDefaultCacheConfiguration(true); dcc.transaction().autoCommit(false); dcc.memory().size(1000); dcc.jmxStatistics().enable(); server = PerThreadMBeanServerLookup.getThreadMBeanServer(); return new DefaultCacheManager(gcb.build(), dcc.build()); }
@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; }
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)); }
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); }