Search in sources :

Example 6 with CacheMode

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

the class InfinispanCachePropertiesTestCase method isPersistent.

@Test
public void isPersistent() {
    for (CacheMode mode : EnumSet.allOf(CacheMode.class)) {
        Configuration config = new ConfigurationBuilder().clustering().cacheMode(mode).build();
        CacheProperties configuration = new InfinispanCacheProperties(config);
        if (mode.isDistributed() || mode.isReplicated()) {
            Assert.assertTrue(mode.name(), configuration.isPersistent());
        } else {
            Assert.assertFalse(mode.name(), configuration.isPersistent());
        }
    }
    Configuration config = new ConfigurationBuilder().clustering().cacheMode(CacheMode.LOCAL).persistence().passivation(false).addSingleFileStore().build();
    Assert.assertTrue(new InfinispanCacheProperties(config).isPersistent());
    Configuration passivating = new ConfigurationBuilder().read(config).persistence().passivation(true).build();
    Assert.assertFalse(new InfinispanCacheProperties(passivating).isPersistent());
    Configuration noStore = new ConfigurationBuilder().read(config).persistence().clearStores().build();
    Assert.assertFalse(new InfinispanCacheProperties(noStore).isPersistent());
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) Configuration(org.infinispan.configuration.cache.Configuration) CacheMode(org.infinispan.configuration.cache.CacheMode) Test(org.junit.Test)

Example 7 with CacheMode

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

the class InfinispanCachePropertiesTestCase method isMarshalling.

@Test
public void isMarshalling() {
    for (CacheMode mode : EnumSet.allOf(CacheMode.class)) {
        Configuration config = new ConfigurationBuilder().clustering().cacheMode(mode).build();
        CacheProperties configuration = new InfinispanCacheProperties(config);
        if (mode.isDistributed() || mode.isReplicated()) {
            Assert.assertTrue(mode.name(), configuration.isMarshalling());
        } else {
            Assert.assertFalse(mode.name(), configuration.isMarshalling());
        }
    }
    Configuration config = new ConfigurationBuilder().clustering().cacheMode(CacheMode.LOCAL).persistence().passivation(false).addSingleFileStore().build();
    Assert.assertTrue(new InfinispanCacheProperties(config).isMarshalling());
    Configuration passivating = new ConfigurationBuilder().read(config).persistence().passivation(true).build();
    Assert.assertTrue(new InfinispanCacheProperties(passivating).isMarshalling());
    Configuration noStore = new ConfigurationBuilder().read(config).persistence().clearStores().build();
    Assert.assertFalse(new InfinispanCacheProperties(noStore).isMarshalling());
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) Configuration(org.infinispan.configuration.cache.Configuration) CacheMode(org.infinispan.configuration.cache.CacheMode) Test(org.junit.Test)

Example 8 with CacheMode

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

the class ClientMappingsCacheBuilderProvider method getBuilders.

@Override
public Collection<CapabilityServiceBuilder<?>> getBuilders(ServiceNameRegistry<ClusteringCacheRequirement> registry, String containerName, String aliasCacheName) {
    List<CapabilityServiceBuilder<?>> builders = new LinkedList<>();
    if (aliasCacheName == null) {
        String cacheName = BeanManagerFactoryBuilderConfiguration.CLIENT_MAPPINGS_CACHE_NAME;
        builders.add(new TemplateConfigurationBuilder(ServiceName.parse(InfinispanCacheRequirement.CONFIGURATION.resolve(containerName, cacheName)), containerName, cacheName, aliasCacheName, builder -> {
            CacheMode mode = builder.clustering().cacheMode();
            builder.clustering().cacheMode(mode.isClustered() ? CacheMode.REPL_SYNC : CacheMode.LOCAL);
            builder.clustering().l1().disable();
            builder.persistence().clearStores();
        }));
        builders.add(new CacheBuilder<>(ServiceName.parse(InfinispanCacheRequirement.CACHE.resolve(containerName, cacheName)), containerName, cacheName));
        ServiceNameRegistry<ClusteringCacheRequirement> routingRegistry = requirement -> ServiceName.parse(requirement.resolve(containerName, cacheName));
        for (CacheBuilderProvider provider : ServiceLoader.load(this.providerClass, this.providerClass.getClassLoader())) {
            builders.addAll(provider.getBuilders(routingRegistry, containerName, cacheName));
        }
    }
    return builders;
}
Also used : TemplateConfigurationBuilder(org.wildfly.clustering.infinispan.spi.service.TemplateConfigurationBuilder) ClusteringCacheRequirement(org.wildfly.clustering.spi.ClusteringCacheRequirement) Collection(java.util.Collection) ServiceLoader(java.util.ServiceLoader) BeanManagerFactoryBuilderConfiguration(org.wildfly.clustering.ejb.BeanManagerFactoryBuilderConfiguration) ServiceNameRegistry(org.wildfly.clustering.spi.ServiceNameRegistry) List(java.util.List) CacheMode(org.infinispan.configuration.cache.CacheMode) CacheAliasBuilderProvider(org.wildfly.clustering.spi.CacheAliasBuilderProvider) CacheBuilder(org.wildfly.clustering.infinispan.spi.service.CacheBuilder) ServiceName(org.jboss.msc.service.ServiceName) InfinispanCacheRequirement(org.wildfly.clustering.infinispan.spi.InfinispanCacheRequirement) CacheBuilderProvider(org.wildfly.clustering.spi.CacheBuilderProvider) CapabilityServiceBuilder(org.jboss.as.clustering.controller.CapabilityServiceBuilder) LinkedList(java.util.LinkedList) CapabilityServiceBuilder(org.jboss.as.clustering.controller.CapabilityServiceBuilder) CacheBuilderProvider(org.wildfly.clustering.spi.CacheBuilderProvider) TemplateConfigurationBuilder(org.wildfly.clustering.infinispan.spi.service.TemplateConfigurationBuilder) CacheMode(org.infinispan.configuration.cache.CacheMode) ClusteringCacheRequirement(org.wildfly.clustering.spi.ClusteringCacheRequirement) LinkedList(java.util.LinkedList)

