Search in sources :

Example 36 with ConfigurationBuilder

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

the class InfinispanRegionFactory method defineDataTypeCacheConfigurations.

private void defineDataTypeCacheConfigurations() {
    for (DataType type : DataType.values()) {
        String cacheName = baseConfigurations.get(type.key);
        if (cacheName == null) {
            cacheName = type.defaultCacheName;
        }
        Configuration configuration = manager.getCacheConfiguration(cacheName);
        ConfigurationBuilder builder;
        if (configuration == null) {
            log.debugf("Cache configuration not found for %s", type);
            if (!cacheName.equals(type.defaultCacheName)) {
                log.customConfigForTypeNotFound(cacheName, type.key);
            }
            builder = defaultConfiguration.getNamedConfigurationBuilders().get(type.defaultCacheName);
            if (builder == null) {
                throw new IllegalStateException("Generic data types must have default configuration, none found for " + type);
            }
        } else {
            builder = new ConfigurationBuilder().read(configuration);
        }
        ConfigurationBuilder override = configOverrides.get(type.key);
        if (override != null) {
            builder.read(override.build(false));
        }
        builder.template(true);
        configureTransactionManager(builder);
        dataTypeConfigurations.put(type, builder.build());
    }
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) TransactionConfiguration(org.infinispan.configuration.cache.TransactionConfiguration) Configuration(org.infinispan.configuration.cache.Configuration)

Example 37 with ConfigurationBuilder

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

the class ClusteredCacheBuilder method configure.

@Override
public Builder<Configuration> configure(OperationContext context, ModelNode model) throws OperationFailedException {
    Mode mode = ModelNodes.asEnum(MODE.resolveModelAttribute(context, model), Mode.class);
    ClusteringConfigurationBuilder builder = new ConfigurationBuilder().clustering().cacheMode(mode.apply(this.mode));
    if (mode.isSynchronous()) {
        builder.sync().replTimeout(REMOTE_TIMEOUT.resolveModelAttribute(context, model).asLong());
    } else {
        builder.async();
    }
    this.clustering = builder.create();
    return super.configure(context, model);
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) ClusteringConfigurationBuilder(org.infinispan.configuration.cache.ClusteringConfigurationBuilder) ClusteringConfigurationBuilder(org.infinispan.configuration.cache.ClusteringConfigurationBuilder) CacheMode(org.infinispan.configuration.cache.CacheMode)

Example 38 with ConfigurationBuilder

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

the class DistributedCacheBuilder method configure.

@Override
public Builder<Configuration> configure(OperationContext context, ModelNode model) throws OperationFailedException {
    this.consistentHashStrategy = ModelNodes.asEnum(CONSISTENT_HASH_STRATEGY.resolveModelAttribute(context, model), ConsistentHashStrategy.class);
    ClusteringConfigurationBuilder builder = new ConfigurationBuilder().clustering();
    this.hash = builder.hash().capacityFactor(CAPACITY_FACTOR.resolveModelAttribute(context, model).asInt()).numOwners(OWNERS.resolveModelAttribute(context, model).asInt()).numSegments(SEGMENTS.resolveModelAttribute(context, model).asInt()).create();
    long l1Lifespan = L1_LIFESPAN.resolveModelAttribute(context, model).asLong();
    this.l1 = builder.l1().enabled(l1Lifespan > 0).lifespan(l1Lifespan).create();
    this.global = new InjectedValueDependency<>(InfinispanRequirement.CONFIGURATION.getServiceName(context, this.containerName), GlobalConfiguration.class);
    return super.configure(context, model);
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) HashConfigurationBuilder(org.infinispan.configuration.cache.HashConfigurationBuilder) ClusteringConfigurationBuilder(org.infinispan.configuration.cache.ClusteringConfigurationBuilder) ClusteringConfigurationBuilder(org.infinispan.configuration.cache.ClusteringConfigurationBuilder) GlobalConfiguration(org.infinispan.configuration.global.GlobalConfiguration)

