Search in sources :

Example 1 with CacheBuilder

use of org.wildfly.clustering.infinispan.spi.service.CacheBuilder 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 2 with CacheBuilder

use of org.wildfly.clustering.infinispan.spi.service.CacheBuilder 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 3 with CacheBuilder

use of org.wildfly.clustering.infinispan.spi.service.CacheBuilder in project wildfly by wildfly.

the class CacheServiceHandler method installServices.

@Override
public void installServices(OperationContext context, ModelNode model) throws OperationFailedException {
    PathAddress cacheAddress = context.getCurrentAddress();
    PathAddress containerAddress = cacheAddress.getParent();
    String containerName = containerAddress.getLastElement().getValue();
    String cacheName = cacheAddress.getLastElement().getValue();
    ServiceTarget target = context.getServiceTarget();
    ServiceName moduleServiceName = CacheComponent.MODULE.getServiceName(cacheAddress);
    if (model.hasDefined(MODULE.getName())) {
        new ModuleBuilder(moduleServiceName, MODULE).configure(context, model).build(target).install();
    } else {
        new AliasServiceBuilder<>(moduleServiceName, CacheContainerComponent.MODULE.getServiceName(containerAddress), Module.class).build(target).install();
    }
    this.builderFactory.createBuilder(cacheAddress).configure(context, model).build(target).setInitialMode(ServiceController.Mode.PASSIVE).install();
    new CacheBuilder<>(CACHE.getServiceName(cacheAddress), containerName, cacheName).configure(context).build(target).install();
    new XAResourceRecoveryBuilder(cacheAddress).build(target).install();
    new BinderServiceBuilder<>(InfinispanBindingFactory.createCacheConfigurationBinding(containerName, cacheName), CONFIGURATION.getServiceName(cacheAddress), Configuration.class).build(target).install();
    BinderServiceBuilder<?> bindingBuilder = new BinderServiceBuilder<>(InfinispanBindingFactory.createCacheBinding(containerName, cacheName), CACHE.getServiceName(cacheAddress), Cache.class);
    ModelNodes.optionalString(JNDI_NAME.resolveModelAttribute(context, model)).map(jndiName -> ContextNames.bindInfoFor(JndiNameFactory.parse(jndiName).getAbsoluteName())).ifPresent(aliasBinding -> bindingBuilder.alias(aliasBinding));
    bindingBuilder.build(target).install();
    for (CacheBuilderProvider provider : ServiceLoader.load(this.providerClass, this.providerClass.getClassLoader())) {
        for (CapabilityServiceBuilder<?> builder : provider.getBuilders(requirement -> CLUSTERING_CAPABILITIES.get(requirement).getServiceName(cacheAddress), containerName, cacheName)) {
            builder.configure(context).build(target).install();
        }
    }
}
Also used : BinderServiceBuilder(org.jboss.as.clustering.naming.BinderServiceBuilder) ServiceNameProvider(org.wildfly.clustering.service.ServiceNameProvider) Cache(org.infinispan.Cache) ModuleBuilder(org.jboss.as.clustering.controller.ModuleBuilder) OperationContext(org.jboss.as.controller.OperationContext) AliasServiceBuilder(org.wildfly.clustering.service.AliasServiceBuilder) CacheBuilder(org.wildfly.clustering.infinispan.spi.service.CacheBuilder) Capability(org.jboss.as.clustering.infinispan.subsystem.CacheResourceDefinition.Capability) CapabilityServiceBuilder(org.jboss.as.clustering.controller.CapabilityServiceBuilder) ServiceTarget(org.jboss.msc.service.ServiceTarget) EnumSet(java.util.EnumSet) BinderServiceBuilder(org.jboss.as.clustering.naming.BinderServiceBuilder) ContextNames(org.jboss.as.naming.deployment.ContextNames) PathAddress(org.jboss.as.controller.PathAddress) Attribute(org.jboss.as.clustering.infinispan.subsystem.CacheResourceDefinition.Attribute) ServiceLoader(java.util.ServiceLoader) ResourceServiceBuilderFactory(org.jboss.as.clustering.controller.ResourceServiceBuilderFactory) ModelNodes(org.jboss.as.clustering.dmr.ModelNodes) ServiceController(org.jboss.msc.service.ServiceController) ResourceServiceHandler(org.jboss.as.clustering.controller.ResourceServiceHandler) Module(org.jboss.modules.Module) OperationFailedException(org.jboss.as.controller.OperationFailedException) Configuration(org.infinispan.configuration.cache.Configuration) ServiceName(org.jboss.msc.service.ServiceName) CacheBuilderProvider(org.wildfly.clustering.spi.CacheBuilderProvider) ModelNode(org.jboss.dmr.ModelNode) CLUSTERING_CAPABILITIES(org.jboss.as.clustering.infinispan.subsystem.CacheResourceDefinition.CLUSTERING_CAPABILITIES) JndiNameFactory(org.jboss.as.clustering.naming.JndiNameFactory) CacheBuilderProvider(org.wildfly.clustering.spi.CacheBuilderProvider) ServiceTarget(org.jboss.msc.service.ServiceTarget) ModuleBuilder(org.jboss.as.clustering.controller.ModuleBuilder) AliasServiceBuilder(org.wildfly.clustering.service.AliasServiceBuilder) ServiceName(org.jboss.msc.service.ServiceName) PathAddress(org.jboss.as.controller.PathAddress)

Aggregations

ServiceLoader (java.util.ServiceLoader)3 CapabilityServiceBuilder (org.jboss.as.clustering.controller.CapabilityServiceBuilder)3 ServiceName (org.jboss.msc.service.ServiceName)3 CacheBuilder (org.wildfly.clustering.infinispan.spi.service.CacheBuilder)3 CacheBuilderProvider (org.wildfly.clustering.spi.CacheBuilderProvider)3 Collection (java.util.Collection)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 CacheMode (org.infinispan.configuration.cache.CacheMode)2 InfinispanCacheRequirement (org.wildfly.clustering.infinispan.spi.InfinispanCacheRequirement)2 TemplateConfigurationBuilder (org.wildfly.clustering.infinispan.spi.service.TemplateConfigurationBuilder)2 CacheAliasBuilderProvider (org.wildfly.clustering.spi.CacheAliasBuilderProvider)2 ClusteringCacheRequirement (org.wildfly.clustering.spi.ClusteringCacheRequirement)2 ServiceNameRegistry (org.wildfly.clustering.spi.ServiceNameRegistry)2 EnumSet (java.util.EnumSet)1 Cache (org.infinispan.Cache)1 Configuration (org.infinispan.configuration.cache.Configuration)1 ModuleBuilder (org.jboss.as.clustering.controller.ModuleBuilder)1 ResourceServiceBuilderFactory (org.jboss.as.clustering.controller.ResourceServiceBuilderFactory)1 ResourceServiceHandler (org.jboss.as.clustering.controller.ResourceServiceHandler)1