use of com.hazelcast.internal.nearcache.NearCache in project hazelcast by hazelcast.
the class DefaultNearCacheManager method destroyAllNearCaches.
@Override
public void destroyAllNearCaches() {
for (NearCache nearCache : new HashSet<NearCache>(nearCacheMap.values())) {
nearCacheMap.remove(nearCache.getName());
nearCache.destroy();
}
for (ScheduledFuture preloadTaskFuture : preloadTaskFutures) {
preloadTaskFuture.cancel(true);
}
if (storageTaskFuture != null) {
storageTaskFuture.cancel(true);
}
}
use of com.hazelcast.internal.nearcache.NearCache in project hazelcast by hazelcast.
the class NearCacheBatchInvalidationTest method testBatchInvalidationRemovesEntries.
@Test
public void testBatchInvalidationRemovesEntries() throws Exception {
String mapName = randomMapName();
Config config = newConfig(mapName);
config.setProperty(GroupProperty.PARTITION_COUNT.getName(), "1");
configureBatching(config, true, 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() throws Exception {
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 NearCacheLiteMemberTest method testPutAll.
public static void testPutAll(HazelcastInstance instance, HazelcastInstance lite, String mapName) {
IMap<Object, Object> map = instance.getMap(mapName);
IMap<Object, Object> liteMap = lite.getMap(mapName);
NearCachedMapProxyImpl proxy = (NearCachedMapProxyImpl) liteMap;
NearCache liteNearCache = proxy.getNearCache();
SerializationService serializationService = ((SerializationServiceSupport) instance).getSerializationService();
int count = 100;
// fill the near cache with the same data as below so we can detect when it is emptied
for (int i = 0; i < count; i++) {
liteNearCache.put(serializationService.toData(i), i);
}
final NearCacheStats stats = liteNearCache.getNearCacheStats();
assertEquals(100, stats.getOwnedEntryCount());
Map<Object, Object> localMap = new HashMap<Object, Object>();
for (int i = 0; i < count; i++) {
localMap.put(i, i);
}
map.putAll(localMap);
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertEquals(0, stats.getOwnedEntryCount());
}
});
for (int i = 0; i < count; i++) {
liteMap.get(i);
}
assertLiteMemberNearCacheNonEmpty(lite, mapName);
}
use of com.hazelcast.internal.nearcache.NearCache in project hazelcast by hazelcast.
the class NearCacheLiteMemberTest method assertLiteMemberNearCacheNonEmpty.
private static void assertLiteMemberNearCacheNonEmpty(HazelcastInstance instance, String mapName) {
NearCache nearCache = getNearCache(instance, mapName);
int sizeAfterPut = nearCache.size();
assertTrue("Near Cache size should be > 0 but was " + sizeAfterPut, sizeAfterPut > 0);
}
use of com.hazelcast.internal.nearcache.NearCache in project hazelcast by hazelcast.
the class ClientCacheRecordStateStressTest method assertFinalRecordStateIsReadPermitted.
private void assertFinalRecordStateIsReadPermitted(Cache clientCache, HazelcastInstance member) {
ClientCacheProxy proxy = ((ClientCacheProxy) clientCache);
NearCache nearCache = proxy.getNearCache();
DefaultNearCache unwrap = (DefaultNearCache) nearCache.unwrap(DefaultNearCache.class);
InternalSerializationService ss = getSerializationService(member);
for (int i = 0; i < KEY_SPACE; i++) {
Data key = ss.toData(i);
AbstractNearCacheRecordStore nearCacheRecordStore = (AbstractNearCacheRecordStore) unwrap.getNearCacheRecordStore();
NearCacheRecord record = nearCacheRecordStore.getRecord(key);
if (record != null) {
assertEquals(record.toString(), READ_PERMITTED, record.getRecordState());
}
}
}
Aggregations