Search in sources :

Example 1 with MulticastDiscoveryReceiver

use of com.hazelcast.spi.discovery.multicast.impl.MulticastDiscoveryReceiver in project hazelcast by hazelcast.

the class MulticastDiscoveryStrategy method initializeMulticastSocket.

private void initializeMulticastSocket() {
    try {
        int port = getOrDefault(MulticastProperties.PORT, DEFAULT_MULTICAST_PORT);
        PortValueValidator validator = new PortValueValidator();
        validator.validate(port);
        String group = getOrDefault(MulticastProperties.GROUP, DEFAULT_MULTICAST_GROUP);
        multicastSocket = new MulticastSocket(null);
        multicastSocket.bind(new InetSocketAddress(port));
        multicastSocket.setReuseAddress(true);
        multicastSocket.setTimeToLive(SOCKET_TIME_TO_LIVE);
        multicastSocket.setReceiveBufferSize(DATA_OUTPUT_BUFFER_SIZE);
        multicastSocket.setSendBufferSize(DATA_OUTPUT_BUFFER_SIZE);
        multicastSocket.setSoTimeout(SOCKET_TIMEOUT);
        multicastSocket.joinGroup(InetAddress.getByName(group));
        multicastDiscoverySender = new MulticastDiscoverySender(discoveryNode, multicastSocket, logger, group, port);
        multicastDiscoveryReceiver = new MulticastDiscoveryReceiver(multicastSocket, logger);
        if (discoveryNode != null) {
            isClient = false;
        }
    } catch (Exception e) {
        logger.finest(e.getMessage());
        rethrow(e);
    }
}
Also used : MulticastSocket(java.net.MulticastSocket) MulticastDiscoverySender(com.hazelcast.spi.discovery.multicast.impl.MulticastDiscoverySender) MulticastDiscoveryReceiver(com.hazelcast.spi.discovery.multicast.impl.MulticastDiscoveryReceiver) InetSocketAddress(java.net.InetSocketAddress) ValidationException(com.hazelcast.config.properties.ValidationException) UnknownHostException(java.net.UnknownHostException)

Aggregations

ValidationException (com.hazelcast.config.properties.ValidationException)1 MulticastDiscoveryReceiver (com.hazelcast.spi.discovery.multicast.impl.MulticastDiscoveryReceiver)1 MulticastDiscoverySender (com.hazelcast.spi.discovery.multicast.impl.MulticastDiscoverySender)1 InetSocketAddress (java.net.InetSocketAddress)1 MulticastSocket (java.net.MulticastSocket)1 UnknownHostException (java.net.UnknownHostException)1