Search in sources :

Example 1 with ServiceValueCaptorServiceConfigurator

use of org.jboss.as.clustering.controller.ServiceValueCaptorServiceConfigurator in project wildfly by wildfly.

the class RemoteCacheContainerServiceHandler method installServices.

@Override
public void installServices(OperationContext context, ModelNode model) throws OperationFailedException {
    super.installServices(context, model);
    PathAddress address = context.getCurrentAddress();
    String name = context.getCurrentAddressValue();
    ServiceTarget target = context.getServiceTarget();
    Module defaultModule = Module.forClass(RemoteCacheContainer.class);
    new ModulesServiceConfigurator(RemoteCacheContainerComponent.MODULES.getServiceName(address), MODULES, Collections.singletonList(defaultModule)).configure(context, model).build(target).setInitialMode(ServiceController.Mode.PASSIVE).install();
    ServiceConfigurator containerBuilder = new RemoteCacheContainerServiceConfigurator(address).configure(context, model);
    containerBuilder.build(target).install();
    new ServiceValueCaptorServiceConfigurator<>(this.registry.add(containerBuilder.getServiceName())).build(target).install();
    new BinderServiceConfigurator(InfinispanBindingFactory.createRemoteCacheContainerBinding(name), containerBuilder.getServiceName()).build(target).install();
}
Also used : ModulesServiceConfigurator(org.jboss.as.clustering.controller.ModulesServiceConfigurator) BinderServiceConfigurator(org.jboss.as.clustering.naming.BinderServiceConfigurator) PathAddress(org.jboss.as.controller.PathAddress) ServiceTarget(org.jboss.msc.service.ServiceTarget) ServiceValueCaptorServiceConfigurator(org.jboss.as.clustering.controller.ServiceValueCaptorServiceConfigurator) Module(org.jboss.modules.Module) BinderServiceConfigurator(org.jboss.as.clustering.naming.BinderServiceConfigurator) ServiceValueCaptorServiceConfigurator(org.jboss.as.clustering.controller.ServiceValueCaptorServiceConfigurator) ModulesServiceConfigurator(org.jboss.as.clustering.controller.ModulesServiceConfigurator) ServiceConfigurator(org.wildfly.clustering.service.ServiceConfigurator)

Example 2 with ServiceValueCaptorServiceConfigurator

use of org.jboss.as.clustering.controller.ServiceValueCaptorServiceConfigurator in project wildfly by wildfly.

the class RemoteCacheContainerServiceHandler method removeServices.

@Override
public void removeServices(OperationContext context, ModelNode model) throws OperationFailedException {
    PathAddress address = context.getCurrentAddress();
    String name = context.getCurrentAddressValue();
    context.removeService(InfinispanBindingFactory.createRemoteCacheContainerBinding(name).getBinderServiceName());
    context.removeService(new ServiceValueCaptorServiceConfigurator<>(this.registry.remove(new RemoteCacheContainerServiceConfigurator(address).getServiceName())).getServiceName());
    for (RemoteCacheContainerResourceDefinition.Capability component : EnumSet.allOf(RemoteCacheContainerResourceDefinition.Capability.class)) {
        ServiceName serviceName = component.getServiceName(address);
        context.removeService(serviceName);
    }
    context.removeService(RemoteCacheContainerComponent.MODULES.getServiceName(address));
    super.removeServices(context, model);
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) PathAddress(org.jboss.as.controller.PathAddress) ServiceValueCaptorServiceConfigurator(org.jboss.as.clustering.controller.ServiceValueCaptorServiceConfigurator)

Example 3 with ServiceValueCaptorServiceConfigurator

use of org.jboss.as.clustering.controller.ServiceValueCaptorServiceConfigurator 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 ServiceValueCaptorServiceConfigurator

use of org.jboss.as.clustering.controller.ServiceValueCaptorServiceConfigurator in project wildfly by wildfly.

the class ModClusterSubsystemServiceHandler method installServices.

