Search in sources :

Example 1 with ClusterConfigurationBuilder

use of org.infinispan.client.hotrod.configuration.ClusterConfigurationBuilder 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)

Aggregations

ArrayList (java.util.ArrayList)1 EnumMap (java.util.EnumMap)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 ClusterConfigurationBuilder (org.infinispan.client.hotrod.configuration.ClusterConfigurationBuilder)1 ConfigurationBuilder (org.infinispan.client.hotrod.configuration.ConfigurationBuilder)1 Marshaller (org.infinispan.commons.marshall.Marshaller)1 AggregatedClassLoader (org.infinispan.commons.util.AggregatedClassLoader)1 MBeanServerProvider (org.jboss.as.clustering.infinispan.MBeanServerProvider)1 OutboundSocketBinding (org.jboss.as.network.OutboundSocketBinding)1 Module (org.jboss.modules.Module)1 ServiceSupplierDependency (org.wildfly.clustering.service.ServiceSupplierDependency)1 SupplierDependency (org.wildfly.clustering.service.SupplierDependency)1