use of org.infinispan.configuration.cache.ConfigurationBuilder in project wildfly by wildfly.
the class MemoryServiceConfigurator method get.
@Override
public MemoryConfiguration get() {
EvictionStrategy strategy = this.size > 0 ? EvictionStrategy.REMOVE : EvictionStrategy.MANUAL;
MemoryConfigurationBuilder builder = new ConfigurationBuilder().memory().storage(this.storageType).whenFull(strategy);
if (strategy.isEnabled()) {
if (this.unit == MemorySizeUnit.ENTRIES) {
builder.maxCount(this.size);
} else {
builder.maxSize(Long.toString(this.unit.applyAsLong(this.size)));
}
}
return builder.create();
}
use of org.infinispan.configuration.cache.ConfigurationBuilder in project openolat by klemens.
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);
}
}
use of org.infinispan.configuration.cache.ConfigurationBuilder in project keycloak by keycloak.
the class ClusteredCacheBehaviorTest method createManager.
public EmbeddedCacheManager createManager() {
System.setProperty("java.net.preferIPv4Stack", "true");
System.setProperty("jgroups.tcp.port", "53715");
GlobalConfigurationBuilder gcb = new GlobalConfigurationBuilder();
gcb = gcb.clusteredDefault();
gcb.transport().clusterName("test-clustering");
gcb.jmx().domain(InfinispanConnectionProvider.JMX_DOMAIN).enable();
EmbeddedCacheManager cacheManager = new DefaultCacheManager(gcb.build());
ConfigurationBuilder invalidationConfigBuilder = new ConfigurationBuilder();
invalidationConfigBuilder.clustering().cacheMode(CacheMode.INVALIDATION_SYNC);
Configuration invalidationCacheConfiguration = invalidationConfigBuilder.build();
cacheManager.defineConfiguration(InfinispanConnectionProvider.REALM_CACHE_NAME, invalidationCacheConfiguration);
return cacheManager;
}
use of org.infinispan.configuration.cache.ConfigurationBuilder in project keycloak by keycloak.
the class ConcurrencyLockingTest method getVersionedCacheManager.
protected DefaultCacheManager getVersionedCacheManager() {
GlobalConfigurationBuilder gcb = new GlobalConfigurationBuilder();
gcb.jmx().domain(InfinispanConnectionProvider.JMX_DOMAIN).enable();
final DefaultCacheManager cacheManager = new DefaultCacheManager(gcb.build());
ConfigurationBuilder invalidationConfigBuilder = new ConfigurationBuilder();
Configuration invalidationCacheConfiguration = invalidationConfigBuilder.build();
cacheManager.defineConfiguration(InfinispanConnectionProvider.REALM_CACHE_NAME, invalidationCacheConfiguration);
ConfigurationBuilder counterConfigBuilder = new ConfigurationBuilder();
counterConfigBuilder.invocationBatching().enable();
counterConfigBuilder.transaction().transactionManagerLookup(new EmbeddedTransactionManagerLookup());
counterConfigBuilder.transaction().lockingMode(LockingMode.PESSIMISTIC);
Configuration counterCacheConfiguration = counterConfigBuilder.build();
cacheManager.defineConfiguration("COUNTER_CACHE", counterCacheConfiguration);
return cacheManager;
}
use of org.infinispan.configuration.cache.ConfigurationBuilder in project keycloak by keycloak.
the class DistributedCacheConcurrentWritesTest method createManager.
public static EmbeddedCacheManager createManager(String nodeName) {
System.setProperty("java.net.preferIPv4Stack", "true");
System.setProperty("jgroups.tcp.port", "53715");
GlobalConfigurationBuilder gcb = new GlobalConfigurationBuilder();
gcb = gcb.clusteredDefault();
gcb.transport().clusterName("test-clustering");
gcb.transport().nodeName(nodeName);
gcb.jmx().domain(InfinispanConnectionProvider.JMX_DOMAIN).enable();
EmbeddedCacheManager cacheManager = new DefaultCacheManager(gcb.build());
ConfigurationBuilder distConfigBuilder = new ConfigurationBuilder();
distConfigBuilder.clustering().cacheMode(CacheMode.DIST_SYNC);
distConfigBuilder.clustering().hash().numOwners(1);
// Disable L1 cache
distConfigBuilder.clustering().hash().l1().enabled(false);
Configuration distConfig = distConfigBuilder.build();
cacheManager.defineConfiguration(InfinispanConnectionProvider.USER_SESSION_CACHE_NAME, distConfig);
return cacheManager;
}
Aggregations