use of com.hazelcast.config.SplitBrainProtectionConfig in project hazelcast by hazelcast.
the class SplitBrainProtectionTest method givenRecentlyActiveSplitBrainProtection_whenHeartbeatTolerance_lessThanHeartbeatInterval_exceptionIsThrown.
@Test(expected = InvalidConfigurationException.class)
public void givenRecentlyActiveSplitBrainProtection_whenHeartbeatTolerance_lessThanHeartbeatInterval_exceptionIsThrown() {
Config config = new Config();
config.setProperty(ClusterProperty.HEARTBEAT_INTERVAL_SECONDS.getName(), "5");
SplitBrainProtectionConfig recentlyActiveSplitBrainProtectionConfig = SplitBrainProtectionConfig.newRecentlyActiveSplitBrainProtectionConfigBuilder("test-splitBrainProtection", 3, 3000).build();
config.addSplitBrainProtectionConfig(recentlyActiveSplitBrainProtectionConfig);
createHazelcastInstance(config);
}
use of com.hazelcast.config.SplitBrainProtectionConfig 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.config.SplitBrainProtectionConfig in project hazelcast by hazelcast.
the class SplitBrainProtectionTest method givenSplitBrainProtectionFunctionConfigured_whenImplementsHazelcastInstanceAware_thenHazelcastInjectsItsInstance.
@Test
public void givenSplitBrainProtectionFunctionConfigured_whenImplementsHazelcastInstanceAware_thenHazelcastInjectsItsInstance() {
SplitBrainProtectionConfig splitBrainProtectionConfig = new SplitBrainProtectionConfig(randomString(), true).setFunctionClassName(HazelcastInstanceAwareSplitBrainProtectionFunction.class.getName());
Config config = new Config().addSplitBrainProtectionConfig(splitBrainProtectionConfig);
HazelcastInstance instance = createHazelcastInstance(config);
assertEquals(instance, HazelcastInstanceAwareSplitBrainProtectionFunction.instance);
}
use of com.hazelcast.config.SplitBrainProtectionConfig in project hazelcast by hazelcast.
the class SplitBrainProtectionServiceImpl method initializeSplitBrainProtections.
private Map<String, SplitBrainProtectionImpl> initializeSplitBrainProtections() {
Map<String, SplitBrainProtectionImpl> splitBrainProtections = new HashMap<>();
for (SplitBrainProtectionConfig splitBrainProtectionConfig : nodeEngine.getConfig().getSplitBrainProtectionConfigs().values()) {
validateSplitBrainProtectionConfig(splitBrainProtectionConfig);
if (!splitBrainProtectionConfig.isEnabled()) {
continue;
}
SplitBrainProtectionImpl splitBrainProtection = new SplitBrainProtectionImpl(splitBrainProtectionConfig, nodeEngine);
splitBrainProtections.put(splitBrainProtectionConfig.getName(), splitBrainProtection);
}
return splitBrainProtections;
}
use of com.hazelcast.config.SplitBrainProtectionConfig 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());
}
Aggregations