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;
}
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;
}
Aggregations