Search in sources :

Example 1 with CacheServiceConfiguratorProvider

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

use of org.wildfly.clustering.spi.CacheServiceConfiguratorProvider 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.MODULES.getServiceName(cacheAddress);
    if (model.hasDefined(MODULES.getName())) {
        new ModulesServiceConfigurator(moduleServiceName, MODULES, Collections.emptyList()).configure(context, model).build(target).setInitialMode(ServiceController.Mode.ON_DEMAND).install();
    } else {
        new IdentityServiceConfigurator<>(moduleServiceName, CacheContainerComponent.MODULES.getServiceName(containerAddress)).build(target).install();
    }
    this.configuratorFactory.createServiceConfigurator(cacheAddress).configure(context, model).build(target).install();
    new CacheServiceConfigurator<>(CACHE.getServiceName(cacheAddress), containerName, cacheName).configure(context).build(target).install();
    if (context.hasOptionalCapability(XA_RESOURCE_RECOVERY_REGISTRY.getName(), null, null)) {
        new XAResourceRecoveryServiceConfigurator(cacheAddress).configure(context).build(target).install();
    }
    new BinderServiceConfigurator(InfinispanBindingFactory.createCacheConfigurationBinding(containerName, cacheName), CONFIGURATION.getServiceName(cacheAddress)).build(target).install();
    new BinderServiceConfigurator(InfinispanBindingFactory.createCacheBinding(containerName, cacheName), CACHE.getServiceName(cacheAddress)).build(target).install();
    ServiceNameRegistry<ClusteringCacheRequirement> registry = new CapabilityServiceNameRegistry<>(CLUSTERING_CAPABILITIES, cacheAddress);
    for (CacheServiceConfiguratorProvider provider : ServiceLoader.load(this.providerClass, this.providerClass.getClassLoader())) {
        for (CapabilityServiceConfigurator configurator : provider.getServiceConfigurators(registry, containerName, cacheName)) {
            configurator.configure(context).build(target).install();
        }
    }
}
Also used : ModulesServiceConfigurator(org.jboss.as.clustering.controller.ModulesServiceConfigurator) CapabilityServiceNameRegistry(org.wildfly.clustering.spi.CapabilityServiceNameRegistry) CacheServiceConfiguratorProvider(org.wildfly.clustering.spi.CacheServiceConfiguratorProvider) BinderServiceConfigurator(org.jboss.as.clustering.naming.BinderServiceConfigurator) CapabilityServiceConfigurator(org.jboss.as.clustering.controller.CapabilityServiceConfigurator) ServiceTarget(org.jboss.msc.service.ServiceTarget) ClusteringCacheRequirement(org.wildfly.clustering.spi.ClusteringCacheRequirement) ServiceName(org.jboss.msc.service.ServiceName) PathAddress(org.jboss.as.controller.PathAddress) IdentityServiceConfigurator(org.wildfly.clustering.service.IdentityServiceConfigurator)

Example 3 with CacheServiceConfiguratorProvider

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

the class CacheServiceHandler method removeServices.

@Override
public void removeServices(OperationContext context, ModelNode model) {
    PathAddress cacheAddress = context.getCurrentAddress();
    PathAddress containerAddress = cacheAddress.getParent();
    String containerName = containerAddress.getLastElement().getValue();
    String cacheName = cacheAddress.getLastElement().getValue();
    ServiceNameRegistry<ClusteringCacheRequirement> registry = new CapabilityServiceNameRegistry<>(CLUSTERING_CAPABILITIES, cacheAddress);
    for (CacheServiceConfiguratorProvider provider : ServiceLoader.load(this.providerClass, this.providerClass.getClassLoader())) {
        for (ServiceNameProvider configurator : provider.getServiceConfigurators(registry, containerName, cacheName)) {
            context.removeService(configurator.getServiceName());
        }
    }
    context.removeService(InfinispanBindingFactory.createCacheBinding(containerName, cacheName).getBinderServiceName());
    context.removeService(InfinispanBindingFactory.createCacheConfigurationBinding(containerName, cacheName).getBinderServiceName());
    context.removeService(new XAResourceRecoveryServiceConfigurator(cacheAddress).getServiceName());
    context.removeService(CacheComponent.MODULES.getServiceName(cacheAddress));
    for (Capability capability : EnumSet.allOf(Capability.class)) {
        context.removeService(capability.getServiceName(cacheAddress));
    }
}
Also used : CapabilityServiceNameRegistry(org.wildfly.clustering.spi.CapabilityServiceNameRegistry) CacheServiceConfiguratorProvider(org.wildfly.clustering.spi.CacheServiceConfiguratorProvider) Capability(org.jboss.as.clustering.infinispan.subsystem.CacheResourceDefinition.Capability) PathAddress(org.jboss.as.controller.PathAddress) ServiceNameProvider(org.wildfly.clustering.service.ServiceNameProvider) ClusteringCacheRequirement(org.wildfly.clustering.spi.ClusteringCacheRequirement)

