Search in sources :

Example 1 with SupplierDependency

use of org.wildfly.clustering.service.SupplierDependency in project wildfly by wildfly.

the class RemoteCacheContainerConfigurationServiceConfigurator method configure.

@Override
public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException {
    this.connectionTimeout = Attribute.CONNECTION_TIMEOUT.resolveModelAttribute(context, model).asInt();
    this.defaultRemoteCluster = Attribute.DEFAULT_REMOTE_CLUSTER.resolveModelAttribute(context, model).asString();
    this.maxRetries = Attribute.MAX_RETRIES.resolveModelAttribute(context, model).asInt();
    this.protocolVersion = Attribute.PROTOCOL_VERSION.resolveModelAttribute(context, model).asString();
    this.socketTimeout = Attribute.SOCKET_TIMEOUT.resolveModelAttribute(context, model).asInt();
    this.tcpNoDelay = Attribute.TCP_NO_DELAY.resolveModelAttribute(context, model).asBoolean();
    this.tcpKeepAlive = Attribute.TCP_KEEP_ALIVE.resolveModelAttribute(context, model).asBoolean();
    this.statisticsEnabled = Attribute.STATISTICS_ENABLED.resolveModelAttribute(context, model).asBoolean();
    this.transactionTimeout = Attribute.TRANSACTION_TIMEOUT.resolveModelAttribute(context, model).asLong();
    this.marshallerFactory = HotRodMarshallerFactory.valueOf(Attribute.MARSHALLER.resolveModelAttribute(context, model).asString());
    this.clusters.clear();
    Resource container = context.readResource(PathAddress.EMPTY_ADDRESS);
    for (Resource.ResourceEntry entry : container.getChildren(RemoteClusterResourceDefinition.WILDCARD_PATH.getKey())) {
        String clusterName = entry.getName();
        ModelNode cluster = entry.getModel();
        List<String> bindings = StringListAttributeDefinition.unwrapValue(context, RemoteClusterResourceDefinition.Attribute.SOCKET_BINDINGS.resolveModelAttribute(context, cluster));
        List<SupplierDependency<OutboundSocketBinding>> bindingDependencies = new ArrayList<>(bindings.size());
        for (String binding : bindings) {
            bindingDependencies.add(new ServiceSupplierDependency<>(CommonUnaryRequirement.OUTBOUND_SOCKET_BINDING.getServiceName(context, binding)));
        }
        this.clusters.put(clusterName, bindingDependencies);
    }
    this.server = context.hasOptionalCapability(CommonRequirement.MBEAN_SERVER.getName(), null, null) ? new ServiceSupplierDependency<>(CommonRequirement.MBEAN_SERVER.getServiceName(context)) : null;
    this.properties.clear();
    for (Property property : Attribute.PROPERTIES.resolveModelAttribute(context, model).asPropertyListOrEmpty()) {
        this.properties.setProperty(property.getName(), property.getValue().asString());
    }
    return this;
}
Also used : Resource(org.jboss.as.controller.registry.Resource) ArrayList(java.util.ArrayList) ServiceSupplierDependency(org.wildfly.clustering.service.ServiceSupplierDependency) ModelNode(org.jboss.dmr.ModelNode) SupplierDependency(org.wildfly.clustering.service.SupplierDependency) ServiceSupplierDependency(org.wildfly.clustering.service.ServiceSupplierDependency) Property(org.jboss.dmr.Property)

Example 2 with SupplierDependency

use of org.wildfly.clustering.service.SupplierDependency in project wildfly by wildfly.

the class RemoteCacheContainerConfigurationServiceConfigurator method get.

