use of com.hazelcast.splitbrainprotection.impl.RecentlyActiveSplitBrainProtectionFunction in project hazelcast by hazelcast.
the class XMLConfigBuilderTest method testConfig_whenRecentlyActiveSplitBrainProtection_withCustomValues.
@Override
@Test
public void testConfig_whenRecentlyActiveSplitBrainProtection_withCustomValues() {
String xml = HAZELCAST_START_TAG + " <split-brain-protection enabled=\"true\" name=\"mySplitBrainProtection\">\n" + " <minimum-cluster-size>3</minimum-cluster-size>\n" + " <recently-active-split-brain-protection heartbeat-tolerance-millis=\"13000\" />" + " </split-brain-protection>\n" + HAZELCAST_END_TAG;
Config config = buildConfig(xml);
SplitBrainProtectionConfig splitBrainProtectionConfig = config.getSplitBrainProtectionConfig("mySplitBrainProtection");
assertEquals(3, splitBrainProtectionConfig.getMinimumClusterSize());
assertInstanceOf(RecentlyActiveSplitBrainProtectionFunction.class, splitBrainProtectionConfig.getFunctionImplementation());
RecentlyActiveSplitBrainProtectionFunction splitBrainProtectionFunction = (RecentlyActiveSplitBrainProtectionFunction) splitBrainProtectionConfig.getFunctionImplementation();
assertEquals(13000, splitBrainProtectionFunction.getHeartbeatToleranceMillis());
}
use of com.hazelcast.splitbrainprotection.impl.RecentlyActiveSplitBrainProtectionFunction in project hazelcast by hazelcast.
the class YamlConfigBuilderTest method testConfig_whenRecentlyActiveSplitBrainProtection_withCustomValues.
@Override
@Test
public void testConfig_whenRecentlyActiveSplitBrainProtection_withCustomValues() {
String yaml = "" + "hazelcast:\n" + " split-brain-protection:\n" + " mySplitBrainProtection:\n" + " enabled: true\n" + " minimum-cluster-size: 3\n" + " recently-active-split-brain-protection:\n" + " heartbeat-tolerance-millis: 13000\n";
Config config = buildConfig(yaml);
SplitBrainProtectionConfig splitBrainProtectionConfig = config.getSplitBrainProtectionConfig("mySplitBrainProtection");
assertEquals(3, splitBrainProtectionConfig.getMinimumClusterSize());
assertInstanceOf(RecentlyActiveSplitBrainProtectionFunction.class, splitBrainProtectionConfig.getFunctionImplementation());
RecentlyActiveSplitBrainProtectionFunction splitBrainProtectionFunction = (RecentlyActiveSplitBrainProtectionFunction) splitBrainProtectionConfig.getFunctionImplementation();
assertEquals(13000, splitBrainProtectionFunction.getHeartbeatToleranceMillis());
}
use of com.hazelcast.splitbrainprotection.impl.RecentlyActiveSplitBrainProtectionFunction in project hazelcast by hazelcast.
the class SplitBrainProtectionTest method testRecentlyActiveSplitBrainProtectionConsidersLocalMember.
@Test
public void testRecentlyActiveSplitBrainProtectionConsidersLocalMember() {
final String splitBrainProtectionName = randomString();
SplitBrainProtectionFunction splitBrainProtectionFunction = new RecentlyActiveSplitBrainProtectionFunction(1, 10000);
SplitBrainProtectionConfig splitBrainProtectionConfig = new SplitBrainProtectionConfig().setName(splitBrainProtectionName).setEnabled(true).setFunctionImplementation(splitBrainProtectionFunction);
Config config = new Config().addSplitBrainProtectionConfig(splitBrainProtectionConfig).setProperty(ClusterProperty.HEARTBEAT_INTERVAL_SECONDS.getName(), "1");
HazelcastInstance instance = createHazelcastInstance(config);
final SplitBrainProtection splitBrainProtection = instance.getSplitBrainProtectionService().getSplitBrainProtection(splitBrainProtectionName);
assertTrueEventually(new AssertTask() {
@Override
public void run() {
assertTrue(splitBrainProtection.hasMinimumSize());
}
});
}
Aggregations