ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject ignite git commit: 2224-3
Date Thu, 28 Jan 2016 17:30:32 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-2224-3 4f97b2f17 -> b6eb1cb48


2224-3


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

Branch: refs/heads/ignite-2224-3
Commit: b6eb1cb48a8de2b9ffcdf8bdd248d15a5700fd58
Parents: 4f97b2f
Author: Anton Vinogradov <av@apache.org>
Authored: Thu Jan 28 20:29:45 2016 +0300
Committer: Anton Vinogradov <av@apache.org>
Committed: Thu Jan 28 20:29:45 2016 +0300

----------------------------------------------------------------------
 .../transactions/IgniteTxLocalAdapter.java      |  16 +-
 .../cache/CacheGetEntryAbstractSeltTest.java    | 524 +++++++++++++++++++
 ...GetEntryOptimisticReadCommittedSeltTest.java |  35 ++
 ...etEntryOptimisticRepeatableReadSeltTest.java |  35 ++
 ...eGetEntryOptimisticSerializableSeltTest.java |  35 ++
 ...etEntryPessimisticReadCommittedSeltTest.java |  35 ++
 ...tEntryPessimisticRepeatableReadSeltTest.java |  35 ++
 ...GetEntryPessimisticSerializableSeltTest.java |  35 ++
 .../processors/cache/CacheGetEntrySeltTest.java | 330 ------------
 .../testsuites/IgniteCacheTestSuite4.java       |  14 +-
 10 files changed, 758 insertions(+), 336 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/b6eb1cb4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
index b9ae613..6aa8113 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
@@ -1413,12 +1413,20 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
implements Ig
                             else {
                                 if (serializable()) {
                                     ver = txEntry.serializableReadVersion();
+
+                                    //assert ver != null; // TODO: value should not be null;
                                 }
-                                else
+                                else if (optimistic()) {
+                                    assert isolation() == TransactionIsolation.REPEATABLE_READ;
+
                                     throw new IgniteCheckedException(
-                                        "Get versioned entry within transaction failed. "
+
-                                            "Transaction should be Optimistic Serializable.
" +
-                                            "[level=" + isolation + ", conc=" + concurrency
+ "]");
+                                        "Impossible to getEntry() or getEntries() after get()
at " +
+                                            "OPTIMISTIC REPEATABLE_READ case. " +
+                                            "Use only getEntry() or getEntries() to solve
the problem. ");
+                                }
+                                else {
+                                    //assert ver != null; // TODO: value should not be null;
+                                }
                             }
                         }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/b6eb1cb4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryAbstractSeltTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryAbstractSeltTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryAbstractSeltTest.java
