Search in sources :

Example 11 with ProtocolConfiguration

use of org.jgroups.conf.ProtocolConfiguration in project JGroups by belaban.

the class Configurator method createProtocolsAndInitializeAttrs.

public static List<Protocol> createProtocolsAndInitializeAttrs(List<ProtocolConfiguration> cfgs, ProtocolStack st) throws Exception {
    List<Protocol> protocols = createProtocols(cfgs, st);
    if (protocols == null)
        return null;
    // Determine how to resolve addresses that are set (e.g.) via symbolic names, by the type of bind_addr in the
    // transport. The logic below is described in https://issues.jboss.org/browse/JGRP-2343
    StackType ip_version = Util.getIpStackType();
    Protocol transport = protocols.get(0);
    if (transport instanceof TP) {
        ProtocolConfiguration cfg = cfgs.get(0);
        Field bind_addr_field = Util.getField(transport.getClass(), "bind_addr");
        resolveAndAssignField(transport, bind_addr_field, cfg.getProperties(), ip_version);
        InetAddress resolved_addr = (InetAddress) Util.getField(bind_addr_field, transport);
        if (resolved_addr != null)
            ip_version = resolved_addr instanceof Inet6Address ? StackType.IPv6 : StackType.IPv4;
        else if (ip_version == StackType.Dual)
            // prefer IPv4 addresses
            ip_version = StackType.IPv4;
    }
    for (int i = 0; i < cfgs.size(); i++) {
        ProtocolConfiguration config = cfgs.get(i);
        Protocol prot = protocols.get(i);
        initializeAttrs(prot, config, ip_version);
    }
    setDefaultAddressValues(protocols, ip_version);
    ensureValidBindAddresses(protocols);
    return protocols;
}
Also used : ProtocolConfiguration(org.jgroups.conf.ProtocolConfiguration) StackType(org.jgroups.util.StackType) Inet6Address(java.net.Inet6Address) TP(org.jgroups.protocols.TP) InetAddress(java.net.InetAddress)

Example 12 with ProtocolConfiguration

use of org.jgroups.conf.ProtocolConfiguration in project JGroups by belaban.

the class Configurator method createProtocols.

/**
 * Takes a list of configurations, creates a protocol for each and returns all protocols in a list.
 * @param protocol_configs A list of ProtocolConfigurations
 * @param stack            The protocol stack
 * @return List of Protocols
 */
public static List<Protocol> createProtocols(List<ProtocolConfiguration> protocol_configs, ProtocolStack stack) throws Exception {
    List<Protocol> retval = new LinkedList<>();
    for (int i = 0; i < protocol_configs.size(); i++) {
        ProtocolConfiguration protocol_config = protocol_configs.get(i);
        Protocol layer = createLayer(stack, protocol_config);
        if (layer == null)
            return null;
        retval.add(layer);
    }
    return retval;
}
Also used : ProtocolConfiguration(org.jgroups.conf.ProtocolConfiguration)

Aggregations

ProtocolConfiguration (org.jgroups.conf.ProtocolConfiguration)12 InetAddress (java.net.InetAddress)6 Protocol (org.jgroups.stack.Protocol)4 Property (org.jgroups.annotations.Property)3 Inet6Address (java.net.Inet6Address)2 ArrayList (java.util.ArrayList)2 TP (org.jgroups.protocols.TP)2 StackType (org.jgroups.util.StackType)2 Field (java.lang.reflect.Field)1 Method (java.lang.reflect.Method)1 java.util (java.util)1 Entry (java.util.Map.Entry)1 Pattern (java.util.regex.Pattern)1 org.jgroups (org.jgroups)1 DeprecatedProperty (org.jgroups.annotations.DeprecatedProperty)1 ClassConfigurator (org.jgroups.conf.ClassConfigurator)1 PropertyConverter (org.jgroups.conf.PropertyConverter)1 XmlNode (org.jgroups.conf.XmlNode)1 ReflectUtils (org.jgroups.jmx.ReflectUtils)1 MessageBatch (org.jgroups.util.MessageBatch)1