Example 4 with CacheServiceConfiguratorProvider

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

the class InfinispanSessionManagerFactoryServiceConfigurator method configure.

@Override
public ServiceConfigurator configure(CapabilityServiceSupport support) {
    String containerName = this.configuration.getContainerName();
    String cacheName = this.configuration.getCacheName();
    String deploymentName = this.factoryConfiguration.getDeploymentName();
    this.configurationConfigurator = new TemplateConfigurationServiceConfigurator(InfinispanCacheRequirement.CONFIGURATION.getServiceName(support, containerName, deploymentName), containerName, deploymentName, cacheName, this).configure(support);
    this.cacheConfigurator = new CacheServiceConfigurator<>(InfinispanCacheRequirement.CACHE.getServiceName(support, containerName, deploymentName), containerName, deploymentName).configure(support);
    for (CacheServiceConfiguratorProvider provider : ServiceLoader.load(DistributedCacheServiceConfiguratorProvider.class, DistributedCacheServiceConfiguratorProvider.class.getClassLoader())) {
        for (CapabilityServiceConfigurator configurator : provider.getServiceConfigurators(this, this.configuration.getContainerName(), this.factoryConfiguration.getDeploymentName())) {
            this.configurators.add(configurator.configure(support));
        }
    }
    this.affinityFactory = new ServiceSupplierDependency<>(InfinispanRequirement.KEY_AFFINITY_FACTORY.getServiceName(support, containerName));
    this.dispatcherFactory = new ServiceSupplierDependency<>(ClusteringRequirement.COMMAND_DISPATCHER_FACTORY.getServiceName(support, containerName));
    this.group = new ServiceSupplierDependency<>(ClusteringCacheRequirement.GROUP.getServiceName(support, containerName, deploymentName));
    return this;
}
Also used : DistributedCacheServiceConfiguratorProvider(org.wildfly.clustering.spi.DistributedCacheServiceConfiguratorProvider) DistributedCacheServiceConfiguratorProvider(org.wildfly.clustering.spi.DistributedCacheServiceConfiguratorProvider) CacheServiceConfiguratorProvider(org.wildfly.clustering.spi.CacheServiceConfiguratorProvider) TemplateConfigurationServiceConfigurator(org.wildfly.clustering.infinispan.spi.service.TemplateConfigurationServiceConfigurator) CapabilityServiceConfigurator(org.jboss.as.clustering.controller.CapabilityServiceConfigurator) CacheServiceConfigurator(org.wildfly.clustering.infinispan.spi.service.CacheServiceConfigurator)

Example 5 with CacheServiceConfiguratorProvider

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

CacheServiceConfiguratorProvider (org.wildfly.clustering.spi.CacheServiceConfiguratorProvider)6 CapabilityServiceConfigurator (org.jboss.as.clustering.controller.CapabilityServiceConfigurator)5 ClusteringCacheRequirement (org.wildfly.clustering.spi.ClusteringCacheRequirement)5 CacheServiceConfigurator (org.wildfly.clustering.infinispan.spi.service.CacheServiceConfigurator)4 TemplateConfigurationServiceConfigurator (org.wildfly.clustering.infinispan.spi.service.TemplateConfigurationServiceConfigurator)4 DistributedCacheServiceConfiguratorProvider (org.wildfly.clustering.spi.DistributedCacheServiceConfiguratorProvider)4 LinkedList (java.util.LinkedList)3 CompositeIterable (org.wildfly.clustering.ee.CompositeIterable)3 ServiceNameRegistry (org.wildfly.clustering.service.ServiceNameRegistry)3 PathAddress (org.jboss.as.controller.PathAddress)2 ServiceName (org.jboss.msc.service.ServiceName)2 CapabilityServiceNameRegistry (org.wildfly.clustering.spi.CapabilityServiceNameRegistry)2 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 List (java.util.List)1 ServiceLoader (java.util.ServiceLoader)1 Consumer (java.util.function.Consumer)1 ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)1 ExpirationConfiguration (org.infinispan.configuration.cache.ExpirationConfiguration)1 StorageType (org.infinispan.configuration.cache.StorageType)1