Search in sources :

Example 21 with Configuration

use of org.infinispan.configuration.cache.Configuration in project wildfly by wildfly.

the class InfinispanCachePropertiesTestCase method isMarshalling.

@Test
public void isMarshalling() {
    for (CacheMode mode : EnumSet.allOf(CacheMode.class)) {
        Configuration config = new ConfigurationBuilder().clustering().cacheMode(mode).build();
        CacheProperties configuration = new InfinispanCacheProperties(config);
        if (mode.isDistributed() || mode.isReplicated() || mode.isScattered()) {
            Assert.assertTrue(mode.name(), configuration.isMarshalling());
        } else {
            Assert.assertFalse(mode.name(), configuration.isMarshalling());
        }
    }
    Configuration config = new ConfigurationBuilder().clustering().cacheMode(CacheMode.LOCAL).persistence().passivation(false).addSingleFileStore().build();
    Assert.assertTrue(new InfinispanCacheProperties(config).isMarshalling());
    Configuration passivating = new ConfigurationBuilder().read(config).persistence().passivation(true).build();
    Assert.assertTrue(new InfinispanCacheProperties(passivating).isMarshalling());
    Configuration noStore = new ConfigurationBuilder().read(config).persistence().clearStores().build();
    Assert.assertFalse(new InfinispanCacheProperties(noStore).isMarshalling());
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) CacheProperties(org.wildfly.clustering.ee.cache.CacheProperties) Configuration(org.infinispan.configuration.cache.Configuration) CacheMode(org.infinispan.configuration.cache.CacheMode) Test(org.junit.Test)

Example 22 with Configuration

use of org.infinispan.configuration.cache.Configuration in project wildfly by wildfly.

the class InfinispanCachePropertiesTestCase method isLockOnWrite.

@Test
public void isLockOnWrite() {
    Configuration config = new ConfigurationBuilder().transaction().transactionMode(TransactionMode.TRANSACTIONAL).lockingMode(LockingMode.PESSIMISTIC).build();
    Assert.assertTrue(new InfinispanCacheProperties(config).isLockOnWrite());
    Configuration optimistic = config = new ConfigurationBuilder().read(config).transaction().lockingMode(LockingMode.OPTIMISTIC).build();
    Assert.assertFalse(new InfinispanCacheProperties(optimistic).isLockOnWrite());
    Configuration nonTx = new ConfigurationBuilder().read(config).transaction().transactionMode(TransactionMode.NON_TRANSACTIONAL).build();
    Assert.assertFalse(new InfinispanCacheProperties(nonTx).isLockOnWrite());
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) Configuration(org.infinispan.configuration.cache.Configuration) Test(org.junit.Test)

Example 23 with Configuration

use of org.infinispan.configuration.cache.Configuration in project wildfly by wildfly.

the class InfinispanCachePropertiesTestCase method isPersistent.

@Test
public void isPersistent() {
    for (CacheMode mode : EnumSet.allOf(CacheMode.class)) {
        Configuration config = new ConfigurationBuilder().clustering().cacheMode(mode).build();
        CacheProperties configuration = new InfinispanCacheProperties(config);
        if (mode.isDistributed() || mode.isReplicated() || mode.isScattered()) {
            Assert.assertTrue(mode.name(), configuration.isPersistent());
        } else {
            Assert.assertFalse(mode.name(), configuration.isPersistent());
        }
    }
    Configuration config = new ConfigurationBuilder().clustering().cacheMode(CacheMode.LOCAL).persistence().passivation(false).addSingleFileStore().build();
    Assert.assertTrue(new InfinispanCacheProperties(config).isPersistent());
    Configuration passivating = new ConfigurationBuilder().read(config).persistence().passivation(true).build();
    Assert.assertFalse(new InfinispanCacheProperties(passivating).isPersistent());
    Configuration noStore = new ConfigurationBuilder().read(config).persistence().clearStores().build();
    Assert.assertFalse(new InfinispanCacheProperties(noStore).isPersistent());
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) CacheProperties(org.wildfly.clustering.ee.cache.CacheProperties) Configuration(org.infinispan.configuration.cache.Configuration) CacheMode(org.infinispan.configuration.cache.CacheMode) Test(org.junit.Test)

Example 24 with Configuration

use of org.infinispan.configuration.cache.Configuration in project gora by apache.

the class SimulationDriver method create.

