Search in sources :

Example 31 with JoinConfig

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

the class SplitBrainHandlerTest method testClusterMerge.

private void testClusterMerge(boolean multicast) throws Exception {
    Config config1 = new Config();
    config1.setProperty(GroupProperty.MERGE_FIRST_RUN_DELAY_SECONDS.getName(), "5");
    config1.setProperty(GroupProperty.MERGE_NEXT_RUN_DELAY_SECONDS.getName(), "3");
    String firstGroupName = generateRandomString(10);
    config1.getGroupConfig().setName(firstGroupName);
    NetworkConfig networkConfig1 = config1.getNetworkConfig();
    JoinConfig join1 = networkConfig1.getJoin();
    join1.getMulticastConfig().setEnabled(multicast);
    join1.getTcpIpConfig().setEnabled(!multicast);
    join1.getTcpIpConfig().addMember("127.0.0.1");
    Config config2 = new Config();
    config2.setProperty(GroupProperty.MERGE_FIRST_RUN_DELAY_SECONDS.getName(), "5");
    config2.setProperty(GroupProperty.MERGE_NEXT_RUN_DELAY_SECONDS.getName(), "3");
    String secondGroupName = generateRandomString(10);
    config2.getGroupConfig().setName(secondGroupName);
    NetworkConfig networkConfig2 = config2.getNetworkConfig();
    JoinConfig join2 = networkConfig2.getJoin();
    join2.getMulticastConfig().setEnabled(multicast);
    join2.getTcpIpConfig().setEnabled(!multicast);
    join2.getTcpIpConfig().addMember("127.0.0.1");
    HazelcastInstance h1 = Hazelcast.newHazelcastInstance(config1);
    HazelcastInstance h2 = Hazelcast.newHazelcastInstance(config2);
    LifecycleCountingListener l = new LifecycleCountingListener();
    h2.getLifecycleService().addLifecycleListener(l);
    assertEquals(1, h1.getCluster().getMembers().size());
    assertEquals(1, h2.getCluster().getMembers().size());
    // warning: assuming group name will be visible to the split brain handler!
    config1.getGroupConfig().setName(secondGroupName);
    assertTrue(l.waitFor(LifecycleState.MERGED, 30));
    assertEquals(1, l.getCount(LifecycleState.MERGING));
    assertEquals(1, l.getCount(LifecycleState.MERGED));
    assertEquals(2, h1.getCluster().getMembers().size());
    assertEquals(2, h2.getCluster().getMembers().size());
    assertEquals(ACTIVE, h1.getCluster().getClusterState());
    assertEquals(ACTIVE, h2.getCluster().getClusterState());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) HazelcastInstanceFactory.newHazelcastInstance(com.hazelcast.instance.HazelcastInstanceFactory.newHazelcastInstance) ListenerConfig(com.hazelcast.config.ListenerConfig) 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 32 with JoinConfig

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

the class SplitBrainHandlerTest method testClusterShouldNotMergeDifferentGroupName.

