Search in sources :

Example 11 with JoinConfig

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

the class BadConfigurationMemberStartTest method testMulticastAndTcpEnabled.

@Test(expected = InvalidConfigurationException.class)
public void testMulticastAndTcpEnabled() throws Exception {
    Config config = new Config();
    NetworkConfig networkConfig = config.getNetworkConfig();
    JoinConfig joinConfig = networkConfig.getJoin();
    joinConfig.getMulticastConfig().setEnabled(true);
    joinConfig.getTcpIpConfig().setEnabled(true);
    Hazelcast.newHazelcastInstance(config);
}
Also used : Config(com.hazelcast.config.Config) NetworkConfig(com.hazelcast.config.NetworkConfig) JoinConfig(com.hazelcast.config.JoinConfig) NetworkConfig(com.hazelcast.config.NetworkConfig) JoinConfig(com.hazelcast.config.JoinConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 12 with JoinConfig

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

the class SplitBrainHandlerTest method testMergeAfterSplitBrain.

private void testMergeAfterSplitBrain(boolean multicast) throws InterruptedException {
    String groupName = generateRandomString(10);
    Config config = new Config();
    config.setProperty(GroupProperty.MERGE_FIRST_RUN_DELAY_SECONDS.getName(), "5");
    config.setProperty(GroupProperty.MERGE_NEXT_RUN_DELAY_SECONDS.getName(), "3");
    config.getGroupConfig().setName(groupName);
    NetworkConfig networkConfig = config.getNetworkConfig();
    JoinConfig join = networkConfig.getJoin();
    join.getMulticastConfig().setEnabled(multicast);
    join.getTcpIpConfig().setEnabled(!multicast);
    join.getTcpIpConfig().addMember("127.0.0.1");
    HazelcastInstance h1 = Hazelcast.newHazelcastInstance(config);
    HazelcastInstance h2 = Hazelcast.newHazelcastInstance(config);
    HazelcastInstance h3 = Hazelcast.newHazelcastInstance(config);
    final CountDownLatch splitLatch = new CountDownLatch(2);
    h3.getCluster().addMembershipListener(new MembershipListener() {

        @Override
        public void memberAdded(MembershipEvent membershipEvent) {
        }

        @Override
        public void memberRemoved(MembershipEvent membershipEvent) {
            splitLatch.countDown();
        }

        @Override
        public void memberAttributeChanged(MemberAttributeEvent memberAttributeEvent) {
        }
    });
    final CountDownLatch mergeLatch = new CountDownLatch(1);
    h3.getLifecycleService().addLifecycleListener(new MergedEventLifeCycleListener(mergeLatch));
    closeConnectionBetween(h1, h3);
    closeConnectionBetween(h2, h3);
    assertTrue(splitLatch.await(10, TimeUnit.SECONDS));
    assertEquals(2, h1.getCluster().getMembers().size());
    assertEquals(2, h2.getCluster().getMembers().size());
    assertEquals(1, h3.getCluster().getMembers().size());
    assertTrue(mergeLatch.await(30, TimeUnit.SECONDS));
    assertEquals(3, h1.getCluster().getMembers().size());
    assertEquals(3, h2.getCluster().getMembers().size());
    assertEquals(3, h3.getCluster().getMembers().size());
    assertEquals(ACTIVE, h1.getCluster().getClusterState());
    assertEquals(ACTIVE, h2.getCluster().getClusterState());
    assertEquals(ACTIVE, h3.getCluster().getClusterState());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) HazelcastInstanceFactory.newHazelcastInstance(com.hazelcast.instance.HazelcastInstanceFactory.newHazelcastInstance) MemberAttributeEvent(com.hazelcast.core.MemberAttributeEvent) ListenerConfig(com.hazelcast.config.ListenerConfig) JoinConfig(com.hazelcast.config.JoinConfig) Config(com.hazelcast.config.Config) NetworkConfig(com.hazelcast.config.NetworkConfig) MembershipEvent(com.hazelcast.core.MembershipEvent) NetworkConfig(com.hazelcast.config.NetworkConfig) JoinConfig(com.hazelcast.config.JoinConfig) CountDownLatch(java.util.concurrent.CountDownLatch) MembershipListener(com.hazelcast.core.MembershipListener)

Example 13 with JoinConfig

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

the class MulticastJoinTest method test_whenInterfacesEnabled.

@Test
public void test_whenInterfacesEnabled() throws Exception {
    Config config = new Config();
    NetworkConfig networkConfig = config.getNetworkConfig();
    JoinConfig join = networkConfig.getJoin();
    join.getTcpIpConfig().setEnabled(false);
    MulticastConfig multicastConfig = join.getMulticastConfig();
    multicastConfig.setEnabled(true);
    InterfacesConfig interfaces = networkConfig.getInterfaces();
    interfaces.setEnabled(true);
    interfaces.addInterface("127.0.0.1");
    testJoin(config);
}
Also used : InterfacesConfig(com.hazelcast.config.InterfacesConfig) Config(com.hazelcast.config.Config) MulticastConfig(com.hazelcast.config.MulticastConfig) NetworkConfig(com.hazelcast.config.NetworkConfig) 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) MulticastConfig(com.hazelcast.config.MulticastConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 14 with JoinConfig

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

the class ListSplitBrainTest method getConfig.

private Config getConfig(boolean multicast) {
    Config config = new Config();
    config.setProperty(GroupProperty.MERGE_FIRST_RUN_DELAY_SECONDS.getName(), "30");
    config.setProperty(GroupProperty.MERGE_NEXT_RUN_DELAY_SECONDS.getName(), "3");
    NetworkConfig networkConfig = config.getNetworkConfig();
    JoinConfig join = networkConfig.getJoin();
    join.getMulticastConfig().setEnabled(multicast);
    join.getTcpIpConfig().setEnabled(!multicast);
    join.getTcpIpConfig().addMember("127.0.0.1");
    return config;
}
Also used : JoinConfig(com.hazelcast.config.JoinConfig) Config(com.hazelcast.config.Config) NetworkConfig(com.hazelcast.config.NetworkConfig) NetworkConfig(com.hazelcast.config.NetworkConfig) JoinConfig(com.hazelcast.config.JoinConfig)

Example 15 with JoinConfig

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

the class TcpIpJoinTest method test_whenNoExplicitPortConfigured.

@Test
public void test_whenNoExplicitPortConfigured() 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");
    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)

