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 38D7B17671 for ; Wed, 24 Jun 2015 22:50:35 +0000 (UTC) Received: (qmail 57640 invoked by uid 500); 24 Jun 2015 22:50:35 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 57609 invoked by uid 500); 24 Jun 2015 22:50:35 -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 57561 invoked by uid 99); 24 Jun 2015 22:50:35 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 24 Jun 2015 22:50:35 +0000 X-ASF-Spam-Status: No, hits=-2001.4 required=5.0 tests=ALL_TRUSTED,RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO mail.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with SMTP; Wed, 24 Jun 2015 22:48:08 +0000 Received: (qmail 54485 invoked by uid 99); 24 Jun 2015 22:49:49 -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, 24 Jun 2015 22:49:49 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 73A8CE3621; Wed, 24 Jun 2015 22:49:49 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: vkulichenko@apache.org To: commits@ignite.incubator.apache.org Date: Wed, 24 Jun 2015 22:50:33 -0000 Message-Id: <3e28c8ff683c47489d18b87ed7cd72ba@git.apache.org> In-Reply-To: <92500060c8d74c6e8c4b0cec1dfe08c2@git.apache.org> References: <92500060c8d74c6e8c4b0cec1dfe08c2@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [46/49] incubator-ignite git commit: #ignite-1043: Add tests for read through flag. X-Virus-Checked: Checked by ClamAV on apache.org #ignite-1043: Add tests for read through flag. Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/bf1ea21b Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/bf1ea21b Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/bf1ea21b Branch: refs/heads/ignite-1026 Commit: bf1ea21b2f2ff6964b8e13e821b5194243855ff4 Parents: b3e2bd4 Author: ivasilinets Authored: Wed Jun 24 11:30:15 2015 +0300 Committer: ivasilinets Committed: Wed Jun 24 11:30:15 2015 +0300 ---------------------------------------------------------------------- .../processors/cache/GridCacheContext.java | 2 +- .../distributed/dht/GridDhtLockFuture.java | 2 +- .../CacheReadThroughAtomicRestartSelfTest.java | 32 +++++ ...heReadThroughLocalAtomicRestartSelfTest.java | 32 +++++ .../CacheReadThroughLocalRestartSelfTest.java | 32 +++++ ...dThroughReplicatedAtomicRestartSelfTest.java | 32 +++++ ...cheReadThroughReplicatedRestartSelfTest.java | 32 +++++ .../cache/CacheReadThroughRestartSelfTest.java | 133 +++++++++++++++++++ .../cache/GridCacheAbstractSelfTest.java | 2 +- .../IgniteCacheTxStoreSessionTest.java | 4 + .../testsuites/IgniteCacheTestSuite4.java | 7 + 11 files changed, 307 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bf1ea21b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java index 8a4e3b9..9b7801c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java @@ -1377,7 +1377,7 @@ public class GridCacheContext implements Externalizable { } /** - * @return {@code True} if store read-through mode is enabled. + * @return {@code True} if {@link CacheConfiguration#isLoadPreviousValue()} flag is set. */ public boolean loadPreviousValue() { return cacheCfg.isLoadPreviousValue(); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bf1ea21b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java index bdaa552..e160529 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java @@ -958,7 +958,7 @@ public final class GridDhtLockFuture extends GridCompoundIdentityFuture * */ private void loadMissingFromStore() { - if (!skipStore && cctx.loadPreviousValue() && cctx.readThrough() && (needReturnVal || read)) { + if (!skipStore && (read || cctx.loadPreviousValue()) && cctx.readThrough() && (needReturnVal || read)) { final Map loadMap = new LinkedHashMap<>(); final GridCacheVersion ver = version(); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bf1ea21b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheReadThroughAtomicRestartSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheReadThroughAtomicRestartSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheReadThroughAtomicRestartSelfTest.java new file mode 100644 index 0000000..3ac7c3c --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheReadThroughAtomicRestartSelfTest.java @@ -0,0 +1,32 @@ +/* + * 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; + +import org.apache.ignite.cache.*; + +import static org.apache.ignite.cache.CacheAtomicityMode.*; + +/** + * Test for read through store. + */ +public class CacheReadThroughAtomicRestartSelfTest extends CacheReadThroughRestartSelfTest { + /** {@inheritDoc} */ + @Override protected CacheAtomicityMode atomicityMode() { + return ATOMIC; + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bf1ea21b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheReadThroughLocalAtomicRestartSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheReadThroughLocalAtomicRestartSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheReadThroughLocalAtomicRestartSelfTest.java new file mode 100644 index 0000000..f0892ef --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheReadThroughLocalAtomicRestartSelfTest.java @@ -0,0 +1,32 @@ +/* + * 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; + +import org.apache.ignite.cache.*; + +import static org.apache.ignite.cache.CacheAtomicityMode.*; + +/** + * Test for read through store. + */ +public class CacheReadThroughLocalAtomicRestartSelfTest extends CacheReadThroughLocalRestartSelfTest { + /** {@inheritDoc} */ + @Override protected CacheAtomicityMode atomicityMode() { + return ATOMIC; + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bf1ea21b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheReadThroughLocalRestartSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheReadThroughLocalRestartSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheReadThroughLocalRestartSelfTest.java new file mode 100644 index 0000000..7561edf --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheReadThroughLocalRestartSelfTest.java @@ -0,0 +1,32 @@ +/* + * 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; + +import org.apache.ignite.cache.*; + +import static org.apache.ignite.cache.CacheMode.*; + +/** + * Test for read through store. + */ +public class CacheReadThroughLocalRestartSelfTest extends CacheReadThroughRestartSelfTest { + /** {@inheritDoc} */ + @Override protected CacheMode cacheMode() { + return LOCAL; + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bf1ea21b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheReadThroughReplicatedAtomicRestartSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheReadThroughReplicatedAtomicRestartSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheReadThroughReplicatedAtomicRestartSelfTest.java new file mode 100644 index 0000000..0e179ff --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheReadThroughReplicatedAtomicRestartSelfTest.java @@ -0,0 +1,32 @@ +/* + * 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; + +import org.apache.ignite.cache.*; + +import static org.apache.ignite.cache.CacheAtomicityMode.*; + +/** + * Test for read through store. + */ +public class CacheReadThroughReplicatedAtomicRestartSelfTest extends CacheReadThroughReplicatedRestartSelfTest { + /** {@inheritDoc} */ + @Override protected CacheAtomicityMode atomicityMode() { + return ATOMIC; + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bf1ea21b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheReadThroughReplicatedRestartSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheReadThroughReplicatedRestartSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheReadThroughReplicatedRestartSelfTest.java new file mode 100644 index 0000000..5f1419c --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheReadThroughReplicatedRestartSelfTest.java @@ -0,0 +1,32 @@ +/* + * 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; + +import org.apache.ignite.cache.*; + +import static org.apache.ignite.cache.CacheMode.*; + +/** + * Test for read through store. + */ +public class CacheReadThroughReplicatedRestartSelfTest extends CacheReadThroughRestartSelfTest { + /** {@inheritDoc} */ + @Override protected CacheMode cacheMode() { + return REPLICATED; + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bf1ea21b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheReadThroughRestartSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheReadThroughRestartSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheReadThroughRestartSelfTest.java new file mode 100644 index 0000000..7d0cd4c --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheReadThroughRestartSelfTest.java @@ -0,0 +1,133 @@ +/* + * 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; + +import org.apache.ignite.*; +import org.apache.ignite.cache.*; +import org.apache.ignite.configuration.*; +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.transactions.*; + +import static org.apache.ignite.cache.CacheAtomicityMode.*; +import static org.apache.ignite.cache.CacheMode.*; + +/** + * Test for read through store. + */ +public class CacheReadThroughRestartSelfTest extends GridCacheAbstractSelfTest { + /** */ + private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); + + /** {@inheritDoc} */ + @Override protected int gridCount() { + return 2; + } + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(gridName); + + TransactionConfiguration txCfg = new TransactionConfiguration(); + + txCfg.setTxSerializableEnabled(true); + + cfg.setTransactionConfiguration(txCfg); + + CacheConfiguration cc = cacheConfiguration(gridName); + + cc.setLoadPreviousValue(false); + + cfg.setCacheConfiguration(cc); + + TcpDiscoverySpi disco = new TcpDiscoverySpi(); + + disco.setIpFinder(IP_FINDER); + + cfg.setDiscoverySpi(disco); + + return cfg; + } + + /** {@inheritDoc} */ + @Override protected CacheAtomicityMode atomicityMode() { + return TRANSACTIONAL; + } + + /** {@inheritDoc} */ + @Override protected CacheMode cacheMode() { + return PARTITIONED; + } + + /** + * @throws Exception If failed. + */ + public void testReadThroughInTx() throws Exception { + IgniteCache cache = grid(1).cache(null); + + for (int k = 0; k < 1000; k++) + cache.put("key" + k, k); + + stopAllGrids(); + + startGrids(2); + + Ignite ignite = grid(1); + + cache = ignite.cache(null); + + for (TransactionConcurrency txConcurrency : TransactionConcurrency.values()) { + for (TransactionIsolation txIsolation : TransactionIsolation.values()) { + try (Transaction tx = ignite.transactions().txStart(txConcurrency, txIsolation, 100000, 1000)) { + for (int k = 0; k < 1000; k++) { + String key = "key" + k; + + assertNotNull("Null value for key: " + key, cache.get(key)); + } + + tx.commit(); + } + } + } + } + + /** + * @throws Exception If failed. + */ + public void testReadThrough() throws Exception { + IgniteCache cache = grid(1).cache(null); + + for (int k = 0; k < 1000; k++) + cache.put("key" + k, k); + + stopAllGrids(); + + startGrids(2); + + Ignite ignite = grid(1); + + cache = ignite.cache(null); + + for (int k = 0; k < 1000; k++) { + String key = "key" + k; + + assertNotNull("Null value for key: " + key, cache.get(key)); + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bf1ea21b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java index 3f14f49..468aec1 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java @@ -531,7 +531,7 @@ public abstract class GridCacheAbstractSelfTest extends GridCommonAbstractTest { /** * Serializable factory. */ - private static class TestStoreFactory implements Factory { + protected static class TestStoreFactory implements Factory { @Override public CacheStore create() { return cacheStore(); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bf1ea21b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxStoreSessionTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxStoreSessionTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxStoreSessionTest.java index 269b9ae..c97fe29 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxStoreSessionTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxStoreSessionTest.java @@ -135,9 +135,13 @@ public class IgniteCacheTxStoreSessionTest extends IgniteCacheStoreSessionAbstra try (Transaction tx = startTx(concurrency, isolation)) { log.info("Do tx get."); + expData.add(new ExpectedData(false, "load", new HashMap(), cache.getName())); + expData.add(new ExpectedData(true, "sessionEnd", F.asMap(0, "load"), cache.getName())); cache.get(key1); + expData.clear(); + log.info("Do tx put."); cache.put(key1, key1); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bf1ea21b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java index 6295a4d..682965a 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java @@ -145,6 +145,13 @@ public class IgniteCacheTestSuite4 extends TestSuite { suite.addTestSuite(IgniteCacheManyClientsTest.class); + suite.addTestSuite(CacheReadThroughRestartSelfTest.class); + suite.addTestSuite(CacheReadThroughReplicatedRestartSelfTest.class); + suite.addTestSuite(CacheReadThroughReplicatedAtomicRestartSelfTest.class); + suite.addTestSuite(CacheReadThroughLocalRestartSelfTest.class); + suite.addTestSuite(CacheReadThroughLocalAtomicRestartSelfTest.class); + suite.addTestSuite(CacheReadThroughAtomicRestartSelfTest.class); + return suite; } }