throw ExceptionUtil.rethrow(e);
}
}
private MulticastService createMulticastService(AddressPicker addressPicker) {
MulticastService mcService = null;
try {
JoinConfig join = config.getNetworkConfig().getJoin();
if (join.getMulticastConfig().isEnabled()) {
MulticastConfig multicastConfig = join.getMulticastConfig();
MulticastSocket multicastSocket = new MulticastSocket(null);
multicastSocket.setReuseAddress(true);
// bind to receive interface
multicastSocket.bind(new InetSocketAddress(multicastConfig.getMulticastPort()));
multicastSocket.setTimeToLive(multicastConfig.getMulticastTimeToLive());
try {
// set the send interface
final Address bindAddress = addressPicker.getBindAddress();
// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4417033
// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6402758
if (!bindAddress.getInetAddress().isLoopbackAddress()) {
multicastSocket.setInterface(bindAddress.getInetAddress());
}
} catch (Exception e) {
logger.warning(e);
}
multicastSocket.setReceiveBufferSize(64 * 1024);
multicastSocket.setSendBufferSize(64 * 1024);
String multicastGroup = System.getProperty("hazelcast.multicast.group");
if (multicastGroup == null) {
multicastGroup = multicastConfig.getMulticastGroup();
}
multicastConfig.setMulticastGroup(multicastGroup);
multicastSocket.joinGroup(InetAddress.getByName(multicastGroup));
multicastSocket.setSoTimeout(1000);
mcService = new MulticastService(this, multicastSocket);
mcService.addMulticastListener(new NodeMulticastListener(this));
}
} catch (Exception e) {
logger.severe(e);
}
return mcService;