use of org.apache.ignite.events.CacheQueryExecutedEvent in project ignite by apache.
the class IgniteSqlSkipReducerOnUpdateDmlSelfTest method testEvents.
/**
* @throws Exception if failed.
*/
@Test
public void testEvents() throws Exception {
final CountDownLatch latch = new CountDownLatch(NODE_COUNT);
final IgnitePredicate<Event> pred = new IgnitePredicate<Event>() {
@Override
public boolean apply(Event evt) {
assert evt instanceof CacheQueryExecutedEvent;
CacheQueryExecutedEvent qe = (CacheQueryExecutedEvent) evt;
assertNotNull(qe.clause());
latch.countDown();
return true;
}
};
for (int idx = 0; idx < NODE_COUNT; idx++) grid(idx).events().localListen(pred, EVT_CACHE_QUERY_EXECUTED);
IgniteCache<Integer, Organization> cache = grid(NODE_CLIENT).cache(CACHE_ORG);
for (int i = 0; i < 1024; i++) cache.put(i, new Organization("Acme Inc #" + i, 0));
cache.query(new SqlFieldsQueryEx("UPDATE \"org\".Organization o SET name = UPPER(name)", false).setSkipReducerOnUpdate(true)).getAll();
assertTrue(latch.await(5000, MILLISECONDS));
for (int idx = 0; idx < NODE_COUNT; idx++) grid(idx).events().stopLocalListen(pred);
}
Aggregations