Example 9 with CacheMode

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

the class RouteCacheGroupBuilderProvider method getBuilders.

@Override
public Collection<CapabilityServiceBuilder<?>> getBuilders(ServiceNameRegistry<ClusteringCacheRequirement> registry, String containerName, String aliasCacheName) {
    List<CapabilityServiceBuilder<?>> builders = new LinkedList<>();
    if (aliasCacheName == null) {
        builders.add(new TemplateConfigurationBuilder(ServiceName.parse(InfinispanCacheRequirement.CONFIGURATION.resolve(containerName, CACHE_NAME)), containerName, CACHE_NAME, aliasCacheName, builder -> {
            CacheMode mode = builder.clustering().cacheMode();
            builder.clustering().cacheMode(mode.isClustered() ? CacheMode.REPL_SYNC : CacheMode.LOCAL);
            builder.clustering().l1().disable();
            builder.persistence().clearStores();
        }));
        builders.add(new CacheBuilder<>(ServiceName.parse(InfinispanCacheRequirement.CACHE.resolve(containerName, CACHE_NAME)), containerName, CACHE_NAME));
        ServiceNameRegistry<ClusteringCacheRequirement> routingRegistry = requirement -> ServiceName.parse(requirement.resolve(containerName, CACHE_NAME));
        for (CacheBuilderProvider provider : ServiceLoader.load(this.providerClass, this.providerClass.getClassLoader())) {
            builders.addAll(provider.getBuilders(routingRegistry, containerName, CACHE_NAME));
        }
    }
    return builders;
}
Also used : TemplateConfigurationBuilder(org.wildfly.clustering.infinispan.spi.service.TemplateConfigurationBuilder) ClusteringCacheRequirement(org.wildfly.clustering.spi.ClusteringCacheRequirement) Collection(java.util.Collection) ServiceLoader(java.util.ServiceLoader) ServiceNameRegistry(org.wildfly.clustering.spi.ServiceNameRegistry) List(java.util.List) CacheMode(org.infinispan.configuration.cache.CacheMode) CacheAliasBuilderProvider(org.wildfly.clustering.spi.CacheAliasBuilderProvider) CacheBuilder(org.wildfly.clustering.infinispan.spi.service.CacheBuilder) ServiceName(org.jboss.msc.service.ServiceName) InfinispanCacheRequirement(org.wildfly.clustering.infinispan.spi.InfinispanCacheRequirement) CacheBuilderProvider(org.wildfly.clustering.spi.CacheBuilderProvider) CapabilityServiceBuilder(org.jboss.as.clustering.controller.CapabilityServiceBuilder) LinkedList(java.util.LinkedList) CapabilityServiceBuilder(org.jboss.as.clustering.controller.CapabilityServiceBuilder) CacheBuilderProvider(org.wildfly.clustering.spi.CacheBuilderProvider) TemplateConfigurationBuilder(org.wildfly.clustering.infinispan.spi.service.TemplateConfigurationBuilder) CacheMode(org.infinispan.configuration.cache.CacheMode) ClusteringCacheRequirement(org.wildfly.clustering.spi.ClusteringCacheRequirement) LinkedList(java.util.LinkedList)

Example 10 with CacheMode

use of org.infinispan.configuration.cache.CacheMode 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)

Aggregations

CacheMode (org.infinispan.configuration.cache.CacheMode)10 ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)5 ServiceName (org.jboss.msc.service.ServiceName)4 LinkedList (java.util.LinkedList)3 List (java.util.List)3 Configuration (org.infinispan.configuration.cache.Configuration)3 Test (org.junit.Test)3 Field (java.lang.reflect.Field)2 Collection (java.util.Collection)2 Collections (java.util.Collections)2 ServiceLoader (java.util.ServiceLoader)2 ExecutorService (java.util.concurrent.ExecutorService)2 Executors (java.util.concurrent.Executors)2 Consumer (java.util.function.Consumer)2 CapabilityServiceBuilder (org.jboss.as.clustering.controller.CapabilityServiceBuilder)2 PathAddress (org.jboss.as.controller.PathAddress)2 ServiceBuilder (org.jboss.msc.service.ServiceBuilder)2 ServiceController (org.jboss.msc.service.ServiceController)2 ServiceTarget (org.jboss.msc.service.ServiceTarget)2 InfinispanCacheRequirement (org.wildfly.clustering.infinispan.spi.InfinispanCacheRequirement)2