Search in sources :

Example 11 with SocketBinding

use of org.jboss.as.network.SocketBinding in project wildfly by wildfly.

the class ModClusterConfigurationServiceBuilder method getValue.

@Override
public ModClusterConfiguration getValue() throws IllegalStateException, IllegalArgumentException {
    // Advertise
    if (advertiseSocketDependency != null) {
        final SocketBinding binding = advertiseSocketDependency.getValue();
        builder.advertise().setAdvertiseSocketAddress(binding.getMulticastSocketAddress()).setAdvertiseInterface(binding.getSocketAddress().getAddress());
        if (!isMulticastEnabled(binding.getSocketBindings().getDefaultInterfaceBinding().getNetworkInterfaces())) {
            ROOT_LOGGER.multicastInterfaceNotAvailable();
        }
    }
    // Proxies
    List<ProxyConfiguration> proxies = new LinkedList<>();
    for (final ValueDependency<OutboundSocketBinding> outboundSocketBindingValueDependency : outboundSocketBindings) {
        OutboundSocketBinding binding = outboundSocketBindingValueDependency.getValue();
        proxies.add(new ProxyConfiguration() {

            @Override
            public InetSocketAddress getRemoteAddress() {
                // Don't do resolving here, let mod_cluster deal with it
                return new InetSocketAddress(binding.getUnresolvedDestinationAddress(), binding.getDestinationPort());
            }

            @Override
            public InetSocketAddress getLocalAddress() {
                if (binding.getOptionalSourceAddress() != null) {
                    return new InetSocketAddress(binding.getOptionalSourceAddress(), binding.getAbsoluteSourcePort() == null ? 0 : binding.getAbsoluteSourcePort());
                } else if (binding.getAbsoluteSourcePort() != null) {
                    // Bind to port only if source address is not configured
                    return new InetSocketAddress(binding.getAbsoluteSourcePort());
                }
                // No binding configured so don't bind
                return null;
            }
        });
    }
    builder.mcmp().setProxyConfigurations(proxies);
    // SSL
    if (sslContextDependency != null) {
        builder.mcmp().setSocketFactory(sslContextDependency.getValue().getSocketFactory());
    }
    return builder.build();
}
Also used : OutboundSocketBinding(org.jboss.as.network.OutboundSocketBinding) SocketBinding(org.jboss.as.network.SocketBinding) ProxyConfiguration(org.jboss.modcluster.config.ProxyConfiguration) OutboundSocketBinding(org.jboss.as.network.OutboundSocketBinding) InetSocketAddress(java.net.InetSocketAddress) LinkedList(java.util.LinkedList)

Example 12 with SocketBinding

use of org.jboss.as.network.SocketBinding in project wildfly by wildfly.

the class TransportConfigurationBuilder method accept.

@Override
public void accept(T protocol) {
    InetSocketAddress socketAddress = this.getSocketBinding().getSocketAddress();
    protocol.setBindAddress(socketAddress.getAddress());
    protocol.setBindPort(socketAddress.getPort());
    protocol.setThreadFactory(new ClassLoaderThreadFactory(new DefaultThreadFactory("", false), JChannelFactory.class.getClassLoader()));
    protocol.setDefaultThreadPool(this.threadPoolFactories.get(ThreadPoolResourceDefinition.DEFAULT).getValue().get());
    protocol.setInternalThreadPool(this.threadPoolFactories.get(ThreadPoolResourceDefinition.INTERNAL).getValue().get());
    protocol.setOOBThreadPool(this.threadPoolFactories.get(ThreadPoolResourceDefinition.OOB).getValue().get());
    protocol.setTimer(this.timerFactory.getValue().get());
    Optional<InetSocketAddress> diagnosticsSocketAddress = Optional.ofNullable(this.diagnosticsSocketBinding).map(Value::getValue).map(SocketBinding::getSocketAddress);
    protocol.setValue("enable_diagnostics", diagnosticsSocketAddress.isPresent());
    diagnosticsSocketAddress.ifPresent(address -> {
        protocol.setValue("diagnostics_addr", address.getAddress());
        protocol.setValue("diagnostics_port", address.getPort());
    });
}
Also used : DefaultThreadFactory(org.jgroups.util.DefaultThreadFactory) SocketBinding(org.jboss.as.network.SocketBinding) InetSocketAddress(java.net.InetSocketAddress) ClassLoaderThreadFactory(org.jboss.as.clustering.jgroups.ClassLoaderThreadFactory)