@Override
public Configuration get() {
    String name = this.getServiceName().getSimpleName();
    ConfigurationBuilder builder = new ConfigurationBuilder();
    // Configure formal security first
    builder.security().read(this.security.get());
    // Apply properties next, which may override formal security configuration
    builder.withProperties(this.properties).connectionTimeout(this.connectionTimeout).maxRetries(this.maxRetries).version(ProtocolVersion.parseVersion(this.protocolVersion)).socketTimeout(this.socketTimeout).statistics().enabled(this.statisticsEnabled).jmxDomain("org.wildfly.clustering.infinispan").jmxEnabled(this.server != null).jmxName(name).mBeanServerLookup((this.server != null) ? new MBeanServerProvider(this.server.get()) : null).tcpNoDelay(this.tcpNoDelay).tcpKeepAlive(this.tcpKeepAlive).transactionTimeout(this.transactionTimeout, TimeUnit.MILLISECONDS);
    List<Module> modules = this.modules.get();
    Marshaller marshaller = this.marshallerFactory.apply(this.loader.get(), modules);
    builder.marshaller(marshaller);
    builder.classLoader(modules.size() > 1 ? new AggregatedClassLoader(modules.stream().map(Module::getClassLoader).collect(Collectors.toList())) : modules.get(0).getClassLoader());
    builder.connectionPool().read(this.connectionPool.get());
    builder.asyncExecutorFactory().read(this.threadPools.get(ThreadPoolResourceDefinition.CLIENT).get());
    for (Map.Entry<String, List<SupplierDependency<OutboundSocketBinding>>> cluster : this.clusters.entrySet()) {
        String clusterName = cluster.getKey();
        List<SupplierDependency<OutboundSocketBinding>> bindingDependencies = cluster.getValue();
        if (this.defaultRemoteCluster.equals(clusterName)) {
            for (Supplier<OutboundSocketBinding> bindingDependency : bindingDependencies) {
                OutboundSocketBinding binding = bindingDependency.get();
                builder.addServer().host(binding.getUnresolvedDestinationAddress()).port(binding.getDestinationPort());
            }
        } else {
            ClusterConfigurationBuilder clusterConfigurationBuilder = builder.addCluster(clusterName);
            for (Supplier<OutboundSocketBinding> bindingDependency : bindingDependencies) {
                OutboundSocketBinding binding = bindingDependency.get();
                clusterConfigurationBuilder.addClusterNode(binding.getUnresolvedDestinationAddress(), binding.getDestinationPort());
            }
        }
    }
    return builder.build();
}
Also used : ClusterConfigurationBuilder(org.infinispan.client.hotrod.configuration.ClusterConfigurationBuilder) ConfigurationBuilder(org.infinispan.client.hotrod.configuration.ConfigurationBuilder) Marshaller(org.infinispan.commons.marshall.Marshaller) OutboundSocketBinding(org.jboss.as.network.OutboundSocketBinding) SupplierDependency(org.wildfly.clustering.service.SupplierDependency) ServiceSupplierDependency(org.wildfly.clustering.service.ServiceSupplierDependency) MBeanServerProvider(org.jboss.as.clustering.infinispan.MBeanServerProvider) AggregatedClassLoader(org.infinispan.commons.util.AggregatedClassLoader) ClusterConfigurationBuilder(org.infinispan.client.hotrod.configuration.ClusterConfigurationBuilder) List(java.util.List) ArrayList(java.util.ArrayList) Module(org.jboss.modules.Module) Map(java.util.Map) EnumMap(java.util.EnumMap) HashMap(java.util.HashMap)

Example 3 with SupplierDependency

use of org.wildfly.clustering.service.SupplierDependency in project wildfly by wildfly.

