use of com.hazelcast.map.impl.querycache.utils.Employee in project hazelcast by hazelcast.
the class QueryCacheTest method testQueryCacheCleared_afterCalling_IMap_evictAll.
@Test
public void testQueryCacheCleared_afterCalling_IMap_evictAll() {
final IMap<Integer, Employee> map = getIMapWithDefaultConfig(TRUE_PREDICATE);
QueryCache<Integer, Employee> queryCache = map.getQueryCache(cacheName);
populateMap(map, 1000);
IFunction evictAll = (ignored) -> {
map.evictAll();
return null;
};
assertQueryCacheSizeEventually(0, evictAll, queryCache);
}
use of com.hazelcast.map.impl.querycache.utils.Employee in project hazelcast by hazelcast.
the class QueryCacheTest method testDestroy_emptiesQueryCache.
@Test
public void testDestroy_emptiesQueryCache() {
int entryCount = 1000;
final CountDownLatch numberOfAddEvents = new CountDownLatch(entryCount);
IMap<Integer, Employee> map = getIMapWithDefaultConfig(TRUE_PREDICATE);
QueryCache<Integer, Employee> queryCache = map.getQueryCache(cacheName, (EntryAddedListener<Integer, Employee>) (event) -> numberOfAddEvents.countDown(), TRUE_PREDICATE, false);
populateMap(map, entryCount);
assertOpenEventually(numberOfAddEvents);
queryCache.destroy();
assertEquals(0, queryCache.size());
}
use of com.hazelcast.map.impl.querycache.utils.Employee in project hazelcast by hazelcast.
the class QueryCacheTest method testWithInitialPopulation.
private void testWithInitialPopulation(boolean enableInitialPopulation, int expectedSize, int numberOfElementsToPut) {
QueryCacheConfig queryCacheConfig = new QueryCacheConfig(cacheName);
queryCacheConfig.setPopulate(enableInitialPopulation);
Config config = new Config();
config.getMapConfig(mapName).addQueryCacheConfig(queryCacheConfig);
IMap<Integer, Employee> map = getIMap(config);
populateMap(map, numberOfElementsToPut);
QueryCache<Integer, Employee> queryCache = map.getQueryCache(cacheName, TRUE_PREDICATE, true);
assertEquals(expectedSize, queryCache.size());
}
use of com.hazelcast.map.impl.querycache.utils.Employee in project hazelcast by hazelcast.
the class QueryCacheDataSyncWithMapTest method test_map_wide_event.
private void test_map_wide_event(MethodName methodName) {
for (int i = 0; i < 3; i++) {
callMethod(methodName);
int start = i * 10;
for (int j = start; j < start + 10; j++) {
map.put(j, new Employee(j));
}
}
assertTrueEventually(new AssertTask() {
@Override
public void run() {
int mapSize = map.size();
int queryCacheSize = queryCache.size();
String msg = "query cache should have same size with underlying imap but" + " its size found %d while map size is %d";
assertEquals(format(msg, queryCacheSize, mapSize), mapSize, queryCacheSize);
Collection<Employee> valuesInMap = map.values();
Collection<Employee> valuesInQueryCache = queryCache.values();
String msg2 = "valuesInMap %s but valuesInQueryCache %s";
assertTrue(format(msg2, valuesInMap, valuesInQueryCache), valuesInMap.containsAll(valuesInQueryCache));
}
});
}
use of com.hazelcast.map.impl.querycache.utils.Employee in project hazelcast by hazelcast.
the class QueryCacheMethodsWithPredicateTest method testKeySetIsNotBackedByQueryCache.
@Test
public void testKeySetIsNotBackedByQueryCache() {
int count = 111;
IMap<Employee, Employee> map = getIMapWithDefaultConfig(TRUE_PREDICATE);
for (int i = 0; i < count; i++) {
map.put(new Employee(i), new Employee(i));
}
Predicate<Employee, Employee> predicate = Predicates.lessThan("id", count);
QueryCache<Employee, Employee> cache = map.getQueryCache(cacheName);
cache.addIndex(IndexType.SORTED, "id");
for (Map.Entry<Employee, Employee> entry : cache.entrySet(predicate)) {
entry.getValue().setAge(Employee.MAX_AGE + 1);
}
for (Map.Entry<Employee, Employee> entry : cache.entrySet(predicate)) {
assertNotEquals(Employee.MAX_AGE + 1, entry.getValue().getAge());
}
}
Aggregations