Search in sources :

Example 1 with GlobalConfiguration

use of org.infinispan.configuration.global.GlobalConfiguration in project indy by Commonjava.

the class ContentControllerTest method setupClass.

@BeforeClass
public static void setupClass() {
    GlobalConfiguration globalConfiguration = new GlobalConfigurationBuilder().globalJmxStatistics().allowDuplicateDomains(true).build();
    cacheManager = new DefaultCacheManager(globalConfiguration, new ConfigurationBuilder().simpleCache(true).build());
    contentMetadata = cacheManager.getCache("content-metadata", true);
}
Also used : GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) DefaultCacheManager(org.infinispan.manager.DefaultCacheManager) ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) GlobalConfiguration(org.infinispan.configuration.global.GlobalConfiguration) BeforeClass(org.junit.BeforeClass)

Example 2 with GlobalConfiguration

use of org.infinispan.configuration.global.GlobalConfiguration in project wildfly by wildfly.

the class GlobalConfigurationServiceConfigurator method build.

@Override
public ServiceBuilder<?> build(ServiceTarget target) {
    ServiceBuilder<?> builder = target.addService(this.getServiceName());
    Consumer<GlobalConfiguration> global = new CompositeDependency(this.loader, this.modules, this.transport, this.server).register(builder).provides(this.getServiceName());
    for (Dependency dependency : this.pools.values()) {
        dependency.register(builder);
    }
    for (Dependency dependency : this.scheduledPools.values()) {
        dependency.register(builder);
    }
    Service service = new FunctionalService<>(global, Function.identity(), this);
    return builder.setInstance(service).setInitialMode(ServiceController.Mode.PASSIVE);
}
Also used : GlobalConfiguration(org.infinispan.configuration.global.GlobalConfiguration) FunctionalService(org.wildfly.clustering.service.FunctionalService) FunctionalService(org.wildfly.clustering.service.FunctionalService) Service(org.jboss.msc.Service) CompositeDependency(org.wildfly.clustering.service.CompositeDependency) CompositeDependency(org.wildfly.clustering.service.CompositeDependency) SupplierDependency(org.wildfly.clustering.service.SupplierDependency) ServiceSupplierDependency(org.wildfly.clustering.service.ServiceSupplierDependency) Dependency(org.wildfly.clustering.service.Dependency)

Example 3 with GlobalConfiguration

use of org.infinispan.configuration.global.GlobalConfiguration in project kernel by exoplatform.

the class ExoCacheFactoryImpl method configureCacheManager.

/**
 * Configure the cache manager
 *
 * @param configBuilder the configuration builder on which we applied all the required changes
 * @throws ExoCacheInitException
 */
private void configureCacheManager(GlobalConfigurationBuilder configBuilder) throws ExoCacheInitException {
    GlobalConfiguration config = configBuilder.build();
    // Configure JGroups
    configureJGroups(config, configBuilder);
    // Configure the name of the cache manager
    configBuilder.globalJmxStatistics().enable().cacheManagerName(config.globalJmxStatistics().cacheManagerName() + "_" + ctx.getName()).mBeanServerLookup(MBEAN_SERVER_LOOKUP);
}
Also used : GlobalConfiguration(org.infinispan.configuration.global.GlobalConfiguration)

Example 4 with GlobalConfiguration

use of org.infinispan.configuration.global.GlobalConfiguration in project wildfly by wildfly.

the class CacheContainerBuilder method build.

