use of com.hazelcast.internal.nearcache.NearCache in project hazelcast by hazelcast.
the class NearCacheManagerTestSupport method doDestroyNearCacheAndDestroyAllNearCaches.
void doDestroyNearCacheAndDestroyAllNearCaches() {
NearCacheManager nearCacheManager = createNearCacheManager();
for (int i = 0; i < DEFAULT_NEAR_CACHE_COUNT; i++) {
createNearCache(nearCacheManager, DEFAULT_NEAR_CACHE_NAME + "-" + i);
}
Collection<NearCache> nearCaches1 = nearCacheManager.listAllNearCaches();
assertEquals(DEFAULT_NEAR_CACHE_COUNT, nearCaches1.size());
for (int i = 0; i < DEFAULT_NEAR_CACHE_COUNT; i++) {
assertTrue(nearCacheManager.destroyNearCache(DEFAULT_NEAR_CACHE_NAME + "-" + i));
}
Collection<NearCache> nearCaches2 = nearCacheManager.listAllNearCaches();
// destroy also removes Near Cache
assertEquals(0, nearCaches2.size());
assertFalse(nearCacheManager.clearNearCache(DEFAULT_NEAR_CACHE_NAME + "-" + DEFAULT_NEAR_CACHE_COUNT));
for (int i = 0; i < DEFAULT_NEAR_CACHE_COUNT; i++) {
createNearCache(nearCacheManager, DEFAULT_NEAR_CACHE_NAME + "-" + i);
}
Collection<NearCache> nearCaches3 = nearCacheManager.listAllNearCaches();
assertEquals(DEFAULT_NEAR_CACHE_COUNT, nearCaches3.size());
nearCacheManager.destroyAllNearCaches();
Collection<NearCache> nearCaches4 = nearCacheManager.listAllNearCaches();
// destroy all also removes Near Caches
assertEquals(0, nearCaches4.size());
}
use of com.hazelcast.internal.nearcache.NearCache in project hazelcast by hazelcast.
the class ClientMapNearCacheTest method receives_one_clearEvent_after_mapLoadAll_call_from_member.
@Test
public void receives_one_clearEvent_after_mapLoadAll_call_from_member() {
// configure map-store
Config config = newConfig();
config.getMapConfig("default").getMapStoreConfig().setEnabled(true).setImplementation(new SimpleMapStore());
// populate Near Cache
NearCacheConfig nearCacheConfig = newNearCacheConfig();
final IMap<Integer, Integer> clientMap = getNearCachedMapFromClient(config, nearCacheConfig, 2);
populateMap(clientMap, 1000);
populateNearCache(clientMap, 1000);
HazelcastInstance member = hazelcastFactory.getAllHazelcastInstances().iterator().next();
IMap<Object, Object> memberMap = member.getMap(clientMap.getName());
memberMap.loadAll(true);
InternalSerializationService serializationService = getSerializationService(member);
assertTrueEventually(new AssertTask() {
@Override
public void run() {
NearCache<Object, Object> nearCache = ((NearCachedClientMapProxy<Integer, Integer>) clientMap).getNearCache();
for (int i = 0; i < 1000; i++) {
Object key = i;
if (nearCacheConfig.isSerializeKeys()) {
key = serializationService.toData(i);
}
assertNull("Near Cache should be empty", nearCache.get(key));
}
}
});
}
use of com.hazelcast.internal.nearcache.NearCache in project hazelcast by hazelcast.
the class MapNearCacheInvalidationFromClientTest method testEvict.
@Test
public void testEvict() {
IMap<Object, Object> map = client.getMap(mapName);
final int count = 100;
for (int i = 0; i < count; i++) {
map.put(i, i);
}
final IMap<Object, Object> liteMap = lite.getMap(mapName);
final NearCache nearCache = getNearCache(lite, mapName);
assertTrueEventually(new AssertTask() {
@Override
public void run() {
for (int i = 0; i < count; i++) {
liteMap.get(i);
}
assertEquals(count, nearCache.size());
}
});
map.evict(0);
assertTrueEventually(new AssertTask() {
@Override
public void run() {
assertTrue(nearCache.size() < count);
}
});
}
use of com.hazelcast.internal.nearcache.NearCache in project hazelcast by hazelcast.
the class MapNearCacheInvalidationFromClientTest method testEvictAll.
@Test
public void testEvictAll() {
IMap<Object, Object> map = client.getMap(mapName);
final int count = 100;
for (int i = 0; i < count; i++) {
map.put(i, i);
}
final IMap<Object, Object> liteMap = lite.getMap(mapName);
final NearCache nearCache = getNearCache(lite, mapName);
assertTrueEventually(new AssertTask() {
@Override
public void run() {
for (int i = 0; i < count; i++) {
liteMap.get(i);
}
assertEquals(count, nearCache.size());
}
});
map.evictAll();
assertTrueEventually(new AssertTask() {
@Override
public void run() {
assertTrue(nearCache.size() < count);
}
});
}
use of com.hazelcast.internal.nearcache.NearCache in project hazelcast by hazelcast.
the class MapNearCacheInvalidationFromClientTest method testPut.
@Test
public void testPut() {
IMap<Object, Object> map = client.getMap(mapName);
int count = 100;
for (int i = 0; i < count; i++) {
map.put(i, i);
}
IMap<Object, Object> liteMap = lite.getMap(mapName);
for (int i = 0; i < count; i++) {
assertNotNull(liteMap.get(i));
}
NearCache nearCache = getNearCache(lite, mapName);
int sizeAfterPut = nearCache.size();
assertTrue("Near Cache size should be > 0 but was " + sizeAfterPut, sizeAfterPut > 0);
}
Aggregations