Search in sources :

Example 1 with CacheBuilderProvider

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

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

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

the class EJB3RemoteServiceAdd method installRuntimeServices.

void installRuntimeServices(final OperationContext context, final ModelNode model) throws OperationFailedException {
    final String clientMappingsClusterName = EJB3RemoteResourceDefinition.CLIENT_MAPPINGS_CLUSTER_NAME.resolveModelAttribute(context, model).asString();
    final String connectorName = EJB3RemoteResourceDefinition.CONNECTOR_REF.resolveModelAttribute(context, model).asString();
    final ServiceName remotingServerInfoServiceName = RemotingConnectorBindingInfoService.serviceName(connectorName);
    final String threadPoolName = EJB3RemoteResourceDefinition.THREAD_POOL_NAME.resolveModelAttribute(context, model).asString();
    final boolean executeInWorker = EJB3RemoteResourceDefinition.EXECUTE_IN_WORKER.resolveModelAttribute(context, model).asBoolean();
    final ServiceTarget target = context.getServiceTarget();
    // Install the client-mapping service for the remoting connector
    new EJBRemotingConnectorClientMappingsEntryProviderService(clientMappingsClusterName, remotingServerInfoServiceName).configure(context).build(target).setInitialMode(ServiceController.Mode.ON_DEMAND).install();
    new RegistryInstallerService(clientMappingsClusterName).configure(context).build(target).setInitialMode(ServiceController.Mode.ON_DEMAND).install();
    // Handle case where no infinispan subsystem exists or does not define an ejb cache-container
    Resource rootResource = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS);
    PathElement infinispanPath = PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, "infinispan");
    if (!rootResource.hasChild(infinispanPath) || !rootResource.getChild(infinispanPath).hasChild(PathElement.pathElement("cache-container", clientMappingsClusterName))) {
        // Install services that would normally be installed by this container/cache
        CapabilityServiceSupport support = context.getCapabilityServiceSupport();
        for (GroupBuilderProvider provider : ServiceLoader.load(LocalGroupBuilderProvider.class, LocalGroupBuilderProvider.class.getClassLoader())) {
            for (CapabilityServiceBuilder<?> builder : provider.getBuilders(requirement -> requirement.getServiceName(support, clientMappingsClusterName), clientMappingsClusterName)) {
                builder.configure(support).build(target).install();
            }
        }
        for (CacheBuilderProvider provider : ServiceLoader.load(LocalCacheBuilderProvider.class, LocalCacheBuilderProvider.class.getClassLoader())) {
            for (CapabilityServiceBuilder<?> builder : provider.getBuilders(requirement -> requirement.getServiceName(support, clientMappingsClusterName, null), clientMappingsClusterName, null)) {
                builder.configure(support).build(target).install();
            }
        }
    }
    final OptionMap channelCreationOptions = this.getChannelCreationOptions(context);
    // Install the EJB remoting connector service which will listen for client connections on the remoting channel
    // TODO: Externalize (expose via management API if needed) the version and the marshalling strategy
    final EJBRemoteConnectorService ejbRemoteConnectorService = new EJBRemoteConnectorService(channelCreationOptions);
    ServiceBuilder<EJBRemoteConnectorService> builder = target.addService(EJBRemoteConnectorService.SERVICE_NAME, ejbRemoteConnectorService);
    builder.addDependency(RemotingServices.SUBSYSTEM_ENDPOINT, Endpoint.class, ejbRemoteConnectorService.getEndpointInjector()).addDependency(remotingServerInfoServiceName, RemotingConnectorBindingInfoService.RemotingConnectorInfo.class, ejbRemoteConnectorService.getRemotingConnectorInfoInjectedValue()).addDependency(AssociationService.SERVICE_NAME, AssociationService.class, ejbRemoteConnectorService.getAssociationServiceInjector()).addDependency(TxnServices.JBOSS_TXN_REMOTE_TRANSACTION_SERVICE, RemotingTransactionService.class, ejbRemoteConnectorService.getRemotingTransactionServiceInjector()).addDependency(ControlledProcessStateService.SERVICE_NAME, ControlledProcessStateService.class, ejbRemoteConnectorService.getControlledProcessStateServiceInjector()).setInitialMode(ServiceController.Mode.ACTIVE);
    if (!executeInWorker) {
        builder.addDependency(EJB3SubsystemModel.BASE_THREAD_POOL_SERVICE_NAME.append(threadPoolName), ExecutorService.class, ejbRemoteConnectorService.getExecutorService());
    }
    builder.install();
}
Also used : LocalCacheBuilderProvider(org.wildfly.clustering.spi.LocalCacheBuilderProvider) CacheBuilderProvider(org.wildfly.clustering.spi.CacheBuilderProvider) ControlledProcessStateService(org.jboss.as.controller.ControlledProcessStateService) EJBRemotingConnectorClientMappingsEntryProviderService(org.jboss.as.ejb3.remote.EJBRemotingConnectorClientMappingsEntryProviderService) ServiceTarget(org.jboss.msc.service.ServiceTarget) RegistryInstallerService(org.jboss.as.ejb3.remote.RegistryInstallerService) RemotingConnectorBindingInfoService(org.jboss.as.remoting.RemotingConnectorBindingInfoService) Resource(org.jboss.as.controller.registry.Resource) AssociationService(org.jboss.as.ejb3.remote.AssociationService) CapabilityServiceSupport(org.jboss.as.controller.capability.CapabilityServiceSupport) PathElement(org.jboss.as.controller.PathElement) Endpoint(org.jboss.remoting3.Endpoint) ServiceName(org.jboss.msc.service.ServiceName) EJBRemoteConnectorService(org.jboss.as.ejb3.remote.EJBRemoteConnectorService) GroupBuilderProvider(org.wildfly.clustering.spi.GroupBuilderProvider) LocalGroupBuilderProvider(org.wildfly.clustering.spi.LocalGroupBuilderProvider) OptionMap(org.xnio.OptionMap) LocalCacheBuilderProvider(org.wildfly.clustering.spi.LocalCacheBuilderProvider) LocalGroupBuilderProvider(org.wildfly.clustering.spi.LocalGroupBuilderProvider)

