use of com.hazelcast.internal.nearcache.NearCache in project hazelcast by hazelcast.
the class MapNearCacheInvalidationTest method testBatchInvalidationRemovesEntries.
@Test
public void testBatchInvalidationRemovesEntries() {
Config config = getConfig(mapName).setProperty(PARTITION_COUNT.getName(), "1");
configureBatching(config, 12, 1);
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory();
HazelcastInstance node1 = factory.newHazelcastInstance(config);
HazelcastInstance node2 = factory.newHazelcastInstance(config);
final IMap<Integer, Integer> map1 = node1.getMap(mapName);
final IMap<Integer, Integer> map2 = node2.getMap(mapName);
int size = 1000;
// fill map-1
for (int i = 0; i < size; i++) {
map1.put(i, i);
}
// fill Near Cache on node-1
for (int i = 0; i < size; i++) {
map1.get(i);
}
// fill Near Cache on node-2
for (int i = 0; i < size; i++) {
map2.get(i);
}
// generate invalidation data
for (int i = 0; i < size; i++) {
map1.put(i, i);
}
assertTrueEventually(new AssertTask() {
@Override
public void run() {
NearCache nearCache1 = ((NearCachedMapProxyImpl) map1).getNearCache();
NearCache nearCache2 = ((NearCachedMapProxyImpl) map2).getNearCache();
assertEquals(0, nearCache1.size() + nearCache2.size());
}
});
}
use of com.hazelcast.internal.nearcache.NearCache in project hazelcast by hazelcast.
the class MapNearCacheInvalidationTest method testMapEvictAll_shouldClearNearCaches_onOwnerAndBackupNodes.
@Test
public void testMapEvictAll_shouldClearNearCaches_onOwnerAndBackupNodes() {
Config config = getConfig(mapName).setProperty(PARTITION_COUNT.getName(), "1");
configureBatching(config, 5, 5);
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory();
HazelcastInstance node1 = factory.newHazelcastInstance(config);
HazelcastInstance node2 = factory.newHazelcastInstance(config);
final IMap<Integer, Integer> map1 = node1.getMap(mapName);
final IMap<Integer, Integer> map2 = node2.getMap(mapName);
int size = 1000;
// fill map-1
for (int i = 0; i < size; i++) {
map1.put(i, i);
}
// fill Near Cache on node-1
for (int i = 0; i < size; i++) {
map1.get(i);
}
// fill Near Cache on node-2
for (int i = 0; i < size; i++) {
map2.get(i);
}
map1.evictAll();
assertTrueEventually(new AssertTask() {
@Override
public void run() {
NearCache nearCache1 = ((NearCachedMapProxyImpl) map1).getNearCache();
NearCache nearCache2 = ((NearCachedMapProxyImpl) map2).getNearCache();
assertEquals(0, nearCache1.size() + nearCache2.size());
}
});
}
use of com.hazelcast.internal.nearcache.NearCache in project hazelcast by hazelcast.
the class MapNearCacheInvalidationTest method testMapClear_shouldClearNearCaches_onOwnerAndBackupNodes.
@Test
public void testMapClear_shouldClearNearCaches_onOwnerAndBackupNodes() {
Config config = getConfig(mapName).setProperty(PARTITION_COUNT.getName(), "1");
configureBatching(config, 5, 5);
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory();
HazelcastInstance node1 = factory.newHazelcastInstance(config);
HazelcastInstance node2 = factory.newHazelcastInstance(config);
final IMap<Integer, Integer> map1 = node1.getMap(mapName);
final IMap<Integer, Integer> map2 = node2.getMap(mapName);
int size = 1000;
// fill map-1
for (int i = 0; i < size; i++) {
map1.put(i, i);
}
// fill Near Cache on node-1
for (int i = 0; i < size; i++) {
map1.get(i);
}
// fill Near Cache on node-2
for (int i = 0; i < size; i++) {
map2.get(i);
}
map1.clear();
assertTrueEventually(new AssertTask() {
@Override
public void run() {
NearCache nearCache1 = ((NearCachedMapProxyImpl) map1).getNearCache();
NearCache nearCache2 = ((NearCachedMapProxyImpl) map2).getNearCache();
assertEquals(0, nearCache1.size() + nearCache2.size());
}
});
}
Aggregations