Example 39 with ConfigurationBuilder

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

the class BackupsBuilder method getValue.

@Override
public SitesConfiguration getValue() {
    SitesConfigurationBuilder builder = new ConfigurationBuilder().sites();
    builder.backupFor().read(this.backupFor.getValue());
    builder.disableBackups(this.backups.isEmpty());
    for (Map.Entry<String, BackupConfiguration> backup : this.backups.entrySet()) {
        builder.addBackup().read(backup.getValue());
        builder.addInUseBackupSite(backup.getKey());
    }
    return builder.create();
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) SitesConfigurationBuilder(org.infinispan.configuration.cache.SitesConfigurationBuilder) BackupConfigurationBuilder(org.infinispan.configuration.cache.BackupConfigurationBuilder) SitesConfigurationBuilder(org.infinispan.configuration.cache.SitesConfigurationBuilder) BackupConfiguration(org.infinispan.configuration.cache.BackupConfiguration) HashMap(java.util.HashMap) Map(java.util.Map)

Example 40 with ConfigurationBuilder

use of org.infinispan.configuration.cache.ConfigurationBuilder in project OpenOLAT by OpenOLAT.

the class InfinispanCacher method createInfinispanConfiguration.

private void createInfinispanConfiguration(String cacheName) {
    Configuration conf = cacheManager.getCacheConfiguration(cacheName);
    if (conf == null) {
        long maxEntries = 10000;
        long maxIdle = 900000l;
        ConfigurationBuilder builder = new ConfigurationBuilder();
        builder.eviction().strategy(EvictionStrategy.LRU);
        builder.eviction().type(EvictionType.COUNT).size(maxEntries);
        builder.expiration().maxIdle(maxIdle);
        builder.transaction().transactionMode(TransactionMode.NON_TRANSACTIONAL);
        builder.dataContainer().storeAsBinary().storeValuesAsBinary(false);
        builder.locking().concurrencyLevel(1000);
        builder.locking().useLockStriping(false);
        builder.locking().lockAcquisitionTimeout(15000);
        builder.locking().isolationLevel(IsolationLevel.READ_COMMITTED);
        builder.jmxStatistics().enable();
        Configuration configurationOverride = builder.build();
        cacheManager.defineConfiguration(cacheName, configurationOverride);
    }
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) Configuration(org.infinispan.configuration.cache.Configuration)

Aggregations

ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)53 Configuration (org.infinispan.configuration.cache.Configuration)24 Test (org.junit.Test)19 GlobalConfigurationBuilder (org.infinispan.configuration.global.GlobalConfigurationBuilder)14 DefaultCacheManager (org.infinispan.manager.DefaultCacheManager)12 ClusteringConfigurationBuilder (org.infinispan.configuration.cache.ClusteringConfigurationBuilder)7 GlobalConfiguration (org.infinispan.configuration.global.GlobalConfiguration)7 Properties (java.util.Properties)6 Map (java.util.Map)5 InfinispanRegionFactory (org.hibernate.cache.infinispan.InfinispanRegionFactory)5 TimestampsRegionImpl (org.hibernate.cache.infinispan.timestamp.TimestampsRegionImpl)5 BeforeClass (org.junit.BeforeClass)5 AdvancedCache (org.infinispan.AdvancedCache)4 BackupConfigurationBuilder (org.infinispan.configuration.cache.BackupConfigurationBuilder)4 CacheMode (org.infinispan.configuration.cache.CacheMode)4 SitesConfigurationBuilder (org.infinispan.configuration.cache.SitesConfigurationBuilder)3 EmbeddedCacheManager (org.infinispan.manager.EmbeddedCacheManager)3 HashMap (java.util.HashMap)2 Consumer (java.util.function.Consumer)2 CacheProducer (org.commonjava.indy.subsys.infinispan.CacheProducer)2