Search in sources :

Example 56 with ConfigurationBuilder

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

the class BackupsServiceConfigurator method get.

@Override
public SitesConfiguration get() {
    SitesConfigurationBuilder builder = new ConfigurationBuilder().sites();
    builder.disableBackups(this.backups.isEmpty());
    for (Map.Entry<String, BackupConfiguration> backup : this.backups.entrySet()) {
        builder.addBackup().read(backup.getValue());
        builder.addInUseBackupSite(backup.getKey());
    }
    return builder.create();
}
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) BackupConfiguration(org.infinispan.configuration.cache.BackupConfiguration) HashMap(java.util.HashMap) Map(java.util.Map)

Example 57 with ConfigurationBuilder

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

the class BackupsServiceConfigurator method configure.

@Override
public ServiceConfigurator 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(BackupFailurePolicy.valueOf(FAILURE_POLICY.resolveModelAttribute(context, backup).asString())).replicationTimeout(TIMEOUT.resolveModelAttribute(context, backup).asLong()).strategy(BackupStrategy.valueOf(STRATEGY.resolveModelAttribute(context, backup).asString())).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 58 with ConfigurationBuilder

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

the class CustomStoreServiceConfigurator method get.

@Override
public PersistenceConfiguration get() {
    PersistenceConfiguration persistence = super.get();
    StoreConfiguration store = persistence.stores().get(0);
    try {
        @SuppressWarnings("unchecked") Class<StoreConfigurationBuilder<?, ?>> storeClass = (Class<StoreConfigurationBuilder<?, ?>>) this.module.get().getClassLoader().loadClass(this.className).asSubclass(StoreConfigurationBuilder.class);
        return new ConfigurationBuilder().persistence().passivation(persistence.passivation()).addStore(storeClass).async().read(store.async()).fetchPersistentState(store.fetchPersistentState()).preload(store.preload()).purgeOnStartup(store.purgeOnStartup()).shared(store.shared()).withProperties(store.properties()).persistence().create();
    } catch (ClassNotFoundException | ClassCastException e) {
        throw InfinispanLogger.ROOT_LOGGER.invalidCacheStore(e, this.className);
    }
}
Also used : PersistenceConfiguration(org.infinispan.configuration.cache.PersistenceConfiguration) ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) StoreConfigurationBuilder(org.infinispan.configuration.cache.StoreConfigurationBuilder) StoreConfiguration(org.infinispan.configuration.cache.StoreConfiguration) StoreConfigurationBuilder(org.infinispan.configuration.cache.StoreConfigurationBuilder)

Example 59 with ConfigurationBuilder

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

the class DefaultCacheContainerTestCase method defineConfiguration.

@Test
public void defineConfiguration() {
    ConfigurationBuilder builder = new ConfigurationBuilder();
    Configuration config = builder.build();
    when(this.manager.defineConfiguration("other", config)).thenReturn(config);
    Configuration result = this.subject.defineConfiguration("other", config);
    assertSame(config, result);
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) GlobalConfiguration(org.infinispan.configuration.global.GlobalConfiguration) Configuration(org.infinispan.configuration.cache.Configuration) Test(org.junit.Test)

Example 60 with ConfigurationBuilder

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

the class InfinispanBeanManagerFactoryServiceConfiguratorFactory method getDeploymentServiceConfigurators.

