null, "mcast_addr", false, null);
makeUnique(channel, num, str);
}
protected void makeUnique(Channel channel, int num, String mcast_address) throws Exception {
ProtocolStack stack = channel.getProtocolStack();
Protocol transport = stack.getTransport();
if (transport instanceof UDP) {
short mcast_port = ResourceManager.getNextMulticastPort(InetAddress.getByName(bind_addr));
((UDP) transport).setMulticastPort(mcast_port);
if (mcast_address != null) {
((UDP) transport).setMulticastAddress(InetAddress.getByName(mcast_address));
} else {
String mcast_addr = ResourceManager.getNextMulticastAddress();
((UDP) transport).setMulticastAddress(InetAddress.getByName(mcast_addr));
}
} else if (transport instanceof BasicTCP) {
List<Short> ports = ResourceManager.getNextTcpPorts(InetAddress.getByName(bind_addr), num);
((TP) transport).setBindPort(ports.get(0));
((TP) transport).setPortRange(num);
Protocol ping = stack.findProtocol(TCPPING.class);
if (ping == null)
throw new IllegalStateException("TCP stack must consist of TCP:TCPPING - other config are not supported");
List<String> initial_hosts = new LinkedList<String>();
for (short port : ports) {