use of com.hazelcast.config.Config in project hazelcast by hazelcast.
the class MapInvalidationMetaDataMigrationTest method newConfig.
protected Config newConfig(String mapName) {
NearCacheConfig nearCacheConfig = new NearCacheConfig();
nearCacheConfig.setInMemoryFormat(getNearCacheInMemoryFormat());
nearCacheConfig.setName(mapName);
nearCacheConfig.setInvalidateOnChange(true);
nearCacheConfig.setCacheLocalEntries(true);
MapConfig mapConfig = new MapConfig(mapName);
mapConfig.setNearCacheConfig(nearCacheConfig);
mapConfig.setBackupCount(0).setAsyncBackupCount(0);
Config config = getConfig();
return config.addMapConfig(mapConfig);
}
use of com.hazelcast.config.Config in project hazelcast by hazelcast.
the class MapInvalidationMetaDataMigrationTest method sequences_migrated_whenOneNodeContinuouslyStartsAndStops.
@Test
public void sequences_migrated_whenOneNodeContinuouslyStartsAndStops() throws Exception {
final String mapName = "test";
final Config config = newConfig(mapName);
final HazelcastInstance instance1 = factory.newHazelcastInstance(config);
IMap<Object, Object> map = instance1.getMap(mapName);
for (int i = 0; i < 10000; i++) {
map.put(i, i);
}
Map<Integer, Long> source = getPartitionToSequenceMap(mapName, instance1);
HazelcastInstance instance2 = factory.newHazelcastInstance(config);
final AtomicBoolean stop = new AtomicBoolean();
Thread shadow = new Thread(new Runnable() {
public void run() {
while (!stop.get()) {
HazelcastInstance instance = factory.newHazelcastInstance(config);
waitAllForSafeState(instance);
sleepSeconds(5);
instance.shutdown();
}
}
});
shadow.start();
sleepSeconds(20);
stop.set(true);
shadow.join();
instance2.shutdown();
Map<Integer, Long> destination = getPartitionToSequenceMap(mapName, instance1);
assertEquals(source, destination);
}
use of com.hazelcast.config.Config in project hazelcast by hazelcast.
the class MapInvalidationMetaDataMigrationTest method sequences_migrated_whenNewlyJoinedNodesShutdown.
@Test
public void sequences_migrated_whenNewlyJoinedNodesShutdown() throws Exception {
String mapName = "test";
Config config = newConfig(mapName);
HazelcastInstance instance1 = factory.newHazelcastInstance(config);
IMap<Object, Object> map = instance1.getMap(mapName);
for (int i = 0; i < 10000; i++) {
map.put(i, i);
}
Map<Integer, Long> source = getPartitionToSequenceMap(mapName, instance1);
HazelcastInstance instance2 = factory.newHazelcastInstance(config);
waitAllForSafeState(instance2);
instance1.shutdown();
HazelcastInstance instance3 = factory.newHazelcastInstance(config);
waitAllForSafeState(instance3);
instance2.shutdown();
waitAllForSafeState(instance3);
Map<Integer, Long> destination = getPartitionToSequenceMap(mapName, instance3);
for (Map.Entry<Integer, Long> entry : source.entrySet()) {
Integer key = entry.getKey();
Long first = entry.getValue();
Long last = destination.get(key);
assertEquals(first, last);
}
}
use of com.hazelcast.config.Config in project hazelcast by hazelcast.
the class QueryAdvancedTest method testUnknownPortableField_notCausesQueryException_withoutIndex.
@Test
public // see: https://github.com/hazelcast/hazelcast/issues/3927
void testUnknownPortableField_notCausesQueryException_withoutIndex() {
String mapName = randomMapName();
Config config = getConfig();
config.getSerializationConfig().addPortableFactory(666, new PortableFactory() {
public Portable create(int classId) {
return new PortableEmployee();
}
});
HazelcastInstance hazelcastInstance = createHazelcastInstance(config);
IMap<Integer, PortableEmployee> map = hazelcastInstance.getMap(mapName);
for (int i = 0; i < 5; i++) {
map.put(i, new PortableEmployee(i, "name_" + i));
}
Collection values = map.values(new SqlPredicate("notExist = name_0 OR a > 1"));
assertEquals(3, values.size());
}
use of com.hazelcast.config.Config in project hazelcast by hazelcast.
the class QueryAdvancedTest method testTwoMembersWithIndexes.
@Test
public void testTwoMembersWithIndexes() {
Config config = getConfig();
TestHazelcastInstanceFactory nodeFactory = createHazelcastInstanceFactory(2);
HazelcastInstance instance = nodeFactory.newHazelcastInstance(config);
nodeFactory.newHazelcastInstance(config);
IMap<String, Employee> map = instance.getMap("employees");
map.addIndex("name", false);
map.addIndex("age", true);
map.addIndex("active", false);
QueryBasicTest.doFunctionalQueryTest(map);
}
Aggregations