Search in sources :

Example 16 with CacheEntryEventSerializableFilter

use of org.apache.ignite.cache.CacheEntryEventSerializableFilter in project ignite by apache.

the class GridP2PContinuousDeploymentClientDisconnectTest method testContinuousQueryRemoteFilter.

/**
 * Test starts 1 server node and 1 client node. Class-loading request for the {@link #P2P_TEST_OBJ_RSRC_NAME}
 * resource blocks on the client node. The client node tries to deploy CQ with remote filter for
 * the cache {@link #DEFAULT_CACHE_NAME}.
 * Expected that exception with 'Failed to unmarshal deployable object.' error message will be thrown and
 * the server node wouldn't be failed.
 *
 * @throws Exception If failed.
 */
@Test
public void testContinuousQueryRemoteFilter() throws Exception {
    final Class<CacheEntryEventSerializableFilter<Integer, Integer>> rmtFilterCls = (Class<CacheEntryEventSerializableFilter<Integer, Integer>>) getExternalClassLoader().loadClass(REMOTE_FILTER_CLS_NAME);
    ContinuousQuery<Integer, Integer> qry = new ContinuousQuery<Integer, Integer>().setLocalListener(evts -> {
    // No-op.
    }).setRemoteFilter(rmtFilterCls.newInstance());
    IgniteEx client = grid(1);
    LogListener lsnr = LogListener.matches("Failed to unmarshal deployable object.").build();
    testLog.registerListener(lsnr);
    IgniteCache<Integer, Integer> cache = client.cache(DEFAULT_CACHE_NAME);
    assertThrowsWithCause(() -> cache.query(qry), CacheException.class);
    assertTrue(lsnr.check());
    // Check that the failure handler was not called.
    assertFalse(failure.get());
}
Also used : ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger) LogListener(org.apache.ignite.testframework.LogListener) AbstractContinuousQuery(org.apache.ignite.cache.query.AbstractContinuousQuery) IgniteBiPredicate(org.apache.ignite.lang.IgniteBiPredicate) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) CacheEntryEventSerializableFilter(org.apache.ignite.cache.CacheEntryEventSerializableFilter) IgniteEx(org.apache.ignite.internal.IgniteEx) TOPIC_CLASSLOAD(org.apache.ignite.internal.GridTopic.TOPIC_CLASSLOAD) GridKernalContext(org.apache.ignite.internal.GridKernalContext) GridDeploymentManager(org.apache.ignite.internal.managers.deployment.GridDeploymentManager) AbstractFailureHandler(org.apache.ignite.failure.AbstractFailureHandler) CacheEntryEventFilter(javax.cache.event.CacheEntryEventFilter) FailureContext(org.apache.ignite.failure.FailureContext) IgniteClosure(org.apache.ignite.lang.IgniteClosure) IgnitePredicate(org.apache.ignite.lang.IgnitePredicate) GridDeploymentRequest(org.apache.ignite.internal.managers.deployment.GridDeploymentRequest) CacheException(javax.cache.CacheException) GridMessageListener(org.apache.ignite.internal.managers.communication.GridMessageListener) Factory(javax.cache.configuration.Factory) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) GridTestUtils.assertThrowsWithCause(org.apache.ignite.testframework.GridTestUtils.assertThrowsWithCause) EventType(org.apache.ignite.events.EventType) IgniteException(org.apache.ignite.IgniteException) Event(org.apache.ignite.events.Event) Test(org.junit.Test) UUID(java.util.UUID) Ignite(org.apache.ignite.Ignite) ContinuousQuery(org.apache.ignite.cache.query.ContinuousQuery) IgniteCache(org.apache.ignite.IgniteCache) GridTestUtils(org.apache.ignite.testframework.GridTestUtils) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) CacheEntryEvent(javax.cache.event.CacheEntryEvent) ContinuousQueryWithTransformer(org.apache.ignite.cache.query.ContinuousQueryWithTransformer) CacheEntryEventSerializableFilter(org.apache.ignite.cache.CacheEntryEventSerializableFilter) AbstractContinuousQuery(org.apache.ignite.cache.query.AbstractContinuousQuery) ContinuousQuery(org.apache.ignite.cache.query.ContinuousQuery) LogListener(org.apache.ignite.testframework.LogListener) IgniteEx(org.apache.ignite.internal.IgniteEx) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Aggregations

CacheEntryEventSerializableFilter (org.apache.ignite.cache.CacheEntryEventSerializableFilter)16 CacheEntryEvent (javax.cache.event.CacheEntryEvent)12 Test (org.junit.Test)10 ContinuousQuery (org.apache.ignite.cache.query.ContinuousQuery)9 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)8 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)7 Ignite (org.apache.ignite.Ignite)6 IgniteCache (org.apache.ignite.IgniteCache)6 UUID (java.util.UUID)5 CacheEntryListenerException (javax.cache.event.CacheEntryListenerException)5 ContinuousQueryWithTransformer (org.apache.ignite.cache.query.ContinuousQueryWithTransformer)5 FactoryBuilder (javax.cache.configuration.FactoryBuilder)4 CacheEntryEventFilter (javax.cache.event.CacheEntryEventFilter)4 CacheEntryUpdatedListener (javax.cache.event.CacheEntryUpdatedListener)4 IgniteException (org.apache.ignite.IgniteException)4 IgniteClosure (org.apache.ignite.lang.IgniteClosure)4 GridTestUtils.waitForCondition (org.apache.ignite.testframework.GridTestUtils.waitForCondition)4 CountDownLatch (java.util.concurrent.CountDownLatch)3 Cache (javax.cache.Cache)3 MutableCacheEntryListenerConfiguration (javax.cache.configuration.MutableCacheEntryListenerConfiguration)3