use of com.hazelcast.internal.nearcache.NearCache in project hazelcast by hazelcast.
the class ClientMapRecordStateStressTest method assertFinalRecordStateIsReadPermitted.
private void assertFinalRecordStateIsReadPermitted(IMap clientMap, InternalSerializationService ss) {
NearCachedClientMapProxy proxy = (NearCachedClientMapProxy) clientMap;
NearCache nearCache = proxy.getNearCache();
DefaultNearCache unwrap = (DefaultNearCache) nearCache.unwrap(DefaultNearCache.class);
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());
}
}
}
use of com.hazelcast.internal.nearcache.NearCache in project hazelcast by hazelcast.
the class EvictionChecker method getUsedHeapInBytes.
protected long getUsedHeapInBytes(String mapName) {
long heapCost = 0L;
final List<Integer> partitionIds = findPartitionIds();
for (int partitionId : partitionIds) {
final PartitionContainer container = mapServiceContext.getPartitionContainer(partitionId);
if (container == null) {
continue;
}
heapCost += getRecordStoreHeapCost(mapName, container);
}
MapContainer mapContainer = mapServiceContext.getMapContainer(mapName);
if (!mapContainer.getMapConfig().isNearCacheEnabled()) {
return heapCost;
}
MapNearCacheManager mapNearCacheManager = mapServiceContext.getMapNearCacheManager();
NearCache nearCache = mapNearCacheManager.getNearCache(mapName);
NearCacheStats nearCacheStats = nearCache.getNearCacheStats();
heapCost += nearCacheStats.getOwnedEntryMemoryCost();
return heapCost;
}
use of com.hazelcast.internal.nearcache.NearCache in project hazelcast by hazelcast.
the class NearCacheLiteMemberTest method assertNearCacheIsEmptyEventually.
private static void assertNearCacheIsEmptyEventually(HazelcastInstance instance, String mapName) {
final NearCache nearCache = getNearCache(instance, mapName);
assertTrueEventually(new AssertTask() {
@Override
public void run() {
int size = nearCache.size();
assertEquals("Lite member Near Cache size should be 0 after evict but was " + size, 0, size);
}
});
}
use of com.hazelcast.internal.nearcache.NearCache in project hazelcast by hazelcast.
the class NearCacheBatchInvalidationTest method testHigherBatchSize_shouldNotCauseAnyInvalidation_onRemoteNode.
@Test
public void testHigherBatchSize_shouldNotCauseAnyInvalidation_onRemoteNode() throws Exception {
String mapName = randomMapName();
Config config = newConfig(mapName);
configureBatching(config, true, Integer.MAX_VALUE, Integer.MAX_VALUE);
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory();
HazelcastInstance node1 = factory.newHazelcastInstance(config);
HazelcastInstance node2 = factory.newHazelcastInstance(config);
IMap<String, Integer> map1 = node1.getMap(mapName);
IMap<String, Integer> map2 = node2.getMap(mapName);
int size = 1000;
List<String> keys = new ArrayList<String>();
for (int i = 0; i < size; i++) {
keys.add(generateKeyOwnedBy(node1));
}
// fill map-1
for (int i = 0; i < size; i++) {
map1.put(keys.get(i), i);
}
// fill Near Cache on node-1
for (int i = 0; i < size; i++) {
map1.get(keys.get(i));
}
// fill Near Cache on node-2
for (int i = 0; i < size; i++) {
map2.get(keys.get(i));
}
// generate invalidation data
for (int i = 0; i < size; i++) {
map1.put(keys.get(i), i);
}
NearCache nearCache1 = ((NearCachedMapProxyImpl) map1).getNearCache();
NearCache nearCache2 = ((NearCachedMapProxyImpl) map2).getNearCache();
// Near Cache on one node should be invalidated wholly, other node should not receive any event.
// Due to the higher batch-size to sent invalidation.
assertEquals(size, nearCache1.size() + nearCache2.size());
}
use of com.hazelcast.internal.nearcache.NearCache in project hazelcast by hazelcast.
the class NearCacheBatchInvalidationTest method testMapEvictAll_shouldClearNearCaches_onOwnerAndBackupNodes.
@Test
public void testMapEvictAll_shouldClearNearCaches_onOwnerAndBackupNodes() throws Exception {
String mapName = randomMapName();
Config config = newConfig(mapName);
config.setProperty(GroupProperty.PARTITION_COUNT.getName(), "1");
configureBatching(config, true, 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() throws Exception {
NearCache nearCache1 = ((NearCachedMapProxyImpl) map1).getNearCache();
NearCache nearCache2 = ((NearCachedMapProxyImpl) map2).getNearCache();
assertEquals(0, nearCache1.size() + nearCache2.size());
}
});
}
Aggregations