@Override
public ServiceBuilder<CacheContainer> build(ServiceTarget target) {
    Function<EmbeddedCacheManager, CacheContainer> mapper = manager -> new DefaultCacheContainer(this.name, manager, this.defaultCache, this.batcherFactory);
    Supplier<EmbeddedCacheManager> supplier = () -> {
        GlobalConfiguration config = this.configuration.getValue();
        EmbeddedCacheManager manager = new DefaultCacheManager(config, null, false);
        manager.addListener(this);
        manager.start();
        InfinispanLogger.ROOT_LOGGER.debugf("%s cache container started", this.name);
        return manager;
    };
    Consumer<EmbeddedCacheManager> destroyer = manager -> {
        manager.stop();
        manager.removeListener(this);
        InfinispanLogger.ROOT_LOGGER.debugf("%s cache container stopped", this.name);
    };
    Service<CacheContainer> service = new SuppliedValueService<>(mapper, supplier, destroyer);
    ServiceBuilder<CacheContainer> builder = target.addService(this.getServiceName(), service).addAliases(this.aliases.stream().toArray(ServiceName[]::new)).setInitialMode(ServiceController.Mode.PASSIVE);
    return this.configuration.register(builder);
}
Also used : ValueDependency(org.wildfly.clustering.service.ValueDependency) Service(org.jboss.msc.service.Service) GlobalConfiguration(org.infinispan.configuration.global.GlobalConfiguration) DefaultCacheContainer(org.jboss.as.clustering.infinispan.DefaultCacheContainer) InfinispanBatcherFactory(org.jboss.as.clustering.infinispan.InfinispanBatcherFactory) CacheContainer(org.wildfly.clustering.infinispan.spi.CacheContainer) Function(java.util.function.Function) Supplier(java.util.function.Supplier) CacheStoppedEvent(org.infinispan.notifications.cachemanagerlistener.event.CacheStoppedEvent) SuppliedValueService(org.wildfly.clustering.service.SuppliedValueService) ALIASES(org.jboss.as.clustering.infinispan.subsystem.CacheContainerResourceDefinition.Attribute.ALIASES) DefaultCacheManager(org.infinispan.manager.DefaultCacheManager) OperationContext(org.jboss.as.controller.OperationContext) EmbeddedCacheManager(org.infinispan.manager.EmbeddedCacheManager) InfinispanLogger(org.jboss.as.clustering.infinispan.InfinispanLogger) InfinispanRequirement(org.wildfly.clustering.infinispan.spi.InfinispanRequirement) CacheStopped(org.infinispan.notifications.cachemanagerlistener.annotation.CacheStopped) CacheStartedEvent(org.infinispan.notifications.cachemanagerlistener.event.CacheStartedEvent) InjectedValueDependency(org.wildfly.clustering.service.InjectedValueDependency) ServiceTarget(org.jboss.msc.service.ServiceTarget) LinkedList(java.util.LinkedList) BatcherFactory(org.jboss.as.clustering.infinispan.BatcherFactory) BasicCacheContainer(org.infinispan.commons.api.BasicCacheContainer) Listener(org.infinispan.notifications.Listener) CONTAINER(org.jboss.as.clustering.infinispan.subsystem.CacheContainerResourceDefinition.Capability.CONTAINER) PathAddress(org.jboss.as.controller.PathAddress) ServiceBuilder(org.jboss.msc.service.ServiceBuilder) ResourceServiceBuilder(org.jboss.as.clustering.controller.ResourceServiceBuilder) Consumer(java.util.function.Consumer) ModelNodes(org.jboss.as.clustering.dmr.ModelNodes) CacheStarted(org.infinispan.notifications.cachemanagerlistener.annotation.CacheStarted) ServiceController(org.jboss.msc.service.ServiceController) List(java.util.List) DEFAULT_CACHE(org.jboss.as.clustering.infinispan.subsystem.CacheContainerResourceDefinition.Attribute.DEFAULT_CACHE) OperationFailedException(org.jboss.as.controller.OperationFailedException) ServiceName(org.jboss.msc.service.ServiceName) ModelNode(org.jboss.dmr.ModelNode) DefaultCacheManager(org.infinispan.manager.DefaultCacheManager) GlobalConfiguration(org.infinispan.configuration.global.GlobalConfiguration) DefaultCacheContainer(org.jboss.as.clustering.infinispan.DefaultCacheContainer) DefaultCacheContainer(org.jboss.as.clustering.infinispan.DefaultCacheContainer) CacheContainer(org.wildfly.clustering.infinispan.spi.CacheContainer) BasicCacheContainer(org.infinispan.commons.api.BasicCacheContainer) EmbeddedCacheManager(org.infinispan.manager.EmbeddedCacheManager) SuppliedValueService(org.wildfly.clustering.service.SuppliedValueService)

Example 5 with GlobalConfiguration

use of org.infinispan.configuration.global.GlobalConfiguration in project wildfly by wildfly.

the class CacheContainerServiceConfigurator method get.

@Override
public EmbeddedCacheManager get() {
    GlobalConfiguration config = this.configuration.get();
    String defaultCacheName = config.defaultCacheName().orElse(null);
    ConfigurationBuilderHolder holder = new ConfigurationBuilderHolder(config.classLoader(), new GlobalConfigurationBuilder().read(config));
    // We need to create a dummy default configuration if cache has a default cache
    if (defaultCacheName != null) {
        holder.newConfigurationBuilder(defaultCacheName);
    }
    EmbeddedCacheManager manager = new DefaultCacheManager(holder, false);
    // Undefine the default cache, if we defined one
    if (defaultCacheName != null) {
        manager.undefineConfiguration(defaultCacheName);
    }
    manager.start();
    // Must create executor before registering cache listener
    this.executor = Executors.newSingleThreadExecutor(new DefaultThreadFactory(this.getClass()));
    manager.addListener(this);
    InfinispanLogger.ROOT_LOGGER.debugf("%s cache container started", this.name);
    return manager;
}
Also used : GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) DefaultThreadFactory(org.jboss.as.clustering.context.DefaultThreadFactory) DefaultCacheManager(org.infinispan.manager.DefaultCacheManager) GlobalConfiguration(org.infinispan.configuration.global.GlobalConfiguration) ConfigurationBuilderHolder(org.infinispan.configuration.parsing.ConfigurationBuilderHolder) EmbeddedCacheManager(org.infinispan.manager.EmbeddedCacheManager)

Aggregations

GlobalConfiguration (org.infinispan.configuration.global.GlobalConfiguration)8 GlobalConfigurationBuilder (org.infinispan.configuration.global.GlobalConfigurationBuilder)4 DefaultCacheManager (org.infinispan.manager.DefaultCacheManager)4 ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)2 ConfigurationBuilderHolder (org.infinispan.configuration.parsing.ConfigurationBuilderHolder)2 EmbeddedCacheManager (org.infinispan.manager.EmbeddedCacheManager)2 Serializable (java.io.Serializable)1 PrivilegedActionException (java.security.PrivilegedActionException)1 PrivilegedExceptionAction (java.security.PrivilegedExceptionAction)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Callable (java.util.concurrent.Callable)1 Consumer (java.util.function.Consumer)1 Function (java.util.function.Function)1 Supplier (java.util.function.Supplier)1 ExoCache (org.exoplatform.services.cache.ExoCache)1 ExoCacheInitException (org.exoplatform.services.cache.ExoCacheInitException)1 DistributedExoCache (org.exoplatform.services.cache.impl.infinispan.distributed.DistributedExoCache)1 GenericExoCacheCreator (org.exoplatform.services.cache.impl.infinispan.generic.GenericExoCacheCreator)1 Cache (org.infinispan.Cache)1