Ejemplo n.º 1
0
  static List<org.jgroups.conf.ProtocolConfiguration> createProtocols(
      ProtocolStackConfiguration stack, boolean multicastCapable) {

    List<ProtocolConfiguration> protocols = stack.getProtocols();
    List<org.jgroups.conf.ProtocolConfiguration> result = new ArrayList<>(protocols.size());
    TransportConfiguration transport = stack.getTransport();

    for (ProtocolConfiguration protocol : protocols) {
      org.jgroups.conf.ProtocolConfiguration config = createProtocol(stack, protocol);
      Introspector introspector = new Introspector(config);
      SocketBinding binding = protocol.getSocketBinding();
      if (binding != null) {
        configureBindAddress(introspector, config, binding);
        configureServerSocket(introspector, config, "bind_port", binding);
        configureServerSocket(introspector, config, "start_port", binding);
        configureMulticastSocket(introspector, config, "mcast_addr", "mcast_port", binding);
      } else if (transport.getSocketBinding() != null) {
        // If no socket-binding was specified, use bind address of transport
        configureBindAddress(introspector, config, transport.getSocketBinding());
      }
      if (!multicastCapable) {
        setProperty(introspector, config, "use_mcast_xmit", String.valueOf(false));
        setProperty(introspector, config, "use_mcast_xmit_req", String.valueOf(false));
      }
      result.add(config);
    }

    return result;
  }
Ejemplo n.º 2
0
 private static org.jgroups.conf.ProtocolConfiguration createProtocol(
     ProtocolStackConfiguration stack, ProtocolConfiguration protocol) {
   String protocolName = protocol.getName();
   ModuleIdentifier module = protocol.getModule();
   final Map<String, String> properties = new HashMap<>(stack.getDefaultProperties(protocolName));
   properties.putAll(protocol.getProperties());
   try {
     return new org.jgroups.conf.ProtocolConfiguration(
         protocol.getProtocolClassName(),
         properties,
         stack.getModuleLoader().loadModule(module).getClassLoader()) {
       @Override
       public Map<String, String> getOriginalProperties() {
         return properties;
       }
     };
   } catch (ModuleLoadException e) {
     throw new IllegalArgumentException(e);
   }
 }