use of org.xnio.channels.MulticastMessageChannel in project undertow by undertow-io.
the class MCMPAdvertiseTask method advertise.
static void advertise(final ModClusterContainer container, final MCMPConfig.AdvertiseConfig config, final XnioWorker worker) throws IOException {
InetSocketAddress bindAddress;
final InetAddress group = InetAddress.getByName(config.getAdvertiseAddress());
if (group == null) {
bindAddress = new InetSocketAddress(config.getAdvertisePort());
} else {
bindAddress = new InetSocketAddress(group, config.getAdvertisePort());
}
MulticastMessageChannel channel;
try {
channel = worker.createUdpServer(bindAddress, null, OptionMap.EMPTY);
} catch (IOException e) {
if (group != null && (linuxLike || windows)) {
//try again with no group
//see UNDERTOW-454
UndertowLogger.ROOT_LOGGER.potentialCrossTalking(group, (group instanceof Inet4Address) ? "IPv4" : "IPv6", e.getLocalizedMessage());
bindAddress = new InetSocketAddress(config.getAdvertisePort());
channel = worker.createUdpServer(bindAddress, null, OptionMap.EMPTY);
} else {
throw e;
}
}
final MCMPAdvertiseTask task = new MCMPAdvertiseTask(container, config, channel);
//execute immediately, so there is no delay before load balancing starts working
channel.getIoThread().execute(task);
channel.getIoThread().executeAtInterval(task, config.getAdvertiseFrequency(), TimeUnit.MILLISECONDS);
}
Aggregations