the class CacheDependenciesProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext context) {
    DeploymentUnit unit = context.getDeploymentUnit();
    final ServiceName name = unit.getServiceName();
    EEModuleDescription moduleDescription = unit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
    if (moduleDescription == null) {
        return;
    }
    final CapabilityServiceSupport support = unit.getAttachment(org.jboss.as.server.deployment.Attachments.CAPABILITY_SERVICE_SUPPORT);
    final ServiceTarget target = context.getServiceTarget();
    Set<SupplierDependency<CacheFactoryBuilder<SessionID, StatefulSessionComponentInstance>>> dependencies = new HashSet<>();
    for (ComponentDescription description : moduleDescription.getComponentDescriptions()) {
        if (description instanceof StatefulComponentDescription) {
            StatefulComponentDescription statefulDescription = (StatefulComponentDescription) description;
            dependencies.add(new ServiceSupplierDependency<>(getCacheFactoryBuilderServiceName(statefulDescription)));
        }
    }
    Service service = new ChildTargetService(new Consumer<ServiceTarget>() {

        @Override
        public void accept(ServiceTarget target) {
            // Cache factory builder dependencies might still contain duplicates (if referenced via alias), so ensure we collect only distinct instances.
            Set<CacheFactoryBuilder<SessionID, StatefulSessionComponentInstance>> builders = new HashSet<>(dependencies.size());
            for (Supplier<CacheFactoryBuilder<SessionID, StatefulSessionComponentInstance>> dependency : dependencies) {
                builders.add(dependency.get());
            }
            for (CacheFactoryBuilder<SessionID, StatefulSessionComponentInstance> builder : builders) {
                for (CapabilityServiceConfigurator configurator : builder.getDeploymentServiceConfigurators(unit)) {
                    configurator.configure(support).build(target).install();
                }
            }
        }
    });
    ServiceBuilder<?> builder = target.addService(name.append("cache-dependencies-installer"));
    for (Dependency dependency : dependencies) {
        dependency.register(builder);
    }
    builder.setInstance(service).install();
    // Install versioned marshalling configuration
    new MarshallingConfigurationRepositoryServiceConfigurator(unit).build(target).setInitialMode(ServiceController.Mode.ON_DEMAND).install();
}
Also used : StatefulComponentDescription(org.jboss.as.ejb3.component.stateful.StatefulComponentDescription) ComponentDescription(org.jboss.as.ee.component.ComponentDescription) HashSet(java.util.HashSet) Set(java.util.Set) StatefulSessionComponentInstance(org.jboss.as.ejb3.component.stateful.StatefulSessionComponentInstance) CapabilityServiceSupport(org.jboss.as.controller.capability.CapabilityServiceSupport) CacheFactoryBuilder(org.jboss.as.ejb3.cache.CacheFactoryBuilder) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) StatefulComponentDescription(org.jboss.as.ejb3.component.stateful.StatefulComponentDescription) Supplier(java.util.function.Supplier) HashSet(java.util.HashSet) CapabilityServiceConfigurator(org.jboss.as.clustering.controller.CapabilityServiceConfigurator) ChildTargetService(org.wildfly.clustering.service.ChildTargetService) ServiceTarget(org.jboss.msc.service.ServiceTarget) MarshallingConfigurationRepositoryServiceConfigurator(org.jboss.as.ejb3.component.stateful.MarshallingConfigurationRepositoryServiceConfigurator) Service(org.jboss.msc.Service) ChildTargetService(org.wildfly.clustering.service.ChildTargetService) SupplierDependency(org.wildfly.clustering.service.SupplierDependency) ServiceSupplierDependency(org.wildfly.clustering.service.ServiceSupplierDependency) Dependency(org.wildfly.clustering.service.Dependency) SupplierDependency(org.wildfly.clustering.service.SupplierDependency) ServiceSupplierDependency(org.wildfly.clustering.service.ServiceSupplierDependency) ServiceName(org.jboss.msc.service.ServiceName) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) SessionID(org.jboss.ejb.client.SessionID)

Example 4 with SupplierDependency

use of org.wildfly.clustering.service.SupplierDependency in project wildfly by wildfly.

the class DistributableSingleSignOnManagerServiceConfigurator method configure.

@Override
public ServiceConfigurator configure(OperationContext context) {
    String securityDomainName = this.configuration.getSecurityDomainName();
    Supplier<String> generator = this.configuration.getIdentifierGenerator();
    CapabilityServiceSupport support = context.getCapabilityServiceSupport();
    SupplierDependency<DistributableSSOManagementProvider> provider = getProvider(context, securityDomainName);
    ServiceName managerServiceName = this.getServiceName().append("manager");
    this.manager = new ServiceSupplierDependency<>(managerServiceName);
    this.provider = provider;
    this.installer = new Consumer<ServiceTarget>() {

        @Override
        public void accept(ServiceTarget target) {
            ServiceConfigurator factoryConfigurator = provider.get().getServiceConfigurator(securityDomainName).configure(support);
            factoryConfigurator.build(target).install();
            SupplierDependency<SSOManagerFactory<ElytronAuthentication, String, Map.Entry<String, URI>, Batch>> factoryDependency = new ServiceSupplierDependency<>(factoryConfigurator);
            SupplierDependency<SessionIdGenerator> generatorDependency = new SimpleSupplierDependency<>(new SessionIdGeneratorAdapter(generator));
            new SSOManagerServiceConfigurator<>(managerServiceName, factoryDependency, generatorDependency, new LocalSSOContextFactory()).configure(support).build(target).install();
        }
    };
    return this;
}
Also used : ServiceTarget(org.jboss.msc.service.ServiceTarget) SupplierDependency(org.wildfly.clustering.service.SupplierDependency) SimpleSupplierDependency(org.wildfly.clustering.service.SimpleSupplierDependency) ServiceSupplierDependency(org.wildfly.clustering.service.ServiceSupplierDependency) SSOManagerServiceConfigurator(org.wildfly.clustering.web.undertow.sso.SSOManagerServiceConfigurator) DistributableSSOManagementProvider(org.wildfly.clustering.web.sso.DistributableSSOManagementProvider) CapabilityServiceSupport(org.jboss.as.controller.capability.CapabilityServiceSupport) Entry(java.util.Map.Entry) ServiceName(org.jboss.msc.service.ServiceName) Batch(org.wildfly.clustering.ee.Batch) ServiceConfigurator(org.wildfly.clustering.service.ServiceConfigurator) SSOManagerServiceConfigurator(org.wildfly.clustering.web.undertow.sso.SSOManagerServiceConfigurator) CapabilityServiceConfigurator(org.jboss.as.clustering.controller.CapabilityServiceConfigurator)