// Helpers
protected void create(int nnodes, ConfigurationBuilder defaultBuilder) {
    // Start Hot Rod servers at each site.
    for (int j = 0; j < nnodes; j++) {
        GlobalConfigurationBuilder gbuilder = GlobalConfigurationBuilder.defaultClusteredBuilder();
        Transport transport = gbuilder.transport().getTransport();
        gbuilder.transport().transport(transport);
        gbuilder.transport().clusterName("test");
        startHotRodServer(gbuilder, defaultBuilder, j + 1);
    }
    // Create appropriate caches at each node.
    ConfigurationBuilder builder = hotRodCacheConfiguration(getDefaultClusteredCacheConfig(CacheMode.DIST_SYNC, false));
    builder.indexing().index(Index.LOCAL).addProperty("default.directory_provider", "ram").addProperty("hibernate.search.default.exclusive_index_use", "true").addProperty("hibernate.search.default.indexmanager", "near-real-time").addProperty("hibernate.search.default.indexwriter.ram_buffer_size", "128").addProperty("lucene_version", "LUCENE_CURRENT");
    builder.clustering().hash().numOwners(1);
    builder.jmxStatistics().enable();
    builder.transaction().transactionMode(TransactionMode.TRANSACTIONAL);
    Configuration configuration = builder.build();
    for (int j = 0; j < nnodes; j++) {
        for (String name : cacheNames) {
            manager(j).defineConfiguration(name, configuration);
            manager(j).getCache(name, true);
        }
    }
    // Verify that default caches are started.
    for (int j = 0; j < nnodes; j++) {
        assert manager(j).getCache() != null;
    }
    // Verify that the default caches is running.
    for (int j = 0; j < nnodes; j++) {
        blockUntilCacheStatusAchieved(manager(j).getCache(), ComponentStatus.RUNNING, 10000);
    }
    for (int j = 0; j < nnodes; j++) {
        if (j != 0)
            connectionString += ";";
        connectionString += server(j).getHost() + ":" + server(j).getPort();
    }
}
Also used : GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) HotRodTestingUtil.hotRodCacheConfiguration(org.infinispan.server.hotrod.test.HotRodTestingUtil.hotRodCacheConfiguration) Configuration(org.infinispan.configuration.cache.Configuration) Transport(org.infinispan.remoting.transport.Transport)

Example 25 with Configuration

use of org.infinispan.configuration.cache.Configuration in project hibernate-orm by hibernate.

the class BaseTransactionalDataRegion method prepareForTombstones.

private void prepareForTombstones() {
    if (strategy != null) {
        assert strategy == Strategy.TOMBSTONES;
        return;
    }
    Configuration configuration = cache.getCacheConfiguration();
    if (configuration.eviction().maxEntries() >= 0) {
        log.evictionWithTombstones();
    }
    replaceCommonInterceptors();
    replaceExpirationManager();
    cache.removeInterceptor(CallInterceptor.class);
    TombstoneCallInterceptor tombstoneCallInterceptor = new TombstoneCallInterceptor(this);
    cache.getComponentRegistry().registerComponent(tombstoneCallInterceptor, TombstoneCallInterceptor.class);
    List<CommandInterceptor> interceptorChain = cache.getInterceptorChain();
    cache.addInterceptor(tombstoneCallInterceptor, interceptorChain.size());
    strategy = Strategy.TOMBSTONES;
}
Also used : Configuration(org.infinispan.configuration.cache.Configuration) CommandInterceptor(org.infinispan.interceptors.base.CommandInterceptor) TombstoneCallInterceptor(org.hibernate.cache.infinispan.access.TombstoneCallInterceptor)

Aggregations

Configuration (org.infinispan.configuration.cache.Configuration)37 ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)24 Test (org.junit.Test)24 Properties (java.util.Properties)12 AdvancedCache (org.infinispan.AdvancedCache)9 GlobalConfigurationBuilder (org.infinispan.configuration.global.GlobalConfigurationBuilder)6 InfinispanRegionFactory (org.hibernate.cache.infinispan.InfinispanRegionFactory)5 EntityRegionImpl (org.hibernate.cache.infinispan.entity.EntityRegionImpl)4 GlobalConfiguration (org.infinispan.configuration.global.GlobalConfiguration)4 CacheMode (org.infinispan.configuration.cache.CacheMode)3 TransactionConfiguration (org.infinispan.configuration.cache.TransactionConfiguration)3 EmbeddedCacheManager (org.infinispan.manager.EmbeddedCacheManager)3 CollectionRegionImpl (org.hibernate.cache.infinispan.collection.CollectionRegionImpl)2 QueryResultsRegionImpl (org.hibernate.cache.infinispan.query.QueryResultsRegionImpl)2 TimestampsRegionImpl (org.hibernate.cache.infinispan.timestamp.TimestampsRegionImpl)2 DefaultCacheManager (org.infinispan.manager.DefaultCacheManager)2 CacheProperties (org.wildfly.clustering.ee.cache.CacheProperties)2 TransactionBatch (org.wildfly.clustering.ee.infinispan.TransactionBatch)2 Method (java.lang.reflect.Method)1 Map (java.util.Map)1