@Test
public void testClusterShouldNotMergeDifferentGroupName() throws Exception {
    Config config1 = new Config();
    config1.setProperty(GroupProperty.MERGE_FIRST_RUN_DELAY_SECONDS.getName(), "5");
    config1.setProperty(GroupProperty.MERGE_NEXT_RUN_DELAY_SECONDS.getName(), "3");
    String firstGroupName = generateRandomString(10);
    config1.getGroupConfig().setName(firstGroupName);
    NetworkConfig networkConfig1 = config1.getNetworkConfig();
    JoinConfig join1 = networkConfig1.getJoin();
    join1.getMulticastConfig().setEnabled(true);
    join1.getTcpIpConfig().addMember("127.0.0.1");
    Config config2 = new Config();
    config2.setProperty(GroupProperty.MERGE_FIRST_RUN_DELAY_SECONDS.getName(), "5");
    config2.setProperty(GroupProperty.MERGE_NEXT_RUN_DELAY_SECONDS.getName(), "3");
    String secondGroupName = generateRandomString(10);
    config2.getGroupConfig().setName(secondGroupName);
    NetworkConfig networkConfig2 = config2.getNetworkConfig();
    JoinConfig join2 = networkConfig2.getJoin();
    join2.getMulticastConfig().setEnabled(true);
    join2.getTcpIpConfig().addMember("127.0.0.1");
    HazelcastInstance h1 = Hazelcast.newHazelcastInstance(config1);
    HazelcastInstance h2 = Hazelcast.newHazelcastInstance(config2);
    LifecycleCountingListener l = new LifecycleCountingListener();
    h2.getLifecycleService().addLifecycleListener(l);
    assertEquals(1, h1.getCluster().getMembers().size());
    assertEquals(1, h2.getCluster().getMembers().size());
    HazelcastTestSupport.sleepSeconds(10);
    assertEquals(0, l.getCount(LifecycleState.MERGING));
    assertEquals(0, l.getCount(LifecycleState.MERGED));
    assertEquals(1, h1.getCluster().getMembers().size());
    assertEquals(1, h2.getCluster().getMembers().size());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) HazelcastInstanceFactory.newHazelcastInstance(com.hazelcast.instance.HazelcastInstanceFactory.newHazelcastInstance) ListenerConfig(com.hazelcast.config.ListenerConfig) 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) NightlyTest(com.hazelcast.test.annotation.NightlyTest) Test(org.junit.Test)

Example 33 with JoinConfig

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

the class MulticastJoinTest method test_whenDifferentBuildNumber.

@Test
public void test_whenDifferentBuildNumber() {
    Config config = new Config();
    JoinConfig join = config.getNetworkConfig().getJoin();
    MulticastConfig multicastConfig = join.getMulticastConfig();
    multicastConfig.setEnabled(true);
    join.getTcpIpConfig().setEnabled(false);
    testJoin_With_DifferentBuildNumber(config);
}
Also used : 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) JoinConfig(com.hazelcast.config.JoinConfig) MulticastConfig(com.hazelcast.config.MulticastConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 34 with JoinConfig

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

the class MulticastJoinTest method test.

@Test
public void test() 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);
    testJoin(config);
}
Also used : 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 35 with JoinConfig

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

the class TcpIpJoinTest method test_whenDifferentBuildNumber.

@Test
public void test_whenDifferentBuildNumber() {
    Config config = new Config();
    NetworkConfig networkConfig = config.getNetworkConfig();
    JoinConfig join = networkConfig.getJoin();
    join.getMulticastConfig().setEnabled(false);
    join.getTcpIpConfig().setEnabled(true);
    join.getTcpIpConfig().addMember("127.0.0.1");
    testJoin_With_DifferentBuildNumber(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)

Aggregations

JoinConfig (com.hazelcast.config.JoinConfig)39 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)12 HazelcastInstance (com.hazelcast.core.HazelcastInstance)11 PartitionGroupConfig (com.hazelcast.config.PartitionGroupConfig)10 ListenerConfig (com.hazelcast.config.ListenerConfig)9 MulticastConfig (com.hazelcast.config.MulticastConfig)9 ClientConfig (com.hazelcast.client.config.ClientConfig)8 DiscoveryConfig (com.hazelcast.config.DiscoveryConfig)7 DiscoveryStrategyConfig (com.hazelcast.config.DiscoveryStrategyConfig)6 MemberAttributeConfig (com.hazelcast.config.MemberAttributeConfig)6 AwsConfig (com.hazelcast.config.AwsConfig)5 Member (com.hazelcast.core.Member)5 ParallelTest (com.hazelcast.test.annotation.ParallelTest)5 CountDownLatch (java.util.concurrent.CountDownLatch)5 MembershipListener (com.hazelcast.core.MembershipListener)4