use of com.hazelcast.splitbrainprotection.impl.RecentlyActiveSplitBrainProtectionFunction in project hazelcast by hazelcast.
the class YamlConfigBuilderTest method testConfig_whenRecentlyActiveSplitBrainProtection_withDefaultValues.
@Override
@Test
public void testConfig_whenRecentlyActiveSplitBrainProtection_withDefaultValues() {
String yaml = "" + "hazelcast:\n" + " split-brain-protection:\n" + " mySplitBrainProtection:\n" + " enabled: true\n" + " minimum-cluster-size: 3\n" + " recently-active-split-brain-protection: {}";
Config config = buildConfig(yaml);
SplitBrainProtectionConfig splitBrainProtectionConfig = config.getSplitBrainProtectionConfig("mySplitBrainProtection");
assertInstanceOf(RecentlyActiveSplitBrainProtectionFunction.class, splitBrainProtectionConfig.getFunctionImplementation());
RecentlyActiveSplitBrainProtectionFunction splitBrainProtectionFunction = (RecentlyActiveSplitBrainProtectionFunction) splitBrainProtectionConfig.getFunctionImplementation();
assertEquals(RecentlyActiveSplitBrainProtectionConfigBuilder.DEFAULT_HEARTBEAT_TOLERANCE_MILLIS, splitBrainProtectionFunction.getHeartbeatToleranceMillis());
}
use of com.hazelcast.splitbrainprotection.impl.RecentlyActiveSplitBrainProtectionFunction in project hazelcast by hazelcast.
the class TestFullApplicationContext method testRecentlyActiveSplitBrainProtectionConfig.
@Test
public void testRecentlyActiveSplitBrainProtectionConfig() {
SplitBrainProtectionConfig recentlyActiveSplitBrainProtectionConfig = config.getSplitBrainProtectionConfig("recently-active-split-brain-protection");
assertNotNull(recentlyActiveSplitBrainProtectionConfig);
assertEquals("recently-active-split-brain-protection", recentlyActiveSplitBrainProtectionConfig.getName());
assertNotNull(recentlyActiveSplitBrainProtectionConfig.getFunctionImplementation());
assertInstanceOf(RecentlyActiveSplitBrainProtectionFunction.class, recentlyActiveSplitBrainProtectionConfig.getFunctionImplementation());
assertTrue(recentlyActiveSplitBrainProtectionConfig.isEnabled());
assertEquals(5, recentlyActiveSplitBrainProtectionConfig.getMinimumClusterSize());
assertEquals(SplitBrainProtectionOn.READ_WRITE, recentlyActiveSplitBrainProtectionConfig.getProtectOn());
RecentlyActiveSplitBrainProtectionFunction splitBrainProtectionFunction = (RecentlyActiveSplitBrainProtectionFunction) recentlyActiveSplitBrainProtectionConfig.getFunctionImplementation();
assertEquals(5123, splitBrainProtectionFunction.getHeartbeatToleranceMillis());
}
use of com.hazelcast.splitbrainprotection.impl.RecentlyActiveSplitBrainProtectionFunction in project hazelcast by hazelcast.
the class ConfigXmlGenerator method handleSplitBrainProtectionFunction.
private static void handleSplitBrainProtectionFunction(XmlGenerator gen, SplitBrainProtectionConfig splitBrainProtectionConfig) {
if (splitBrainProtectionConfig.getFunctionImplementation() instanceof ProbabilisticSplitBrainProtectionFunction) {
ProbabilisticSplitBrainProtectionFunction qf = (ProbabilisticSplitBrainProtectionFunction) splitBrainProtectionConfig.getFunctionImplementation();
long acceptableHeartbeatPause = qf.getAcceptableHeartbeatPauseMillis();
double threshold = qf.getSuspicionThreshold();
int maxSampleSize = qf.getMaxSampleSize();
long minStdDeviation = qf.getMinStdDeviationMillis();
long firstHeartbeatEstimate = qf.getHeartbeatIntervalMillis();
gen.open("probabilistic-split-brain-protection", "acceptable-heartbeat-pause-millis", acceptableHeartbeatPause, "suspicion-threshold", threshold, "max-sample-size", maxSampleSize, "min-std-deviation-millis", minStdDeviation, "heartbeat-interval-millis", firstHeartbeatEstimate);
gen.close();
} else if (splitBrainProtectionConfig.getFunctionImplementation() instanceof RecentlyActiveSplitBrainProtectionFunction) {
RecentlyActiveSplitBrainProtectionFunction qf = (RecentlyActiveSplitBrainProtectionFunction) splitBrainProtectionConfig.getFunctionImplementation();
gen.open("recently-active-split-brain-protection", "heartbeat-tolerance-millis", qf.getHeartbeatToleranceMillis());
gen.close();
} else {
gen.node("function-class-name", classNameOrImplClass(splitBrainProtectionConfig.getFunctionClassName(), splitBrainProtectionConfig.getFunctionImplementation()));
}
}
use of com.hazelcast.splitbrainprotection.impl.RecentlyActiveSplitBrainProtectionFunction in project hazelcast by hazelcast.
the class RecentlyActiveSplitBrainProtectionConfigBuilder method build.
public SplitBrainProtectionConfig build() {
RecentlyActiveSplitBrainProtectionFunction splitBrainProtectionFunction = new RecentlyActiveSplitBrainProtectionFunction(size, heartbeatToleranceMillis);
SplitBrainProtectionConfig splitBrainProtectionConfig = new SplitBrainProtectionConfig(name, enabled, size);
splitBrainProtectionConfig.setFunctionImplementation(splitBrainProtectionFunction);
return splitBrainProtectionConfig;
}
use of com.hazelcast.splitbrainprotection.impl.RecentlyActiveSplitBrainProtectionFunction in project hazelcast by hazelcast.
the class XMLConfigBuilderTest method testConfig_whenRecentlyActiveSplitBrainProtection_withDefaultValues.
@Override
@Test
public void testConfig_whenRecentlyActiveSplitBrainProtection_withDefaultValues() {
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 />" + " </split-brain-protection>\n" + HAZELCAST_END_TAG;
Config config = buildConfig(xml);
SplitBrainProtectionConfig splitBrainProtectionConfig = config.getSplitBrainProtectionConfig("mySplitBrainProtection");
assertInstanceOf(RecentlyActiveSplitBrainProtectionFunction.class, splitBrainProtectionConfig.getFunctionImplementation());
RecentlyActiveSplitBrainProtectionFunction splitBrainProtectionFunction = (RecentlyActiveSplitBrainProtectionFunction) splitBrainProtectionConfig.getFunctionImplementation();
assertEquals(RecentlyActiveSplitBrainProtectionConfigBuilder.DEFAULT_HEARTBEAT_TOLERANCE_MILLIS, splitBrainProtectionFunction.getHeartbeatToleranceMillis());
}
Aggregations