new file mode 100644
index 0000000..96122dd
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryAbstractSeltTest.java
@@ -0,0 +1,524 @@
+/*
+ * 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 java.io.Serializable;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.cache.CacheEntry;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.NearCacheConfiguration;
+import org.apache.ignite.internal.IgniteKernal;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheAdapter;
+import org.apache.ignite.internal.processors.cache.transactions.TransactionProxyImpl;
+import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
+import org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.transactions.Transaction;
+import org.apache.ignite.transactions.TransactionConcurrency;
+import org.apache.ignite.transactions.TransactionIsolation;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+
+/**
+ * Test getEntry and getEntries methods.
+ */
+public abstract class CacheGetEntryAbstractSeltTest extends GridCacheAbstractSelfTest {
+
+    @Override protected int gridCount() {
+        return 3;
+    }
+
+    abstract protected TransactionConcurrency concurrency();
+
+    abstract protected TransactionIsolation isolation();
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception
{
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        cfg.setMarshaller(null);
+
+        return cfg;
+    }
+
+    /** */
+    public void testNear() {
+        CacheConfiguration cfg = new CacheConfiguration();
+
+        cfg.setCacheMode(CacheMode.PARTITIONED);
+        cfg.setName("near");
+        cfg.setNearConfiguration(new NearCacheConfiguration());
+
+        test(cfg);
+    }
+
+    /** */
+    public void testNearTransactional() {
+        CacheConfiguration cfg = new CacheConfiguration();
+
+        cfg.setCacheMode(CacheMode.PARTITIONED);
+        cfg.setAtomicityMode(TRANSACTIONAL);
+        cfg.setName("nearT");
+        cfg.setNearConfiguration(new NearCacheConfiguration());
+
+        test(cfg);
+    }
+
+    /** */
+    public void testPartitioned() {
+        CacheConfiguration cfg = new CacheConfiguration();
+        cfg.setCacheMode(CacheMode.PARTITIONED);
+        cfg.setName("partitioned");
+
+        test(cfg);
+    }
+
+    /** */
+    public void testPartitionedTransactional() {
+        CacheConfiguration cfg = new CacheConfiguration();
+
+        cfg.setCacheMode(CacheMode.PARTITIONED);
+        cfg.setAtomicityMode(TRANSACTIONAL);
+        cfg.setName("partitionedT");
+
+        test(cfg);
+    }
+
+    /** */
+    public void testLocal() {
+        CacheConfiguration cfg = new CacheConfiguration();
+
+        cfg.setCacheMode(CacheMode.LOCAL);
+        cfg.setName("local");
+
+        test(cfg);
+    }
+
+    /** */
+    public void testLocalTransactional() {
+        CacheConfiguration cfg = new CacheConfiguration();
+
+        cfg.setCacheMode(CacheMode.LOCAL);
+        cfg.setAtomicityMode(TRANSACTIONAL);
+        cfg.setName("localT");
+
+        test(cfg);
+    }
+
+    /** */
+    public void testReplicated() {
+        CacheConfiguration cfg = new CacheConfiguration();
+
+        cfg.setCacheMode(CacheMode.REPLICATED);
+        cfg.setName("replicated");
+
+        test(cfg);
+    }
+
+    /** */
+    public void testReplicatedTransactional() {
+        CacheConfiguration cfg = new CacheConfiguration();
+
+        cfg.setCacheMode(CacheMode.REPLICATED);
+        cfg.setAtomicityMode(TRANSACTIONAL);
+        cfg.setName("replicatedT");
+
+        test(cfg);
+    }
+
+    /** */
+    private void test(CacheConfiguration cfg) {
+        test(cfg, true);
+        test(cfg, false);
+    }
+
+    /** */
+    private void test(CacheConfiguration cfg, boolean oneEntry) {
+        IgniteCache<Integer, TestValue> cache = grid(0).createCache(cfg);
+        try {
+            init(cache);
+
+            test(cache, null, null, null, oneEntry);
+
+            if (cfg.getAtomicityMode() == TRANSACTIONAL) {
+                TransactionConcurrency txConcurrency = concurrency();
+                TransactionIsolation txIsolation = isolation();
+                try (Transaction tx = grid(0).transactions().txStart(txConcurrency, txIsolation,
100000, 1000)) {
+                    initTx(cache);
+
+                    test(cache, txConcurrency, txIsolation, tx, oneEntry);
+
+                    tx.commit();
+                }
+            }
+        }
+        finally {
+            cache.destroy();
+        }
+    }
+
+    private Set<Integer> getKeys(int base) {
+        int start = 0;
+        int finish = 100;
+
+        Set<Integer> keys = new HashSet<>(finish - start);
+
+        for (int i = base + start; i < base + finish; ++i)
+            keys.add(i);
+
+        return keys;
+    }
+
+    private Set<Integer> createdBeforeTxKeys() {
+        return getKeys(0);
+    }
+
+    private Set<Integer> createdBeforeTxWithBinaryKeys() {
+        return getKeys(1_000);
+    }
+
+    private Set<Integer> createdBeforeTxKeys2() {
+        return getKeys(2_000);
+    }
+
+    private Set<Integer> createdBeforeTxWithBinaryKeys2() {
+        return getKeys(3_000);
+    }
+
+    private Set<Integer> createdBeforeTxKeys3() {
+        return getKeys(4_000);
+    }
+
+    private Set<Integer> createdBeforeTxWithBinaryKeys3() {
+        return getKeys(5_000);
+    }
+
+    private Set<Integer> removedBeforeTxKeys() {
+        return getKeys(6_000);
+    }
+
+    private Set<Integer> removedBeforeTxWithBinaryKeys() {
+        return getKeys(7_000);
+    }
+
+    private Set<Integer> createdAtTxKeys() {
+        return getKeys(8_000);
+    }
+
+    private Set<Integer> createdAtTxWithBinaryKeys() {
+        return getKeys(9_000);
+    }
+
+    private Set<Integer> removedAtTxKeys() {
+        return getKeys(10_000);
+    }
+
+    private Set<Integer> removedAtTxWithBinaryKeys() {
+        return getKeys(11_000);
+    }
+
+    /** */
+    private void init(IgniteCache<Integer, TestValue> cache) {
+        Set<Integer> keys = new HashSet<>();
+
+        keys.addAll(createdBeforeTxKeys());
+        keys.addAll(createdBeforeTxWithBinaryKeys());
+        keys.addAll(createdBeforeTxKeys2());
+        keys.addAll(createdBeforeTxWithBinaryKeys2());
+        keys.addAll(createdBeforeTxKeys3());
+        keys.addAll(createdBeforeTxWithBinaryKeys3());
+        keys.addAll(removedBeforeTxKeys());
+        keys.addAll(removedBeforeTxWithBinaryKeys());
+        keys.addAll(removedAtTxKeys());
+        keys.addAll(removedAtTxWithBinaryKeys());
+
+        for (int i : keys)
+            cache.put(i, new TestValue(i));
+
+        for (int i : removedBeforeTxKeys())
+            cache.remove(i);
+
+        for (int i : removedBeforeTxWithBinaryKeys())
+            cache.remove(i);
+    }
+
+    /** */
+    private void initTx(IgniteCache<Integer, TestValue> cache) {
+        for (int i : createdAtTxKeys())
+            cache.put(i, new TestValue(i));
+
+        for (int i : createdAtTxWithBinaryKeys())
+            cache.put(i, new TestValue(i));
+
+        for (int i : removedAtTxKeys())
+            cache.remove(i);
+
+        for (int i : removedAtTxWithBinaryKeys())
+            cache.remove(i);
+    }
+
+    /** */
+    private void compareVersionWithPrimaryNode(CacheEntry<Integer, ?> e, IgniteCache<Integer,
TestValue> cache) {
+        CacheConfiguration cfg = cache.getConfiguration(CacheConfiguration.class);
+
+        if (cfg.getCacheMode() != CacheMode.LOCAL) {
+            Ignite prim = primaryNode(e.getKey(), cache.getName());
+
+            GridCacheAdapter<Object, Object> cacheAdapter = ((IgniteKernal)prim).internalCache(cache.getName());
+
+            if (cfg.getNearConfiguration() != null)
+                cacheAdapter = ((GridNearCacheAdapter)cacheAdapter).dht();
+
+            IgniteCacheObjectProcessor cacheObjects = cacheAdapter.context().cacheObjects();
+
+            CacheObjectContext cacheObjCtx = cacheAdapter.context().cacheObjectContext();
+
+            GridCacheMapEntry me = cacheAdapter.map().getEntry(cacheObjects.toCacheKeyObject(cacheObjCtx,
e.getKey(), true));
+
+            try {
+                assertEquals(me.version(), e.version());
+            }
+            catch (GridCacheEntryRemovedException ex) {
+                throw new RuntimeException(ex);
+            }
+        }
+    }
+
+    private void checkData(IgniteCache<Integer, TestValue> cache, int i, boolean oneEntry,
GridCacheVersion txVer) {
+        if (oneEntry) {
+            CacheEntry<Integer, TestValue> e = cache.getEntry(i);
+
+            if (txVer != null)
+                assertEquals(txVer, e.version());
+            else
+                compareVersionWithPrimaryNode(e, cache);
+
+            assertEquals(e.getValue().val, i);
+        }
+        else {
+            Set<Integer> set = new HashSet<>();
+
+            for (int j = 0; j < 10; j++)
+                set.add(i + j);
+
+            Collection<CacheEntry<Integer, TestValue>> es = cache.getEntries(set);
+
+            for (CacheEntry<Integer, TestValue> e : es) {
+                if (txVer != null)
+                    assertEquals(txVer, e.version());
+                else
+                    compareVersionWithPrimaryNode(e, cache);
+
+                assertEquals((Integer)e.getValue().val, e.getKey());
+
+                assertTrue(set.contains(e.getValue().val));
+            }
+        }
+    }
+
+    private void checkBinaryData(IgniteCache<Integer, TestValue> cache, int i, boolean
oneEntry,
+        GridCacheVersion txVer) {
+        IgniteCache<Integer, BinaryObject> cacheB = cache.withKeepBinary();
+
+        if (oneEntry) {
+            CacheEntry<Integer, BinaryObject> e = cacheB.getEntry(i);
+
+            if (txVer != null)
+                assertEquals(txVer, e.version());
+            else
+                compareVersionWithPrimaryNode(e, cache);
+
+            assertEquals(((TestValue)e.getValue().deserialize()).val, i);
+        }
+        else {
+            Set<Integer> set = new HashSet<>();
+
+            for (int j = 0; j < 10; j++)
+                set.add(i + j);
+
+            Collection<CacheEntry<Integer, BinaryObject>> es = cacheB.getEntries(set);
+
+            for (CacheEntry<Integer, BinaryObject> e : es) {
+                if (txVer != null)
+                    assertEquals(txVer, e.version());
+                else
+                    compareVersionWithPrimaryNode(e, cache);
+
+                TestValue tv = e.getValue().deserialize();
+
+                assertEquals((Integer)tv.val, e.getKey());
+
+                assertTrue(set.contains((tv).val));
+            }
+        }
+    }
+
+    private void checkRemoved(IgniteCache<Integer, TestValue> cache, int i, boolean
oneEntry) {
+        if (oneEntry) {
+            CacheEntry<Integer, TestValue> e = cache.getEntry(i);
+
+            assertNull(e);
+        }
+        else {
+            Set<Integer> set = new HashSet<>();
+
+            for (int j = 0; j < 10; j++)
+                set.add(i + j);
+
+            Collection<CacheEntry<Integer, TestValue>> es = cache.getEntries(set);
+
+            assertTrue(es.isEmpty());
+        }
+    }
+
+    private void checkBinaryRemoved(IgniteCache<Integer, TestValue> cache, int i, boolean
oneEntry) {
+        IgniteCache<Integer, BinaryObject> cacheB = cache.withKeepBinary();
+
+        if (oneEntry) {
+            CacheEntry<Integer, BinaryObject> e = cacheB.getEntry(i);
+
+            assertNull(e);
+        }
+        else {
+            Set<Integer> set = new HashSet<>();
+
+            for (int j = 0; j < 10; j++)
+                set.add(i + j);
+
+            Collection<CacheEntry<Integer, BinaryObject>> es = cacheB.getEntries(set);
+
+            assertTrue(es.isEmpty());
+        }
+    }
+
+    /** */
+    private void test(IgniteCache<Integer, TestValue> cache,
+        TransactionConcurrency txConcurrency,
+        TransactionIsolation txIsolation,
+        Transaction tx,
+        boolean oneEntry) {
+        if (tx == null) {
+            for (int i : createdBeforeTxKeys()) {
+                checkData(cache, i, oneEntry, null);
+            }
+
+            for (int i : createdBeforeTxWithBinaryKeys()) {
+                checkBinaryData(cache, i, oneEntry, null);
+            }
+
+            for (int i : removedBeforeTxKeys()) {
+                checkRemoved(cache, i, oneEntry);
+            }
+
+            for (int i : removedBeforeTxWithBinaryKeys()) {
+                checkBinaryRemoved(cache, i, oneEntry);
+            }
+        }
+        else {
+            GridCacheVersion txVer = ((TransactionProxyImpl)tx).tx().xidVersion();
+
+            for (int i : createdBeforeTxKeys2()) {
+                checkData(cache, i, oneEntry, null);
+                checkData(cache, i, oneEntry, null);
+            }
+
+            for (int i : createdBeforeTxWithBinaryKeys2()) {
+                checkBinaryData(cache, i, oneEntry, null);
+                checkBinaryData(cache, i, oneEntry, null);
+            }
+
+            try {
+                for (int i : createdBeforeTxKeys3()) {
+                    cache.get(i);
+
+                    checkData(cache, i, oneEntry, null);
+                }
+
+                for (int i : createdBeforeTxWithBinaryKeys3()) {
+                    cache.get(i);
+
+                    checkBinaryData(cache, i, oneEntry, null);
+                }
+
+                assertFalse(txIsolation == TransactionIsolation.REPEATABLE_READ &&
+                    txConcurrency == TransactionConcurrency.OPTIMISTIC);
+            }
+            catch (Exception e) {
+                assertTrue(txIsolation == TransactionIsolation.REPEATABLE_READ &&
+                    txConcurrency == TransactionConcurrency.OPTIMISTIC);
+            }
+
+            for (int i : createdAtTxKeys()) {
+                checkData(cache, i, oneEntry, txVer);
+            }
+
+            for (int i : createdAtTxWithBinaryKeys()) {
+                checkBinaryData(cache, i, oneEntry, txVer);
+            }
+
+            for (int i : removedBeforeTxKeys()) {
+                checkRemoved(cache, i, oneEntry);
+            }
+
+            for (int i : removedBeforeTxWithBinaryKeys()) {
+                checkBinaryRemoved(cache, i, oneEntry);
+            }
+            for (int i : removedAtTxKeys()) {
+                checkRemoved(cache, i, oneEntry);
+            }
+
+            for (int i : removedAtTxWithBinaryKeys()) {
+                checkBinaryRemoved(cache, i, oneEntry);
+            }
+        }
+    }
+
+    /**
+     *
+     */
+    private static class TestValue implements Serializable {
+        /** */
+        private int val;
+
+        /**
+         * @param val Value.
+         */
+        public TestValue(int val) {
+            this.val = val;
+        }
+
+        /**
+         * @return Value.
+         */
+        public int value() {
+            return val;
+        }
+
+        /** {@inheritDoc} */
+        @Override public String toString() {
+            return S.toString(TestValue.class, this);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/b6eb1cb4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticReadCommittedSeltTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticReadCommittedSeltTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticReadCommittedSeltTest.java
new file mode 100644
index 0000000..b7cd28b
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticReadCommittedSeltTest.java
@@ -0,0 +1,35 @@
+/*
+ * 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.transactions.TransactionConcurrency;
+import org.apache.ignite.transactions.TransactionIsolation;
+
+/**
+ * Test getEntry and getEntries methods.
+ */
+public class CacheGetEntryOptimisticReadCommittedSeltTest extends CacheGetEntryAbstractSeltTest
{
+
+    @Override protected TransactionConcurrency concurrency() {
+        return TransactionConcurrency.OPTIMISTIC;
+    }
+
+    @Override protected TransactionIsolation isolation() {
+        return TransactionIsolation.READ_COMMITTED;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/b6eb1cb4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticRepeatableReadSeltTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticRepeatableReadSeltTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticRepeatableReadSeltTest.java
new file mode 100644
index 0000000..d8453ba
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticRepeatableReadSeltTest.java
@@ -0,0 +1,35 @@
+/*
+ * 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.transactions.TransactionConcurrency;
+import org.apache.ignite.transactions.TransactionIsolation;
+
+/**
+ * Test getEntry and getEntries methods.
+ */
+public class CacheGetEntryOptimisticRepeatableReadSeltTest extends CacheGetEntryAbstractSeltTest
{
+
+    @Override protected TransactionConcurrency concurrency() {
+        return TransactionConcurrency.OPTIMISTIC;
+    }
+
+    @Override protected TransactionIsolation isolation() {
+        return TransactionIsolation.REPEATABLE_READ;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/b6eb1cb4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticSerializableSeltTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticSerializableSeltTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticSerializableSeltTest.java
new file mode 100644
index 0000000..4fbe66e
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticSerializableSeltTest.java
@@ -0,0 +1,35 @@
+/*
+ * 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.transactions.TransactionConcurrency;
+import org.apache.ignite.transactions.TransactionIsolation;
+
+/**
+ * Test getEntry and getEntries methods.
+ */
+public class CacheGetEntryOptimisticSerializableSeltTest extends CacheGetEntryAbstractSeltTest
{
+
+    @Override protected TransactionConcurrency concurrency() {
+        return TransactionConcurrency.OPTIMISTIC;
+    }
+
+    @Override protected TransactionIsolation isolation() {
+        return TransactionIsolation.SERIALIZABLE;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/b6eb1cb4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticReadCommittedSeltTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticReadCommittedSeltTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticReadCommittedSeltTest.java
new file mode 100644
index 0000000..86d6e4e
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticReadCommittedSeltTest.java
@@ -0,0 +1,35 @@
+/*
+ * 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.transactions.TransactionConcurrency;
+import org.apache.ignite.transactions.TransactionIsolation;
+
+/**
+ * Test getEntry and getEntries methods.
+ */
+public class CacheGetEntryPessimisticReadCommittedSeltTest extends CacheGetEntryAbstractSeltTest
{
+
+    @Override protected TransactionConcurrency concurrency() {
+        return TransactionConcurrency.PESSIMISTIC;
+    }
+
+    @Override protected TransactionIsolation isolation() {
+        return TransactionIsolation.READ_COMMITTED;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/b6eb1cb4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticRepeatableReadSeltTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticRepeatableReadSeltTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticRepeatableReadSeltTest.java
new file mode 100644
index 0000000..7fc7aa3
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticRepeatableReadSeltTest.java
@@ -0,0 +1,35 @@
+/*
+ * 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.transactions.TransactionConcurrency;
+import org.apache.ignite.transactions.TransactionIsolation;
+
+/**
+ * Test getEntry and getEntries methods.
+ */
+public class CacheGetEntryPessimisticRepeatableReadSeltTest extends CacheGetEntryAbstractSeltTest
{
+
+    @Override protected TransactionConcurrency concurrency() {
+        return TransactionConcurrency.PESSIMISTIC;
+    }
+
+    @Override protected TransactionIsolation isolation() {
+        return TransactionIsolation.REPEATABLE_READ;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/b6eb1cb4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticSerializableSeltTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticSerializableSeltTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticSerializableSeltTest.java
new file mode 100644
index 0000000..da28eca
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticSerializableSeltTest.java
@@ -0,0 +1,35 @@
+/*
+ * 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.transactions.TransactionConcurrency;
+import org.apache.ignite.transactions.TransactionIsolation;
+
+/**
+ * Test getEntry and getEntries methods.
+ */
+public class CacheGetEntryPessimisticSerializableSeltTest extends CacheGetEntryAbstractSeltTest
{
+
+    @Override protected TransactionConcurrency concurrency() {
+        return TransactionConcurrency.PESSIMISTIC;
+    }
+
+    @Override protected TransactionIsolation isolation() {
+        return TransactionIsolation.SERIALIZABLE;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/b6eb1cb4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntrySeltTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntrySeltTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntrySeltTest.java
deleted file mode 100644
index 7ef68c8..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntrySeltTest.java
+++ /dev/null
@@ -1,330 +0,0 @@
-/*
- * 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 java.io.Serializable;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.binary.BinaryObject;
-import org.apache.ignite.cache.CacheEntry;
-import org.apache.ignite.cache.CacheMode;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.configuration.NearCacheConfiguration;
-import org.apache.ignite.internal.IgniteKernal;
-import org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheAdapter;
-import org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.transactions.Transaction;
-import org.apache.ignite.transactions.TransactionConcurrency;
-import org.apache.ignite.transactions.TransactionIsolation;
-
-import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
-
-/**
- * Test getEntry and getEntries methods.
- */
-public class CacheGetEntrySeltTest extends GridCacheAbstractSelfTest {
-
-    @Override protected int gridCount() {
-        return 3;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception
{
-        IgniteConfiguration cfg = super.getConfiguration(gridName);
-
-        cfg.setMarshaller(null);
-
-        return cfg;
-    }
-
-    /** */
-    public void testNear() {
-        CacheConfiguration cfg = new CacheConfiguration();
-
-        cfg.setCacheMode(CacheMode.PARTITIONED);
-        cfg.setName("near");
-        cfg.setNearConfiguration(new NearCacheConfiguration());
-
-        test(cfg);
-    }
-
-    /** */
-    public void testNearTransactional() {
-        CacheConfiguration cfg = new CacheConfiguration();
-
-        cfg.setCacheMode(CacheMode.PARTITIONED);
-        cfg.setAtomicityMode(TRANSACTIONAL);
-        cfg.setName("nearT");
-        cfg.setNearConfiguration(new NearCacheConfiguration());
-
-        testT(cfg);
-    }
-
-    /** */
-    public void testPartitioned() {
-        CacheConfiguration cfg = new CacheConfiguration();
-        cfg.setCacheMode(CacheMode.PARTITIONED);
-        cfg.setName("partitioned");
-
-        test(cfg);
-    }
-
-    /** */
-    public void testPartitionedTransactional() {
-        CacheConfiguration cfg = new CacheConfiguration();
-
-        cfg.setCacheMode(CacheMode.PARTITIONED);
-        cfg.setAtomicityMode(TRANSACTIONAL);
-        cfg.setName("partitionedT");
-
-        testT(cfg);
-    }
-
-    /** */
-    public void testLocal() {
-        CacheConfiguration cfg = new CacheConfiguration();
-
-        cfg.setCacheMode(CacheMode.LOCAL);
-        cfg.setName("local");
-
-        test(cfg);
-    }
-
-    /** */
-    public void testLocalTransactional() {
-        CacheConfiguration cfg = new CacheConfiguration();
-
-        cfg.setCacheMode(CacheMode.LOCAL);
-        cfg.setAtomicityMode(TRANSACTIONAL);
-        cfg.setName("localT");
-
-        testT(cfg);
-    }
-
-    /** */
-    public void testReplicated() {
-        CacheConfiguration cfg = new CacheConfiguration();
-
-        cfg.setCacheMode(CacheMode.REPLICATED);
-        cfg.setName("replicated");
-
-        test(cfg);
-    }
-
-    /** */
-    public void testReplicatedTransactional() {
-        CacheConfiguration cfg = new CacheConfiguration();
-
-        cfg.setCacheMode(CacheMode.REPLICATED);
-        cfg.setAtomicityMode(TRANSACTIONAL);
-        cfg.setName("replicatedT");
-
-        testT(cfg);
-    }
-
-    /** */
-    private void testT(CacheConfiguration cfg) {
-        Ignite ignite = grid(0);
-
-        try (IgniteCache<Integer, TestValue> cache = ignite.createCache(cfg)) {
-            init(cache);
-
-            for (TransactionConcurrency txConcurrency : TransactionConcurrency.values())
{
-                for (TransactionIsolation txIsolation : TransactionIsolation.values()) {
-                    try (Transaction tx = ignite.transactions().txStart(txConcurrency, txIsolation,
100000, 1000)) {
-                        try {
-                            testGetEntry(cache);
-
-                            tx.commit();
-                        }
-                        catch (Exception e) {
-                            assert txIsolation == TransactionIsolation.REPEATABLE_READ ||
-                                (txIsolation == TransactionIsolation.SERIALIZABLE &&
-                                    tx.concurrency() == TransactionConcurrency.PESSIMISTIC);
-                        }
-                    }
-
-                    try (Transaction tx = ignite.transactions().txStart(txConcurrency, txIsolation,
100000, 1000)) {
-                        try {
-                            testGetEntries(cache);
-
-                            tx.commit();
-                        }
-                        catch (Exception e) {
-                            assert txIsolation == TransactionIsolation.REPEATABLE_READ ||
-                                (txIsolation == TransactionIsolation.SERIALIZABLE &&
-                                    tx.concurrency() == TransactionConcurrency.PESSIMISTIC);
-                        }
-                    }
-                }
-
-            }
-        }
-    }
-
-    /** */
-    private void test(CacheConfiguration cfg) {
-        try (IgniteCache<Integer, TestValue> cache = grid(0).createCache(cfg)) {
-            init(cache);
-
-            testGetEntry(cache);
-
-            testGetEntries(cache);
-        }
-    }
-
-    /** */
-    private void init(IgniteCache<Integer, TestValue> cache) {
-        // Put.
-        for (int i = 0; i < 100; ++i)
-            cache.put(i, new TestValue(i));
-    }
-
-    /** */
-    private void checkVersion(CacheEntry<Integer, ?> e, IgniteCache<Integer, TestValue>
cache) {
-        CacheConfiguration cfg = cache.getConfiguration(CacheConfiguration.class);
-
-        if (cfg.getCacheMode() != CacheMode.LOCAL) {
-            Ignite prim = primaryNode(e.getKey(), cache.getName());
-
-            GridCacheAdapter<Object, Object> cacheAdapter = ((IgniteKernal)prim).internalCache(cache.getName());
-
-            if (cfg.getNearConfiguration() != null)
-                cacheAdapter = ((GridNearCacheAdapter)cacheAdapter).dht();
-
-            IgniteCacheObjectProcessor cacheObjects = cacheAdapter.context().cacheObjects();
-
-            CacheObjectContext cacheObjCtx = cacheAdapter.context().cacheObjectContext();
-
-            GridCacheMapEntry me = cacheAdapter.map().getEntry(cacheObjects.toCacheKeyObject(cacheObjCtx,
e.getKey(), true));
-
-            try {
-                assert me.version().equals(e.version());
-            }
-            catch (GridCacheEntryRemovedException ex) {
-                throw new RuntimeException(ex);
-            }
-        }
-    }
-
-    /** */
-    private void testGetEntry(IgniteCache<Integer, TestValue> cache) {
-        // getEntry regular.
-        for (int i = 0; i < 100; ++i) {
-            CacheEntry<Integer, TestValue> e = cache.getEntry(i);
-
-            checkVersion(e, cache);
-
-            assertEquals(e.getValue().val, i);
-
-            assertNotNull(e.version());
-        }
-
-        IgniteCache<Integer, BinaryObject> cacheB = cache.withKeepBinary();
-
-        // getEntry withKeepBinary.
-        for (int i = 0; i < 100; ++i) {
-            CacheEntry<Integer, BinaryObject> e = cacheB.getEntry(i);
-
-            checkVersion(e, cache);
-
-            assertEquals(((TestValue)e.getValue().deserialize()).val, i);
-
-            assertNotNull(e.version());
-        }
-    }
-
-    /** */
-    private void testGetEntries(IgniteCache<Integer, TestValue> cache) {
-        // getEntries regular.
-        for (int i = 0; i < 100; i++) {
-            Set<Integer> set = new HashSet<>();
-
-            for (int j = 0; j < 10; j++)
-                set.add(i + j);
-
-            Collection<CacheEntry<Integer, TestValue>> es = cache.getEntries(set);
-
-            for (CacheEntry<Integer, TestValue> e : es) {
-                checkVersion(e, cache);
-
-                assertEquals((Integer)e.getValue().val, e.getKey());
-
-                assertTrue(set.contains(e.getValue().val));
-
-                assertNotNull(e.version());
-            }
-        }
-
-        IgniteCache<Integer, BinaryObject> cacheB = cache.withKeepBinary();
-
-        // getEntries withKeepBinary.
-        for (int i = 0; i < 100; i++) {
-            Set<Integer> set = new HashSet<>();
-
-            for (int j = 0; j < 10; j++)
-                set.add(i + j);
-
-            Collection<CacheEntry<Integer, BinaryObject>> es = cacheB.getEntries(set);
-
-            for (CacheEntry<Integer, BinaryObject> e : es) {
-                checkVersion(e, cache);
-
-                TestValue tv = e.getValue().deserialize();
-
-                assertEquals((Integer)tv.val, e.getKey());
-
-                assertTrue(set.contains((tv).val));
-
-                assertNotNull(e.version());
-            }
-        }
-    }
-
-    /**
-     *
-     */
-    private static class TestValue implements Serializable {
-        /** */
-        private int val;
-
-        /**
-         * @param val Value.
-         */
-        public TestValue(int val) {
-            this.val = val;
-        }
-
-        /**
-         * @return Value.
-         */
-        public int value() {
-            return val;
-        }
-
-        /** {@inheritDoc} */
-        @Override public String toString() {
-            return S.toString(TestValue.class, this);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/b6eb1cb4/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 8fb5e14..45679dd 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
@@ -19,7 +19,12 @@ package org.apache.ignite.testsuites;
 
 import junit.framework.TestSuite;
 import org.apache.ignite.cache.store.jdbc.CacheJdbcStoreSessionListenerSelfTest;
-import org.apache.ignite.internal.processors.cache.CacheGetEntrySeltTest;
+import org.apache.ignite.internal.processors.cache.CacheGetEntryOptimisticReadCommittedSeltTest;
+import org.apache.ignite.internal.processors.cache.CacheGetEntryOptimisticRepeatableReadSeltTest;
+import org.apache.ignite.internal.processors.cache.CacheGetEntryOptimisticSerializableSeltTest;
+import org.apache.ignite.internal.processors.cache.CacheGetEntryPessimisticReadCommittedSeltTest;
+import org.apache.ignite.internal.processors.cache.CacheGetEntryPessimisticRepeatableReadSeltTest;
+import org.apache.ignite.internal.processors.cache.CacheGetEntryPessimisticSerializableSeltTest;
 import org.apache.ignite.internal.processors.cache.IgniteCacheGetCustomCollectionsSelfTest;
 import org.apache.ignite.internal.processors.GridCacheTxLoadFromStoreOnLockSelfTest;
 import org.apache.ignite.internal.processors.cache.CacheClientStoreSelfTest;
@@ -242,7 +247,12 @@ public class IgniteCacheTestSuite4 extends TestSuite {
         suite.addTestSuite(IgniteSystemCacheOnClientTest.class);
 
         suite.addTestSuite(CacheRemoveAllSelfTest.class);
-        suite.addTestSuite(CacheGetEntrySeltTest.class);
+        suite.addTestSuite(CacheGetEntryOptimisticReadCommittedSeltTest.class);
+        suite.addTestSuite(CacheGetEntryOptimisticRepeatableReadSeltTest.class);
+        suite.addTestSuite(CacheGetEntryOptimisticSerializableSeltTest.class);
+        suite.addTestSuite(CacheGetEntryPessimisticReadCommittedSeltTest.class);
+        suite.addTestSuite(CacheGetEntryPessimisticRepeatableReadSeltTest.class);
+        suite.addTestSuite(CacheGetEntryPessimisticSerializableSeltTest.class);
 
         suite.addTestSuite(CacheStopAndDestroySelfTest.class);
 


Mime
View raw message