Example 13 with SocketBinding

use of org.jboss.as.network.SocketBinding in project wildfly by wildfly.

the class CoreEnvironmentService method start.

@Override
public void start(StartContext context) throws StartException {
    // Global configuration.
    final CoreEnvironmentBean coreEnvironmentBean = arjPropertyManager.getCoreEnvironmentBean();
    if (coreEnvironmentBean.getProcessImplementationClassName() == null) {
        UuidProcessId id = new UuidProcessId();
        coreEnvironmentBean.setProcessImplementation(id);
    }
    try {
        coreEnvironmentBean.setNodeIdentifier(nodeIdentifier);
    } catch (CoreEnvironmentBeanException e) {
        throw new StartException(e.getCause());
    }
    // Setup the socket process id if there is a binding
    SocketBinding binding = socketProcessBindingInjector.getOptionalValue();
    if (binding != null) {
        int port = binding.getPort();
        coreEnvironmentBean.setSocketProcessIdPort(port);
    }
}
Also used : SocketBinding(org.jboss.as.network.SocketBinding) CoreEnvironmentBeanException(com.arjuna.ats.arjuna.common.CoreEnvironmentBeanException) CoreEnvironmentBean(com.arjuna.ats.arjuna.common.CoreEnvironmentBean) StartException(org.jboss.msc.service.StartException) UuidProcessId(com.arjuna.ats.internal.arjuna.utils.UuidProcessId)

Aggregations

SocketBinding (org.jboss.as.network.SocketBinding)13 InetSocketAddress (java.net.InetSocketAddress)3 StartException (org.jboss.msc.service.StartException)3 InetAddress (java.net.InetAddress)2 ArrayList (java.util.ArrayList)2 NetworkInterfaceBinding (org.jboss.as.network.NetworkInterfaceBinding)2 OutboundSocketBinding (org.jboss.as.network.OutboundSocketBinding)2 SocketBindingManager (org.jboss.as.network.SocketBindingManager)2 Test (org.junit.Test)2 CoreEnvironmentBean (com.arjuna.ats.arjuna.common.CoreEnvironmentBean)1 CoreEnvironmentBeanException (com.arjuna.ats.arjuna.common.CoreEnvironmentBeanException)1 RecoveryEnvironmentBean (com.arjuna.ats.arjuna.common.RecoveryEnvironmentBean)1 AtomicActionRecoveryModule (com.arjuna.ats.internal.arjuna.recovery.AtomicActionRecoveryModule)1 ExpiredTransactionStatusManagerScanner (com.arjuna.ats.internal.arjuna.recovery.ExpiredTransactionStatusManagerScanner)1 UuidProcessId (com.arjuna.ats.internal.arjuna.utils.UuidProcessId)1 CommitMarkableResourceRecordRecoveryModule (com.arjuna.ats.internal.jta.recovery.arjunacore.CommitMarkableResourceRecordRecoveryModule)1 JCAServerTransactionRecoveryModule (com.arjuna.ats.internal.jta.recovery.jts.JCAServerTransactionRecoveryModule)1 ExpiredContactScanner (com.arjuna.ats.internal.jts.recovery.contact.ExpiredContactScanner)1 ExpiredServerScanner (com.arjuna.ats.internal.jts.recovery.transactions.ExpiredServerScanner)1 ExpiredToplevelScanner (com.arjuna.ats.internal.jts.recovery.transactions.ExpiredToplevelScanner)1