use of com.hazelcast.config.QuorumConfig in project hazelcast by hazelcast.
the class PartitionedCluster method createFiveMemberCluster.
public PartitionedCluster createFiveMemberCluster(CacheSimpleConfig cacheSimpleConfig, QuorumConfig quorumConfig) {
Config config = createClusterConfig().addCacheConfig(cacheSimpleConfig).addQuorumConfig(quorumConfig);
createInstances(config);
return this;
}
use of com.hazelcast.config.QuorumConfig in project hazelcast by hazelcast.
the class PartitionedCluster method createFiveMemberCluster.
private PartitionedCluster createFiveMemberCluster(MapConfig mapConfig, QuorumConfig quorumConfig) {
Config config = createClusterConfig().addMapConfig(mapConfig).addQuorumConfig(quorumConfig);
createInstances(config);
return this;
}
use of com.hazelcast.config.QuorumConfig in project hazelcast by hazelcast.
the class QuorumTest method oneQuorumShouldNotAffectQuorumAwareOperationsOnDataStructuresWithoutQuorumConfiguration.
/**
* https://github.com/hazelcast/hazelcast/issues/9792
*/
@Test
public void oneQuorumShouldNotAffectQuorumAwareOperationsOnDataStructuresWithoutQuorumConfiguration() {
String quorumName = randomString();
QuorumConfig quorumConfig = new QuorumConfig(quorumName, true).setQuorumFunctionImplementation(new QuorumFunction() {
@Override
public boolean apply(Collection<Member> members) {
return members.size() == 3;
}
});
MapConfig mapConfig = new MapConfig("quorumMap").setQuorumName(quorumName);
Config config = new Config().addMapConfig(mapConfig).addQuorumConfig(quorumConfig);
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(3);
HazelcastInstance hz = factory.newHazelcastInstance(config);
factory.newHazelcastInstance(config);
factory.newHazelcastInstance(config);
IMap<Object, Object> quorumMap = hz.getMap("quorumMap");
quorumMap.put(generateKeyOwnedBy(hz), "bar");
ILock lock = hz.getLock("noQuorumLock");
try {
lock.lock();
} finally {
lock.unlock();
}
}
use of com.hazelcast.config.QuorumConfig in project hazelcast by hazelcast.
the class QuorumTest method testOneQuorumsFailsOneQuorumSuccessForDifferentMaps.
@Test
public void testOneQuorumsFailsOneQuorumSuccessForDifferentMaps() {
String fourNodeQuorum = randomString();
String threeNodeQuorum = randomString();
MapConfig fourNodeMapConfig = new MapConfig("fourNode").setQuorumName(fourNodeQuorum);
MapConfig threeNodeMapConfig = new MapConfig("threeNode").setQuorumName(threeNodeQuorum);
QuorumConfig fourNodeQuorumConfig = new QuorumConfig(fourNodeQuorum, true).setQuorumFunctionImplementation(new QuorumFunction() {
@Override
public boolean apply(Collection<Member> members) {
return members.size() == 4;
}
});
QuorumConfig threeNodeQuorumConfig = new QuorumConfig(threeNodeQuorum, true).setQuorumFunctionImplementation(new QuorumFunction() {
@Override
public boolean apply(Collection<Member> members) {
return members.size() == 3;
}
});
Config config = new Config().addMapConfig(fourNodeMapConfig).addMapConfig(threeNodeMapConfig).addQuorumConfig(threeNodeQuorumConfig).addQuorumConfig(fourNodeQuorumConfig);
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(3);
HazelcastInstance hz = factory.newHazelcastInstance(config);
factory.newHazelcastInstance(config);
factory.newHazelcastInstance(config);
IMap<Object, Object> fourNode = hz.getMap("fourNode");
IMap<Object, Object> threeNode = hz.getMap("threeNode");
threeNode.put(generateKeyOwnedBy(hz), "bar");
try {
fourNode.put(generateKeyOwnedBy(hz), "bar");
fail();
} catch (Exception ignored) {
}
}
use of com.hazelcast.config.QuorumConfig in project hazelcast by hazelcast.
the class QuorumTest method testCustomQuorumFunctionIsPresent.
@Test
public void testCustomQuorumFunctionIsPresent() {
String mapName = randomMapName();
String quorumName = randomString();
MapConfig mapConfig = new MapConfig(mapName).setQuorumName(quorumName);
QuorumConfig quorumConfig = new QuorumConfig().setName(quorumName).setEnabled(true).setQuorumFunctionImplementation(new QuorumFunction() {
@Override
public boolean apply(Collection<Member> members) {
return false;
}
});
Config config = new Config().addQuorumConfig(quorumConfig).addMapConfig(mapConfig);
HazelcastInstance hazelcastInstance = createHazelcastInstance(config);
IMap<Object, Object> map = hazelcastInstance.getMap(mapName);
try {
map.put("1", "1");
fail();
} catch (Exception ignored) {
}
Quorum quorum = hazelcastInstance.getQuorumService().getQuorum(quorumName);
assertFalse(quorum.isPresent());
}
Aggregations