Return-Path: X-Original-To: apmail-ignite-commits-archive@minotaur.apache.org Delivered-To: apmail-ignite-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4ECD718DDB for ; Wed, 23 Sep 2015 01:36:31 +0000 (UTC) Received: (qmail 48138 invoked by uid 500); 23 Sep 2015 01:36:31 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 48042 invoked by uid 500); 23 Sep 2015 01:36:31 -0000 Mailing-List: contact commits-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list commits@ignite.apache.org Received: (qmail 47875 invoked by uid 99); 23 Sep 2015 01:36:31 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 Sep 2015 01:36:31 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id D759EE0571; Wed, 23 Sep 2015 01:36:30 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: agoncharuk@apache.org To: commits@ignite.apache.org Date: Wed, 23 Sep 2015 01:36:37 -0000 Message-Id: <1d7aaca529f049e1b4d9bdd0d217d5fc@git.apache.org> In-Reply-To: <323bccd76c734f259f63595b3b69c644@git.apache.org> References: <323bccd76c734f259f63595b3b69c644@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [08/23] ignite git commit: IGNITE-1522 - Made cache entry listener configurations transient in cache configuration IGNITE-1522 - Made cache entry listener configurations transient in cache configuration Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/e51fb420 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/e51fb420 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/e51fb420 Branch: refs/heads/ignite-1171 Commit: e51fb420d1284465c7cbe55a28c2374ddf67d495 Parents: 621eb0f Author: Valentin Kulichenko Authored: Mon Sep 21 23:29:20 2015 -0700 Committer: Valentin Kulichenko Committed: Mon Sep 21 23:29:20 2015 -0700 ---------------------------------------------------------------------- .../configuration/CacheConfiguration.java | 15 +++++ .../IgniteCacheEntryListenerAbstractTest.java | 65 +++++++++++++++++++- 2 files changed, 79 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/e51fb420/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java index 7d1e14d..44a3fa9 100644 --- a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java +++ b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java @@ -19,6 +19,7 @@ package org.apache.ignite.configuration; import java.io.Serializable; import java.util.Collection; +import java.util.HashSet; import javax.cache.Cache; import javax.cache.configuration.CompleteConfiguration; import javax.cache.configuration.Factory; @@ -1799,6 +1800,20 @@ public class CacheConfiguration extends MutableConfiguration { return this; } + /** + * Creates a copy of current configuration and removes all cache entry listeners. + * They are executed only locally and should never be sent to remote nodes. + * + * @return Configuration object that will be serialized. + */ + protected Object writeReplace() { + CacheConfiguration cfg = new CacheConfiguration<>(this); + + cfg.listenerConfigurations = new HashSet<>(); + + return cfg; + } + /** {@inheritDoc} */ @Override public String toString() { return S.toString(CacheConfiguration.class, this); http://git-wip-us.apache.org/repos/asf/ignite/blob/e51fb420/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerAbstractTest.java index 78a6700..3fdd7fc 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerAbstractTest.java @@ -17,6 +17,10 @@ package org.apache.ignite.internal.processors.cache; +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -32,11 +36,13 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicBoolean; import javax.cache.configuration.CacheEntryListenerConfiguration; import javax.cache.configuration.Factory; +import javax.cache.configuration.FactoryBuilder; import javax.cache.configuration.MutableCacheEntryListenerConfiguration; import javax.cache.event.CacheEntryCreatedListener; import javax.cache.event.CacheEntryEvent; import javax.cache.event.CacheEntryExpiredListener; import javax.cache.event.CacheEntryListener; +import javax.cache.event.CacheEntryListenerException; import javax.cache.event.CacheEntryRemovedListener; import javax.cache.event.CacheEntryUpdatedListener; import javax.cache.event.EventType; @@ -358,6 +364,34 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb } /** + * @throws Exception If failed. + */ + public void testSerialization() throws Exception { + if (cacheMode() == LOCAL) + return; + + AtomicBoolean serialized = new AtomicBoolean(); + + NonSerializableListener lsnr = new NonSerializableListener(serialized); + + jcache(0).registerCacheEntryListener(new MutableCacheEntryListenerConfiguration<>( + FactoryBuilder.factoryOf(lsnr), + null, + true, + false + )); + + try { + startGrid(gridCount()); + } + finally { + stopGrid(gridCount()); + } + + assertFalse(serialized.get()); + } + + /** * @param key Key. * @param val Value. * @param cache Cache. @@ -1190,4 +1224,33 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb } } -} \ No newline at end of file + /** + */ + public static class NonSerializableListener implements CacheEntryCreatedListener, Externalizable { + /** */ + private final AtomicBoolean serialized; + + /** + * @param serialized Serialized flag. + */ + public NonSerializableListener(AtomicBoolean serialized) { + this.serialized = serialized; + } + + /** {@inheritDoc} */ + @Override public void onCreated(Iterable> evts) + throws CacheEntryListenerException { + // No-op. + } + + /** {@inheritDoc} */ + @Override public void writeExternal(ObjectOutput out) throws IOException { + serialized.set(true); + } + + /** {@inheritDoc} */ + @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + // No-op. + } + } +}