Search in sources :

Example 1 with ClusteringCacheRequirement

use of org.wildfly.clustering.spi.ClusteringCacheRequirement 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 ClusteringCacheRequirement

use of org.wildfly.clustering.spi.ClusteringCacheRequirement 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 ClusteringCacheRequirement

use of org.wildfly.clustering.spi.ClusteringCacheRequirement in project wildfly by wildfly.

the class CacheContainerServiceHandler method installServices.

@Override
public void installServices(OperationContext context, ModelNode model) throws OperationFailedException {
    PathAddress address = context.getCurrentAddress();
    String name = context.getCurrentAddressValue();
    ServiceTarget target = context.getServiceTarget();
    new ModulesServiceConfigurator(CacheContainerComponent.MODULES.getServiceName(address), MODULES, Collections.singletonList(Module.forClass(WildFlyInfinispanModuleLifecycle.class))).configure(context, model).build(target).setInitialMode(ServiceController.Mode.PASSIVE).install();
    GlobalConfigurationServiceConfigurator configBuilder = new GlobalConfigurationServiceConfigurator(address);
    configBuilder.configure(context, model).build(target).install();
    CacheContainerServiceConfigurator containerBuilder = new CacheContainerServiceConfigurator(address, this.cacheRegistry).configure(context, model);
    containerBuilder.build(target).install();
    new ServiceValueCaptorServiceConfigurator<>(this.containerRegistry.add(containerBuilder.getServiceName())).build(target).install();
    new KeyAffinityServiceFactoryServiceConfigurator(address).build(target).install();
    new BinderServiceConfigurator(InfinispanBindingFactory.createCacheContainerBinding(name), containerBuilder.getServiceName()).build(target).install();
    String defaultCache = DEFAULT_CACHE.resolveModelAttribute(context, model).asString(null);
    if (defaultCache != null) {
        for (Map.Entry<InfinispanCacheRequirement, Capability> entry : DEFAULT_CAPABILITIES.entrySet()) {
            new IdentityServiceConfigurator<>(entry.getValue().getServiceName(address), entry.getKey().getServiceName(context, name, defaultCache)).build(target).install();
        }
        if (!defaultCache.equals(JndiNameFactory.DEFAULT_LOCAL_NAME)) {
            new BinderServiceConfigurator(InfinispanBindingFactory.createCacheBinding(name, JndiNameFactory.DEFAULT_LOCAL_NAME), DEFAULT_CAPABILITIES.get(InfinispanCacheRequirement.CACHE).getServiceName(address)).build(target).install();
            new BinderServiceConfigurator(InfinispanBindingFactory.createCacheConfigurationBinding(name, JndiNameFactory.DEFAULT_LOCAL_NAME), DEFAULT_CAPABILITIES.get(InfinispanCacheRequirement.CONFIGURATION).getServiceName(address)).build(target).install();
        }
        ServiceNameRegistry<ClusteringCacheRequirement> registry = new CapabilityServiceNameRegistry<>(DEFAULT_CLUSTERING_CAPABILITIES, address);
        for (IdentityCacheServiceConfiguratorProvider provider : ServiceLoader.load(IdentityCacheServiceConfiguratorProvider.class, IdentityCacheServiceConfiguratorProvider.class.getClassLoader())) {
            for (CapabilityServiceConfigurator configurator : provider.getServiceConfigurators(registry, name, null, defaultCache)) {
                configurator.configure(context).build(target).install();
            }
        }
    }
}
Also used : ModulesServiceConfigurator(org.jboss.as.clustering.controller.ModulesServiceConfigurator) CapabilityServiceNameRegistry(org.wildfly.clustering.spi.CapabilityServiceNameRegistry) BinderServiceConfigurator(org.jboss.as.clustering.naming.BinderServiceConfigurator) Capability(org.jboss.as.clustering.controller.Capability) CapabilityServiceConfigurator(org.jboss.as.clustering.controller.CapabilityServiceConfigurator) ServiceTarget(org.jboss.msc.service.ServiceTarget) ServiceValueCaptorServiceConfigurator(org.jboss.as.clustering.controller.ServiceValueCaptorServiceConfigurator) ClusteringCacheRequirement(org.wildfly.clustering.spi.ClusteringCacheRequirement) InfinispanCacheRequirement(org.wildfly.clustering.infinispan.spi.InfinispanCacheRequirement) IdentityCacheServiceConfiguratorProvider(org.wildfly.clustering.spi.IdentityCacheServiceConfiguratorProvider) PathAddress(org.jboss.as.controller.PathAddress) Map(java.util.Map) IdentityServiceConfigurator(org.wildfly.clustering.service.IdentityServiceConfigurator)