Aggregations

JoinConfig (com.hazelcast.config.JoinConfig)37 Config (com.hazelcast.config.Config)28 Test (org.junit.Test)20 NetworkConfig (com.hazelcast.config.NetworkConfig)19 QuickTest (com.hazelcast.test.annotation.QuickTest)19 InterfacesConfig (com.hazelcast.config.InterfacesConfig)14 TcpIpConfig (com.hazelcast.config.TcpIpConfig)11 HazelcastInstance (com.hazelcast.core.HazelcastInstance)11 ListenerConfig (com.hazelcast.config.ListenerConfig)9 PartitionGroupConfig (com.hazelcast.config.PartitionGroupConfig)9 ClientConfig (com.hazelcast.client.config.ClientConfig)8 MulticastConfig (com.hazelcast.config.MulticastConfig)8 MemberAttributeConfig (com.hazelcast.config.MemberAttributeConfig)6 AwsConfig (com.hazelcast.config.AwsConfig)5 DiscoveryConfig (com.hazelcast.config.DiscoveryConfig)5 Member (com.hazelcast.core.Member)5 ParallelTest (com.hazelcast.test.annotation.ParallelTest)5 CountDownLatch (java.util.concurrent.CountDownLatch)5 DiscoveryStrategyConfig (com.hazelcast.config.DiscoveryStrategyConfig)4 MembershipListener (com.hazelcast.core.MembershipListener)4