Example 4 with CacheBuilderProvider

use of org.wildfly.clustering.spi.CacheBuilderProvider 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();
    for (CacheBuilderProvider provider : ServiceLoader.load(this.providerClass, this.providerClass.getClassLoader())) {
        for (ServiceNameProvider builder : provider.getBuilders(requirement -> CLUSTERING_CAPABILITIES.get(requirement).getServiceName(cacheAddress), containerName, cacheName)) {
            context.removeService(builder.getServiceName());
        }
    }
    context.removeService(InfinispanBindingFactory.createCacheBinding(containerName, cacheName).getBinderServiceName());
    context.removeService(InfinispanBindingFactory.createCacheConfigurationBinding(containerName, cacheName).getBinderServiceName());
    context.removeService(new XAResourceRecoveryBuilder(cacheAddress).getServiceName());
    context.removeService(CacheComponent.MODULE.getServiceName(cacheAddress));
    EnumSet.allOf(CacheResourceDefinition.Capability.class).stream().map(capability -> capability.getServiceName(cacheAddress)).forEach(serviceName -> context.removeService(serviceName));
}
Also used : 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) Capability(org.jboss.as.clustering.infinispan.subsystem.CacheResourceDefinition.Capability) PathAddress(org.jboss.as.controller.PathAddress) ServiceNameProvider(org.wildfly.clustering.service.ServiceNameProvider)

Example 5 with CacheBuilderProvider

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

ServiceName (org.jboss.msc.service.ServiceName)5 CacheBuilderProvider (org.wildfly.clustering.spi.CacheBuilderProvider)5 ServiceLoader (java.util.ServiceLoader)4 CapabilityServiceBuilder (org.jboss.as.clustering.controller.CapabilityServiceBuilder)4 CacheBuilder (org.wildfly.clustering.infinispan.spi.service.CacheBuilder)4 ServiceTarget (org.jboss.msc.service.ServiceTarget)3 Collection (java.util.Collection)2 EnumSet (java.util.EnumSet)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 Cache (org.infinispan.Cache)2 CacheMode (org.infinispan.configuration.cache.CacheMode)2 Configuration (org.infinispan.configuration.cache.Configuration)2 ModuleBuilder (org.jboss.as.clustering.controller.ModuleBuilder)2 ResourceServiceBuilderFactory (org.jboss.as.clustering.controller.ResourceServiceBuilderFactory)2 ResourceServiceHandler (org.jboss.as.clustering.controller.ResourceServiceHandler)2 ModelNodes (org.jboss.as.clustering.dmr.ModelNodes)2 Attribute (org.jboss.as.clustering.infinispan.subsystem.CacheResourceDefinition.Attribute)2 CLUSTERING_CAPABILITIES (org.jboss.as.clustering.infinispan.subsystem.CacheResourceDefinition.CLUSTERING_CAPABILITIES)2 Capability (org.jboss.as.clustering.infinispan.subsystem.CacheResourceDefinition.Capability)2