Search in sources :

Example 1 with SoftIndexFileStoreConfiguration

use of org.infinispan.persistence.sifs.configuration.SoftIndexFileStoreConfiguration 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());
}
Also used : GlobalConfiguration(org.infinispan.configuration.global.GlobalConfiguration) JGroupsTransport(org.infinispan.remoting.transport.jgroups.JGroupsTransport) PersistenceConfiguration(org.infinispan.configuration.cache.PersistenceConfiguration) GlobalConfiguration(org.infinispan.configuration.global.GlobalConfiguration) InterceptorConfiguration(org.infinispan.configuration.cache.InterceptorConfiguration) SoftIndexFileStoreConfiguration(org.infinispan.persistence.sifs.configuration.SoftIndexFileStoreConfiguration) AbstractStoreConfiguration(org.infinispan.configuration.cache.AbstractStoreConfiguration) StoreConfiguration(org.infinispan.configuration.cache.StoreConfiguration) Configuration(org.infinispan.configuration.cache.Configuration) DummyInMemoryStoreConfiguration(org.infinispan.persistence.dummy.DummyInMemoryStoreConfiguration) ClusterLoaderConfiguration(org.infinispan.configuration.cache.ClusterLoaderConfiguration) GenericTransactionManagerLookup(org.infinispan.transaction.lookup.GenericTransactionManagerLookup) DefaultConsistentHashFactory(org.infinispan.distribution.ch.impl.DefaultConsistentHashFactory) InterceptorConfiguration(org.infinispan.configuration.cache.InterceptorConfiguration) FooInterceptor(org.infinispan.interceptors.FooInterceptor) EnhancedQueueExecutorFactory(org.infinispan.factories.threads.EnhancedQueueExecutorFactory) SoftIndexFileStoreConfiguration(org.infinispan.persistence.sifs.configuration.SoftIndexFileStoreConfiguration) DefaultThreadFactory(org.infinispan.factories.threads.DefaultThreadFactory) TestMBeanServerLookup(org.infinispan.commons.jmx.TestMBeanServerLookup) AbstractThreadPoolExecutorFactory(org.infinispan.factories.threads.AbstractThreadPoolExecutorFactory) AdvancedExternalizer(org.infinispan.commons.marshall.AdvancedExternalizer) TestObjectStreamMarshaller(org.infinispan.marshall.TestObjectStreamMarshaller) ClusterLoaderConfiguration(org.infinispan.configuration.cache.ClusterLoaderConfiguration) TestLookup(org.infinispan.test.tx.TestLookup)

Aggregations

TestMBeanServerLookup (org.infinispan.commons.jmx.TestMBeanServerLookup)1 AdvancedExternalizer (org.infinispan.commons.marshall.AdvancedExternalizer)1 AbstractStoreConfiguration (org.infinispan.configuration.cache.AbstractStoreConfiguration)1 ClusterLoaderConfiguration (org.infinispan.configuration.cache.ClusterLoaderConfiguration)1 Configuration (org.infinispan.configuration.cache.Configuration)1 InterceptorConfiguration (org.infinispan.configuration.cache.InterceptorConfiguration)1 PersistenceConfiguration (org.infinispan.configuration.cache.PersistenceConfiguration)1 StoreConfiguration (org.infinispan.configuration.cache.StoreConfiguration)1 GlobalConfiguration (org.infinispan.configuration.global.GlobalConfiguration)1 DefaultConsistentHashFactory (org.infinispan.distribution.ch.impl.DefaultConsistentHashFactory)1 AbstractThreadPoolExecutorFactory (org.infinispan.factories.threads.AbstractThreadPoolExecutorFactory)1 DefaultThreadFactory (org.infinispan.factories.threads.DefaultThreadFactory)1 EnhancedQueueExecutorFactory (org.infinispan.factories.threads.EnhancedQueueExecutorFactory)1 FooInterceptor (org.infinispan.interceptors.FooInterceptor)1 TestObjectStreamMarshaller (org.infinispan.marshall.TestObjectStreamMarshaller)1 DummyInMemoryStoreConfiguration (org.infinispan.persistence.dummy.DummyInMemoryStoreConfiguration)1 SoftIndexFileStoreConfiguration (org.infinispan.persistence.sifs.configuration.SoftIndexFileStoreConfiguration)1 JGroupsTransport (org.infinispan.remoting.transport.jgroups.JGroupsTransport)1 TestLookup (org.infinispan.test.tx.TestLookup)1 GenericTransactionManagerLookup (org.infinispan.transaction.lookup.GenericTransactionManagerLookup)1