use of org.infinispan.configuration.cache.ConfigurationBuilder in project wildfly by wildfly.
the class InfinispanBatcherFactoryTestCase method nonTransactional.
@Test
public void nonTransactional() {
AdvancedCache<Object, Object> cache = mock(AdvancedCache.class);
Configuration configuration = new ConfigurationBuilder().transaction().transactionMode(TransactionMode.NON_TRANSACTIONAL).build();
when(cache.getAdvancedCache()).thenReturn(cache);
when(cache.getCacheConfiguration()).thenReturn(configuration);
Batcher<TransactionBatch> batcher = this.factory.createBatcher(cache);
assertNull(batcher);
}
use of org.infinispan.configuration.cache.ConfigurationBuilder in project wildfly by wildfly.
the class InfinispanBatcherFactoryTestCase method transactional.
@Test
public void transactional() {
AdvancedCache<Object, Object> cache = mock(AdvancedCache.class);
Configuration configuration = new ConfigurationBuilder().transaction().transactionMode(TransactionMode.TRANSACTIONAL).build();
when(cache.getAdvancedCache()).thenReturn(cache);
when(cache.getCacheConfiguration()).thenReturn(configuration);
Batcher<TransactionBatch> batcher = this.factory.createBatcher(cache);
assertNotNull(batcher);
}
use of org.infinispan.configuration.cache.ConfigurationBuilder in project wildfly by wildfly.
the class BackupsBuilder method configure.
@Override
public Builder<SitesConfiguration> configure(OperationContext context, ModelNode model) throws OperationFailedException {
this.backups.clear();
if (model.hasDefined(BackupResourceDefinition.WILDCARD_PATH.getKey())) {
SitesConfigurationBuilder builder = new ConfigurationBuilder().sites();
for (Property property : model.get(BackupResourceDefinition.WILDCARD_PATH.getKey()).asPropertyList()) {
String siteName = property.getName();
ModelNode backup = property.getValue();
BackupConfigurationBuilder backupBuilder = builder.addBackup();
backupBuilder.site(siteName).enabled(ENABLED.resolveModelAttribute(context, backup).asBoolean()).backupFailurePolicy(ModelNodes.asEnum(FAILURE_POLICY.resolveModelAttribute(context, backup), BackupFailurePolicy.class)).replicationTimeout(TIMEOUT.resolveModelAttribute(context, backup).asLong()).strategy(ModelNodes.asEnum(STRATEGY.resolveModelAttribute(context, backup), BackupStrategy.class)).takeOffline().afterFailures(AFTER_FAILURES.resolveModelAttribute(context, backup).asInt()).minTimeToWait(MIN_WAIT.resolveModelAttribute(context, backup).asLong());
this.backups.put(siteName, backupBuilder.create());
}
}
return this;
}
use of org.infinispan.configuration.cache.ConfigurationBuilder in project wildfly by wildfly.
the class CacheConfigurationBuilder method configure.
@Override
public Builder<Configuration> configure(OperationContext context, ModelNode model) throws OperationFailedException {
boolean enabled = STATISTICS_ENABLED.resolveModelAttribute(context, model).asBoolean();
this.statistics = new ConfigurationBuilder().jmxStatistics().enabled(enabled).available(enabled).create();
this.global = new InjectedValueDependency<>(InfinispanRequirement.CONFIGURATION.getServiceName(context, this.containerName), GlobalConfiguration.class);
this.builder = new org.wildfly.clustering.infinispan.spi.service.ConfigurationBuilder(CONFIGURATION.getServiceName(context.getCurrentAddress()), this.containerName, this.cacheName, this.andThen(builder -> {
CacheMode mode = builder.clustering().cacheMode();
if (mode.isSynchronous() && (this.transaction.getValue().lockingMode() == LockingMode.OPTIMISTIC) && (this.locking.getValue().isolationLevel() == IsolationLevel.REPEATABLE_READ)) {
builder.locking().writeSkewCheck(true);
builder.versioning().enable().scheme(VersioningScheme.SIMPLE);
}
GroupsConfigurationBuilder groupsBuilder = builder.clustering().hash().groups().enabled();
this.module.getValue().loadService(Grouper.class).forEach(grouper -> groupsBuilder.addGrouper(grouper));
})).configure(context);
return this;
}
use of org.infinispan.configuration.cache.ConfigurationBuilder in project spring-boot by spring-projects.
the class CacheAutoConfigurationTests method infinispanCacheWithCachesAndCustomConfig.
@Test
public void infinispanCacheWithCachesAndCustomConfig() {
load(InfinispanCustomConfiguration.class, "spring.cache.type=infinispan", "spring.cache.cacheNames[0]=foo", "spring.cache.cacheNames[1]=bar");
SpringEmbeddedCacheManager cacheManager = validateCacheManager(SpringEmbeddedCacheManager.class);
assertThat(cacheManager.getCacheNames()).containsOnly("foo", "bar");
ConfigurationBuilder defaultConfigurationBuilder = this.context.getBean(ConfigurationBuilder.class);
verify(defaultConfigurationBuilder, times(2)).build();
}
Aggregations