Search in sources :

Example 11 with Configuration

use of org.infinispan.configuration.cache.Configuration 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 12 with Configuration

use of org.infinispan.configuration.cache.Configuration 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 13 with Configuration

use of org.infinispan.configuration.cache.Configuration 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 14 with Configuration

use of org.infinispan.configuration.cache.Configuration in project indy by Commonjava.

the class StorageFileIOTest method setup.

@Before
public void setup() throws IOException {
    storageRoot = temp.newFolder("data");
    Properties storageProps = new Properties();
    storageProps.setProperty(StorageFileIO.STORAGE_ROOT_DIR, storageRoot.getAbsolutePath());
    Configuration dataConfig = new ConfigurationBuilder().persistence().passivation(true).addStore(CustomStoreConfigurationBuilder.class).customStoreClass(StorageFileIO.class).properties(storageProps).build();
    String dataName = name.getMethodName() + "-data";
    CACHE_MANAGER.defineConfiguration(dataName, dataConfig);
    Configuration mdConfig = new ConfigurationBuilder().build();
    String metadataName = name.getMethodName() + "-metadata";
    CACHE_MANAGER.defineConfiguration(metadataName, mdConfig);
    dataCache = CACHE_MANAGER.getCache(dataName);
    fs = new GridFilesystem(dataCache, CACHE_MANAGER.getCache(metadataName));
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) CustomStoreConfigurationBuilder(org.infinispan.configuration.cache.CustomStoreConfigurationBuilder) Configuration(org.infinispan.configuration.cache.Configuration) GridFilesystem(org.infinispan.io.GridFilesystem) Properties(java.util.Properties) CustomStoreConfigurationBuilder(org.infinispan.configuration.cache.CustomStoreConfigurationBuilder) Before(org.junit.Before)

Example 15 with Configuration

use of org.infinispan.configuration.cache.Configuration in project adeptj-modules by AdeptJ.

the class InfinispanCacheProvider method initInfinispan.

protected void initInfinispan() {
    long startTime = System.nanoTime();
    if (this.cacheManager == null) {
        Configuration defaultConfiguration = new ConfigurationBuilder().simpleCache(true).eviction().strategy(EvictionStrategy.LRU).type(EvictionType.COUNT).size(1000l).expiration().lifespan(60, TimeUnit.MINUTES).maxIdle(30, TimeUnit.MINUTES).build();
        this.cacheManager = new DefaultCacheManager(defaultConfiguration);
        LOGGER.info("Infinispan initialization took: [{}] ms!!", TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTime));
    }
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) DefaultCacheManager(org.infinispan.manager.DefaultCacheManager) Configuration(org.infinispan.configuration.cache.Configuration)

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