Example 4 with ClusteringCacheRequirement

use of org.wildfly.clustering.spi.ClusteringCacheRequirement in project wildfly by wildfly.

the class InfinispanRoutingProvider method getServiceConfigurators.

@Override
public Iterable<CapabilityServiceConfigurator> getServiceConfigurators(String serverName, SupplierDependency<String> route) {
    String containerName = this.config.getContainerName();
    String cacheName = this.config.getCacheName();
    CapabilityServiceConfigurator localRouteConfigurator = new LocalRouteServiceConfigurator(serverName, route);
    CapabilityServiceConfigurator registryEntryConfigurator = new RouteRegistryEntryProviderServiceConfigurator(containerName, serverName);
    CapabilityServiceConfigurator configurationConfigurator = new TemplateConfigurationServiceConfigurator(ServiceNameFactory.parseServiceName(InfinispanCacheRequirement.CONFIGURATION.getName()).append(containerName, serverName), containerName, serverName, cacheName, this.config);
    CapabilityServiceConfigurator cacheConfigurator = new CacheServiceConfigurator<>(ServiceNameFactory.parseServiceName(InfinispanCacheRequirement.CACHE.getName()).append(containerName, serverName), containerName, serverName);
    List<Iterable<CapabilityServiceConfigurator>> configurators = new LinkedList<>();
    configurators.add(Arrays.asList(localRouteConfigurator, registryEntryConfigurator, configurationConfigurator, cacheConfigurator));
    ServiceNameRegistry<ClusteringCacheRequirement> registry = new ServiceNameRegistry<ClusteringCacheRequirement>() {

        @Override
        public ServiceName getServiceName(ClusteringCacheRequirement requirement) {
            return REGISTRY_REQUIREMENTS.contains(requirement) ? ServiceNameFactory.parseServiceName(requirement.getName()).append(containerName, serverName) : null;
        }
    };
    for (CacheServiceConfiguratorProvider provider : ServiceLoader.load(DistributedCacheServiceConfiguratorProvider.class, DistributedCacheServiceConfiguratorProvider.class.getClassLoader())) {
        configurators.add(provider.getServiceConfigurators(registry, containerName, serverName));
    }
    return new CompositeIterable<>(configurators);
}
Also used : DistributedCacheServiceConfiguratorProvider(org.wildfly.clustering.spi.DistributedCacheServiceConfiguratorProvider) 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) LocalRouteServiceConfigurator(org.wildfly.clustering.web.cache.routing.LocalRouteServiceConfigurator) CompositeIterable(org.wildfly.clustering.ee.CompositeIterable) ClusteringCacheRequirement(org.wildfly.clustering.spi.ClusteringCacheRequirement) LinkedList(java.util.LinkedList) TemplateConfigurationServiceConfigurator(org.wildfly.clustering.infinispan.spi.service.TemplateConfigurationServiceConfigurator) CacheServiceConfigurator(org.wildfly.clustering.infinispan.spi.service.CacheServiceConfigurator) ServiceNameRegistry(org.wildfly.clustering.service.ServiceNameRegistry)

Example 5 with ClusteringCacheRequirement

use of org.wildfly.clustering.spi.ClusteringCacheRequirement in project wildfly by wildfly.

the class CacheContainerServiceHandler method removeServices.

