use of com.hazelcast.config.SplitBrainProtectionConfig in project hazelcast by hazelcast.
the class MapSplitBrainProtectionLiteMemberTest method createConfig.
private Config createConfig(String name, SplitBrainProtectionOn type, int size, boolean liteMember) {
SplitBrainProtectionConfig splitBrainProtectionConfig = new SplitBrainProtectionConfig().setName(name).setProtectOn(type).setEnabled(true).setMinimumClusterSize(size);
MapConfig mapConfig = new MapConfig(name);
mapConfig.setSplitBrainProtectionName(name);
Config config = new Config();
config.addSplitBrainProtectionConfig(splitBrainProtectionConfig);
config.addMapConfig(mapConfig);
config.setLiteMember(liteMember);
return config;
}
use of com.hazelcast.config.SplitBrainProtectionConfig in project hazelcast by hazelcast.
the class SplitBrainProtectionTest method givenRecentlyActiveSplitBrainProtection_whenHeartbeatTolerance_greaterThanMaxNoHeartbeat_exceptionIsThrown.
@Test(expected = InvalidConfigurationException.class)
public void givenRecentlyActiveSplitBrainProtection_whenHeartbeatTolerance_greaterThanMaxNoHeartbeat_exceptionIsThrown() {
Config config = new Config();
config.setProperty(ClusterProperty.MAX_NO_HEARTBEAT_SECONDS.getName(), "10");
SplitBrainProtectionConfig recentlyActiveSplitBrainProtectionConfig = SplitBrainProtectionConfig.newRecentlyActiveSplitBrainProtectionConfigBuilder("test-splitBrainProtection", 3, 13000).build();
config.addSplitBrainProtectionConfig(recentlyActiveSplitBrainProtectionConfig);
createHazelcastInstance(config);
}
use of com.hazelcast.config.SplitBrainProtectionConfig 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());
}
});
}
use of com.hazelcast.config.SplitBrainProtectionConfig in project hazelcast by hazelcast.
the class SplitBrainProtectionTest method oneSplitBrainProtectionShouldNotAffectSplitBrainProtectionAwareOperationsOnDataStructuresWithoutSplitBrainProtectionConfiguration.
/**
* https://github.com/hazelcast/hazelcast/issues/9792
*/
@Test
public void oneSplitBrainProtectionShouldNotAffectSplitBrainProtectionAwareOperationsOnDataStructuresWithoutSplitBrainProtectionConfiguration() {
String splitBrainProtectionName = randomString();
SplitBrainProtectionConfig splitBrainProtectionConfig = new SplitBrainProtectionConfig(splitBrainProtectionName, true).setFunctionImplementation(new SplitBrainProtectionFunction() {
@Override
public boolean apply(Collection<Member> members) {
return members.size() == 3;
}
});
MapConfig mapConfig = new MapConfig("splitBrainProtectionMap").setSplitBrainProtectionName(splitBrainProtectionName);
Config config = new Config().addMapConfig(mapConfig).addSplitBrainProtectionConfig(splitBrainProtectionConfig);
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(3);
HazelcastInstance hz = factory.newHazelcastInstance(config);
factory.newHazelcastInstance(config);
factory.newHazelcastInstance(config);
IMap<Object, Object> splitBrainProtectionMap = hz.getMap("splitBrainProtectionMap");
splitBrainProtectionMap.put(generateKeyOwnedBy(hz), "bar");
IQueue queue = hz.getQueue("noSplitBrainProtectionQueue");
queue.offer("item");
}
use of com.hazelcast.config.SplitBrainProtectionConfig in project hazelcast by hazelcast.
the class SplitBrainProtectionTest method testSplitBrainProtectionNotChecked_whenIsNotEnabled.
@Test
public void testSplitBrainProtectionNotChecked_whenIsNotEnabled() {
String disabledSBPName = "disabled-quorum";
SplitBrainProtectionConfig disabledSBPConfig = new SplitBrainProtectionConfig().setName(disabledSBPName).setMinimumClusterSize(3);
MapConfig mapConfig = new MapConfig(randomMapName()).setSplitBrainProtectionName(disabledSBPName);
Config config = new Config().addSplitBrainProtectionConfig(disabledSBPConfig).addMapConfig(mapConfig);
HazelcastInstance instance = createHazelcastInstance(config);
instance.getSplitBrainProtectionService().ensureNoSplitBrain(disabledSBPName, disabledSBPConfig.getProtectOn());
instance.getMap(mapConfig.getName()).put("key", "value");
}
Aggregations