Search in sources :

Example 46 with HazelcastProperties

use of com.hazelcast.spi.properties.HazelcastProperties in project hazelcast by hazelcast.

the class MulticastServiceTest method testSetInterfaceDefaultWhenLoopback.

@Test
public void testSetInterfaceDefaultWhenLoopback() throws Exception {
    Config config = createConfig(null);
    MulticastConfig multicastConfig = config.getNetworkConfig().getJoin().getMulticastConfig();
    multicastConfig.setLoopbackModeEnabled(true);
    MulticastSocket multicastSocket = mock(MulticastSocket.class);
    Address address = new Address("127.0.0.1", 5701);
    HazelcastProperties hzProperties = new HazelcastProperties(config);
    MulticastService.configureMulticastSocket(multicastSocket, address, hzProperties, multicastConfig, mock(ILogger.class));
    verify(multicastSocket).setLoopbackMode(false);
    // https://github.com/hazelcast/hazelcast/pull/19251#issuecomment-891375270
    if (OsHelper.isMac()) {
        verify(multicastSocket).setInterface(address.getInetAddress());
    } else {
        verify(multicastSocket, never()).setInterface(any());
    }
}
Also used : MulticastSocket(java.net.MulticastSocket) HazelcastProperties(com.hazelcast.spi.properties.HazelcastProperties) Address(com.hazelcast.cluster.Address) InetSocketAddress(java.net.InetSocketAddress) InetAddress(java.net.InetAddress) Config(com.hazelcast.config.Config) MulticastConfig(com.hazelcast.config.MulticastConfig) JoinConfig(com.hazelcast.config.JoinConfig) MulticastConfig(com.hazelcast.config.MulticastConfig) ILogger(com.hazelcast.logging.ILogger) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 47 with HazelcastProperties

use of com.hazelcast.spi.properties.HazelcastProperties in project hazelcast by hazelcast.

the class MulticastServiceTest method testSetInterfaceDefaultWhenNonLoopbackAddrAndLoopbackMode.

@Test
public void testSetInterfaceDefaultWhenNonLoopbackAddrAndLoopbackMode() throws Exception {
    Config config = createConfig(null);
    MulticastConfig multicastConfig = config.getNetworkConfig().getJoin().getMulticastConfig();
    multicastConfig.setLoopbackModeEnabled(true);
    MulticastSocket multicastSocket = mock(MulticastSocket.class);
    Address address = new Address("10.0.0.2", 5701);
    HazelcastProperties hzProperties = new HazelcastProperties(config);
    MulticastService.configureMulticastSocket(multicastSocket, address, hzProperties, multicastConfig, mock(ILogger.class));
    verify(multicastSocket).setInterface(address.getInetAddress());
    verify(multicastSocket).setLoopbackMode(false);
}
Also used : MulticastSocket(java.net.MulticastSocket) HazelcastProperties(com.hazelcast.spi.properties.HazelcastProperties) Address(com.hazelcast.cluster.Address) InetSocketAddress(java.net.InetSocketAddress) InetAddress(java.net.InetAddress) Config(com.hazelcast.config.Config) MulticastConfig(com.hazelcast.config.MulticastConfig) JoinConfig(com.hazelcast.config.JoinConfig) MulticastConfig(com.hazelcast.config.MulticastConfig) ILogger(com.hazelcast.logging.ILogger) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 48 with HazelcastProperties

use of com.hazelcast.spi.properties.HazelcastProperties in project hazelcast by hazelcast.

the class MulticastServiceTest method testMulticastGroupProperty.

@Test
public void testMulticastGroupProperty() throws Exception {
    Config config = createConfig(null);
    String customMulticastGroup = "225.225.225.225";
    config.setProperty(ClusterProperty.MULTICAST_GROUP.getName(), customMulticastGroup);
    MulticastConfig multicastConfig = config.getNetworkConfig().getJoin().getMulticastConfig();
    MulticastSocket multicastSocket = mock(MulticastSocket.class);
    Address address = new Address("10.0.0.2", 5701);
    HazelcastProperties hzProperties = new HazelcastProperties(config);
    MulticastService.configureMulticastSocket(multicastSocket, address, hzProperties, multicastConfig, mock(ILogger.class));
    verify(multicastSocket).bind(new InetSocketAddress(multicastConfig.getMulticastPort()));
    verify(multicastSocket).setTimeToLive(multicastConfig.getMulticastTimeToLive());
    verify(multicastSocket, never()).setLoopbackMode(anyBoolean());
    verify(multicastSocket).joinGroup(InetAddress.getByName(customMulticastGroup));
}
Also used : MulticastSocket(java.net.MulticastSocket) HazelcastProperties(com.hazelcast.spi.properties.HazelcastProperties) Address(com.hazelcast.cluster.Address) InetSocketAddress(java.net.InetSocketAddress) InetAddress(java.net.InetAddress) Config(com.hazelcast.config.Config) MulticastConfig(com.hazelcast.config.MulticastConfig) JoinConfig(com.hazelcast.config.JoinConfig) InetSocketAddress(java.net.InetSocketAddress) MulticastConfig(com.hazelcast.config.MulticastConfig) ILogger(com.hazelcast.logging.ILogger) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 49 with HazelcastProperties

