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 8628A17217 for ; Tue, 12 May 2015 12:00:15 +0000 (UTC) Received: (qmail 8086 invoked by uid 500); 12 May 2015 12:00:15 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 8056 invoked by uid 500); 12 May 2015 12:00:15 -0000 Mailing-List: contact commits-help@ignite.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.incubator.apache.org Delivered-To: mailing list commits@ignite.incubator.apache.org Received: (qmail 8047 invoked by uid 99); 12 May 2015 12:00:15 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 May 2015 12:00:15 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id F16C918294F for ; Tue, 12 May 2015 12:00:14 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.771 X-Spam-Level: * X-Spam-Status: No, score=1.771 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, T_RP_MATCHES_RCVD=-0.01, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id px9K1S1siT0z for ; Tue, 12 May 2015 12:00:04 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with SMTP id 392BD20524 for ; Tue, 12 May 2015 12:00:04 +0000 (UTC) Received: (qmail 7906 invoked by uid 99); 12 May 2015 12:00:03 -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; Tue, 12 May 2015 12:00:03 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id A1AF8E17DD; Tue, 12 May 2015 12:00:03 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sboikov@apache.org To: commits@ignite.incubator.apache.org Date: Tue, 12 May 2015 12:00:03 -0000 Message-Id: <26866d85ec064672b4bf298aecd81514@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/5] incubator-ignite git commit: #ignite-373: add test. Repository: incubator-ignite Updated Branches: refs/heads/ignite-373 7b77ba92a -> ceb283542 #ignite-373: add test. Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/656ffc09 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/656ffc09 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/656ffc09 Branch: refs/heads/ignite-373 Commit: 656ffc09d99d58d2b42ec8e904659e6437fde10e Parents: 61808ed Author: ivasilinets Authored: Thu May 7 18:22:25 2015 +0300 Committer: ivasilinets Committed: Thu May 7 18:22:25 2015 +0300 ---------------------------------------------------------------------- .../CacheContinuousQueryRestartSelfTest.java | 145 +++++++++++++++++++ ...ridCacheContinuousQueryAbstractSelfTest.java | 35 ----- .../junits/common/GridCommonAbstractTest.java | 37 +++++ .../IgniteCacheQuerySelfTestSuite.java | 1 + 4 files changed, 183 insertions(+), 35 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/656ffc09/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryRestartSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryRestartSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryRestartSelfTest.java new file mode 100644 index 0000000..039d184 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryRestartSelfTest.java @@ -0,0 +1,145 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.cache.query.continuous; + +import org.apache.ignite.*; +import org.apache.ignite.cache.*; +import org.apache.ignite.cache.query.*; +import org.apache.ignite.configuration.*; +import org.apache.ignite.internal.*; +import org.apache.ignite.marshaller.optimized.*; +import org.apache.ignite.spi.discovery.tcp.*; +import org.apache.ignite.spi.discovery.tcp.ipfinder.*; +import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*; +import org.apache.ignite.testframework.*; +import org.apache.ignite.testframework.junits.common.*; +import org.jsr166.*; + +import javax.cache.*; +import javax.cache.event.*; + +import java.util.*; +import java.util.concurrent.atomic.*; + +import static org.apache.ignite.cache.CacheRebalanceMode.*; +import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*; + +/** + * Continuous queries test. + */ +public class CacheContinuousQueryRestartSelfTest extends GridCommonAbstractTest { + /** IP finder. */ + private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); + + /** Grid count. */ + private static final int GRID_COUNT = 3; + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(gridName); + + CacheConfiguration cacheCfg = defaultCacheConfiguration(); + + cacheCfg.setCacheMode(CacheMode.PARTITIONED); + cacheCfg.setBackups(2); + cacheCfg.setRebalanceMode(ASYNC); + cacheCfg.setWriteSynchronizationMode(FULL_SYNC); + cacheCfg.setReadThrough(true); + cacheCfg.setWriteThrough(true); + cacheCfg.setCacheStoreFactory(new StoreFactory()); + cacheCfg.setLoadPreviousValue(true); + + cfg.setCacheConfiguration(cacheCfg); + + TcpDiscoverySpi disco = new TcpDiscoverySpi(); + + disco.setIpFinder(IP_FINDER); + + cfg.setDiscoverySpi(disco); + + cfg.setMarshaller(new OptimizedMarshaller(false)); + + return cfg; + } + + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + startGrids(GRID_COUNT); + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + stopAllGrids(); + } + + /** + * @throws Exception If failed. + */ + public void testNodeJoin() throws Exception { + final ContinuousQuery qry = new ContinuousQuery<>(); + + final Collection> all = new ConcurrentLinkedDeque8<>(); + + qry.setLocalListener(new CacheEntryUpdatedListener() { + @Override public void onUpdated(Iterable> evts) { + for (CacheEntryEvent evt : evts) + all.add(evt); + } + }); + + final AtomicInteger id = new AtomicInteger(GRID_COUNT); + + final int keyCount = 1000; + + final Random random = new Random(keyCount); + + IgniteInternalFuture fut = GridTestUtils.runMultiThreadedAsync(new Runnable() { + @Override public void run() { + for (int i = 0; i < 2; ++i) { + IgniteCache cache = grid(0).cache(null); + + int gridId = id.getAndIncrement(); + + try (QueryCursor> ignored = grid(0).cache(null).query(qry)) { + cache.put(0, 0); + + startGrid(gridId); + + for (int j = 1; j < 40; j++) + cache.put(random.nextInt(), j); + } + catch (Exception e) { + throw new IgniteException(e); + } + } + } + }, 5, "QueryThread"); + + fut.get(); + + for (int i = 0; i < id.get(); i++) { + IgniteCache cache = grid(i).cache(null); + + cache.removeAll(); + } + + for (int i = 0; i < GRID_COUNT; i++) + assertEquals("Cache is not empty [entrySet=" + grid(i).cache(null).localEntries() + + ", i=" + i + ']', 0, grid(i).cache(null).localSize()); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/656ffc09/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryAbstractSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryAbstractSelfTest.java index 5a78f9f..d652cba 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryAbstractSelfTest.java @@ -989,39 +989,4 @@ public abstract class GridCacheContinuousQueryAbstractSelfTest extends GridCommo } } } - - /** - * - */ - private static class StoreFactory implements Factory { - @Override public CacheStore create() { - return new TestStore(); - } - } - - /** - * Store. - */ - private static class TestStore extends CacheStoreAdapter { - /** {@inheritDoc} */ - @Override public void loadCache(IgniteBiInClosure clo, Object... args) { - for (int i = 0; i < 10; i++) - clo.apply(i, i); - } - - /** {@inheritDoc} */ - @Nullable @Override public Object load(Object key) { - return null; - } - - /** {@inheritDoc} */ - @Override public void write(javax.cache.Cache.Entry entry) throws CacheWriterException { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void delete(Object key) throws CacheWriterException { - // No-op. - } - } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/656ffc09/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java index 5533897..8022a7a 100644 --- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java @@ -20,6 +20,7 @@ package org.apache.ignite.testframework.junits.common; import org.apache.ignite.*; import org.apache.ignite.cache.*; import org.apache.ignite.cache.affinity.*; +import org.apache.ignite.cache.store.*; import org.apache.ignite.cluster.*; import org.apache.ignite.compute.*; import org.apache.ignite.configuration.*; @@ -38,6 +39,7 @@ import org.apache.ignite.testframework.junits.*; import org.jetbrains.annotations.*; import javax.cache.*; +import javax.cache.configuration.*; import javax.cache.integration.*; import javax.net.ssl.*; import java.util.*; @@ -858,4 +860,39 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest { ccfg.getAtomicWriteOrderMode() == CacheAtomicWriteOrderMode.CLOCK) U.sleep(50); } + + /** + * + */ + public static class StoreFactory implements Factory { + @Override public CacheStore create() { + return new TestStore(); + } + } + + /** + * Store. + */ + public static class TestStore extends CacheStoreAdapter { + /** {@inheritDoc} */ + @Override public void loadCache(IgniteBiInClosure clo, Object... args) { + for (int i = 0; i < 10; i++) + clo.apply(i, i); + } + + /** {@inheritDoc} */ + @Nullable @Override public Object load(Object key) { + return null; + } + + /** {@inheritDoc} */ + @Override public void write(javax.cache.Cache.Entry entry) throws CacheWriterException { + // No-op. + } + + /** {@inheritDoc} */ + @Override public void delete(Object key) throws CacheWriterException { + // No-op. + } + } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/656ffc09/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java index 69d7548..da3bf5c 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java +++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java @@ -92,6 +92,7 @@ public class IgniteCacheQuerySelfTestSuite extends TestSuite { suite.addTestSuite(GridCacheContinuousQueryAtomicSelfTest.class); suite.addTestSuite(GridCacheContinuousQueryAtomicNearEnabledSelfTest.class); suite.addTestSuite(GridCacheContinuousQueryAtomicP2PDisabledSelfTest.class); + suite.addTestSuite(CacheContinuousQueryRestartSelfTest.class); // Reduce fields queries. suite.addTestSuite(GridCacheReduceFieldsQueryLocalSelfTest.class);