use of com.hazelcast.map.EventLostEvent in project hazelcast by hazelcast.
the class InternalQueryCacheListenerAdapter method onEvent.
@Override
public void onEvent(IMapEvent event) {
EntryEventType eventType = event.getEventType();
if (eventType != null) {
callListener(event, eventType.getType());
return;
}
if (event instanceof EventLostEvent) {
EventLostEvent eventLostEvent = (EventLostEvent) event;
callListener(eventLostEvent, EventLostEvent.EVENT_TYPE);
return;
}
}
use of com.hazelcast.map.EventLostEvent in project hazelcast by hazelcast.
the class ClientQueryCacheRecoveryUponEventLossTest method testForceConsistency.
@Test
public void testForceConsistency() {
String mapName = randomMapName("map");
String queryCacheName = randomMapName("cache");
Config config = new Config();
config.setProperty(PARTITION_COUNT.getName(), "1");
factory.newHazelcastInstance(config);
QueryCacheConfig queryCacheConfig = new QueryCacheConfig(queryCacheName);
queryCacheConfig.setBatchSize(1111);
queryCacheConfig.setDelaySeconds(3);
ClientConfig clientConfig = new ClientConfig();
clientConfig.addQueryCacheConfig(mapName, queryCacheConfig);
HazelcastInstance client = factory.newHazelcastClient(clientConfig);
IMap<Integer, Integer> map = client.getMap(mapName);
// set test sequencer to subscriber
int count = 30;
setTestSequencer(map, 9);
final QueryCache queryCache = map.getQueryCache(queryCacheName, new SqlPredicate("this > 20"), true);
queryCache.addEntryListener(new EventLostListener() {
@Override
public void eventLost(EventLostEvent event) {
queryCache.tryRecover();
}
}, false);
for (int i = 0; i < count; i++) {
map.put(i, i);
}
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertEquals(9, queryCache.size());
}
});
}
Aggregations