@Override
public Iterable<CapabilityServiceConfigurator> getDeploymentServiceConfigurators(final ServiceName name) {
    String cacheName = getCacheName(name, this.name);
    String containerName = this.config.getContainerName();
    String templateCacheName = this.config.getCacheName();
    // Ensure eviction and expiration are disabled
    Consumer<ConfigurationBuilder> configurator = builder -> {
        // Ensure expiration is not enabled on cache
        ExpirationConfiguration expiration = builder.expiration().create();
        if ((expiration.lifespan() >= 0) || (expiration.maxIdle() >= 0)) {
            builder.expiration().lifespan(-1).maxIdle(-1);
            InfinispanEjbLogger.ROOT_LOGGER.expirationDisabled(InfinispanCacheRequirement.CONFIGURATION.resolve(containerName, templateCacheName));
        }
        int size = this.config.getMaxSize();
        EvictionStrategy strategy = (size > 0) ? EvictionStrategy.REMOVE : EvictionStrategy.MANUAL;
        builder.memory().storage(StorageType.HEAP).whenFull(strategy).maxCount(size);
        if (strategy.isEnabled()) {
            // Only evict bean group entries
            // We will cascade eviction to the associated beans
            builder.addModule(DataContainerConfigurationBuilder.class).evictable(BeanGroupKey.class::isInstance);
        }
    };
    CapabilityServiceConfigurator configurationConfigurator = new TemplateConfigurationServiceConfigurator(ServiceNameFactory.parseServiceName(InfinispanCacheRequirement.CONFIGURATION.getName()).append(containerName, cacheName), containerName, cacheName, templateCacheName, configurator);
    CapabilityServiceConfigurator cacheConfigurator = new CacheServiceConfigurator<>(ServiceNameFactory.parseServiceName(InfinispanCacheRequirement.CACHE.getName()).append(containerName, cacheName), containerName, cacheName).require(new ServiceDependency(name.append("marshalling")));
    List<Iterable<CapabilityServiceConfigurator>> configurators = new LinkedList<>();
    configurators.add(Arrays.asList(configurationConfigurator, cacheConfigurator));
    ServiceNameRegistry<ClusteringCacheRequirement> registry = new ServiceNameRegistry<ClusteringCacheRequirement>() {

        @Override
        public ServiceName getServiceName(ClusteringCacheRequirement requirement) {
            return (requirement == ClusteringCacheRequirement.GROUP) ? ServiceNameFactory.parseServiceName(requirement.getName()).append(containerName, cacheName) : null;
        }
    };
    for (CacheServiceConfiguratorProvider provider : ServiceLoader.load(DistributedCacheServiceConfiguratorProvider.class, DistributedCacheServiceConfiguratorProvider.class.getClassLoader())) {
        configurators.add(provider.getServiceConfigurators(registry, containerName, cacheName));
    }
    return new CompositeIterable<>(configurators);
}
Also used : Arrays(java.util.Arrays) Services(org.jboss.as.server.deployment.Services) CacheServiceConfigurator(org.wildfly.clustering.infinispan.spi.service.CacheServiceConfigurator) ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) ExpirationConfiguration(org.infinispan.configuration.cache.ExpirationConfiguration) ServiceDependency(org.wildfly.clustering.service.ServiceDependency) ArrayList(java.util.ArrayList) BeanManagerFactoryServiceConfiguratorFactory(org.wildfly.clustering.ejb.BeanManagerFactoryServiceConfiguratorFactory) StatefulBeanConfiguration(org.wildfly.clustering.ejb.StatefulBeanConfiguration) BeanManagerFactoryServiceConfiguratorConfiguration(org.wildfly.clustering.ejb.BeanManagerFactoryServiceConfiguratorConfiguration) CompositeIterable(org.wildfly.clustering.ee.CompositeIterable) BeanManagerFactory(org.wildfly.clustering.ejb.BeanManagerFactory) LinkedList(java.util.LinkedList) ClusteringCacheRequirement(org.wildfly.clustering.spi.ClusteringCacheRequirement) StorageType(org.infinispan.configuration.cache.StorageType) TemplateConfigurationServiceConfigurator(org.wildfly.clustering.infinispan.spi.service.TemplateConfigurationServiceConfigurator) ServiceLoader(java.util.ServiceLoader) InfinispanEjbLogger(org.wildfly.clustering.ejb.infinispan.logging.InfinispanEjbLogger) DistributedCacheServiceConfiguratorProvider(org.wildfly.clustering.spi.DistributedCacheServiceConfiguratorProvider) CacheServiceConfiguratorProvider(org.wildfly.clustering.spi.CacheServiceConfiguratorProvider) Consumer(java.util.function.Consumer) EvictionStrategy(org.infinispan.eviction.EvictionStrategy) ServiceNameRegistry(org.wildfly.clustering.service.ServiceNameRegistry) List(java.util.List) ServiceNameFactory(org.jboss.as.controller.ServiceNameFactory) ServiceName(org.jboss.msc.service.ServiceName) InfinispanCacheRequirement(org.wildfly.clustering.infinispan.spi.InfinispanCacheRequirement) DataContainerConfigurationBuilder(org.wildfly.clustering.infinispan.spi.DataContainerConfigurationBuilder) CapabilityServiceConfigurator(org.jboss.as.clustering.controller.CapabilityServiceConfigurator) DistributedCacheServiceConfiguratorProvider(org.wildfly.clustering.spi.DistributedCacheServiceConfiguratorProvider) ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) DataContainerConfigurationBuilder(org.wildfly.clustering.infinispan.spi.DataContainerConfigurationBuilder) DistributedCacheServiceConfiguratorProvider(org.wildfly.clustering.spi.DistributedCacheServiceConfiguratorProvider) CacheServiceConfiguratorProvider(org.wildfly.clustering.spi.CacheServiceConfiguratorProvider) CapabilityServiceConfigurator(org.jboss.as.clustering.controller.CapabilityServiceConfigurator) CompositeIterable(org.wildfly.clustering.ee.CompositeIterable) ExpirationConfiguration(org.infinispan.configuration.cache.ExpirationConfiguration) CompositeIterable(org.wildfly.clustering.ee.CompositeIterable) ClusteringCacheRequirement(org.wildfly.clustering.spi.ClusteringCacheRequirement) LinkedList(java.util.LinkedList) TemplateConfigurationServiceConfigurator(org.wildfly.clustering.infinispan.spi.service.TemplateConfigurationServiceConfigurator) ServiceNameRegistry(org.wildfly.clustering.service.ServiceNameRegistry) ServiceDependency(org.wildfly.clustering.service.ServiceDependency) EvictionStrategy(org.infinispan.eviction.EvictionStrategy)

Aggregations

ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)71 Configuration (org.infinispan.configuration.cache.Configuration)36 GlobalConfigurationBuilder (org.infinispan.configuration.global.GlobalConfigurationBuilder)29 DefaultCacheManager (org.infinispan.manager.DefaultCacheManager)23 Test (org.junit.Test)19 EmbeddedCacheManager (org.infinispan.manager.EmbeddedCacheManager)9 ClusteringConfigurationBuilder (org.infinispan.configuration.cache.ClusteringConfigurationBuilder)8 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 BackupConfiguration (org.infinispan.configuration.cache.BackupConfiguration)3 BackupConfigurationBuilder (org.infinispan.configuration.cache.BackupConfigurationBuilder)3 CacheMode (org.infinispan.configuration.cache.CacheMode)3 SitesConfigurationBuilder (org.infinispan.configuration.cache.SitesConfigurationBuilder)3 TransportConfigurationBuilder (org.infinispan.configuration.global.TransportConfigurationBuilder)3 EmbeddedTransactionManagerLookup (org.infinispan.transaction.lookup.EmbeddedTransactionManagerLookup)3