use of com.hazelcast.spi.properties.HazelcastProperties in project hazelcast by hazelcast.

the class MulticastServiceTest method testSetInterfaceDefaultWhenNonLoopbackAddrAndNoLoopbackMode.

@Test
public void testSetInterfaceDefaultWhenNonLoopbackAddrAndNoLoopbackMode() throws Exception {
    Config config = createConfig(null);
    MulticastConfig multicastConfig = config.getNetworkConfig().getJoin().getMulticastConfig();
    multicastConfig.setLoopbackModeEnabled(false);
    MulticastSocket multicastSocket = mock(MulticastSocket.class);
    Address address = new Address("10.0.0.2", 5701);
    HazelcastProperties hzProperties = new HazelcastProperties(config);
    MulticastService.configureMulticastSocket(multicastSocket, address, hzProperties, multicastConfig, mock(ILogger.class));
    verify(multicastSocket).setInterface(address.getInetAddress());
    verify(multicastSocket).setLoopbackMode(true);
}
Also used : MulticastSocket(java.net.MulticastSocket) HazelcastProperties(com.hazelcast.spi.properties.HazelcastProperties) Address(com.hazelcast.cluster.Address) InetSocketAddress(java.net.InetSocketAddress) InetAddress(java.net.InetAddress) Config(com.hazelcast.config.Config) MulticastConfig(com.hazelcast.config.MulticastConfig) JoinConfig(com.hazelcast.config.JoinConfig) MulticastConfig(com.hazelcast.config.MulticastConfig) ILogger(com.hazelcast.logging.ILogger) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 50 with HazelcastProperties

use of com.hazelcast.spi.properties.HazelcastProperties in project hazelcast by hazelcast.

the class MulticastServiceTest method testSetInterfaceDisabled.

@Test
public void testSetInterfaceDisabled() throws Exception {
    Config config = createConfig(Boolean.FALSE);
    MulticastConfig multicastConfig = config.getNetworkConfig().getJoin().getMulticastConfig();
    MulticastSocket multicastSocket = mock(MulticastSocket.class);
    Address address = new Address("127.0.0.1", 5701);
    HazelcastProperties hzProperties = new HazelcastProperties(config);
    MulticastService.configureMulticastSocket(multicastSocket, address, hzProperties, multicastConfig, mock(ILogger.class));
    verify(multicastSocket, never()).setInterface(any());
}
Also used : MulticastSocket(java.net.MulticastSocket) HazelcastProperties(com.hazelcast.spi.properties.HazelcastProperties) Address(com.hazelcast.cluster.Address) InetSocketAddress(java.net.InetSocketAddress) InetAddress(java.net.InetAddress) Config(com.hazelcast.config.Config) MulticastConfig(com.hazelcast.config.MulticastConfig) JoinConfig(com.hazelcast.config.JoinConfig) MulticastConfig(com.hazelcast.config.MulticastConfig) ILogger(com.hazelcast.logging.ILogger) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

HazelcastProperties (com.hazelcast.spi.properties.HazelcastProperties)71 Config (com.hazelcast.config.Config)31 QuickTest (com.hazelcast.test.annotation.QuickTest)29 Test (org.junit.Test)29 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)25 ILogger (com.hazelcast.logging.ILogger)15 Address (com.hazelcast.cluster.Address)11 JoinConfig (com.hazelcast.config.JoinConfig)8 MulticastConfig (com.hazelcast.config.MulticastConfig)8 InetAddress (java.net.InetAddress)8 InetSocketAddress (java.net.InetSocketAddress)8 MulticastSocket (java.net.MulticastSocket)8 Before (org.junit.Before)8 ExecutionService (com.hazelcast.spi.impl.executionservice.ExecutionService)7 Properties (java.util.Properties)7 Node (com.hazelcast.instance.impl.Node)4 LoggingService (com.hazelcast.logging.LoggingService)4 MapConfig (com.hazelcast.config.MapConfig)3 TcpServerConnectionChannelErrorHandler (com.hazelcast.internal.server.tcp.TcpServerConnectionChannelErrorHandler)3 ClientConfig (com.hazelcast.client.config.ClientConfig)2