use of com.hazelcast.config.QuorumConfig in project hazelcast by hazelcast.
the class PartitionedCluster method createSuccessfulSplitTestQuorum.
private QuorumConfig createSuccessfulSplitTestQuorum() {
QuorumConfig splitConfig = new QuorumConfig();
splitConfig.setEnabled(true);
splitConfig.setSize(3);
splitConfig.setName(SUCCESSFUL_SPLIT_TEST_QUORUM_NAME);
return splitConfig;
}
use of com.hazelcast.config.QuorumConfig in project hazelcast by hazelcast.
the class PartitionedCluster method createFiveMemberCluster.
public PartitionedCluster createFiveMemberCluster(LockConfig lockConfig, QuorumConfig quorumConfig) {
Config config = createClusterConfig().addLockConfig(lockConfig).addQuorumConfig(quorumConfig);
createInstances(config);
return this;
}
use of com.hazelcast.config.QuorumConfig in project hazelcast by hazelcast.
the class QuorumTest method givenQuorumFunctionConfigured_whenImplementsHazelcastInstanceAware_thenHazelcastInjectsItsInstance.
@Test
public void givenQuorumFunctionConfigured_whenImplementsHazelcastInstanceAware_thenHazelcastInjectsItsInstance() {
QuorumConfig quorumConfig = new QuorumConfig(randomString(), true).setQuorumFunctionClassName(HazelcastInstanceAwareQuorumFunction.class.getName());
Config config = new Config().addQuorumConfig(quorumConfig);
HazelcastInstance instance = createHazelcastInstance(config);
assertEquals(instance, HazelcastInstanceAwareQuorumFunction.instance);
}
use of com.hazelcast.config.QuorumConfig in project hazelcast by hazelcast.
the class QuorumTest method givenQuorumFunctionInstanceConfigured_whenImplementsHazelcastInstanceAware_thenHazelcastInjectsItsInstance.
@Test
public void givenQuorumFunctionInstanceConfigured_whenImplementsHazelcastInstanceAware_thenHazelcastInjectsItsInstance() {
QuorumConfig quorumConfig = new QuorumConfig(randomString(), true).setQuorumFunctionImplementation(new HazelcastInstanceAwareQuorumFunction());
Config config = new Config().addQuorumConfig(quorumConfig);
HazelcastInstance instance = createHazelcastInstance(config);
assertEquals(instance, HazelcastInstanceAwareQuorumFunction.instance);
}
use of com.hazelcast.config.QuorumConfig in project hazelcast by hazelcast.
the class QuorumTest method testCustomQuorumFunctionFailsThenSuccess.
@Test
public void testCustomQuorumFunctionFailsThenSuccess() {
final AtomicInteger count = new AtomicInteger(1);
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) {
if (count.get() == 1) {
count.incrementAndGet();
return false;
} else {
return true;
}
}
});
Config config = new Config().addMapConfig(mapConfig).addQuorumConfig(quorumConfig);
TestHazelcastInstanceFactory factory = new TestHazelcastInstanceFactory(2);
HazelcastInstance hazelcastInstance = factory.newHazelcastInstance(config);
IMap<Object, Object> map = hazelcastInstance.getMap(mapName);
try {
map.put("1", "1");
fail();
} catch (Exception e) {
e.printStackTrace();
}
factory.newHazelcastInstance(config);
map.put("1", "1");
factory.shutdownAll();
}
Aggregations