/** * Create a UDP server. The UDP server can be configured to be multicast-capable; this should only be * done if multicast is needed, since some providers have a performance penalty associated with multicast. * The provider's default executor will be used to execute listener methods. * * @param bindAddress the bind address * @param optionMap the initial configuration for the server * @return the UDP server channel * @throws java.io.IOException if the server could not be created * * @since 3.0 */ public MulticastMessageChannel createUdpServer(InetSocketAddress bindAddress, OptionMap optionMap) throws IOException { return createUdpServer(bindAddress, ChannelListeners.nullChannelListener(), optionMap); }
static void advertise(final ModClusterContainer container, final MCMPConfig.AdvertiseConfig config, final XnioWorker worker) throws IOException { InetSocketAddress bindAddress; final InetAddress address = InetAddress.getByName(config.getAdvertiseAddress()); if (address == null) { bindAddress = new InetSocketAddress(config.getAdvertisePort()); } else { bindAddress = new InetSocketAddress(address, config.getAdvertisePort()); } MulticastMessageChannel channel; try { channel = worker.createUdpServer(bindAddress, OptionMap.EMPTY); } catch (IOException e) { if (address != null && (linuxLike || windows)) { //try again with no address //see UNDERTOW-454 UndertowLogger.ROOT_LOGGER.potentialCrossTalking(address, (address instanceof Inet4Address) ? "IPv4" : "IPv6", e.getLocalizedMessage()); bindAddress = new InetSocketAddress(config.getAdvertisePort()); channel = worker.createUdpServer(bindAddress, OptionMap.EMPTY); } else { throw e; } } // multicast ttl can only be set after the channel has been created channel.setOption(Options.MULTICAST_TTL, config.getAdvertiseTtl()); 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); }
/** * Create a UDP server. The UDP server can be configured to be multicast-capable; this should only be * done if multicast is needed, since some providers have a performance penalty associated with multicast. * The provider's default executor will be used to execute listener methods. * * @param bindAddress the bind address * @param optionMap the initial configuration for the server * @return the UDP server channel * @throws java.io.IOException if the server could not be created * * @since 3.0 */ public MulticastMessageChannel createUdpServer(InetSocketAddress bindAddress, OptionMap optionMap) throws IOException { return createUdpServer(bindAddress, ChannelListeners.nullChannelListener(), optionMap); }
static void advertise(final ModClusterContainer container, final MCMPConfig.AdvertiseConfig config, final XnioWorker worker) throws IOException { InetSocketAddress bindAddress; final InetAddress address = InetAddress.getByName(config.getAdvertiseAddress()); if (address == null) { bindAddress = new InetSocketAddress(config.getAdvertisePort()); } else { bindAddress = new InetSocketAddress(address, config.getAdvertisePort()); } MulticastMessageChannel channel; try { channel = worker.createUdpServer(bindAddress, OptionMap.EMPTY); } catch (IOException e) { if (address != null && (linuxLike || windows)) { //try again with no address //see UNDERTOW-454 UndertowLogger.ROOT_LOGGER.potentialCrossTalking(address, (address instanceof Inet4Address) ? "IPv4" : "IPv6", e.getLocalizedMessage()); bindAddress = new InetSocketAddress(config.getAdvertisePort()); channel = worker.createUdpServer(bindAddress, OptionMap.EMPTY); } else { throw e; } } // multicast ttl can only be set after the channel has been created channel.setOption(Options.MULTICAST_TTL, config.getAdvertiseTtl()); 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); }
static void advertise(final ModClusterContainer container, final MCMPConfig.AdvertiseConfig config, final XnioWorker worker) throws IOException { InetSocketAddress bindAddress; final InetAddress address = InetAddress.getByName(config.getAdvertiseAddress()); if (address == null) { bindAddress = new InetSocketAddress(config.getAdvertisePort()); } else { bindAddress = new InetSocketAddress(address, config.getAdvertisePort()); } MulticastMessageChannel channel; try { channel = worker.createUdpServer(bindAddress, OptionMap.EMPTY); } catch (IOException e) { if (address != null && (linuxLike || windows)) { //try again with no address //see UNDERTOW-454 UndertowLogger.ROOT_LOGGER.potentialCrossTalking(address, (address instanceof Inet4Address) ? "IPv4" : "IPv6", e.getLocalizedMessage()); bindAddress = new InetSocketAddress(config.getAdvertisePort()); channel = worker.createUdpServer(bindAddress, OptionMap.EMPTY); } else { throw e; } } // multicast ttl can only be set after the channel has been created channel.setOption(Options.MULTICAST_TTL, config.getAdvertiseTtl()); 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); }