Search in sources :

Example 11 with NetworkConfig

use of com.hazelcast.config.NetworkConfig in project hazelcast by hazelcast.

the class TcpIpJoinTest method test_whenHostUnresolvable.

@Test
public void test_whenHostUnresolvable() {
    Config config = new Config();
    NetworkConfig networkConfig = config.getNetworkConfig();
    JoinConfig join = networkConfig.getJoin();
    join.getMulticastConfig().setEnabled(false);
    TcpIpConfig tcpIpConfig = join.getTcpIpConfig();
    tcpIpConfig.setEnabled(true);
    tcpIpConfig.addMember("localhost");
    tcpIpConfig.addMember("nonexistinghost");
    HazelcastInstance hz = Hazelcast.newHazelcastInstance(config);
    assertClusterSize(1, hz);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) NetworkConfig(com.hazelcast.config.NetworkConfig) TcpIpConfig(com.hazelcast.config.TcpIpConfig) JoinConfig(com.hazelcast.config.JoinConfig) InterfacesConfig(com.hazelcast.config.InterfacesConfig) PartitionGroupConfig(com.hazelcast.config.PartitionGroupConfig) NetworkConfig(com.hazelcast.config.NetworkConfig) JoinConfig(com.hazelcast.config.JoinConfig) TcpIpConfig(com.hazelcast.config.TcpIpConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 12 with NetworkConfig

use of com.hazelcast.config.NetworkConfig in project hazelcast by hazelcast.

the class TcpIpJoinTest method test_whenHostAndInterfacesConfigured.

@Test
public void test_whenHostAndInterfacesConfigured() throws Exception {
    System.clearProperty("hazelcast.local.localAddress");
    final Config config = new Config();
    config.setProperty("hazelcast.socket.bind.any", "false");
    final NetworkConfig networkConfig = config.getNetworkConfig();
    networkConfig.setPort(5701).setPortAutoIncrement(true).getInterfaces().addInterface("127.0.0.1").setEnabled(true);
    final JoinConfig joinConfig = networkConfig.getJoin();
    joinConfig.getMulticastConfig().setEnabled(false);
    joinConfig.getAwsConfig().setEnabled(false);
    joinConfig.getTcpIpConfig().addMember("localhost:5701").addMember("localhost:5702").setEnabled(true);
    testJoin(config);
}
Also used : Config(com.hazelcast.config.Config) NetworkConfig(com.hazelcast.config.NetworkConfig) TcpIpConfig(com.hazelcast.config.TcpIpConfig) JoinConfig(com.hazelcast.config.JoinConfig) InterfacesConfig(com.hazelcast.config.InterfacesConfig) PartitionGroupConfig(com.hazelcast.config.PartitionGroupConfig) NetworkConfig(com.hazelcast.config.NetworkConfig) JoinConfig(com.hazelcast.config.JoinConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 13 with NetworkConfig

use of com.hazelcast.config.NetworkConfig in project hazelcast by hazelcast.

the class TcpIpJoinTest method test_whenExplicitPortConfigured.

@Test
public void test_whenExplicitPortConfigured() throws Exception {
    Config config = new Config();
    NetworkConfig networkConfig = config.getNetworkConfig();
    JoinConfig join = networkConfig.getJoin();
    join.getMulticastConfig().setEnabled(false);
    TcpIpConfig tcpIpConfig = join.getTcpIpConfig();
    tcpIpConfig.setEnabled(true);
    tcpIpConfig.addMember("127.0.0.1:5701");
    tcpIpConfig.addMember("127.0.0.1:5702");
    testJoin(config);
}
Also used : Config(com.hazelcast.config.Config) NetworkConfig(com.hazelcast.config.NetworkConfig) TcpIpConfig(com.hazelcast.config.TcpIpConfig) JoinConfig(com.hazelcast.config.JoinConfig) InterfacesConfig(com.hazelcast.config.InterfacesConfig) PartitionGroupConfig(com.hazelcast.config.PartitionGroupConfig) NetworkConfig(com.hazelcast.config.NetworkConfig) JoinConfig(com.hazelcast.config.JoinConfig) TcpIpConfig(com.hazelcast.config.TcpIpConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 14 with NetworkConfig

use of com.hazelcast.config.NetworkConfig in project hazelcast by hazelcast.

the class PartitionServiceBeanDTOTest method createInstanceWithPublicAddress.

private HazelcastInstance createInstanceWithPublicAddress(String publicAddress) {
    try {
        Config config = getConfig();
        NetworkConfig networkConfig = config.getNetworkConfig();
        networkConfig.setPublicAddress(publicAddress);
        return Hazelcast.newHazelcastInstance(config);
    } catch (RuntimeException e) {
        if (e.getCause() instanceof UnknownHostException) {
            // internet access and/or DNS resolver are not available
            return null;
        }
        throw e;
    }
}
Also used : UnknownHostException(java.net.UnknownHostException) Config(com.hazelcast.config.Config) NetworkConfig(com.hazelcast.config.NetworkConfig) JoinConfig(com.hazelcast.config.JoinConfig) NetworkConfig(com.hazelcast.config.NetworkConfig)

Example 15 with NetworkConfig

use of com.hazelcast.config.NetworkConfig in project hazelcast by hazelcast.

the class NodeIOServiceTest method setUp.

@Before
public void setUp() {
    Node mockNode = mock(Node.class);
    NodeEngineImpl mockNodeEngine = mock(NodeEngineImpl.class);
    ioService = new NodeIOService(mockNode, mockNodeEngine);
    Config config = new Config();
    networkConfig = config.getNetworkConfig();
    when(mockNode.getConfig()).thenReturn(config);
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) Config(com.hazelcast.config.Config) NetworkConfig(com.hazelcast.config.NetworkConfig) Node(com.hazelcast.instance.Node) Before(org.junit.Before)

Aggregations

NetworkConfig (com.hazelcast.config.NetworkConfig)34 Config (com.hazelcast.config.Config)25 JoinConfig (com.hazelcast.config.JoinConfig)23 Test (org.junit.Test)13 TcpIpConfig (com.hazelcast.config.TcpIpConfig)11 InterfacesConfig (com.hazelcast.config.InterfacesConfig)10 QuickTest (com.hazelcast.test.annotation.QuickTest)10 PartitionGroupConfig (com.hazelcast.config.PartitionGroupConfig)9 ListenerConfig (com.hazelcast.config.ListenerConfig)8 HazelcastInstance (com.hazelcast.core.HazelcastInstance)8 HazelcastInstanceFactory.newHazelcastInstance (com.hazelcast.instance.HazelcastInstanceFactory.newHazelcastInstance)6 MulticastConfig (com.hazelcast.config.MulticastConfig)4 MembershipEvent (com.hazelcast.core.MembershipEvent)4 Node (com.hazelcast.instance.Node)4 UnknownHostException (java.net.UnknownHostException)4 CountDownLatch (java.util.concurrent.CountDownLatch)4 MembershipAdapter (com.hazelcast.core.MembershipAdapter)3 FirewallingTcpIpConnectionManager (com.hazelcast.nio.tcp.FirewallingTcpIpConnectionManager)3 NightlyTest (com.hazelcast.test.annotation.NightlyTest)3 DiscoveryConfig (com.hazelcast.config.DiscoveryConfig)2