Example 5 with SupplierDependency

use of org.wildfly.clustering.service.SupplierDependency in project wildfly by wildfly.

the class ElectionPolicyServiceConfigurator method configure.

@Override
public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException {
    List<ModelNode> socketBindingPreferences = SOCKET_BINDING_PREFERENCES.resolveModelAttribute(context, model).asListOrEmpty();
    List<ModelNode> namePreferences = NAME_PREFERENCES.resolveModelAttribute(context, model).asListOrEmpty();
    List<Preference> preferences = new ArrayList<>(socketBindingPreferences.size() + namePreferences.size());
    List<Dependency> dependencies = new ArrayList<>(socketBindingPreferences.size());
    for (ModelNode preference : socketBindingPreferences) {
        SupplierDependency<OutboundSocketBinding> binding = new ServiceSupplierDependency<>(CommonUnaryRequirement.OUTBOUND_SOCKET_BINDING.getServiceName(context, preference.asString()));
        preferences.add(new OutboundSocketBindingPreference(binding));
        dependencies.add(binding);
    }
    for (ModelNode preference : namePreferences) {
        preferences.add(new NamePreference(preference.asString()));
    }
    this.dependencies = dependencies;
    this.preferences = preferences;
    return this;
}
Also used : OutboundSocketBindingPreference(org.wildfly.extension.clustering.singleton.election.OutboundSocketBindingPreference) NamePreference(org.wildfly.clustering.singleton.election.NamePreference) OutboundSocketBinding(org.jboss.as.network.OutboundSocketBinding) OutboundSocketBindingPreference(org.wildfly.extension.clustering.singleton.election.OutboundSocketBindingPreference) Preference(org.wildfly.clustering.singleton.election.Preference) NamePreference(org.wildfly.clustering.singleton.election.NamePreference) ArrayList(java.util.ArrayList) SupplierDependency(org.wildfly.clustering.service.SupplierDependency) ServiceSupplierDependency(org.wildfly.clustering.service.ServiceSupplierDependency) Dependency(org.wildfly.clustering.service.Dependency) ServiceSupplierDependency(org.wildfly.clustering.service.ServiceSupplierDependency) ModelNode(org.jboss.dmr.ModelNode)

Aggregations

ServiceSupplierDependency (org.wildfly.clustering.service.ServiceSupplierDependency)6 SupplierDependency (org.wildfly.clustering.service.SupplierDependency)6 ArrayList (java.util.ArrayList)3 Dependency (org.wildfly.clustering.service.Dependency)3 CapabilityServiceConfigurator (org.jboss.as.clustering.controller.CapabilityServiceConfigurator)2 CapabilityServiceSupport (org.jboss.as.controller.capability.CapabilityServiceSupport)2 OutboundSocketBinding (org.jboss.as.network.OutboundSocketBinding)2 ModelNode (org.jboss.dmr.ModelNode)2 Service (org.jboss.msc.Service)2 ServiceName (org.jboss.msc.service.ServiceName)2 ServiceTarget (org.jboss.msc.service.ServiceTarget)2 EnumMap (java.util.EnumMap)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Set (java.util.Set)1 Supplier (java.util.function.Supplier)1 ClusterConfigurationBuilder (org.infinispan.client.hotrod.configuration.ClusterConfigurationBuilder)1