Search in sources :

Example 6 with ConfigurationBuilder

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);
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) Configuration(org.infinispan.configuration.cache.Configuration) TransactionBatch(org.wildfly.clustering.ee.infinispan.TransactionBatch) Test(org.junit.Test)

Example 7 with ConfigurationBuilder

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);
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) Configuration(org.infinispan.configuration.cache.Configuration) TransactionBatch(org.wildfly.clustering.ee.infinispan.TransactionBatch) Test(org.junit.Test)

Example 8 with ConfigurationBuilder

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;
}
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) ModelNode(org.jboss.dmr.ModelNode) Property(org.jboss.dmr.Property) BackupConfigurationBuilder(org.infinispan.configuration.cache.BackupConfigurationBuilder)

Example 9 with ConfigurationBuilder

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;
}
Also used : ValueDependency(org.wildfly.clustering.service.ValueDependency) ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) ExpirationConfiguration(org.infinispan.configuration.cache.ExpirationConfiguration) PersistenceConfiguration(org.infinispan.configuration.cache.PersistenceConfiguration) GlobalConfiguration(org.infinispan.configuration.global.GlobalConfiguration) OperationContext(org.jboss.as.controller.OperationContext) EvictionConfiguration(org.infinispan.configuration.cache.EvictionConfiguration) GroupsConfigurationBuilder(org.infinispan.configuration.cache.GroupsConfigurationBuilder) InfinispanRequirement(org.wildfly.clustering.infinispan.spi.InfinispanRequirement) Capability(org.jboss.as.clustering.infinispan.subsystem.CacheResourceDefinition.Capability) InjectedValueDependency(org.wildfly.clustering.service.InjectedValueDependency) ServiceTarget(org.jboss.msc.service.ServiceTarget) VersioningScheme(org.infinispan.configuration.cache.VersioningScheme) PathAddress(org.jboss.as.controller.PathAddress) Attribute(org.jboss.as.clustering.infinispan.subsystem.CacheResourceDefinition.Attribute) ServiceBuilder(org.jboss.msc.service.ServiceBuilder) LockingMode(org.infinispan.transaction.LockingMode) ResourceServiceBuilder(org.jboss.as.clustering.controller.ResourceServiceBuilder) TransactionConfiguration(org.infinispan.configuration.cache.TransactionConfiguration) Consumer(java.util.function.Consumer) ServiceController(org.jboss.msc.service.ServiceController) CacheMode(org.infinispan.configuration.cache.CacheMode) Grouper(org.infinispan.distribution.group.Grouper) IsolationLevel(org.infinispan.util.concurrent.IsolationLevel) Module(org.jboss.modules.Module) OperationFailedException(org.jboss.as.controller.OperationFailedException) Configuration(org.infinispan.configuration.cache.Configuration) ServiceName(org.jboss.msc.service.ServiceName) ModelNode(org.jboss.dmr.ModelNode) LockingConfiguration(org.infinispan.configuration.cache.LockingConfiguration) JMXStatisticsConfiguration(org.infinispan.configuration.cache.JMXStatisticsConfiguration) Builder(org.wildfly.clustering.service.Builder) InjectedValue(org.jboss.msc.value.InjectedValue) ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) GroupsConfigurationBuilder(org.infinispan.configuration.cache.GroupsConfigurationBuilder) GlobalConfiguration(org.infinispan.configuration.global.GlobalConfiguration) GroupsConfigurationBuilder(org.infinispan.configuration.cache.GroupsConfigurationBuilder) CacheMode(org.infinispan.configuration.cache.CacheMode)

Example 10 with ConfigurationBuilder

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();
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) SpringEmbeddedCacheManager(org.infinispan.spring.provider.SpringEmbeddedCacheManager) Test(org.junit.Test)

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