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());
}
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());
}
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;
}
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;
}
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);
}
Aggregations