@Override
public void removeServices(OperationContext context, ModelNode model) throws OperationFailedException {
    PathAddress address = context.getCurrentAddress();
    String name = context.getCurrentAddressValue();
    String defaultCache = DEFAULT_CACHE.resolveModelAttribute(context, model).asString(null);
    if (defaultCache != null) {
        ServiceNameRegistry<ClusteringCacheRequirement> registry = new CapabilityServiceNameRegistry<>(DEFAULT_CLUSTERING_CAPABILITIES, address);
        for (IdentityCacheServiceConfiguratorProvider provider : ServiceLoader.load(IdentityCacheServiceConfiguratorProvider.class, IdentityCacheServiceConfiguratorProvider.class.getClassLoader())) {
            for (ServiceNameProvider configurator : provider.getServiceConfigurators(registry, name, null, defaultCache)) {
                context.removeService(configurator.getServiceName());
            }
        }
        if (!defaultCache.equals(JndiNameFactory.DEFAULT_LOCAL_NAME)) {
            context.removeService(InfinispanBindingFactory.createCacheBinding(name, JndiNameFactory.DEFAULT_LOCAL_NAME).getBinderServiceName());
            context.removeService(InfinispanBindingFactory.createCacheConfigurationBinding(name, JndiNameFactory.DEFAULT_LOCAL_NAME).getBinderServiceName());
        }
        for (Capability capability : DEFAULT_CAPABILITIES.values()) {
            context.removeService(capability.getServiceName(address));
        }
    }
    context.removeService(InfinispanBindingFactory.createCacheContainerBinding(name).getBinderServiceName());
    context.removeService(CacheContainerComponent.MODULES.getServiceName(address));
    for (Capability capability : EnumSet.allOf(CacheContainerResourceDefinition.Capability.class)) {
        context.removeService(capability.getServiceName(address));
    }
    context.removeService(new ServiceValueCaptorServiceConfigurator<>(this.containerRegistry.remove(CacheContainerResourceDefinition.Capability.CONTAINER.getServiceName(address))).getServiceName());
}
Also used : CapabilityServiceNameRegistry(org.wildfly.clustering.spi.CapabilityServiceNameRegistry) IdentityCacheServiceConfiguratorProvider(org.wildfly.clustering.spi.IdentityCacheServiceConfiguratorProvider) Capability(org.jboss.as.clustering.controller.Capability) PathAddress(org.jboss.as.controller.PathAddress) ServiceValueCaptorServiceConfigurator(org.jboss.as.clustering.controller.ServiceValueCaptorServiceConfigurator) ServiceNameProvider(org.wildfly.clustering.service.ServiceNameProvider) ClusteringCacheRequirement(org.wildfly.clustering.spi.ClusteringCacheRequirement)

Aggregations

ClusteringCacheRequirement (org.wildfly.clustering.spi.ClusteringCacheRequirement)9 LinkedList (java.util.LinkedList)5 CapabilityServiceConfigurator (org.jboss.as.clustering.controller.CapabilityServiceConfigurator)5 CacheServiceConfiguratorProvider (org.wildfly.clustering.spi.CacheServiceConfiguratorProvider)5 PathAddress (org.jboss.as.controller.PathAddress)4 ServiceName (org.jboss.msc.service.ServiceName)4 InfinispanCacheRequirement (org.wildfly.clustering.infinispan.spi.InfinispanCacheRequirement)4 CapabilityServiceNameRegistry (org.wildfly.clustering.spi.CapabilityServiceNameRegistry)4 List (java.util.List)3 ServiceLoader (java.util.ServiceLoader)3 CompositeIterable (org.wildfly.clustering.ee.CompositeIterable)3 CacheServiceConfigurator (org.wildfly.clustering.infinispan.spi.service.CacheServiceConfigurator)3 TemplateConfigurationServiceConfigurator (org.wildfly.clustering.infinispan.spi.service.TemplateConfigurationServiceConfigurator)3 ServiceNameRegistry (org.wildfly.clustering.service.ServiceNameRegistry)3 DistributedCacheServiceConfiguratorProvider (org.wildfly.clustering.spi.DistributedCacheServiceConfiguratorProvider)3 Collection (java.util.Collection)2 CacheMode (org.infinispan.configuration.cache.CacheMode)2 Capability (org.jboss.as.clustering.controller.Capability)2 CapabilityServiceBuilder (org.jboss.as.clustering.controller.CapabilityServiceBuilder)2 ModulesServiceConfigurator (org.jboss.as.clustering.controller.ModulesServiceConfigurator)2