Search in sources :

Example 11 with CacheQueryExecutedEvent

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);
}
Also used : IgnitePredicate(org.apache.ignite.lang.IgnitePredicate) SqlFieldsQueryEx(org.apache.ignite.internal.processors.cache.query.SqlFieldsQueryEx) CacheQueryExecutedEvent(org.apache.ignite.events.CacheQueryExecutedEvent) Event(org.apache.ignite.events.Event) CountDownLatch(java.util.concurrent.CountDownLatch) CacheQueryExecutedEvent(org.apache.ignite.events.CacheQueryExecutedEvent) AbstractIndexingCommonTest(org.apache.ignite.internal.processors.cache.index.AbstractIndexingCommonTest) Test(org.junit.Test)

Aggregations

CacheQueryExecutedEvent (org.apache.ignite.events.CacheQueryExecutedEvent)11 Event (org.apache.ignite.events.Event)10 IgnitePredicate (org.apache.ignite.lang.IgnitePredicate)10 CountDownLatch (java.util.concurrent.CountDownLatch)9 CacheQueryReadEvent (org.apache.ignite.events.CacheQueryReadEvent)9 Test (org.junit.Test)6 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)5 NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)5 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)5 SqlQueryExecutionEvent (org.apache.ignite.events.SqlQueryExecutionEvent)4 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 UUID (java.util.UUID)2 IgniteException (org.apache.ignite.IgniteException)2 SqlQuery (org.apache.ignite.cache.query.SqlQuery)2 ClusterNode (org.apache.ignite.cluster.ClusterNode)2 CacheEvent (org.apache.ignite.events.CacheEvent)2 JobEvent (org.apache.ignite.events.JobEvent)2 TaskEvent (org.apache.ignite.events.TaskEvent)2