@Override
public void installServices(OperationContext context, ModelNode model) throws OperationFailedException {
    if (!context.isBooting())
        return;
    Resource subsystemResource = context.readResource(PathAddress.EMPTY_ADDRESS);
    if (subsystemResource.hasChildren(ProxyConfigurationResourceDefinition.WILDCARD_PATH.getKey())) {
        Set<String> adapterNames = new HashSet<>();
        Set<LoadMetric> enabledMetrics = new HashSet<>();
        for (Resource.ResourceEntry proxyResource : subsystemResource.getChildren(ProxyConfigurationResourceDefinition.WILDCARD_PATH.getKey())) {
            String proxyName = proxyResource.getName();
            PathAddress proxyAddress = context.getCurrentAddress().append(ProxyConfigurationResourceDefinition.pathElement(proxyName));
            adapterNames.add(proxyName);
            ModelNode proxyModel = Resource.Tools.readModel(proxyResource);
            ServiceTarget target = context.getServiceTarget();
            ProxyConfigurationServiceConfigurator configurationBuilder = new ProxyConfigurationServiceConfigurator(proxyAddress);
            configurationBuilder.configure(context, proxyModel).build(target).install();
            // Construct LoadBalanceFactorProvider and call pluggable boot time metric
            Set<LoadMetric> metrics = new HashSet<>();
            LoadBalanceFactorProvider loadProvider = this.getLoadProvider(proxyName, metrics, context, proxyModel);
            enabledMetrics.addAll(metrics);
            String listenerName = LISTENER.resolveModelAttribute(context, proxyModel).asString();
            int statusInterval = STATUS_INTERVAL.resolveModelAttribute(context, proxyModel).asInt();
            ServiceConfigurator configurator = new ContainerEventHandlerServiceConfigurator(proxyAddress, loadProvider);
            configurator.build(target).install();
            new ServiceValueCaptorServiceConfigurator<>(this.registry.add(configurator.getServiceName())).build(target).install();
            // Install services for web container integration
            for (ContainerEventHandlerAdapterServiceConfiguratorProvider provider : ServiceLoader.load(ContainerEventHandlerAdapterServiceConfiguratorProvider.class, ContainerEventHandlerAdapterServiceConfiguratorProvider.class.getClassLoader())) {
                provider.getServiceConfigurator(proxyName, listenerName, Duration.ofSeconds(statusInterval)).configure(context).build(target).setInitialMode(Mode.PASSIVE).install();
            }
        }
        for (BoottimeHandlerProvider handler : ServiceLoader.load(BoottimeHandlerProvider.class, BoottimeHandlerProvider.class.getClassLoader())) {
            handler.performBoottime(context, adapterNames, enabledMetrics);
        }
    }
}
Also used : ServiceTarget(org.jboss.msc.service.ServiceTarget) Resource(org.jboss.as.controller.registry.Resource) ServiceValueCaptorServiceConfigurator(org.jboss.as.clustering.controller.ServiceValueCaptorServiceConfigurator) LoadBalanceFactorProvider(org.jboss.modcluster.load.LoadBalanceFactorProvider) SimpleLoadBalanceFactorProvider(org.jboss.modcluster.load.impl.SimpleLoadBalanceFactorProvider) DynamicLoadBalanceFactorProvider(org.jboss.modcluster.load.impl.DynamicLoadBalanceFactorProvider) LoadMetric(org.jboss.modcluster.load.metric.LoadMetric) PathAddress(org.jboss.as.controller.PathAddress) ModelNode(org.jboss.dmr.ModelNode) HashSet(java.util.HashSet) ServiceConfigurator(org.wildfly.clustering.service.ServiceConfigurator) ServiceValueCaptorServiceConfigurator(org.jboss.as.clustering.controller.ServiceValueCaptorServiceConfigurator)

Example 5 with ServiceValueCaptorServiceConfigurator

use of org.jboss.as.clustering.controller.ServiceValueCaptorServiceConfigurator 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

ServiceValueCaptorServiceConfigurator (org.jboss.as.clustering.controller.ServiceValueCaptorServiceConfigurator)7 PathAddress (org.jboss.as.controller.PathAddress)7 ServiceTarget (org.jboss.msc.service.ServiceTarget)4 CapabilityServiceNameRegistry (org.wildfly.clustering.spi.CapabilityServiceNameRegistry)4 BinderServiceConfigurator (org.jboss.as.clustering.naming.BinderServiceConfigurator)3 Capability (org.jboss.as.clustering.controller.Capability)2 CapabilityServiceConfigurator (org.jboss.as.clustering.controller.CapabilityServiceConfigurator)2 ModulesServiceConfigurator (org.jboss.as.clustering.controller.ModulesServiceConfigurator)2 ModelNode (org.jboss.dmr.ModelNode)2 IdentityServiceConfigurator (org.wildfly.clustering.service.IdentityServiceConfigurator)2 ServiceConfigurator (org.wildfly.clustering.service.ServiceConfigurator)2 ServiceNameProvider (org.wildfly.clustering.service.ServiceNameProvider)2 ClusteringCacheRequirement (org.wildfly.clustering.spi.ClusteringCacheRequirement)2 ClusteringRequirement (org.wildfly.clustering.spi.ClusteringRequirement)2 DistributedGroupServiceConfiguratorProvider (org.wildfly.clustering.spi.DistributedGroupServiceConfiguratorProvider)2 GroupServiceConfiguratorProvider (org.wildfly.clustering.spi.GroupServiceConfiguratorProvider)2 IdentityCacheServiceConfiguratorProvider (org.wildfly.clustering.spi.IdentityCacheServiceConfiguratorProvider)2 HashSet (java.util.HashSet)1 Map (java.util.Map)1 ModuleServiceConfigurator (org.jboss.as.clustering.controller.ModuleServiceConfigurator)1