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());
}
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());
}
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);
}
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);
}
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);
}
Aggregations