use of com.hazelcast.client.proxy.NearCachedClientMapProxy in project hazelcast by hazelcast.
the class ClientMapNearCacheStaleReadTest method flushClientNearCache.
/**
* Flush Near Cache from client map with Near Cache.
* <p>
* Warning: this uses Hazelcast internals which might change from one version to the other.
*/
private void flushClientNearCache(IMap map) {
if (!(map instanceof NearCachedClientMapProxy)) {
return;
}
NearCachedClientMapProxy clientMapProxy = (NearCachedClientMapProxy) map;
clientMapProxy.getNearCache().clear();
}
use of com.hazelcast.client.proxy.NearCachedClientMapProxy in project hazelcast by hazelcast.
the class ClientMapNearCacheTest method receives_one_clearEvent_after_mapEvictAll_call_from_client.
@Test
public void receives_one_clearEvent_after_mapEvictAll_call_from_client() {
// populate Near Cache
IMap<Integer, Integer> clientMap = getNearCachedMapFromClient(newNearCacheConfig());
populateMap(clientMap, 1000);
populateNearCache(clientMap, 1000);
// add test listener to count clear events
final ClearEventCounterEventHandler handler = new ClearEventCounterEventHandler();
((NearCachedClientMapProxy) clientMap).addNearCacheInvalidationListener(handler);
// call evictAll
HazelcastInstance anotherClient = hazelcastFactory.newHazelcastClient(newClientConfig());
IMap<Object, Object> anotherClientMap = anotherClient.getMap(clientMap.getName());
anotherClientMap.evictAll();
// sleep for a while to see there is another clear event coming
sleepSeconds(2);
assertTrueEventually(new AssertTask() {
@Override
public void run() {
assertEquals("Expecting only 1 clear event", 1, handler.getClearEventCount());
}
});
}
use of com.hazelcast.client.proxy.NearCachedClientMapProxy 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.client.proxy.NearCachedClientMapProxy in project hazelcast by hazelcast.
the class ClientMapNearCacheTest method receives_one_clearEvent_after_mapClear_call_from_client.
@Test
public void receives_one_clearEvent_after_mapClear_call_from_client() {
// populate Near Cache
IMap<Integer, Integer> clientMap = getNearCachedMapFromClient(newNearCacheConfig());
populateMap(clientMap, 1000);
populateNearCache(clientMap, 1000);
// add test listener to count clear events
final ClearEventCounterEventHandler handler = new ClearEventCounterEventHandler();
((NearCachedClientMapProxy) clientMap).addNearCacheInvalidationListener(handler);
// create a new client to send events
HazelcastInstance anotherClient = hazelcastFactory.newHazelcastClient(newClientConfig());
IMap<Object, Object> anotherClientMap = anotherClient.getMap(clientMap.getName());
anotherClientMap.clear();
// sleep for a while to see there is another clear event coming
sleepSeconds(2);
assertTrueEventually(new AssertTask() {
@Override
public void run() {
assertEquals("Expecting only 1 clear event", 1, handler.getClearEventCount());
}
});
}
Aggregations