use of com.hazelcast.splitbrainprotection.impl.ProbabilisticSplitBrainProtectionFunction in project hazelcast by hazelcast.
the class YamlConfigBuilderTest method testConfig_whenProbabilisticSplitBrainProtection_withDefaultValues.
@Override
@Test
public void testConfig_whenProbabilisticSplitBrainProtection_withDefaultValues() {
String yaml = "" + "hazelcast:\n" + " split-brain-protection:\n" + " mySplitBrainProtection:\n" + " enabled: true\n" + " minimum-cluster-size: 3\n" + " probabilistic-split-brain-protection: {}";
Config config = buildConfig(yaml);
SplitBrainProtectionConfig splitBrainProtectionConfig = config.getSplitBrainProtectionConfig("mySplitBrainProtection");
assertInstanceOf(ProbabilisticSplitBrainProtectionFunction.class, splitBrainProtectionConfig.getFunctionImplementation());
ProbabilisticSplitBrainProtectionFunction splitBrainProtectionFunction = (ProbabilisticSplitBrainProtectionFunction) splitBrainProtectionConfig.getFunctionImplementation();
assertEquals(ProbabilisticSplitBrainProtectionConfigBuilder.DEFAULT_HEARTBEAT_INTERVAL_MILLIS, splitBrainProtectionFunction.getHeartbeatIntervalMillis());
assertEquals(ProbabilisticSplitBrainProtectionConfigBuilder.DEFAULT_HEARTBEAT_PAUSE_MILLIS, splitBrainProtectionFunction.getAcceptableHeartbeatPauseMillis());
assertEquals(ProbabilisticSplitBrainProtectionConfigBuilder.DEFAULT_MIN_STD_DEVIATION, splitBrainProtectionFunction.getMinStdDeviationMillis());
assertEquals(ProbabilisticSplitBrainProtectionConfigBuilder.DEFAULT_PHI_THRESHOLD, splitBrainProtectionFunction.getSuspicionThreshold(), 0.01);
assertEquals(ProbabilisticSplitBrainProtectionConfigBuilder.DEFAULT_SAMPLE_SIZE, splitBrainProtectionFunction.getMaxSampleSize());
}
use of com.hazelcast.splitbrainprotection.impl.ProbabilisticSplitBrainProtectionFunction 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.ProbabilisticSplitBrainProtectionFunction in project hazelcast by hazelcast.
the class SplitBrainProtectionTest method testProbabilisticSplitBrainProtectionConsidersLocalMember.
@Test
public void testProbabilisticSplitBrainProtectionConsidersLocalMember() {
String splitBrainProtectionName = randomString();
SplitBrainProtectionFunction splitBrainProtectionFunction = new ProbabilisticSplitBrainProtectionFunction(1, 100, 1250, 20, 100, 20);
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());
}
});
}
use of com.hazelcast.splitbrainprotection.impl.ProbabilisticSplitBrainProtectionFunction in project hazelcast by hazelcast.
the class TestFullApplicationContext method testProbabilisticSplitBrainProtectionConfig.
@Test
public void testProbabilisticSplitBrainProtectionConfig() {
SplitBrainProtectionConfig probabilisticSplitBrainProtectionConfig = config.getSplitBrainProtectionConfig("probabilistic-split-brain-protection");
assertNotNull(probabilisticSplitBrainProtectionConfig);
assertEquals("probabilistic-split-brain-protection", probabilisticSplitBrainProtectionConfig.getName());
assertNotNull(probabilisticSplitBrainProtectionConfig.getFunctionImplementation());
assertInstanceOf(ProbabilisticSplitBrainProtectionFunction.class, probabilisticSplitBrainProtectionConfig.getFunctionImplementation());
assertTrue(probabilisticSplitBrainProtectionConfig.isEnabled());
assertEquals(3, probabilisticSplitBrainProtectionConfig.getMinimumClusterSize());
assertEquals(2, probabilisticSplitBrainProtectionConfig.getListenerConfigs().size());
assertEquals(SplitBrainProtectionOn.READ_WRITE, probabilisticSplitBrainProtectionConfig.getProtectOn());
assertEquals("com.hazelcast.spring.DummySplitBrainProtectionListener", probabilisticSplitBrainProtectionConfig.getListenerConfigs().get(0).getClassName());
assertNotNull(probabilisticSplitBrainProtectionConfig.getListenerConfigs().get(1).getImplementation());
ProbabilisticSplitBrainProtectionFunction splitBrainProtectionFunction = (ProbabilisticSplitBrainProtectionFunction) probabilisticSplitBrainProtectionConfig.getFunctionImplementation();
assertEquals(11, splitBrainProtectionFunction.getSuspicionThreshold(), 0.001d);
assertEquals(31415, splitBrainProtectionFunction.getAcceptableHeartbeatPauseMillis());
assertEquals(42, splitBrainProtectionFunction.getMaxSampleSize());
assertEquals(77123, splitBrainProtectionFunction.getHeartbeatIntervalMillis());
assertEquals(1000, splitBrainProtectionFunction.getMinStdDeviationMillis());
}
use of com.hazelcast.splitbrainprotection.impl.ProbabilisticSplitBrainProtectionFunction in project hazelcast by hazelcast.
the class ProbabilisticSplitBrainProtectionConfigBuilder method build.
public SplitBrainProtectionConfig build() {
ProbabilisticSplitBrainProtectionFunction splitBrainProtectionFunction = new ProbabilisticSplitBrainProtectionFunction(minimumClusterSize, heartbeatIntervalMillis, acceptableHeartbeatPauseMillis, maxSampleSize, minStdDeviationMillis, phiThreshold);
SplitBrainProtectionConfig config = new SplitBrainProtectionConfig();
config.setName(name);
config.setEnabled(enabled);
config.setMinimumClusterSize(minimumClusterSize);
config.setFunctionImplementation(splitBrainProtectionFunction);
return config;
}
Aggregations