use of org.infinispan.configuration.cache.ClusterLoaderConfiguration in project infinispan by infinispan.
the class XmlFileParsingTest method assertNamedCacheFile.
private void assertNamedCacheFile(ConfigurationBuilderHolder holder, boolean deprecated) {
GlobalConfiguration gc = holder.getGlobalConfigurationBuilder().build();
EnhancedQueueExecutorFactory listenerThreadPool = gc.listenerThreadPool().threadPoolFactory();
assertEquals(5, listenerThreadPool.maxThreads());
assertEquals(10000, listenerThreadPool.queueLength());
DefaultThreadFactory listenerThreadFactory = gc.listenerThreadPool().threadFactory();
assertEquals("AsyncListenerThread", listenerThreadFactory.threadNamePattern());
AbstractThreadPoolExecutorFactory persistenceThreadPool = gc.persistenceThreadPool().threadPoolFactory();
assertNull(persistenceThreadPool);
AbstractThreadPoolExecutorFactory blockingThreadPool = gc.blockingThreadPool().threadPoolFactory();
assertEquals(6, blockingThreadPool.maxThreads());
assertEquals(10001, blockingThreadPool.queueLength());
DefaultThreadFactory persistenceThreadFactory = gc.blockingThreadPool().threadFactory();
assertEquals("BlockingThread", persistenceThreadFactory.threadNamePattern());
AbstractThreadPoolExecutorFactory asyncThreadPool = gc.asyncThreadPool().threadPoolFactory();
assertNull(asyncThreadPool);
AbstractThreadPoolExecutorFactory nonBlockingThreadPool = gc.nonBlockingThreadPool().threadPoolFactory();
assertEquals(5, nonBlockingThreadPool.coreThreads());
assertEquals(5, nonBlockingThreadPool.maxThreads());
assertEquals(10000, nonBlockingThreadPool.queueLength());
assertEquals(0, nonBlockingThreadPool.keepAlive());
DefaultThreadFactory asyncThreadFactory = gc.nonBlockingThreadPool().threadFactory();
assertEquals("NonBlockingThread", asyncThreadFactory.threadNamePattern());
AbstractThreadPoolExecutorFactory transportThreadPool = gc.transport().transportThreadPool().threadPoolFactory();
assertNull(transportThreadPool);
AbstractThreadPoolExecutorFactory remoteCommandThreadPool = gc.transport().remoteCommandThreadPool().threadPoolFactory();
assertNull(remoteCommandThreadPool);
AbstractThreadPoolExecutorFactory stateTransferThreadPool = gc.stateTransferThreadPool().threadPoolFactory();
assertNull(stateTransferThreadPool);
DefaultThreadFactory evictionThreadFactory = gc.expirationThreadPool().threadFactory();
assertEquals("ExpirationThread", evictionThreadFactory.threadNamePattern());
assertTrue(gc.transport().transport() instanceof JGroupsTransport);
assertEquals("infinispan-cluster", gc.transport().clusterName());
assertEquals("Jalapeno", gc.transport().nodeName());
assertEquals(50000, gc.transport().distributedSyncTimeout());
assertEquals(ShutdownHookBehavior.REGISTER, gc.shutdown().hookBehavior());
assertTrue(gc.serialization().marshaller() instanceof TestObjectStreamMarshaller);
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 = holder.getDefaultConfigurationBuilder().build();
assertEquals(1000, defaultCfg.locking().lockAcquisitionTimeout());
assertEquals(100, defaultCfg.locking().concurrencyLevel());
assertEquals(IsolationLevel.REPEATABLE_READ, defaultCfg.locking().isolationLevel());
if (!deprecated) {
assertReaperAndTimeoutInfo(defaultCfg);
}
Configuration c = getCacheConfiguration(holder, "transactional");
assertFalse(c.clustering().cacheMode().isClustered());
assertTrue(c.transaction().transactionManagerLookup() instanceof GenericTransactionManagerLookup);
if (!deprecated) {
assertReaperAndTimeoutInfo(defaultCfg);
}
c = getCacheConfiguration(holder, "transactional2");
assertTrue(c.transaction().transactionManagerLookup() instanceof TestLookup);
assertEquals(10000, c.transaction().cacheStopTimeout());
assertEquals(LockingMode.PESSIMISTIC, c.transaction().lockingMode());
assertFalse(c.transaction().autoCommit());
c = getCacheConfiguration(holder, "syncInval");
assertEquals(CacheMode.INVALIDATION_SYNC, c.clustering().cacheMode());
assertTrue(c.clustering().stateTransfer().awaitInitialTransfer());
assertEquals(15000, c.clustering().remoteTimeout());
c = getCacheConfiguration(holder, "asyncInval");
assertEquals(CacheMode.INVALIDATION_ASYNC, c.clustering().cacheMode());
assertEquals(15000, c.clustering().remoteTimeout());
c = getCacheConfiguration(holder, "syncRepl");
assertEquals(CacheMode.REPL_SYNC, c.clustering().cacheMode());
assertFalse(c.clustering().stateTransfer().fetchInMemoryState());
assertTrue(c.clustering().stateTransfer().awaitInitialTransfer());
assertEquals(15000, c.clustering().remoteTimeout());
c = getCacheConfiguration(holder, "asyncRepl");
assertEquals(CacheMode.REPL_ASYNC, c.clustering().cacheMode());
assertFalse(c.clustering().stateTransfer().fetchInMemoryState());
assertTrue(c.clustering().stateTransfer().awaitInitialTransfer());
c = getCacheConfiguration(holder, "txSyncRepl");
assertTrue(c.transaction().transactionManagerLookup() instanceof GenericTransactionManagerLookup);
assertEquals(CacheMode.REPL_SYNC, c.clustering().cacheMode());
assertFalse(c.clustering().stateTransfer().fetchInMemoryState());
assertTrue(c.clustering().stateTransfer().awaitInitialTransfer());
assertEquals(15000, c.clustering().remoteTimeout());
c = getCacheConfiguration(holder, "overriding");
assertEquals(CacheMode.LOCAL, c.clustering().cacheMode());
assertEquals(20000, c.locking().lockAcquisitionTimeout());
assertEquals(1000, c.locking().concurrencyLevel());
assertEquals(IsolationLevel.REPEATABLE_READ, c.locking().isolationLevel());
assertEquals(StorageType.HEAP, c.memory().storageType());
c = getCacheConfiguration(holder, "storeAsBinary");
assertEquals(StorageType.BINARY, c.memory().storageType());
c = getCacheConfiguration(holder, "withFileStore");
assertTrue(c.persistence().preload());
assertFalse(c.persistence().passivation());
assertEquals(1, c.persistence().stores().size());
SoftIndexFileStoreConfiguration loaderCfg = (SoftIndexFileStoreConfiguration) c.persistence().stores().get(0);
assertTrue(loaderCfg.fetchPersistentState());
assertFalse(loaderCfg.ignoreModifications());
assertFalse(loaderCfg.purgeOnStartup());
assertEquals("/tmp/FileCacheStore-Location", loaderCfg.dataLocation());
assertTrue(loaderCfg.async().enabled());
assertEquals(700, loaderCfg.async().modificationQueueSize());
c = getCacheConfiguration(holder, "withClusterLoader");
assertEquals(1, c.persistence().stores().size());
ClusterLoaderConfiguration clusterLoaderCfg = (ClusterLoaderConfiguration) c.persistence().stores().get(0);
assertEquals(15000, clusterLoaderCfg.remoteCallTimeout());
c = getCacheConfiguration(holder, "withLoaderDefaults");
loaderCfg = (SoftIndexFileStoreConfiguration) c.persistence().stores().get(0);
assertEquals("/tmp/Another-FileCacheStore-Location", loaderCfg.dataLocation());
c = getCacheConfiguration(holder, "withouthJmxEnabled");
assertFalse(c.statistics().enabled());
assertTrue(gc.statistics());
assertTrue(gc.jmx().enabled());
assertEquals("funky_domain", gc.jmx().domain());
assertTrue(gc.jmx().mbeanServerLookup() instanceof TestMBeanServerLookup);
c = getCacheConfiguration(holder, "dist");
assertEquals(CacheMode.DIST_SYNC, c.clustering().cacheMode());
assertEquals(600000, c.clustering().l1().lifespan());
assertEquals(120000, c.clustering().stateTransfer().timeout());
assertEquals(1200, c.clustering().l1().cleanupTaskFrequency());
assertTrue(c.clustering().hash().consistentHashFactory() instanceof DefaultConsistentHashFactory);
assertEquals(3, c.clustering().hash().numOwners());
assertTrue(c.clustering().l1().enabled());
c = getCacheConfiguration(holder, "dist_with_capacity_factors");
assertEquals(CacheMode.DIST_SYNC, c.clustering().cacheMode());
assertEquals(600000, c.clustering().l1().lifespan());
assertEquals(120000, c.clustering().stateTransfer().timeout());
assertNull(c.clustering().hash().consistentHashFactory());
assertEquals(3, c.clustering().hash().numOwners());
assertTrue(c.clustering().l1().enabled());
assertEquals(0.0f, c.clustering().hash().capacityFactor());
if (!deprecated)
assertEquals(1000, c.clustering().hash().numSegments());
c = getCacheConfiguration(holder, "groups");
assertTrue(c.clustering().hash().groups().enabled());
assertEquals(1, c.clustering().hash().groups().groupers().size());
assertEquals(String.class, c.clustering().hash().groups().groupers().get(0).getKeyType());
c = getCacheConfiguration(holder, "chunkSize");
assertTrue(c.clustering().stateTransfer().fetchInMemoryState());
assertEquals(120000, c.clustering().stateTransfer().timeout());
assertEquals(1000, c.clustering().stateTransfer().chunkSize());
c = getCacheConfiguration(holder, "cacheWithCustomInterceptors");
assertFalse(c.customInterceptors().interceptors().isEmpty());
assertEquals(6, c.customInterceptors().interceptors().size());
for (InterceptorConfiguration i : c.customInterceptors().interceptors()) {
if (i.asyncInterceptor() instanceof FooInterceptor) {
assertEquals(i.properties().getProperty("foo"), "bar");
}
}
c = getCacheConfiguration(holder, "evictionCache");
assertEquals(5000, c.memory().size());
assertEquals(EvictionStrategy.REMOVE, c.memory().evictionStrategy());
assertEquals(EvictionType.COUNT, c.memory().evictionType());
assertEquals(StorageType.OBJECT, c.memory().storageType());
assertEquals(60000, c.expiration().lifespan());
assertEquals(1000, c.expiration().maxIdle());
assertEquals(500, c.expiration().wakeUpInterval());
c = getCacheConfiguration(holder, "evictionMemoryExceptionCache");
assertEquals(5000, c.memory().size());
assertEquals(EvictionStrategy.EXCEPTION, c.memory().evictionStrategy());
assertEquals(EvictionType.MEMORY, c.memory().evictionType());
assertEquals(StorageType.BINARY, c.memory().storageType());
c = getCacheConfiguration(holder, "storeKeyValueBinary");
assertEquals(StorageType.BINARY, c.memory().storageType());
}
use of org.infinispan.configuration.cache.ClusterLoaderConfiguration in project infinispan by infinispan.
the class HotRodConfigurationTest method testLazyLoadTopology.
public void testLazyLoadTopology() {
HotRodServerConfigurationBuilder builder = new HotRodServerConfigurationBuilder();
builder.topologyStateTransfer(false).topologyReplTimeout(43000);
withClusteredServer(builder, (cfg, distSyncTimeout) -> {
assertEquals(cfg.clustering().remoteTimeout(), 43000);
assertTrue(cfg.clustering().stateTransfer().fetchInMemoryState());
ClusterLoaderConfiguration clcfg = ((ClusterLoaderConfiguration) cfg.persistence().stores().get(0));
assertNotNull(clcfg);
assertEquals(clcfg.remoteCallTimeout(), 43000);
});
}
Aggregations