use of com.hazelcast.config.MapConfig in project hazelcast by hazelcast.
the class ObjectRecordTest method setup.
@Before
public void setup() {
String mapName = randomMapName();
Config config = new Config();
MapConfig mapConfig = config.getMapConfig(mapName);
mapConfig.setInMemoryFormat(InMemoryFormat.OBJECT);
mapConfig.setStatisticsEnabled(false);
HazelcastInstance instance = createHazelcastInstance(config);
map = instance.getMap(mapName);
}
use of com.hazelcast.config.MapConfig 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();
}
use of com.hazelcast.config.MapConfig in project hazelcast by hazelcast.
the class QuorumTest method testCustomQuorumFunctionFails.
@Test(expected = QuorumException.class)
public void testCustomQuorumFunctionFails() {
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);
map.put("1", "1");
}
use of com.hazelcast.config.MapConfig in project hazelcast by hazelcast.
the class MapReadWriteQuorumTest method initialize.
@BeforeClass
public static void initialize() throws Exception {
QuorumConfig quorumConfig = new QuorumConfig();
quorumConfig.setName(QUORUM_ID);
quorumConfig.setEnabled(true);
quorumConfig.setSize(3);
MapConfig mapConfig = new MapConfig(MAP_NAME_PREFIX + "*");
mapConfig.setQuorumName(QUORUM_ID);
cluster = new PartitionedCluster(new TestHazelcastInstanceFactory()).partitionFiveMembersThreeAndTwo(mapConfig, quorumConfig);
}
use of com.hazelcast.config.MapConfig in project hazelcast by hazelcast.
the class MapWriteQuorumTest method initialize.
@BeforeClass
public static void initialize() throws Exception {
QuorumConfig quorumConfig = new QuorumConfig();
quorumConfig.setName(QUORUM_ID);
quorumConfig.setEnabled(true);
quorumConfig.setType(QuorumType.WRITE);
quorumConfig.setSize(3);
MapConfig mapConfig = new MapConfig(MAP_NAME_PREFIX + "*");
mapConfig.setQuorumName(QUORUM_ID);
cluster = new PartitionedCluster(new TestHazelcastInstanceFactory()).partitionFiveMembersThreeAndTwo(mapConfig, quorumConfig);
}
Aggregations