}
});
}
private void assertNamedCacheFile(EmbeddedCacheManager cm, boolean deprecated) {
final GlobalConfiguration gc = cm.getCacheManagerConfiguration();
BlockingThreadPoolExecutorFactory listenerThreadPool =
cm.getCacheManagerConfiguration().listenerThreadPool().threadPoolFactory();
assertEquals(5, listenerThreadPool.maxThreads());
assertEquals(10000, listenerThreadPool.queueLength());
DefaultThreadFactory listenerThreadFactory =
cm.getCacheManagerConfiguration().listenerThreadPool().threadFactory();
assertEquals("AsyncListenerThread", listenerThreadFactory.threadNamePattern());
BlockingThreadPoolExecutorFactory persistenceThreadPool =
cm.getCacheManagerConfiguration().persistenceThreadPool().threadPoolFactory();
assertEquals(6, persistenceThreadPool.maxThreads());
assertEquals(10001, persistenceThreadPool.queueLength());
DefaultThreadFactory persistenceThreadFactory =
cm.getCacheManagerConfiguration().persistenceThreadPool().threadFactory();
assertEquals("PersistenceThread", persistenceThreadFactory.threadNamePattern());
BlockingThreadPoolExecutorFactory transportThreadPool =
cm.getCacheManagerConfiguration().transport().transportThreadPool().threadPoolFactory();
assertEquals(TestCacheManagerFactory.MAX_ASYNC_EXEC_THREADS, transportThreadPool.maxThreads());
assertEquals(TestCacheManagerFactory.ASYNC_EXEC_QUEUE_SIZE, transportThreadPool.queueLength());
BlockingThreadPoolExecutorFactory remoteCommandThreadPool =
cm.getCacheManagerConfiguration().transport().remoteCommandThreadPool().threadPoolFactory();
assertEquals(TestCacheManagerFactory.MAX_REQ_EXEC_THREADS, remoteCommandThreadPool.maxThreads());
assertEquals(TestCacheManagerFactory.KEEP_ALIVE, remoteCommandThreadPool.keepAlive());
BlockingThreadPoolExecutorFactory totalOrderThreadPool =
cm.getCacheManagerConfiguration().transport().totalOrderThreadPool().threadPoolFactory();
assertEquals(16, totalOrderThreadPool.maxThreads());
assertEquals(1, totalOrderThreadPool.coreThreads());
assertEquals(1000, totalOrderThreadPool.keepAlive());
assertEquals(0, totalOrderThreadPool.queueLength());
DefaultThreadFactory totalOrderThreadFactory =
cm.getCacheManagerConfiguration().transport().totalOrderThreadPool().threadFactory();
assertEquals("TotalOrderValidatorThread", totalOrderThreadFactory.threadNamePattern());
DefaultThreadFactory evictionThreadFactory =
cm.getCacheManagerConfiguration().evictionThreadPool().threadFactory();
assertEquals("EvictionThread", evictionThreadFactory.threadNamePattern());
DefaultThreadFactory replicationQueueThreadFactory =
cm.getCacheManagerConfiguration().replicationQueueThreadPool().threadFactory();
assertEquals("ReplicationQueueThread", replicationQueueThreadFactory.threadNamePattern());
assertTrue(gc.transport().transport() instanceof JGroupsTransport);
assertEquals("infinispan-cluster", gc.transport().clusterName());
// Should be "Jalapeno" but it's overriden by the test cache manager factory
assertTrue(gc.transport().nodeName().contains("Node"));
assertEquals(50000, gc.transport().distributedSyncTimeout());
assertEquals(ShutdownHookBehavior.REGISTER, gc.shutdown().hookBehavior());
assertTrue(gc.serialization().marshaller() instanceof VersionAwareMarshaller);
assertEquals(Version.getVersionShort("1.0"), gc.serialization().version());
final Map<Integer, AdvancedExternalizer<?>> externalizers = gc.serialization().advancedExternalizers();
assertEquals(3, externalizers.size());
assertTrue(externalizers.get(1234) instanceof AdvancedExternalizerTest.IdViaConfigObj.Externalizer);
assertTrue(externalizers.get(5678) instanceof AdvancedExternalizerTest.IdViaAnnotationObj.Externalizer);
assertTrue(externalizers.get(3456) instanceof AdvancedExternalizerTest.IdViaBothObj.Externalizer);
Configuration defaultCfg = cm.getDefaultCacheConfiguration();
assertEquals(1000, defaultCfg.locking().lockAcquisitionTimeout());
assertEquals(100, defaultCfg.locking().concurrencyLevel());
assertEquals(IsolationLevel.READ_COMMITTED, defaultCfg.locking().isolationLevel());
if (!deprecated) {
assertReaperAndTimeoutInfo(defaultCfg);
}
Configuration c = cm.getCacheConfiguration("transactional");
assertTrue(!c.clustering().cacheMode().isClustered());
assertTrue(c.transaction().transactionManagerLookup() instanceof GenericTransactionManagerLookup);
assertTrue(c.transaction().syncRollbackPhase());
if (!deprecated) {
assertReaperAndTimeoutInfo(defaultCfg);
}
c = cm.getCacheConfiguration("transactional2");
assertTrue(c.transaction().transactionManagerLookup() instanceof TestLookup);
assertEquals(10000, c.transaction().cacheStopTimeout());
assertEquals(LockingMode.PESSIMISTIC, c.transaction().lockingMode());
assertTrue(!c.transaction().autoCommit());
c = cm.getCacheConfiguration("transactional3");
if (!deprecated) {
assertEquals(TransactionProtocol.TOTAL_ORDER, c.transaction().transactionProtocol());
}
c = cm.getCacheConfiguration("syncInval");
assertEquals(CacheMode.INVALIDATION_SYNC, c.clustering().cacheMode());
assertTrue(!c.clustering().stateTransfer().fetchInMemoryState());
assertTrue(c.clustering().stateTransfer().awaitInitialTransfer());
assertEquals(15000, c.clustering().sync().replTimeout());
c = cm.getCacheConfiguration("asyncInval");
assertEquals(CacheMode.INVALIDATION_ASYNC, c.clustering().cacheMode());
assertTrue(!c.clustering().stateTransfer().fetchInMemoryState());
assertEquals(15000, c.clustering().sync().replTimeout());
c = cm.getCacheConfiguration("syncRepl");
assertEquals(CacheMode.REPL_SYNC, c.clustering().cacheMode());
assertTrue(!c.clustering().stateTransfer().fetchInMemoryState());
assertTrue(c.clustering().stateTransfer().awaitInitialTransfer());
assertEquals(15000, c.clustering().sync().replTimeout());
c = cm.getCacheConfiguration("asyncRepl");
assertEquals(CacheMode.REPL_ASYNC, c.clustering().cacheMode());
assertTrue(!c.clustering().async().useReplQueue());
assertTrue(!c.clustering().async().asyncMarshalling());
assertTrue(!c.clustering().stateTransfer().fetchInMemoryState());
assertTrue(c.clustering().stateTransfer().awaitInitialTransfer());
c = cm.getCacheConfiguration("asyncReplQueue");
assertEquals(CacheMode.REPL_ASYNC, c.clustering().cacheMode());
assertTrue(c.clustering().async().useReplQueue());
assertTrue(!c.clustering().async().asyncMarshalling());
assertTrue(!c.clustering().stateTransfer().fetchInMemoryState());
assertTrue(c.clustering().stateTransfer().awaitInitialTransfer());
c = cm.getCacheConfiguration("txSyncRepl");
assertTrue(c.transaction().transactionManagerLookup() instanceof GenericTransactionManagerLookup);
assertEquals(CacheMode.REPL_SYNC, c.clustering().cacheMode());
assertTrue(!c.clustering().stateTransfer().fetchInMemoryState());
assertTrue(c.clustering().stateTransfer().awaitInitialTransfer());
assertEquals(15000, c.clustering().sync().replTimeout());
c = cm.getCacheConfiguration("overriding");
assertEquals(CacheMode.LOCAL, c.clustering().cacheMode());
assertEquals(20000, c.locking().lockAcquisitionTimeout());
assertEquals(1000, c.locking().concurrencyLevel());
assertEquals(IsolationLevel.REPEATABLE_READ, c.locking().isolationLevel());
assertTrue(!c.storeAsBinary().enabled());
c = cm.getCacheConfiguration("storeAsBinary");
assertTrue(c.storeAsBinary().enabled());
c = cm.getCacheConfiguration("withFileStore");
assertTrue(c.persistence().preload());
assertTrue(!c.persistence().passivation());
assertEquals(1, c.persistence().stores().size());
SingleFileStoreConfiguration loaderCfg = (SingleFileStoreConfiguration) c.persistence().stores().get(0);
assertTrue(loaderCfg.fetchPersistentState());
assertTrue(loaderCfg.ignoreModifications());
assertTrue(loaderCfg.purgeOnStartup());
assertEquals("/tmp/FileCacheStore-Location", loaderCfg.location());
assertEquals(5, loaderCfg.async().threadPoolSize());
assertEquals(15000, loaderCfg.async().flushLockTimeout());
assertTrue(loaderCfg.async().enabled());
assertEquals(700, loaderCfg.async().modificationQueueSize());
c = cm.getCacheConfiguration("withClusterLoader");
assertEquals(1, c.persistence().stores().size());
ClusterLoaderConfiguration clusterLoaderCfg = (ClusterLoaderConfiguration) c.persistence().stores().get(0);
assertEquals(15000, clusterLoaderCfg.remoteCallTimeout());
c = cm.getCacheConfiguration("withLoaderDefaults");
loaderCfg = (SingleFileStoreConfiguration) c.persistence().stores().get(0);
assertEquals("/tmp/Another-FileCacheStore-Location", loaderCfg.location());
c = cm.getCacheConfiguration("withouthJmxEnabled");
assertTrue(!c.jmxStatistics().enabled());
assertTrue(gc.globalJmxStatistics().enabled());
assertTrue(gc.globalJmxStatistics().allowDuplicateDomains());
assertEquals("funky_domain", gc.globalJmxStatistics().domain());
assertTrue(gc.globalJmxStatistics().mbeanServerLookup() instanceof PerThreadMBeanServerLookup);
c = cm.getCacheConfiguration("dist");
assertEquals(CacheMode.DIST_SYNC, c.clustering().cacheMode());
assertEquals(600000, c.clustering().l1().lifespan());
if (deprecated) assertEquals(120000, c.clustering().hash().rehashRpcTimeout());