ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agoncha...@apache.org
Subject incubator-ignite git commit: IGNITE-889 - Fixed read-through logic.
Date Mon, 11 May 2015 19:24:59 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-889 f6012f1e8 -> 41ce72f5c


IGNITE-889 - Fixed read-through logic.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/41ce72f5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/41ce72f5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/41ce72f5

Branch: refs/heads/ignite-889
Commit: 41ce72f5c7a4a49ac43c25cb34943f65720eec9f
Parents: f6012f1
Author: Alexey Goncharuk <agoncharuk@gridgain.com>
Authored: Mon May 11 12:24:51 2015 -0700
Committer: Alexey Goncharuk <agoncharuk@gridgain.com>
Committed: Mon May 11 12:24:51 2015 -0700

----------------------------------------------------------------------
 .../distributed/dht/GridDhtLockFuture.java      |  2 +-
 .../IgniteCacheGetReadThroughSelfTest.java      | 94 ++++++++++++++++++++
 .../ignite/testsuites/IgniteCacheTestSuite.java |  2 +
 3 files changed, 97 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/41ce72f5/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 5b0275c..8129ec2 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
@@ -960,7 +960,7 @@ public final class GridDhtLockFuture<K, V> extends GridCompoundIdentityFuture<Bo
      *
      */
     private void loadMissingFromStore() {
-        if (!skipStore && cctx.loadPreviousValue() && cctx.readThrough()
&& (needReturnVal || read)) {
+        if (!skipStore && cctx.readThrough() && (read || needReturnVal &&
cctx.loadPreviousValue())) {
             final Map<KeyCacheObject, GridDhtCacheEntry> loadMap = new LinkedHashMap<>();
 
             final GridCacheVersion ver = version();

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/41ce72f5/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheGetReadThroughSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheGetReadThroughSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheGetReadThroughSelfTest.java
new file mode 100644
index 0000000..81529e1
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheGetReadThroughSelfTest.java
@@ -0,0 +1,94 @@
+/*
+ * 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.cache.store.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.transactions.*;
+
+import javax.cache.*;
+import javax.cache.integration.*;
+
+/**
+ *
+ */
+public class IgniteCacheGetReadThroughSelfTest extends GridCacheAbstractSelfTest {
+    /** {@inheritDoc} */
+    @Override protected int gridCount() {
+        return 3;
+    }
+
+    public void testGet() throws Exception {
+        IgniteCache<Object, Object> cache = grid(0).cache(null);
+
+        assertEquals("1", cache.get("NO_TX"));
+
+        for (TransactionConcurrency conc : TransactionConcurrency.values()) {
+            for (TransactionIsolation iso : TransactionIsolation.values()) {
+                try (Transaction ignored = grid(0).transactions().txStart(conc, iso)) {
+                    String key = iso.toString() + "_" + conc.toString();
+
+                    assertEquals("Failed for: " + key, "1", cache.get(key));
+                }
+            }
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception
{
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        cfg.getTransactionConfiguration().setTxSerializableEnabled(true);
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected CacheConfiguration cacheConfiguration(String gridName) throws Exception
{
+        CacheConfiguration ccfg = new CacheConfiguration();
+
+        ccfg.setCacheStoreFactory(singletonFactory(new LoadingStore()));
+
+        ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
+
+        ccfg.setReadThrough(true);
+
+        ccfg.setLoadPreviousValue(true);
+
+        return ccfg;
+    }
+
+    /** {@inheritDoc} */
+    private static class LoadingStore extends CacheStoreAdapter {
+        /** {@inheritDoc} */
+        @Override public Object load(Object key) throws CacheLoaderException {
+            return "1";
+        }
+
+        /** {@inheritDoc} */
+        @Override public void delete(Object key) throws CacheWriterException {
+
+        }
+
+        /** {@inheritDoc} */
+        @Override public void write(Cache.Entry entry) throws CacheWriterException {
+
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/41ce72f5/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
index 9fd4e88..ba26718 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
@@ -146,6 +146,8 @@ public class IgniteCacheTestSuite extends TestSuite {
         suite.addTestSuite(GridCacheTxPartitionedLocalStoreSelfTest.class);
         suite.addTestSuite(IgniteCacheSystemTransactionsSelfTest.class);
 
+        suite.addTestSuite(IgniteCacheGetReadThroughSelfTest.class);
+
         // Heuristic exception handling. TODO IGNITE-257
 //        suite.addTestSuite(GridCacheColocatedTxExceptionSelfTest.class);
 //        suite.addTestSuite(GridCacheReplicatedTxExceptionSelfTest.class);


Mime
View raw message