You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2016/05/04 14:38:36 UTC

[01/15] ignite git commit: IGNITE-3068: GridDhtPartitionTopology.nodes() now returns List instead of Collection.

Repository: ignite
Updated Branches:
  refs/heads/ignite-db-x-10884 2b9b1baa5 -> 43de3d67d


IGNITE-3068: GridDhtPartitionTopology.nodes() now returns List instead of Collection.


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

Branch: refs/heads/ignite-db-x-10884
Commit: cbc852fd2ffa5494f82943d535e0825a318dd6eb
Parents: ab1f194
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Thu Apr 28 16:32:54 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Thu Apr 28 16:32:54 2016 +0300

----------------------------------------------------------------------
 .../distributed/dht/GridClientPartitionTopology.java      |  6 +++---
 .../cache/distributed/dht/GridDhtPartitionTopology.java   |  2 +-
 .../distributed/dht/GridDhtPartitionTopologyImpl.java     |  6 +++---
 .../distributed/dht/GridDhtTransactionalCacheAdapter.java |  4 ++--
 .../distributed/dht/atomic/GridDhtAtomicUpdateFuture.java |  8 ++++++--
 .../dht/atomic/GridNearAtomicUpdateFuture.java            | 10 +++++++---
 6 files changed, 22 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/cbc852fd/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridClientPartitionTopology.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridClientPartitionTopology.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridClientPartitionTopology.java
index 4635cad..58933b7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridClientPartitionTopology.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridClientPartitionTopology.java
@@ -395,14 +395,14 @@ public class GridClientPartitionTopology implements GridDhtPartitionTopology {
     }
 
     /** {@inheritDoc} */
-    @Override public Collection<ClusterNode> nodes(int p, AffinityTopologyVersion topVer) {
+    @Override public List<ClusterNode> nodes(int p, AffinityTopologyVersion topVer) {
         lock.readLock().lock();
 
         try {
             assert node2part != null && node2part.valid() : "Invalid node-to-partitions map [topVer=" + topVer +
                 ", node2part=" + node2part + ']';
 
-            Collection<ClusterNode> nodes = null;
+            List<ClusterNode> nodes = null;
 
             Collection<UUID> nodeIds = part2node.get(p);
 
@@ -412,7 +412,7 @@ public class GridClientPartitionTopology implements GridDhtPartitionTopology {
 
                     if (n != null && (topVer.topologyVersion() < 0 || n.order() <= topVer.topologyVersion())) {
                         if (nodes == null)
-                            nodes = new ArrayList<>();
+                            nodes = new ArrayList<>(nodeIds.size());
 
                         nodes.add(n);
                     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/cbc852fd/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopology.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopology.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopology.java
index 2c483a1..6e9b907 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopology.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopology.java
@@ -167,7 +167,7 @@ public interface GridDhtPartitionTopology {
      * @param topVer Topology version.
      * @return Collection of all nodes responsible for this partition with primary node being first.
      */
-    public Collection<ClusterNode> nodes(int p, AffinityTopologyVersion topVer);
+    public List<ClusterNode> nodes(int p, AffinityTopologyVersion topVer);
 
     /**
      * @param p Partition ID.

http://git-wip-us.apache.org/repos/asf/ignite/blob/cbc852fd/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
index 9f5fbfb..4be0acb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
@@ -821,10 +821,10 @@ class GridDhtPartitionTopologyImpl implements GridDhtPartitionTopology {
     }
 
     /** {@inheritDoc} */
-    @Override public Collection<ClusterNode> nodes(int p, AffinityTopologyVersion topVer) {
+    @Override public List<ClusterNode> nodes(int p, AffinityTopologyVersion topVer) {
         GridAffinityAssignment affAssignment = cctx.affinity().assignment(topVer);
 
-        Collection<ClusterNode> affNodes = affAssignment.get(p);
+        List<ClusterNode> affNodes = affAssignment.get(p);
 
         lock.readLock().lock();
 
@@ -835,7 +835,7 @@ class GridDhtPartitionTopologyImpl implements GridDhtPartitionTopology {
                 ", cache=" + cctx.name() +
                 ", node2part=" + node2part + ']';
 
-            Collection<ClusterNode> nodes = null;
+            List<ClusterNode> nodes = null;
 
             Collection<UUID> nodeIds = part2node.get(p);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/cbc852fd/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
index 9d277b9..7bace73 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
@@ -1367,9 +1367,9 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach
         Map<ClusterNode, List<KeyCacheObject>> dhtMap,
         Map<ClusterNode, List<KeyCacheObject>> nearMap)
         throws IgniteCheckedException {
-        Collection<ClusterNode> dhtNodes = ctx.dht().topology().nodes(cached.partition(), topVer);
+        List<ClusterNode> dhtNodes = ctx.dht().topology().nodes(cached.partition(), topVer);
 
-        ClusterNode primary = F.first(dhtNodes);
+        ClusterNode primary = dhtNodes.get(0);
 
         assert primary != null;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/cbc852fd/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateFuture.java
index 5760596..fa69f10 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateFuture.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.processors.cache.distributed.dht.atomic;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 import java.util.concurrent.atomic.AtomicReference;
@@ -216,6 +217,7 @@ public class GridDhtAtomicUpdateFuture extends GridFutureAdapter<Void>
      * @param prevVal Previous value.
      * @param updateCntr Partition update counter.
      */
+    @SuppressWarnings("ForLoopReplaceableByForEach")
     public void addWriteEntry(GridDhtCacheEntry entry,
         @Nullable CacheObject val,
         EntryProcessor<Object, Object, Object> entryProcessor,
@@ -227,7 +229,7 @@ public class GridDhtAtomicUpdateFuture extends GridFutureAdapter<Void>
         long updateCntr) {
         AffinityTopologyVersion topVer = updateReq.topologyVersion();
 
-        Collection<ClusterNode> dhtNodes = cctx.dht().topology().nodes(entry.partition(), topVer);
+        List<ClusterNode> dhtNodes = cctx.dht().topology().nodes(entry.partition(), topVer);
 
         if (log.isDebugEnabled())
             log.debug("Mapping entry to DHT nodes [nodes=" + U.nodeIds(dhtNodes) + ", entry=" + entry + ']');
@@ -236,7 +238,9 @@ public class GridDhtAtomicUpdateFuture extends GridFutureAdapter<Void>
 
         keys.add(entry.key());
 
-        for (ClusterNode node : dhtNodes) {
+        for (int i = 0; i < dhtNodes.size(); i++) {
+            ClusterNode node = dhtNodes.get(i);
+
             UUID nodeId = node.id();
 
             if (!nodeId.equals(cctx.localNodeId())) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/cbc852fd/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java
index dfdf1a5..cc0427c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java
@@ -21,6 +21,7 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 import javax.cache.expiry.ExpiryPolicy;
@@ -789,6 +790,7 @@ public class GridNearAtomicUpdateFuture extends GridNearAtomicAbstractUpdateFutu
      * @return Mapping.
      * @throws Exception If failed.
      */
+    @SuppressWarnings("ForLoopReplaceableByForEach")
     private Map<UUID, GridNearAtomicUpdateRequest> mapUpdate(Collection<ClusterNode> topNodes,
         AffinityTopologyVersion topVer,
         GridCacheVersion futVer,
@@ -862,7 +864,7 @@ public class GridNearAtomicUpdateFuture extends GridNearAtomicAbstractUpdateFutu
             if (op != TRANSFORM)
                 val = cctx.toCacheObject(val);
 
-            Collection<ClusterNode> affNodes = mapKey(cacheKey, topVer);
+            List<ClusterNode> affNodes = mapKey(cacheKey, topVer);
 
             if (affNodes.isEmpty())
                 throw new ClusterTopologyServerNotFoundException("Failed to map keys for cache " +
@@ -870,7 +872,9 @@ public class GridNearAtomicUpdateFuture extends GridNearAtomicAbstractUpdateFutu
 
             int i = 0;
 
-            for (ClusterNode affNode : affNodes) {
+            for (int n = 0; n < affNodes.size(); n++) {
+                ClusterNode affNode = affNodes.get(n);
+
                 if (affNode == null)
                     throw new ClusterTopologyServerNotFoundException("Failed to map keys for cache " +
                         "(all partition nodes left the grid).");
@@ -1020,7 +1024,7 @@ public class GridNearAtomicUpdateFuture extends GridNearAtomicAbstractUpdateFutu
      * @param topVer Topology version to map.
      * @return Collection of nodes to which key is mapped.
      */
-    private Collection<ClusterNode> mapKey(KeyCacheObject key, AffinityTopologyVersion topVer) {
+    private List<ClusterNode> mapKey(KeyCacheObject key, AffinityTopologyVersion topVer) {
         GridCacheAffinityManager affMgr = cctx.affinity();
 
         // If we can send updates in parallel - do it.


[14/15] ignite git commit: ignite-db-x-10884

Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/43de3d67/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbPutGetAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbPutGetAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbPutGetAbstractTest.java
new file mode 100644
index 0000000..a9b21ba
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbPutGetAbstractTest.java
@@ -0,0 +1,1017 @@
+/*
+ * 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.database;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import java.util.concurrent.ThreadLocalRandom;
+
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteDataStreamer;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CachePeekMode;
+import org.apache.ignite.cache.CacheRebalanceMode;
+import org.apache.ignite.cache.CacheWriteSynchronizationMode;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.cache.query.annotations.QuerySqlField;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.DatabaseConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
+import org.apache.ignite.internal.util.GridRandom;
+import org.apache.ignite.internal.util.typedef.PA;
+import org.apache.ignite.internal.util.typedef.X;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ *
+ */
+public abstract class IgniteDbPutGetAbstractTest extends GridCommonAbstractTest {
+    /** */
+    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+    /**
+     * @return Node count.
+     */
+    protected abstract int gridCount();
+
+    /**
+     * @return {@code True} if indexing is enabled.
+     */
+    protected abstract boolean indexingEnabled();
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        DatabaseConfiguration dbCfg = new DatabaseConfiguration();
+
+        dbCfg.setConcurrencyLevel(Runtime.getRuntime().availableProcessors() * 4);
+
+        dbCfg.setPageSize(1024);
+
+        dbCfg.setPageCacheSize(100 * 1024 * 1024);
+
+        cfg.setDatabaseConfiguration(dbCfg);
+
+        CacheConfiguration ccfg = new CacheConfiguration();
+
+        if (indexingEnabled())
+            ccfg.setIndexedTypes(Integer.class, DbValue.class);
+
+        ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
+
+        ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
+
+        ccfg.setRebalanceMode(CacheRebalanceMode.SYNC);
+
+        CacheConfiguration ccfg2 = new CacheConfiguration("non-primitive");
+
+        if (indexingEnabled())
+            ccfg2.setIndexedTypes(DbKey.class, DbValue.class);
+
+        ccfg2.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
+
+        ccfg2.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
+
+        ccfg2.setRebalanceMode(CacheRebalanceMode.SYNC);
+
+        cfg.setCacheConfiguration(ccfg, ccfg2);
+
+        TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
+
+        discoSpi.setIpFinder(IP_FINDER);
+
+        cfg.setDiscoverySpi(discoSpi);
+
+        cfg.setMarshaller(null);
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        startGrids(gridCount());
+
+        awaitPartitionMapExchange();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        stopAllGrids();
+    }
+
+    /**
+     *
+     */
+    public void testRandomRemove() {
+        IgniteEx ig = grid(0);
+
+        IgniteCache<Integer, DbValue> cache = ig.cache(null);
+
+        final int cnt = 50_000;
+
+        long seed = System.nanoTime();
+
+        X.println("Seed: " + seed);
+
+        Random rnd = new GridRandom(seed);
+
+        int[] keys = generateUniqueRandomKeys(cnt, rnd);
+
+        X.println("Put start");
+
+        for (int i : keys) {
+            DbValue v0 = new DbValue(i, "test-value", i);
+
+//            if (i % 1000 == 0)
+//                X.println(" --> " + i);
+
+            cache.put(i, v0);
+
+            assertEquals(v0, cache.get(i));
+        }
+
+        keys = generateUniqueRandomKeys(cnt, rnd);
+
+        X.println("Rmv start");
+
+        for (int i : keys) {
+//            X.println(" --> " + i);
+
+            assertTrue(cache.remove(i));
+        }
+    }
+
+
+    /**
+     */
+    public void testRandomPut() {
+        IgniteEx ig = grid(0);
+
+        IgniteCache<Integer, DbValue> cache = ig.cache(null);
+
+        final int cnt = 1_000;
+
+        long seed = System.nanoTime();
+
+        X.println("Seed: " + seed);
+
+        Random rnd = new GridRandom(seed);
+
+        for (int i = 0; i < 500_000; i++) {
+            int k = rnd.nextInt(cnt);
+
+            DbValue v0 = new DbValue(k, "test-value " + k, i);
+
+            if (i % 1000 == 0)
+                X.println(" --> " + i);
+
+            cache.put(k, v0);
+
+            assertEquals(v0, cache.get(k));
+        }
+    }
+
+
+    /**
+     * @throws Exception if failed.
+     */
+    public void testPutGetSimple() throws Exception {
+        IgniteEx ig = grid(0);
+
+        IgniteCache<Integer, DbValue> cache = ig.cache(null);
+
+        GridCacheAdapter<Object, Object> internalCache = ig.context().cache().internalCache();
+
+        int k0 = 0;
+        DbValue v0 = new DbValue(0, "value-0", 0L);
+
+        cache.put(k0, v0);
+
+        checkEmpty(internalCache, k0);
+
+        assertEquals(v0, cache.get(k0));
+
+        checkEmpty(internalCache, k0);
+
+        assertEquals(v0, cache.get(k0));
+
+        checkEmpty(internalCache, k0);
+    }
+
+    /**
+     * @throws Exception if failed.
+     */
+    public void testPutGetOverwrite() throws Exception {
+        IgniteEx ig = grid(0);
+
+        final IgniteCache<Integer, DbValue> cache = ig.cache(null);
+
+        GridCacheAdapter<Object, Object> internalCache = ig.context().cache().internalCache();
+
+        final int k0 = 0;
+        DbValue v0 = new DbValue(0, "value-0", 0L);
+
+        cache.put(k0, v0);
+
+        checkEmpty(internalCache, k0);
+
+        assertEquals(v0, cache.get(k0));
+
+        checkEmpty(internalCache, k0);
+
+        DbValue v1 = new DbValue(1, "value-1", 1L);
+
+        cache.put(k0, v1);
+
+        checkEmpty(internalCache, k0);
+
+        assertEquals(v1, cache.get(k0));
+    }
+
+    /**
+     * @throws Exception if failed.
+     */
+    public void testOverwriteNormalSizeAfterSmallerSize() throws Exception {
+        IgniteEx ig = grid(0);
+
+        final IgniteCache<Integer, DbValue> cache = ig.cache(null);
+
+        GridCacheAdapter<Object, Object> internalCache = ig.context().cache().internalCache();
+
+        String[] vals = new String[] {"long-long-long-value", "short-value"};
+        final int k0 = 0;
+
+        for (int i = 0; i < 10; i++) {
+            DbValue v0 = new DbValue(i, vals[i % vals.length], i);
+
+            info("Update.... " + i);
+
+            cache.put(k0, v0);
+
+            checkEmpty(internalCache, k0);
+
+            assertEquals(v0, cache.get(k0));
+        }
+    }
+
+    /**
+     * @throws Exception if failed.
+     */
+    public void testPutDoesNotTriggerRead() throws Exception {
+        IgniteEx ig = grid(0);
+
+        final IgniteCache<Integer, DbValue> cache = ig.cache(null);
+
+        cache.put(0, new DbValue(0, "test-value-0", 0));
+    }
+
+    /**
+     * @throws Exception if failed.
+     */
+    public void testPutGetMultipleObjects() throws Exception {
+        IgniteEx ig = grid(0);
+
+        final IgniteCache<Integer, DbValue> cache = ig.cache(null);
+
+        GridCacheAdapter<Object, Object> internalCache = ig.context().cache().internalCache();
+
+        int cnt = 20_000;
+
+        X.println("Put start");
+
+        for (int i = 0; i < cnt; i++) {
+            DbValue v0 = new DbValue(i, "test-value", i);
+
+//            if (i % 1000 == 0)
+//                X.println(" --> " + i);
+
+            cache.put(i, v0);
+
+            checkEmpty(internalCache, i);
+
+            assertEquals(v0, cache.get(i));
+        }
+
+        X.println("Get start");
+
+        for (int i = 0; i < cnt; i++) {
+            DbValue v0 = new DbValue(i, "test-value", i);
+
+            checkEmpty(internalCache, i);
+
+//            X.println(" <-- " + i);
+
+            assertEquals(v0, cache.get(i));
+        }
+
+        if (indexingEnabled()) {
+            awaitPartitionMapExchange();
+
+            X.println("Query start");
+
+            assertEquals(cnt, cache.query(new SqlFieldsQuery("select null from dbvalue")).getAll().size());
+
+            List<List<?>> res = cache.query(new SqlFieldsQuery("select ival, _val from dbvalue where ival < ?")
+                .setArgs(10_000)).getAll();
+
+            assertEquals(10_000, res.size());
+
+            for (int i = 0; i < 10_000; i++) {
+                List<?> row = res.get(i);
+
+                assertEquals(2, row.size());
+                assertEquals(i, row.get(0));
+
+                assertEquals(new DbValue(i, "test-value", i), row.get(1));
+            }
+
+            assertEquals(1, cache.query(new SqlFieldsQuery("select lval from dbvalue where ival = 7899")).getAll().size());
+            assertEquals(2000, cache.query(new SqlFieldsQuery("select lval from dbvalue where ival >= 5000 and ival < 7000"))
+                .getAll().size());
+
+            String plan = cache.query(new SqlFieldsQuery(
+                "explain select lval from dbvalue where ival >= 5000 and ival < 7000")).getAll().get(0).get(0).toString();
+
+            assertTrue(plan, plan.contains("iVal_idx"));
+        }
+    }
+
+    /**
+     * @throws Exception if failed.
+     */
+    public void testSizeClear() throws Exception {
+        IgniteEx ig = grid(0);
+
+        final IgniteCache<Integer, DbValue> cache = ig.cache(null);
+
+        GridCacheAdapter<Object, Object> internalCache = ig.context().cache().internalCache();
+
+        int cnt = 5000;
+
+        X.println("Put start");
+
+        for (int i = 0; i < cnt; i++) {
+            DbValue v0 = new DbValue(i, "test-value", i);
+
+            cache.put(i, v0);
+
+            checkEmpty(internalCache, i);
+
+            assertEquals(v0, cache.get(i));
+        }
+
+        awaitPartitionMapExchange();
+
+        assertEquals(cnt, cache.size(CachePeekMode.OFFHEAP));
+
+        X.println("Clear start.");
+
+        cache.clear();
+
+        assertEquals(0, cache.size(CachePeekMode.OFFHEAP));
+
+        for (int i = 0; i < cnt; i++)
+            assertNull(cache.get(i));
+    }
+    /**
+     * @throws Exception if failed.
+     */
+    public void testBounds() throws Exception {
+        IgniteEx ig = grid(0);
+
+        final IgniteCache<Integer, DbValue> cache = ig.cache(null);
+
+        X.println("Put start");
+
+        int cnt = 1000;
+
+        try (IgniteDataStreamer<Integer, DbValue> st = ig.dataStreamer(null)) {
+            st.allowOverwrite(true);
+
+            for (int i = 0; i < cnt; i++) {
+                int k = 2 * i;
+
+                DbValue v0 = new DbValue(k, "test-value", k);
+
+                st.addData(k, v0);
+            }
+        }
+
+        X.println("Get start");
+
+        for (int i = 0; i < cnt; i++) {
+            int k = 2 * i;
+
+            DbValue v0 = new DbValue(k, "test-value", k);
+
+            assertEquals(v0, cache.get(k));
+        }
+
+        if (indexingEnabled()) {
+            awaitPartitionMapExchange();
+
+            X.println("Query start");
+
+            // Make sure to cover multiple pages.
+            int limit = 500;
+
+            for (int i = 0; i < limit; i++) {
+                List<List<?>> res = cache.query(new SqlFieldsQuery("select ival, _val from dbvalue where ival < ? order by ival")
+                    .setArgs(i)).getAll();
+
+                // 0 => 0, 1 => 1, 2=>1,...
+                assertEquals((i + 1) / 2, res.size());
+
+                res = cache.query(new SqlFieldsQuery("select ival, _val from dbvalue where ival <= ? order by ival")
+                    .setArgs(i)).getAll();
+
+                // 0 => 1, 1 => 1, 2=>2,...
+                assertEquals(i / 2 + 1, res.size());
+            }
+        }
+    }
+
+    /**
+     * @throws Exception if failed.
+     */
+    public void testMultithreadedPut() throws Exception {
+        IgniteEx ig = grid(0);
+
+        final IgniteCache<Integer, DbValue> cache = ig.cache(null);
+
+        X.println("Put start");
+
+        int cnt = 20_000;
+
+        try (IgniteDataStreamer<Integer, DbValue> st = ig.dataStreamer(null)) {
+            st.allowOverwrite(true);
+
+            for (int i = 0; i < cnt; i++) {
+                DbValue v0 = new DbValue(i, "test-value", i);
+
+                st.addData(i, v0);
+            }
+        }
+
+        X.println("Get start");
+
+        for (int i = 0; i < cnt; i++) {
+            DbValue v0 = new DbValue(i, "test-value", i);
+
+            assertEquals(v0, cache.get(i));
+        }
+
+        if (indexingEnabled()) {
+            awaitPartitionMapExchange();
+
+            X.println("Query start");
+
+            assertEquals(cnt, cache.query(new SqlFieldsQuery("select null from dbvalue")).getAll().size());
+
+            int limit = 500;
+
+            List<List<?>> res = cache.query(new SqlFieldsQuery("select ival, _val from dbvalue where ival < ? order by ival")
+                .setArgs(limit)).getAll();
+
+            assertEquals(limit, res.size());
+
+            for (int i = 0; i < limit; i++) {
+                List<?> row = res.get(i);
+
+                assertEquals(2, row.size());
+                assertEquals(i, row.get(0));
+
+                assertEquals(new DbValue(i, "test-value", i), row.get(1));
+            }
+
+            assertEquals(1, cache.query(new SqlFieldsQuery("select lval from dbvalue where ival = 7899")).getAll().size());
+            assertEquals(2000, cache.query(new SqlFieldsQuery("select lval from dbvalue where ival >= 5000 and ival < 7000"))
+                .getAll().size());
+
+            String plan = cache.query(new SqlFieldsQuery(
+                "explain select lval from dbvalue where ival >= 5000 and ival < 7000")).getAll().get(0).get(0).toString();
+
+            assertTrue(plan, plan.contains("iVal_idx"));
+        }
+    }
+
+    /**
+     * @throws Exception if failed.
+     */
+    public void testPutGetRandomUniqueMultipleObjects() throws Exception {
+        IgniteEx ig = grid(0);
+
+        final IgniteCache<Integer, DbValue> cache = ig.cache(null);
+
+        GridCacheAdapter<Object, Object> internalCache = ig.context().cache().internalCache();
+
+        int cnt = 100_000;
+
+        Random rnd = new GridRandom();
+
+        int[] keys = generateUniqueRandomKeys(cnt, rnd);
+
+        X.println("Put start");
+
+        for (int i : keys) {
+            DbValue v0 = new DbValue(i, "test-value", i);
+
+//            if (i % 100 == 0)
+//                X.println(" --> " + i);
+
+            cache.put(i, v0);
+
+            checkEmpty(internalCache, i);
+
+            assertEquals(v0, cache.get(i));
+//            for (int j : keys) {
+//                if (j == i)
+//                    break;
+//
+//                assertEquals( i + ", " + j, new DbValue(j, "test-value", j), cache.get(j));
+//            }
+        }
+
+        X.println("Get start");
+
+        for (int i = 0; i < cnt; i++) {
+            DbValue v0 = new DbValue(i, "test-value", i);
+
+            checkEmpty(internalCache, i);
+
+//            X.println(" <-- " + i);
+
+            assertEquals(v0, cache.get(i));
+        }
+    }
+
+    /** */
+    private static int[] generateUniqueRandomKeys(int cnt, Random rnd) {
+        int[] keys = new int[cnt];
+
+        for (int i = 0; i < cnt; i++)
+            keys[i] = i;
+
+        for (int i = 0; i < cnt; i++) {
+            int a = rnd.nextInt(cnt);
+            int b = rnd.nextInt(cnt);
+
+            int k = keys[a];
+            keys[a] = keys[b];
+            keys[b] = k;
+        }
+
+        return keys;
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testPutPrimaryUniqueSecondaryDuplicates() throws Exception {
+        IgniteEx ig = grid(0);
+
+        final IgniteCache<Integer, DbValue> cache = ig.cache(null);
+
+        GridCacheAdapter<Object, Object> internalCache = ig.context().cache().internalCache();
+
+        int cnt = 100_000;
+
+        Random rnd = new GridRandom();
+
+        Map<Integer, DbValue> map = new HashMap<>();
+
+        int[] keys = generateUniqueRandomKeys(cnt, rnd);
+
+        X.println("Put start");
+
+        for (int i : keys) {
+            DbValue v0 = new DbValue(rnd.nextInt(30), "test-value", i);
+
+//            X.println(" --> " + i);
+
+            cache.put(i, v0);
+            map.put(i, v0);
+
+            checkEmpty(internalCache, i);
+
+            assertEquals(v0, cache.get(i));
+        }
+
+        X.println("Get start");
+
+        for (int i = 0; i < cnt; i++) {
+            DbValue v0 = map.get(i);
+
+            checkEmpty(internalCache, i);
+
+//            X.println(" <-- " + i);
+
+            assertEquals(v0, cache.get(i));
+        }
+    }
+
+    /**
+     * @throws Exception if failed.
+     */
+    public void testPutGetRandomNonUniqueMultipleObjects() throws Exception {
+        IgniteEx ig = grid(0);
+
+        final IgniteCache<Integer, DbValue> cache = ig.cache(null);
+
+        GridCacheAdapter<Object, Object> internalCache = ig.context().cache().internalCache();
+
+        int cnt = 100_000;
+
+        Random rnd = new GridRandom();
+
+        Map<Integer, DbValue> map = new HashMap<>();
+
+        X.println("Put start");
+
+        for (int a = 0; a < cnt; a++) {
+            int i = rnd.nextInt();
+            int k = rnd.nextInt(cnt);
+
+            DbValue v0 = new DbValue(k, "test-value", i);
+
+//            if (a % 100 == 0)
+//                X.println(" --> " + k + " = " + i);
+
+            map.put(k, v0);
+            cache.put(k, v0);
+
+            checkEmpty(internalCache, k);
+
+            assertEquals(v0, cache.get(k));
+//            for (Map.Entry<Integer,DbValue> entry : map.entrySet())
+//                assertEquals(entry.getValue(), cache.get(entry.getKey()));
+        }
+
+        X.println("Get start: " + map.size());
+
+        for (int i : map.keySet()) {
+            checkEmpty(internalCache, i);
+
+//            X.println(" <-- " + i);
+
+            assertEquals(map.get(i), cache.get(i));
+        }
+    }
+
+    /**
+     * @throws Exception if failed.
+     */
+    public void testPutGetRemoveMultipleForward() throws Exception {
+        IgniteEx ig = grid(0);
+
+        final IgniteCache<Integer, DbValue> cache = ig.cache(null);
+
+        GridCacheAdapter<Object, Object> internalCache = ig.context().cache().internalCache();
+
+        int cnt = 100_000;
+
+        X.println("Put.");
+
+        for (int i = 0; i < cnt; i++) {
+            DbValue v0 = new DbValue(i, "test-value", i);
+
+//            if (i % 100 == 0)
+//                X.println(" --> " + i);
+
+            cache.put(i, v0);
+
+            checkEmpty(internalCache, i);
+
+            assertEquals(v0, cache.get(i));
+        }
+
+        X.println("Start removing.");
+
+        for (int i = 0; i < cnt; i++) {
+            if (i % 1000 == 0) {
+                X.println("-> " + i);
+
+//                assertEquals((long)(cnt - i),
+//                    cache.query(new SqlFieldsQuery("select count(*) from dbvalue")).getAll().get(0).get(0));
+            }
+
+            cache.remove(i);
+
+            assertNull(cache.get(i));
+
+            if (i + 1 < cnt)
+                assertEquals(new DbValue(i + 1, "test-value", i + 1), cache.get(i + 1));
+        }
+    }
+
+    public void _testRandomPutGetRemove() {
+        IgniteEx ig = grid(0);
+
+        final IgniteCache<Integer, DbValue> cache = ig.cache(null);
+
+        int cnt = 100_000;
+
+        Map<Integer, DbValue> map = new HashMap<>(cnt);
+
+        long seed = 1460943282308L; // System.currentTimeMillis();
+
+        X.println(" seed---> " + seed);
+
+        Random rnd = new GridRandom(seed);
+
+        for (int i = 0 ; i < 1000_000; i++) {
+            if (i % 5000 == 0)
+                X.println(" --> " + i);
+
+            int key = rnd.nextInt(cnt);
+
+            DbValue v0 = new DbValue(key, "test-value-" + rnd.nextInt(200), rnd.nextInt(500));
+
+            switch (rnd.nextInt(3)) {
+                case 0:
+                    X.println("Put: " + key + " = " + v0);
+
+                    assertEquals(map.put(key, v0), cache.getAndPut(key, v0));
+
+                case 1:
+                    X.println("Get: " + key);
+
+                    assertEquals(map.get(key), cache.get(key));
+
+                    break;
+
+                case 2:
+                    X.println("Rmv: " + key);
+
+                    assertEquals(map.remove(key), cache.getAndRemove(key));
+
+                    assertNull(cache.get(key));
+            }
+        }
+
+//        assertEquals(map.size(), cache.size(CachePeekMode.ALL));
+
+        for (Integer key : map.keySet())
+            assertEquals(map.get(key), cache.get(key));
+    }
+
+    public void testPutGetRemoveMultipleBackward() throws Exception {
+        IgniteEx ig = grid(0);
+
+        final IgniteCache<Integer, DbValue> cache = ig.cache(null);
+
+        GridCacheAdapter<Object, Object> internalCache = ig.context().cache().internalCache();
+
+        int cnt = 100_000;
+
+        X.println("Put.");
+
+        for (int i = 0; i < cnt; i++) {
+            DbValue v0 = new DbValue(i, "test-value", i);
+
+//            if (i % 100 == 0)
+//                X.println(" --> " + i);
+
+            cache.put(i, v0);
+
+            checkEmpty(internalCache, i);
+
+            assertEquals(v0, cache.get(i));
+        }
+
+        X.println("Start removing in backward direction.");
+
+        for (int i = cnt - 1; i >= 0; i--) {
+            if (i % 1000 == 0) {
+                X.println("-> " + i);
+
+//                assertEquals((long)(cnt - i),
+//                    cache.query(new SqlFieldsQuery("select count(*) from dbvalue")).getAll().get(0).get(0));
+            }
+
+            cache.remove(i);
+
+            assertNull(cache.get(i));
+
+            if (i - 1 >= 0)
+                assertEquals(new DbValue(i - 1, "test-value", i - 1), cache.get(i - 1));
+        }
+    }
+
+    /**
+     * @throws Exception if failed.
+     */
+    public void testIndexOverwrite() throws Exception {
+        IgniteEx ig = grid(0);
+
+        final IgniteCache<Integer, DbValue> cache = ig.cache(null);
+
+        GridCacheAdapter<Object, Object> internalCache = ig.context().cache().internalCache("non-primitive");
+
+        X.println("Put start");
+
+        int cnt = 10_000;
+
+        for (int a = 0; a < cnt; a++) {
+            DbValue v0 = new DbValue(a, "test-value-" + a, a);
+
+            DbKey k0 = new DbKey(a);
+
+            cache.put(a, v0);
+
+            checkEmpty(internalCache, k0);
+        }
+
+        info("Update start");
+
+        for (int k = 0; k < 4000; k++) {
+            int batchSize = 20;
+
+            LinkedHashMap<Integer, DbValue> batch = new LinkedHashMap<>();
+
+            for (int i = 0; i < batchSize; i++) {
+                int a = ThreadLocalRandom.current().nextInt(cnt);
+
+                DbValue v0 = new DbValue(a, "test-value-" + a, a);
+
+                batch.put(a, v0);
+            }
+
+            cache.putAll(batch);
+
+            cache.remove(ThreadLocalRandom.current().nextInt(cnt));
+        }
+    }
+
+    /**
+     * @throws Exception if failed.
+     */
+    public void testObjectKey() throws Exception {
+        IgniteEx ig = grid(0);
+
+        final IgniteCache<DbKey, DbValue> cache = ig.cache("non-primitive");
+
+        GridCacheAdapter<Object, Object> internalCache = ig.context().cache().internalCache("non-primitive");
+
+        int cnt = 100_000;
+
+        Map<DbKey, DbValue> map = new HashMap<>();
+
+        X.println("Put start");
+
+        for (int a = 0; a < cnt; a++) {
+            DbValue v0 = new DbValue(a, "test-value", a);
+
+//            if (a % 100 == 0)
+//                X.println(" --> " + k + " = " + i);
+
+            DbKey k0 = new DbKey(a);
+
+            map.put(k0, v0);
+            cache.put(k0, v0);
+
+            checkEmpty(internalCache, k0);
+
+//            assertEquals(v0, cache.get(k0));
+//            for (Map.Entry<Integer,DbValue> entry : map.entrySet())
+//                assertEquals(entry.getValue(), cache.get(entry.getKey()));
+        }
+
+        X.println("Get start: " + map.size());
+
+        for (DbKey i : map.keySet()) {
+//            checkEmpty(internalCache, i);
+
+//            X.println(" <-- " + i);
+
+            assertEquals(map.get(i), cache.get(i));
+        }
+    }
+
+    private void checkEmpty(final GridCacheAdapter internalCache, final Object key) throws Exception {
+        GridTestUtils.waitForCondition(new PA() {
+            @Override public boolean apply() {
+                return internalCache.peekEx(key) == null;
+            }
+        }, 5000);
+
+        assertNull(internalCache.peekEx(key));
+    }
+
+    /**
+     *
+     */
+    private static class DbKey implements Serializable {
+        /** */
+        private int val;
+
+        /**
+         * @param val Value.
+         */
+        private DbKey(int val) {
+            this.val = val;
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean equals(Object o) {
+            if (this == o)
+                return true;
+
+            if (o == null || !(o instanceof DbKey))
+                return false;
+
+            DbKey key = (DbKey)o;
+
+            return val == key.val;
+        }
+
+        /** {@inheritDoc} */
+        @Override public int hashCode() {
+            return val;
+        }
+    }
+
+    /**
+     *
+     */
+    private static class DbValue implements Serializable {
+        /** */
+        @QuerySqlField(index = true)
+        private int iVal;
+
+        /** */
+        @QuerySqlField(index = true)
+        private String sVal;
+
+        /** */
+        @QuerySqlField
+        private long lVal;
+
+        /**
+         * @param iVal Integer value.
+         * @param sVal String value.
+         * @param lVal Long value.
+         */
+        public DbValue(int iVal, String sVal, long lVal) {
+            this.iVal = iVal;
+            this.sVal = sVal;
+            this.lVal = lVal;
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean equals(Object o) {
+            if (this == o)
+                return true;
+
+            if (o == null || getClass() != o.getClass())
+                return false;
+
+            DbValue dbVal = (DbValue)o;
+
+            return iVal == dbVal.iVal && lVal == dbVal.lVal &&
+                !(sVal != null ? !sVal.equals(dbVal.sVal) : dbVal.sVal != null);
+        }
+
+        /** {@inheritDoc} */
+        @Override public int hashCode() {
+            int res = iVal;
+
+            res = 31 * res + (sVal != null ? sVal.hashCode() : 0);
+            res = 31 * res + (int)(lVal ^ (lVal >>> 32));
+
+            return res;
+        }
+
+        /** {@inheritDoc} */
+        @Override public String toString() {
+            return S.toString(DbValue.class, this);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/43de3d67/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbSingleNodePutGetTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbSingleNodePutGetTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbSingleNodePutGetTest.java
new file mode 100644
index 0000000..e2d3ca9
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbSingleNodePutGetTest.java
@@ -0,0 +1,33 @@
+/*
+ * 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.database;
+
+/**
+ *
+ */
+public class IgniteDbSingleNodePutGetTest extends IgniteDbPutGetAbstractTest {
+    /** {@inheritDoc} */
+    @Override protected int gridCount() {
+        return 1;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected boolean indexingEnabled() {
+        return false;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/43de3d67/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridCacheTestContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridCacheTestContext.java b/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridCacheTestContext.java
index 0bfb759..93fb784 100644
--- a/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridCacheTestContext.java
+++ b/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridCacheTestContext.java
@@ -79,7 +79,6 @@ public class GridCacheTestContext<K, V> extends GridCacheContext<K, V> {
             true,
             true,
             new GridCacheEventManager(),
-            new GridCacheSwapManager(false),
             new CacheOsStoreManager(null, new CacheConfiguration()),
             new GridCacheEvictionManager(),
             new GridCacheLocalQueryManager<K, V>(),

http://git-wip-us.apache.org/repos/asf/ignite/blob/43de3d67/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteDatabaseTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteDatabaseTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteDatabaseTestSuite.java
new file mode 100644
index 0000000..246b235
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteDatabaseTestSuite.java
@@ -0,0 +1,40 @@
+/*
+ * 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.testsuites;
+
+import junit.framework.TestSuite;
+import org.apache.ignite.internal.processors.database.IgniteDbMultiNodePutGetTest;
+import org.apache.ignite.internal.processors.database.IgniteDbSingleNodePutGetTest;
+
+/**
+ *
+ */
+public class IgniteDatabaseTestSuite extends TestSuite {
+    /**
+     * @return Test suite.
+     * @throws Exception Thrown in case of the failure.
+     */
+    public static TestSuite suite() throws Exception {
+        TestSuite suite = new TestSuite("Ignite Database Tests");
+
+        suite.addTestSuite(IgniteDbSingleNodePutGetTest.class);
+        suite.addTestSuite(IgniteDbMultiNodePutGetTest.class);
+
+        return suite;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/43de3d67/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
index 659c387..d7900cc 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
@@ -594,9 +594,13 @@ public class IgniteH2Indexing implements GridQueryIndexing {
         Class<?> keyCls = getClass(coctx, key);
         Class<?> valCls = val == null ? null : getClass(coctx, val);
 
+        boolean foundTbl = false;
+
         for (TableDescriptor tbl : tables(schema(spaceName))) {
             if (tbl.type().keyClass().isAssignableFrom(keyCls)
                 && (val == null || tbl.type().valueClass().isAssignableFrom(valCls))) {
+                foundTbl = true;
+
                 if (tbl.tbl.update(key, partId, val, ver, 0, true)) {
                     if (tbl.luceneIdx != null)
                         tbl.luceneIdx.remove(key);
@@ -606,7 +610,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
             }
         }
 
-        return false;
+        return foundTbl;
     }
 
     /** {@inheritDoc} */
@@ -622,8 +626,12 @@ public class IgniteH2Indexing implements GridQueryIndexing {
 
         IgniteBiTuple<CacheObject, GridCacheVersion> res = null;
 
+        boolean foundTbl = false;
+
         for (TableDescriptor tbl : tables(schema(spaceName))) {
             if (tbl.type().keyClass().isAssignableFrom(keyCls)) {
+                foundTbl = true;
+
                 res = tbl.tbl.read(cctx, key, partId);
 
                 if (res != null)
@@ -631,28 +639,25 @@ public class IgniteH2Indexing implements GridQueryIndexing {
             }
         }
 
+        if (foundTbl && res == null)
+            return F.t(null, null);
+
         return res;
     }
 
     /** {@inheritDoc} */
-    @Override public List<BPlusTree<?, ? extends CacheDataRow>> pkIndexes(String spaceName) {
+    @Override public BPlusTree<?, ? extends CacheDataRow> pkIndex(String spaceName) {
         Schema schema = schemas.get(schema(spaceName));
 
         if (schema == null)
-            return Collections.emptyList();
-
-        List<BPlusTree<?, ? extends CacheDataRow>> res = null;
+            return null;
 
         for (TableDescriptor tbl : schema.tbls.values()) {
-            if (tbl.pkTreeIdx != null) {
-                if (res == null)
-                    res = new ArrayList<>();
-
-                res.add(tbl.pkTreeIdx.tree());
-            }
+            if (tbl.pkTreeIdx != null)
+                return tbl.pkTreeIdx.tree();
         }
 
-        return res != null ? res : Collections.<BPlusTree<?, ? extends CacheDataRow>>emptyList();
+        return null;
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/43de3d67/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMultiNodePutGetRestartSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMultiNodePutGetRestartSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMultiNodePutGetRestartSelfTest.java
index 8285647..c701ad9 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMultiNodePutGetRestartSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMultiNodePutGetRestartSelfTest.java
@@ -1,10 +1,18 @@
 /*
- *  Copyright (C) GridGain Systems. All Rights Reserved.
- *  _________        _____ __________________        _____
- *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
- *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
- *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
- *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
+ * 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.database;

http://git-wip-us.apache.org/repos/asf/ignite/blob/43de3d67/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMultiNodePutGetSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMultiNodePutGetSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMultiNodePutGetSelfTest.java
deleted file mode 100644
index 1ead18f..0000000
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMultiNodePutGetSelfTest.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- *  Copyright (C) GridGain Systems. All Rights Reserved.
- *  _________        _____ __________________        _____
- *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
- *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
- *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
- *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
- */
-
-package org.apache.ignite.internal.processors.database;
-
-/**
- *
- */
-public class IgniteDbMultiNodePutGetSelfTest extends IgniteDbSingleNodePutGetSelfTest {
-    /** {@inheritDoc} */
-    @Override protected int gridCount() {
-        return 3;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void testMultithreadedPut() throws Exception {
-        super.testMultithreadedPut();
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/43de3d67/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMultiNodeWithIndexingPutGetTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMultiNodeWithIndexingPutGetTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMultiNodeWithIndexingPutGetTest.java
new file mode 100644
index 0000000..09e80d2
--- /dev/null
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMultiNodeWithIndexingPutGetTest.java
@@ -0,0 +1,28 @@
+/*
+ * 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.database;
+
+/**
+ *
+ */
+public class IgniteDbMultiNodeWithIndexingPutGetTest extends IgniteDbMultiNodePutGetTest {
+    /** {@inheritDoc} */
+    @Override protected boolean indexingEnabled() {
+        return true;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/43de3d67/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbSingleNodePutGetSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbSingleNodePutGetSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbSingleNodePutGetSelfTest.java
deleted file mode 100644
index ec3d78d..0000000
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbSingleNodePutGetSelfTest.java
+++ /dev/null
@@ -1,995 +0,0 @@
-/*
- *  Copyright (C) GridGain Systems. All Rights Reserved.
- *  _________        _____ __________________        _____
- *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
- *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
- *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
- *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
- */
-
-package org.apache.ignite.internal.processors.database;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
-import java.util.concurrent.ThreadLocalRandom;
-
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteDataStreamer;
-import org.apache.ignite.cache.CacheAtomicityMode;
-import org.apache.ignite.cache.CachePeekMode;
-import org.apache.ignite.cache.CacheRebalanceMode;
-import org.apache.ignite.cache.CacheWriteSynchronizationMode;
-import org.apache.ignite.cache.query.SqlFieldsQuery;
-import org.apache.ignite.cache.query.annotations.QuerySqlField;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.DatabaseConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.IgniteEx;
-import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
-import org.apache.ignite.internal.util.GridRandom;
-import org.apache.ignite.internal.util.typedef.PA;
-import org.apache.ignite.internal.util.typedef.X;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
-import org.apache.ignite.testframework.GridTestUtils;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-
-/**
- *
- */
-public class IgniteDbSingleNodePutGetSelfTest extends GridCommonAbstractTest {
-    /** */
-    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
-
-    /**
-     * @return Grid count.
-     */
-    protected int gridCount() {
-        return 1;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
-        IgniteConfiguration cfg = super.getConfiguration(gridName);
-
-        DatabaseConfiguration dbCfg = new DatabaseConfiguration();
-
-        dbCfg.setConcurrencyLevel(Runtime.getRuntime().availableProcessors() * 4);
-
-        dbCfg.setPageSize(1024);
-
-        dbCfg.setPageCacheSize(100 * 1024 * 1024);
-
-        cfg.setDatabaseConfiguration(dbCfg);
-
-        CacheConfiguration ccfg = new CacheConfiguration();
-
-        ccfg.setIndexedTypes(Integer.class, DbValue.class);
-
-        ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
-
-        ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
-
-        ccfg.setRebalanceMode(CacheRebalanceMode.SYNC);
-
-        CacheConfiguration ccfg2 = new CacheConfiguration("non-primitive");
-
-        ccfg2.setIndexedTypes(DbKey.class, DbValue.class);
-
-        ccfg2.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
-
-        ccfg2.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
-
-        ccfg2.setRebalanceMode(CacheRebalanceMode.SYNC);
-
-        cfg.setCacheConfiguration(ccfg, ccfg2);
-
-        TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
-
-        discoSpi.setIpFinder(IP_FINDER);
-
-        cfg.setDiscoverySpi(discoSpi);
-
-        cfg.setMarshaller(null);
-
-        return cfg;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void beforeTest() throws Exception {
-        startGrids(gridCount());
-
-        awaitPartitionMapExchange();
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void afterTest() throws Exception {
-        stopAllGrids();
-    }
-
-    /**
-     *
-     */
-    public void testRandomRemove() {
-        IgniteEx ig = grid(0);
-
-        IgniteCache<Integer, DbValue> cache = ig.cache(null);
-
-        final int cnt = 50_000;
-
-        long seed = System.nanoTime();
-
-        X.println("Seed: " + seed);
-
-        Random rnd = new GridRandom(seed);
-
-        int[] keys = generateUniqueRandomKeys(cnt, rnd);
-
-        X.println("Put start");
-
-        for (int i : keys) {
-            DbValue v0 = new DbValue(i, "test-value", i);
-
-//            if (i % 1000 == 0)
-//                X.println(" --> " + i);
-
-            cache.put(i, v0);
-
-            assertEquals(v0, cache.get(i));
-        }
-
-        keys = generateUniqueRandomKeys(cnt, rnd);
-
-        X.println("Rmv start");
-
-        for (int i : keys) {
-//            X.println(" --> " + i);
-
-            assertTrue(cache.remove(i));
-        }
-    }
-
-
-    /**
-     */
-    public void testRandomPut() {
-        IgniteEx ig = grid(0);
-
-        IgniteCache<Integer, DbValue> cache = ig.cache(null);
-
-        final int cnt = 1_000;
-
-        long seed = System.nanoTime();
-
-        X.println("Seed: " + seed);
-
-        Random rnd = new GridRandom(seed);
-
-        for (int i = 0; i < 500_000; i++) {
-            int k = rnd.nextInt(cnt);
-
-            DbValue v0 = new DbValue(k, "test-value " + k, i);
-
-            if (i % 1000 == 0)
-                X.println(" --> " + i);
-
-            cache.put(k, v0);
-
-            assertEquals(v0, cache.get(k));
-        }
-    }
-
-
-    /**
-     * @throws Exception if failed.
-     */
-    public void testPutGetSimple() throws Exception {
-        IgniteEx ig = grid(0);
-
-        IgniteCache<Integer, DbValue> cache = ig.cache(null);
-
-        GridCacheAdapter<Object, Object> internalCache = ig.context().cache().internalCache();
-
-        int k0 = 0;
-        DbValue v0 = new DbValue(0, "value-0", 0L);
-
-        cache.put(k0, v0);
-
-        checkEmpty(internalCache, k0);
-
-        assertEquals(v0, cache.get(k0));
-
-        checkEmpty(internalCache, k0);
-
-        assertEquals(v0, cache.get(k0));
-
-        checkEmpty(internalCache, k0);
-    }
-
-    /**
-     * @throws Exception if failed.
-     */
-    public void testPutGetOverwrite() throws Exception {
-        IgniteEx ig = grid(0);
-
-        final IgniteCache<Integer, DbValue> cache = ig.cache(null);
-
-        GridCacheAdapter<Object, Object> internalCache = ig.context().cache().internalCache();
-
-        final int k0 = 0;
-        DbValue v0 = new DbValue(0, "value-0", 0L);
-
-        cache.put(k0, v0);
-
-        checkEmpty(internalCache, k0);
-
-        assertEquals(v0, cache.get(k0));
-
-        checkEmpty(internalCache, k0);
-
-        DbValue v1 = new DbValue(1, "value-1", 1L);
-
-        cache.put(k0, v1);
-
-        checkEmpty(internalCache, k0);
-
-        assertEquals(v1, cache.get(k0));
-    }
-
-    /**
-     * @throws Exception if failed.
-     */
-    public void testOverwriteNormalSizeAfterSmallerSize() throws Exception {
-        IgniteEx ig = grid(0);
-
-        final IgniteCache<Integer, DbValue> cache = ig.cache(null);
-
-        GridCacheAdapter<Object, Object> internalCache = ig.context().cache().internalCache();
-
-        String[] vals = new String[] {"long-long-long-value", "short-value"};
-        final int k0 = 0;
-
-        for (int i = 0; i < 10; i++) {
-            DbValue v0 = new DbValue(i, vals[i % vals.length], i);
-
-            info("Update.... " + i);
-
-            cache.put(k0, v0);
-
-            checkEmpty(internalCache, k0);
-
-            assertEquals(v0, cache.get(k0));
-        }
-    }
-
-    /**
-     * @throws Exception if failed.
-     */
-    public void testPutDoesNotTriggerRead() throws Exception {
-        IgniteEx ig = grid(0);
-
-        final IgniteCache<Integer, DbValue> cache = ig.cache(null);
-
-        cache.put(0, new DbValue(0, "test-value-0", 0));
-    }
-
-    /**
-     * @throws Exception if failed.
-     */
-    public void testPutGetMultipleObjects() throws Exception {
-        IgniteEx ig = grid(0);
-
-        final IgniteCache<Integer, DbValue> cache = ig.cache(null);
-
-        GridCacheAdapter<Object, Object> internalCache = ig.context().cache().internalCache();
-
-        int cnt = 20_000;
-
-        X.println("Put start");
-
-        for (int i = 0; i < cnt; i++) {
-            DbValue v0 = new DbValue(i, "test-value", i);
-
-//            if (i % 1000 == 0)
-//                X.println(" --> " + i);
-
-            cache.put(i, v0);
-
-            checkEmpty(internalCache, i);
-
-            assertEquals(v0, cache.get(i));
-        }
-
-        X.println("Get start");
-
-        for (int i = 0; i < cnt; i++) {
-            DbValue v0 = new DbValue(i, "test-value", i);
-
-            checkEmpty(internalCache, i);
-
-//            X.println(" <-- " + i);
-
-            assertEquals(v0, cache.get(i));
-        }
-
-        awaitPartitionMapExchange();
-
-        X.println("Query start");
-
-        assertEquals(cnt, cache.query(new SqlFieldsQuery("select null from dbvalue")).getAll().size());
-
-        List<List<?>> res = cache.query(new SqlFieldsQuery("select ival, _val from dbvalue where ival < ?")
-            .setArgs(10_000)).getAll();
-
-        assertEquals(10_000, res.size());
-
-        for (int i = 0; i < 10_000; i++) {
-            List<?> row = res.get(i);
-
-            assertEquals(2, row.size());
-            assertEquals(i, row.get(0));
-
-            assertEquals(new DbValue(i, "test-value", i), row.get(1));
-        }
-
-        assertEquals(1, cache.query(new SqlFieldsQuery("select lval from dbvalue where ival = 7899")).getAll().size());
-        assertEquals(2000, cache.query(new SqlFieldsQuery("select lval from dbvalue where ival >= 5000 and ival < 7000"))
-            .getAll().size());
-
-        String plan = cache.query(new SqlFieldsQuery(
-                "explain select lval from dbvalue where ival >= 5000 and ival < 7000")).getAll().get(0).get(0).toString();
-
-        assertTrue(plan, plan.contains("iVal_idx"));
-    }
-
-    /**
-     * @throws Exception if failed.
-     */
-    public void testSizeClear() throws Exception {
-        IgniteEx ig = grid(0);
-
-        final IgniteCache<Integer, DbValue> cache = ig.cache(null);
-
-        GridCacheAdapter<Object, Object> internalCache = ig.context().cache().internalCache();
-
-        int cnt = 5000;
-
-        X.println("Put start");
-
-        for (int i = 0; i < cnt; i++) {
-            DbValue v0 = new DbValue(i, "test-value", i);
-
-            cache.put(i, v0);
-
-            checkEmpty(internalCache, i);
-
-            assertEquals(v0, cache.get(i));
-        }
-
-        awaitPartitionMapExchange();
-
-        assertEquals(cnt, cache.size(CachePeekMode.OFFHEAP));
-
-        X.println("Clear start.");
-
-        cache.clear();
-
-        assertEquals(0, cache.size(CachePeekMode.OFFHEAP));
-
-        for (int i = 0; i < cnt; i++)
-            assertNull(cache.get(i));
-    }
-    /**
-     * @throws Exception if failed.
-     */
-    public void testBounds() throws Exception {
-        IgniteEx ig = grid(0);
-
-        final IgniteCache<Integer, DbValue> cache = ig.cache(null);
-
-        X.println("Put start");
-
-        int cnt = 1000;
-
-        try (IgniteDataStreamer<Integer, DbValue> st = ig.dataStreamer(null)) {
-            st.allowOverwrite(true);
-
-            for (int i = 0; i < cnt; i++) {
-                int k = 2 * i;
-
-                DbValue v0 = new DbValue(k, "test-value", k);
-
-                st.addData(k, v0);
-            }
-        }
-
-        X.println("Get start");
-
-        for (int i = 0; i < cnt; i++) {
-            int k = 2 * i;
-
-            DbValue v0 = new DbValue(k, "test-value", k);
-
-            assertEquals(v0, cache.get(k));
-        }
-
-        awaitPartitionMapExchange();
-
-        X.println("Query start");
-
-        // Make sure to cover multiple pages.
-        int limit = 500;
-
-        for (int i = 0; i < limit; i++) {
-            List<List<?>> res = cache.query(new SqlFieldsQuery("select ival, _val from dbvalue where ival < ? order by ival")
-                .setArgs(i)).getAll();
-
-            // 0 => 0, 1 => 1, 2=>1,...
-            assertEquals((i + 1) / 2, res.size());
-
-            res = cache.query(new SqlFieldsQuery("select ival, _val from dbvalue where ival <= ? order by ival")
-                .setArgs(i)).getAll();
-
-            // 0 => 1, 1 => 1, 2=>2,...
-            assertEquals(i / 2 + 1, res.size());
-        }
-    }
-
-    /**
-     * @throws Exception if failed.
-     */
-    public void testMultithreadedPut() throws Exception {
-        IgniteEx ig = grid(0);
-
-        final IgniteCache<Integer, DbValue> cache = ig.cache(null);
-
-        X.println("Put start");
-
-        int cnt = 20_000;
-
-        try (IgniteDataStreamer<Integer, DbValue> st = ig.dataStreamer(null)) {
-            st.allowOverwrite(true);
-
-            for (int i = 0; i < cnt; i++) {
-                DbValue v0 = new DbValue(i, "test-value", i);
-
-                st.addData(i, v0);
-            }
-        }
-
-        X.println("Get start");
-
-        for (int i = 0; i < cnt; i++) {
-            DbValue v0 = new DbValue(i, "test-value", i);
-
-            assertEquals(v0, cache.get(i));
-        }
-
-        awaitPartitionMapExchange();
-
-        X.println("Query start");
-
-        assertEquals(cnt, cache.query(new SqlFieldsQuery("select null from dbvalue")).getAll().size());
-
-        int limit = 500;
-
-        List<List<?>> res = cache.query(new SqlFieldsQuery("select ival, _val from dbvalue where ival < ? order by ival")
-            .setArgs(limit)).getAll();
-
-        assertEquals(limit, res.size());
-
-        for (int i = 0; i < limit; i++) {
-            List<?> row = res.get(i);
-
-            assertEquals(2, row.size());
-            assertEquals(i, row.get(0));
-
-            assertEquals(new DbValue(i, "test-value", i), row.get(1));
-        }
-
-        assertEquals(1, cache.query(new SqlFieldsQuery("select lval from dbvalue where ival = 7899")).getAll().size());
-        assertEquals(2000, cache.query(new SqlFieldsQuery("select lval from dbvalue where ival >= 5000 and ival < 7000"))
-            .getAll().size());
-
-        String plan = cache.query(new SqlFieldsQuery(
-            "explain select lval from dbvalue where ival >= 5000 and ival < 7000")).getAll().get(0).get(0).toString();
-
-        assertTrue(plan, plan.contains("iVal_idx"));
-    }
-
-    /**
-     * @throws Exception if failed.
-     */
-    public void testPutGetRandomUniqueMultipleObjects() throws Exception {
-        IgniteEx ig = grid(0);
-
-        final IgniteCache<Integer, DbValue> cache = ig.cache(null);
-
-        GridCacheAdapter<Object, Object> internalCache = ig.context().cache().internalCache();
-
-        int cnt = 100_000;
-
-        Random rnd = new GridRandom();
-
-        int[] keys = generateUniqueRandomKeys(cnt, rnd);
-
-        X.println("Put start");
-
-        for (int i : keys) {
-            DbValue v0 = new DbValue(i, "test-value", i);
-
-//            if (i % 100 == 0)
-//                X.println(" --> " + i);
-
-            cache.put(i, v0);
-
-            checkEmpty(internalCache, i);
-
-            assertEquals(v0, cache.get(i));
-//            for (int j : keys) {
-//                if (j == i)
-//                    break;
-//
-//                assertEquals( i + ", " + j, new DbValue(j, "test-value", j), cache.get(j));
-//            }
-        }
-
-        X.println("Get start");
-
-        for (int i = 0; i < cnt; i++) {
-            DbValue v0 = new DbValue(i, "test-value", i);
-
-            checkEmpty(internalCache, i);
-
-//            X.println(" <-- " + i);
-
-            assertEquals(v0, cache.get(i));
-        }
-    }
-
-    /** */
-    private static int[] generateUniqueRandomKeys(int cnt, Random rnd) {
-        int[] keys = new int[cnt];
-
-        for (int i = 0; i < cnt; i++)
-            keys[i] = i;
-
-        for (int i = 0; i < cnt; i++) {
-            int a = rnd.nextInt(cnt);
-            int b = rnd.nextInt(cnt);
-
-            int k = keys[a];
-            keys[a] = keys[b];
-            keys[b] = k;
-        }
-
-        return keys;
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testPutPrimaryUniqueSecondaryDuplicates() throws Exception {
-        IgniteEx ig = grid(0);
-
-        final IgniteCache<Integer, DbValue> cache = ig.cache(null);
-
-        GridCacheAdapter<Object, Object> internalCache = ig.context().cache().internalCache();
-
-        int cnt = 100_000;
-
-        Random rnd = new GridRandom();
-
-        Map<Integer, DbValue> map = new HashMap<>();
-
-        int[] keys = generateUniqueRandomKeys(cnt, rnd);
-
-        X.println("Put start");
-
-        for (int i : keys) {
-            DbValue v0 = new DbValue(rnd.nextInt(30), "test-value", i);
-
-//            X.println(" --> " + i);
-
-            cache.put(i, v0);
-            map.put(i, v0);
-
-            checkEmpty(internalCache, i);
-
-            assertEquals(v0, cache.get(i));
-        }
-
-        X.println("Get start");
-
-        for (int i = 0; i < cnt; i++) {
-            DbValue v0 = map.get(i);
-
-            checkEmpty(internalCache, i);
-
-//            X.println(" <-- " + i);
-
-            assertEquals(v0, cache.get(i));
-        }
-    }
-
-    /**
-     * @throws Exception if failed.
-     */
-    public void testPutGetRandomNonUniqueMultipleObjects() throws Exception {
-        IgniteEx ig = grid(0);
-
-        final IgniteCache<Integer, DbValue> cache = ig.cache(null);
-
-        GridCacheAdapter<Object, Object> internalCache = ig.context().cache().internalCache();
-
-        int cnt = 100_000;
-
-        Random rnd = new GridRandom();
-
-        Map<Integer, DbValue> map = new HashMap<>();
-
-        X.println("Put start");
-
-        for (int a = 0; a < cnt; a++) {
-            int i = rnd.nextInt();
-            int k = rnd.nextInt(cnt);
-
-            DbValue v0 = new DbValue(k, "test-value", i);
-
-//            if (a % 100 == 0)
-//                X.println(" --> " + k + " = " + i);
-
-            map.put(k, v0);
-            cache.put(k, v0);
-
-            checkEmpty(internalCache, k);
-
-            assertEquals(v0, cache.get(k));
-//            for (Map.Entry<Integer,DbValue> entry : map.entrySet())
-//                assertEquals(entry.getValue(), cache.get(entry.getKey()));
-        }
-
-        X.println("Get start: " + map.size());
-
-        for (int i : map.keySet()) {
-            checkEmpty(internalCache, i);
-
-//            X.println(" <-- " + i);
-
-            assertEquals(map.get(i), cache.get(i));
-        }
-    }
-
-    /**
-     * @throws Exception if failed.
-     */
-    public void testPutGetRemoveMultipleForward() throws Exception {
-        IgniteEx ig = grid(0);
-
-        final IgniteCache<Integer, DbValue> cache = ig.cache(null);
-
-        GridCacheAdapter<Object, Object> internalCache = ig.context().cache().internalCache();
-
-        int cnt = 100_000;
-
-        X.println("Put.");
-
-        for (int i = 0; i < cnt; i++) {
-            DbValue v0 = new DbValue(i, "test-value", i);
-
-//            if (i % 100 == 0)
-//                X.println(" --> " + i);
-
-            cache.put(i, v0);
-
-            checkEmpty(internalCache, i);
-
-            assertEquals(v0, cache.get(i));
-        }
-
-        X.println("Start removing.");
-
-        for (int i = 0; i < cnt; i++) {
-            if (i % 1000 == 0) {
-                X.println("-> " + i);
-
-//                assertEquals((long)(cnt - i),
-//                    cache.query(new SqlFieldsQuery("select count(*) from dbvalue")).getAll().get(0).get(0));
-            }
-
-            cache.remove(i);
-
-            assertNull(cache.get(i));
-
-            if (i + 1 < cnt)
-                assertEquals(new DbValue(i + 1, "test-value", i + 1), cache.get(i + 1));
-        }
-    }
-
-    public void _testRandomPutGetRemove() {
-        IgniteEx ig = grid(0);
-
-        final IgniteCache<Integer, DbValue> cache = ig.cache(null);
-
-        int cnt = 100_000;
-
-        Map<Integer, DbValue> map = new HashMap<>(cnt);
-
-        long seed = 1460943282308L; // System.currentTimeMillis();
-
-        X.println(" seed---> " + seed);
-
-        Random rnd = new GridRandom(seed);
-
-        for (int i = 0 ; i < 1000_000; i++) {
-            if (i % 5000 == 0)
-                X.println(" --> " + i);
-
-            int key = rnd.nextInt(cnt);
-
-            DbValue v0 = new DbValue(key, "test-value-" + rnd.nextInt(200), rnd.nextInt(500));
-
-            switch (rnd.nextInt(3)) {
-                case 0:
-                    X.println("Put: " + key + " = " + v0);
-
-                    assertEquals(map.put(key, v0), cache.getAndPut(key, v0));
-
-                case 1:
-                    X.println("Get: " + key);
-
-                    assertEquals(map.get(key), cache.get(key));
-
-                    break;
-
-                case 2:
-                    X.println("Rmv: " + key);
-
-                    assertEquals(map.remove(key), cache.getAndRemove(key));
-
-                    assertNull(cache.get(key));
-            }
-        }
-
-//        assertEquals(map.size(), cache.size(CachePeekMode.ALL));
-
-        for (Integer key : map.keySet())
-            assertEquals(map.get(key), cache.get(key));
-    }
-
-    public void testPutGetRemoveMultipleBackward() throws Exception {
-        IgniteEx ig = grid(0);
-
-        final IgniteCache<Integer, DbValue> cache = ig.cache(null);
-
-        GridCacheAdapter<Object, Object> internalCache = ig.context().cache().internalCache();
-
-        int cnt = 100_000;
-
-        X.println("Put.");
-
-        for (int i = 0; i < cnt; i++) {
-            DbValue v0 = new DbValue(i, "test-value", i);
-
-//            if (i % 100 == 0)
-//                X.println(" --> " + i);
-
-            cache.put(i, v0);
-
-            checkEmpty(internalCache, i);
-
-            assertEquals(v0, cache.get(i));
-        }
-
-        X.println("Start removing in backward direction.");
-
-        for (int i = cnt - 1; i >= 0; i--) {
-            if (i % 1000 == 0) {
-                X.println("-> " + i);
-
-//                assertEquals((long)(cnt - i),
-//                    cache.query(new SqlFieldsQuery("select count(*) from dbvalue")).getAll().get(0).get(0));
-            }
-
-            cache.remove(i);
-
-            assertNull(cache.get(i));
-
-            if (i - 1 >= 0)
-                assertEquals(new DbValue(i - 1, "test-value", i - 1), cache.get(i - 1));
-        }
-    }
-
-    /**
-     * @throws Exception if failed.
-     */
-    public void testIndexOverwrite() throws Exception {
-        IgniteEx ig = grid(0);
-
-        final IgniteCache<Integer, DbValue> cache = ig.cache(null);
-
-        GridCacheAdapter<Object, Object> internalCache = ig.context().cache().internalCache("non-primitive");
-
-        X.println("Put start");
-
-        int cnt = 10_000;
-
-        for (int a = 0; a < cnt; a++) {
-            DbValue v0 = new DbValue(a, "test-value-" + a, a);
-
-            DbKey k0 = new DbKey(a);
-
-            cache.put(a, v0);
-
-            checkEmpty(internalCache, k0);
-        }
-
-        info("Update start");
-
-        for (int k = 0; k < 4000; k++) {
-            int batchSize = 20;
-
-            LinkedHashMap<Integer, DbValue> batch = new LinkedHashMap<>();
-
-            for (int i = 0; i < batchSize; i++) {
-                int a = ThreadLocalRandom.current().nextInt(cnt);
-
-                DbValue v0 = new DbValue(a, "test-value-" + a, a);
-
-                batch.put(a, v0);
-            }
-
-            cache.putAll(batch);
-
-            cache.remove(ThreadLocalRandom.current().nextInt(cnt));
-        }
-    }
-
-    /**
-     * @throws Exception if failed.
-     */
-    public void testObjectKey() throws Exception {
-        IgniteEx ig = grid(0);
-
-        final IgniteCache<DbKey, DbValue> cache = ig.cache("non-primitive");
-
-        GridCacheAdapter<Object, Object> internalCache = ig.context().cache().internalCache("non-primitive");
-
-        int cnt = 100_000;
-
-        Map<DbKey, DbValue> map = new HashMap<>();
-
-        X.println("Put start");
-
-        for (int a = 0; a < cnt; a++) {
-            DbValue v0 = new DbValue(a, "test-value", a);
-
-//            if (a % 100 == 0)
-//                X.println(" --> " + k + " = " + i);
-
-            DbKey k0 = new DbKey(a);
-
-            map.put(k0, v0);
-            cache.put(k0, v0);
-
-            checkEmpty(internalCache, k0);
-
-//            assertEquals(v0, cache.get(k0));
-//            for (Map.Entry<Integer,DbValue> entry : map.entrySet())
-//                assertEquals(entry.getValue(), cache.get(entry.getKey()));
-        }
-
-        X.println("Get start: " + map.size());
-
-        for (DbKey i : map.keySet()) {
-//            checkEmpty(internalCache, i);
-
-//            X.println(" <-- " + i);
-
-            assertEquals(map.get(i), cache.get(i));
-        }
-    }
-
-    private void checkEmpty(final GridCacheAdapter internalCache, final Object key) throws Exception {
-        GridTestUtils.waitForCondition(new PA() {
-            @Override public boolean apply() {
-                return internalCache.peekEx(key) == null;
-            }
-        }, 5000);
-
-        assertNull(internalCache.peekEx(key));
-    }
-
-    /**
-     *
-     */
-    private static class DbKey implements Serializable {
-        /** */
-        private int val;
-
-        private DbKey(int val) {
-            this.val = val;
-        }
-
-        /** {@inheritDoc} */
-        @Override public boolean equals(Object o) {
-            if (this == o)
-                return true;
-
-            if (o == null || !(o instanceof DbKey))
-                return false;
-
-            DbKey key = (DbKey)o;
-
-            return val == key.val;
-        }
-
-        /** {@inheritDoc} */
-        @Override public int hashCode() {
-            return val;
-        }
-    }
-
-    /**
-     *
-     */
-    private static class DbValue implements Serializable {
-        /** */
-        @QuerySqlField(index = true)
-        private int iVal;
-
-        /** */
-        @QuerySqlField(index = true)
-        private String sVal;
-
-        /** */
-        @QuerySqlField
-        private long lVal;
-
-        /**
-         * @param iVal Integer value.
-         * @param sVal String value.
-         * @param lVal Long value.
-         */
-        public DbValue(int iVal, String sVal, long lVal) {
-            this.iVal = iVal;
-            this.sVal = sVal;
-            this.lVal = lVal;
-        }
-
-        /** {@inheritDoc} */
-        @Override public boolean equals(Object o) {
-            if (this == o)
-                return true;
-
-            if (o == null || getClass() != o.getClass())
-                return false;
-
-            DbValue dbValue = (DbValue)o;
-
-            return iVal == dbValue.iVal && lVal == dbValue.lVal &&
-                !(sVal != null ? !sVal.equals(dbValue.sVal) : dbValue.sVal != null);
-        }
-
-        /** {@inheritDoc} */
-        @Override public int hashCode() {
-            int res = iVal;
-
-            res = 31 * res + (sVal != null ? sVal.hashCode() : 0);
-            res = 31 * res + (int)(lVal ^ (lVal >>> 32));
-
-            return res;
-        }
-
-        /** {@inheritDoc} */
-        @Override public String toString() {
-            return S.toString(DbValue.class, this);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/43de3d67/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbSingleNodeWithIndexingPutGetTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbSingleNodeWithIndexingPutGetTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbSingleNodeWithIndexingPutGetTest.java
new file mode 100644
index 0000000..085e885
--- /dev/null
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbSingleNodeWithIndexingPutGetTest.java
@@ -0,0 +1,28 @@
+/*
+ * 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.database;
+
+/**
+ *
+ */
+public class IgniteDbSingleNodeWithIndexingPutGetTest extends IgniteDbSingleNodePutGetTest {
+    /** {@inheritDoc} */
+    @Override protected boolean indexingEnabled() {
+        return true;
+    }
+}


[03/15] ignite git commit: Fixed BinaryObjectOffheapUnswapTemporaryTest.

Posted by sb...@apache.org.
Fixed BinaryObjectOffheapUnswapTemporaryTest.


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

Branch: refs/heads/ignite-db-x-10884
Commit: 8dd6f199b2b6b79e3d3b313228b9b89b214f5870
Parents: 344cceb
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Fri Apr 29 09:01:47 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Apr 29 09:01:47 2016 +0300

----------------------------------------------------------------------
 .../cache/BinaryObjectOffHeapUnswapTemporaryTest.java   | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/8dd6f199/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/BinaryObjectOffHeapUnswapTemporaryTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/BinaryObjectOffHeapUnswapTemporaryTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/BinaryObjectOffHeapUnswapTemporaryTest.java
index f26191f..824481b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/BinaryObjectOffHeapUnswapTemporaryTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/BinaryObjectOffHeapUnswapTemporaryTest.java
@@ -36,6 +36,7 @@ import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.internal.binary.BinaryMarshaller;
 import org.apache.ignite.internal.binary.BinaryObjectOffheapImpl;
 import org.apache.ignite.lang.IgniteInClosure;
+import org.apache.ignite.spi.swapspace.file.FileSwapSpaceSpi;
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 import org.apache.ignite.transactions.Transaction;
 import org.apache.ignite.transactions.TransactionConcurrency;
@@ -53,6 +54,9 @@ public class BinaryObjectOffHeapUnswapTemporaryTest extends GridCommonAbstractTe
     /** */
     private static final int CNT = 20;
 
+    /** Cache name. */
+    private static final String CACHE_NAME = "cache";
+
     /** */
     @SuppressWarnings("serial")
     private static final CacheEntryProcessor PROC = new CacheEntryProcessor() {
@@ -69,6 +73,7 @@ public class BinaryObjectOffHeapUnswapTemporaryTest extends GridCommonAbstractTe
         IgniteConfiguration c = super.getConfiguration(gridName);
 
         c.setMarshaller(new BinaryMarshaller());
+        c.setSwapSpaceSpi(new FileSwapSpaceSpi());
 
         return c;
     }
@@ -82,8 +87,9 @@ public class BinaryObjectOffHeapUnswapTemporaryTest extends GridCommonAbstractTe
         CacheMemoryMode memoryMode) {
         this.atomicityMode = atomicityMode;
 
-        CacheConfiguration cfg = new CacheConfiguration();
+        CacheConfiguration<Object, Object>  cfg = new CacheConfiguration<>();
 
+        cfg.setName(CACHE_NAME);
         cfg.setCacheMode(CacheMode.PARTITIONED);
         cfg.setAtomicityMode(atomicityMode);
         cfg.setMemoryMode(memoryMode);
@@ -168,10 +174,10 @@ public class BinaryObjectOffHeapUnswapTemporaryTest extends GridCommonAbstractTe
      */
     @SuppressWarnings("serial")
     private void doTest() {
-        final IgniteCache<Integer, BinaryObject> cache = jcache(0).withKeepBinary();
+        final IgniteCache<Integer, BinaryObject> cache = jcache(0, CACHE_NAME).withKeepBinary();
 
         for (int key = 0; key < CNT; key++)
-            jcache(0).put(key, new TestObject(key));
+            jcache(0, CACHE_NAME).put(key, new TestObject(key));
 
         for (int key = CNT; key < 2 * CNT; key++) {
             BinaryObjectBuilder builder = ignite(0).binary().builder("SomeType");


[07/15] ignite git commit: IGNITE-1384 Fixed

Posted by sb...@apache.org.
IGNITE-1384 Fixed


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

Branch: refs/heads/ignite-db-x-10884
Commit: 01f12a238e075ae82232e4fa5e80ba109130e14c
Parents: 6c705da
Author: Yakov Zhdanov <yz...@gridgain.com>
Authored: Fri Apr 29 14:46:41 2016 +0300
Committer: Yakov Zhdanov <yz...@gridgain.com>
Committed: Fri Apr 29 14:46:41 2016 +0300

----------------------------------------------------------------------
 .../processors/task/GridTaskWorker.java         |  2 +-
 .../java/org/apache/ignite/lang/IgniteUuid.java |  2 +-
 .../internal/GridTaskExecutionSelfTest.java     | 76 +++++++++++++++++++-
 3 files changed, 77 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/01f12a23/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java
index 659d5a6..05970ed 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java
@@ -558,7 +558,7 @@ class GridTaskWorker<T, R> extends GridWorker implements GridTimeoutObject {
             if (node == null)
                 throw new IgniteCheckedException("Node can not be null [mappedJob=" + mappedJob + ", ses=" + ses + ']');
 
-            IgniteUuid jobId = IgniteUuid.fromUuid(node.id());
+            IgniteUuid jobId = IgniteUuid.fromUuid(ctx.localNodeId());
 
             GridJobSiblingImpl sib = new GridJobSiblingImpl(ses.getId(), jobId, node.id(), ctx);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/01f12a23/modules/core/src/main/java/org/apache/ignite/lang/IgniteUuid.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/lang/IgniteUuid.java b/modules/core/src/main/java/org/apache/ignite/lang/IgniteUuid.java
index 5c6bb9a..7de389e 100644
--- a/modules/core/src/main/java/org/apache/ignite/lang/IgniteUuid.java
+++ b/modules/core/src/main/java/org/apache/ignite/lang/IgniteUuid.java
@@ -216,4 +216,4 @@ public final class IgniteUuid implements Comparable<IgniteUuid>, Iterable<Ignite
     @Override public String toString() {
         return shortString() + '-' + gid.toString();
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/01f12a23/modules/core/src/test/java/org/apache/ignite/internal/GridTaskExecutionSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridTaskExecutionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridTaskExecutionSelfTest.java
index 31d0ffa..142b9db 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/GridTaskExecutionSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/GridTaskExecutionSelfTest.java
@@ -17,10 +17,18 @@
 
 package org.apache.ignite.internal;
 
+import java.util.ArrayList;
+import java.util.concurrent.atomic.AtomicLong;
 import org.apache.ignite.GridTestTask;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCompute;
+import org.apache.ignite.compute.ComputeJobContext;
 import org.apache.ignite.compute.ComputeTaskFuture;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteCallable;
+import org.apache.ignite.lang.IgniteFuture;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.resources.JobContextResource;
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 import org.apache.ignite.testframework.junits.common.GridCommonTest;
 
@@ -68,4 +76,70 @@ public class GridTaskExecutionSelfTest extends GridCommonAbstractTest {
 
         info("Task result: " + fut.get());
     }
-}
\ No newline at end of file
+
+    /**
+     * Test for https://issues.apache.org/jira/browse/IGNITE-1384
+     *
+     * @throws Exception If failed.
+     */
+    public void testJobIdCollision() throws Exception {
+        long locId = IgniteUuid.lastLocalId();
+
+        ArrayList<IgniteFuture<Object>> futs = new ArrayList<>(2016);
+
+        IgniteCompute compute = grid(1).compute(grid(1).cluster().forNodeId(grid(3).localNode().id())).withAsync();
+
+        for (int i = 0; i < 1000; i++) {
+            compute.call(new IgniteCallable<Object>() {
+                @JobContextResource
+                ComputeJobContext ctx;
+
+                boolean held;
+
+                @Override public Object call() throws Exception {
+                    if (!held) {
+                        ctx.holdcc(1000);
+
+                        held = true;
+                    }
+
+                    return null;
+                }
+            });
+
+            futs.add(compute.future());
+        }
+
+        info("Finished first loop.");
+
+        AtomicLong idx = U.field(IgniteUuid.class, "cntGen");
+
+        idx.set(locId);
+
+        IgniteCompute compute1 = grid(2).compute(grid(2).cluster().forNodeId(grid(3).localNode().id())).withAsync();
+
+        for (int i = 0; i < 100; i++) {
+            compute1.call(new IgniteCallable<Object>() {
+                @JobContextResource
+                ComputeJobContext ctx;
+
+                boolean held;
+
+                @Override public Object call() throws Exception {
+                    if (!held) {
+                        ctx.holdcc(1000);
+
+                        held = true;
+                    }
+
+                    return null;
+                }
+            });
+
+            futs.add(compute1.future());
+        }
+
+        for (IgniteFuture<Object> fut : futs)
+            fut.get();
+    }
+}


[02/15] ignite git commit: Merge remote-tracking branch 'origin/master'

Posted by sb...@apache.org.
Merge remote-tracking branch 'origin/master'


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

Branch: refs/heads/ignite-db-x-10884
Commit: 344cceb59053c84a956bf926cb4a4417f424014e
Parents: cbc852f c457370
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Thu Apr 28 16:36:48 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Thu Apr 28 16:36:48 2016 +0300

----------------------------------------------------------------------
 .../apache/ignite/IgniteSystemProperties.java   |  16 ++-
 .../processors/cluster/GridUpdateNotifier.java  |   3 +-
 .../ignite/spi/discovery/tcp/ServerImpl.java    |   5 +-
 .../spi/discovery/tcp/TcpDiscoveryImpl.java     |  10 ++
 ...GridServiceProxyClientReconnectSelfTest.java |   2 +-
 .../spi/discovery/tcp/TcpDiscoverySelfTest.java |  34 +++++
 .../properties/NotStringSystemPropertyTest.java | 124 +++++++++++++++++++
 .../ignite/testsuites/IgniteBasicTestSuite.java |   2 +
 .../Apache.Ignite.Linq.nuspec                   |   5 +-
 9 files changed, 193 insertions(+), 8 deletions(-)
----------------------------------------------------------------------



[12/15] ignite git commit: IGNITE-3060 Discovery: optimize resource usage for client connections (cherry picked from commits 7b0edfb, 8324233)

Posted by sb...@apache.org.
IGNITE-3060 Discovery: optimize resource usage for client connections
(cherry picked from commits 7b0edfb, 8324233)


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

Branch: refs/heads/ignite-db-x-10884
Commit: f0daea95dfbb1d6aca3a722773001c5ec0e0f5d6
Parents: fc0dd9a
Author: sboikov <sb...@gridgain.com>
Authored: Fri Apr 29 09:57:10 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed May 4 09:12:24 2016 +0300

----------------------------------------------------------------------
 .../ignite/internal/IgniteComponentType.java    |   4 +-
 .../continuous/CacheContinuousQueryHandler.java |   9 +
 .../ignite/spi/discovery/tcp/ServerImpl.java    | 214 ++++++++++++-------
 .../spi/discovery/tcp/TcpDiscoverySpi.java      |   5 +-
 .../TcpDiscoveryClientHeartbeatMessage.java     |   1 +
 .../TcpDiscoveryClientReconnectMessage.java     |  16 ++
 .../tcp/TcpClientDiscoverySpiSelfTest.java      |  44 +++-
 7 files changed, 202 insertions(+), 91 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/f0daea95/modules/core/src/main/java/org/apache/ignite/internal/IgniteComponentType.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteComponentType.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteComponentType.java
index 01872b6..76e495f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteComponentType.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteComponentType.java
@@ -285,7 +285,7 @@ public enum IgniteComponentType {
                 return (T)ctor.newInstance(ctx);
             }
         }
-        catch (Exception e) {
+        catch (Throwable e) {
             throw componentException(e);
         }
     }
@@ -309,7 +309,7 @@ public enum IgniteComponentType {
      * @param err Creation error.
      * @return Component creation exception.
      */
-    private IgniteCheckedException componentException(Exception err) {
+    private IgniteCheckedException componentException(Throwable err) {
         return new IgniteCheckedException("Failed to create Ignite component (consider adding " + module +
             " module to classpath) [component=" + this + ", cls=" + clsName + ']', err);
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/f0daea95/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
index 9ae2972..3b77d48 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
@@ -638,6 +638,15 @@ public class CacheContinuousQueryHandler<K, V> implements GridContinuousHandler
         Collection<CacheContinuousQueryEntry> entries) {
         final GridCacheContext cctx = cacheContext(ctx);
 
+        if (cctx == null) {
+            IgniteLogger log = ctx.log(CacheContinuousQueryHandler.class);
+
+            if (log.isDebugEnabled())
+                log.debug("Failed to notify callback, cache is not found: " + cacheId);
+
+            return;
+        }
+
         final Collection<CacheEntryEvent<? extends K, ? extends V>> entries0 = new ArrayList<>(entries.size());
 
         for (CacheContinuousQueryEntry e : entries) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/f0daea95/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
index 05bb1e6..84400ed 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
@@ -162,7 +162,7 @@ import static org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryStatusChe
  */
 class ServerImpl extends TcpDiscoveryImpl {
     /** */
-    private static final int ENSURED_MSG_HIST_SIZE = getInteger(IGNITE_DISCOVERY_HISTORY_SIZE, 1024 * 10);
+    private static final int ENSURED_MSG_HIST_SIZE = getInteger(IGNITE_DISCOVERY_HISTORY_SIZE, 1024);
 
     /** */
     private static final IgniteProductVersion CUSTOM_MSG_ALLOW_JOINING_FOR_VERIFIED_SINCE =
@@ -1412,6 +1412,8 @@ class ServerImpl extends TcpDiscoveryImpl {
                 ", topSize=" + ring.allNodes().size() +
                 ", leavingNodesSize=" + leavingNodesSize + ", failedNodesSize=" + failedNodesSize +
                 ", msgWorker.queue.size=" + (msgWorker != null ? msgWorker.queueSize() : "N/A") +
+                ", clients=" + ring.clientNodes().size() +
+                ", clientWorkers=" + clientMsgWorkers.size() +
                 ", lastUpdate=" + (locNode != null ? U.format(locNode.lastUpdateTime()) : "N/A") +
                 ", heapFree=" + runtime.freeMemory() / (1024 * 1024) +
                 "M, heapTotal=" + runtime.maxMemory() / (1024 * 1024) + "M]");
@@ -2114,7 +2116,7 @@ class ServerImpl extends TcpDiscoveryImpl {
     /**
      * Message worker thread for messages processing.
      */
-    private class RingMessageWorker extends MessageWorkerAdapter {
+    private class RingMessageWorker extends MessageWorkerAdapter<TcpDiscoveryAbstractMessage> {
         /** Next node. */
         @SuppressWarnings({"FieldAccessedSynchronizedAndUnsynchronized"})
         private TcpDiscoveryNode next;
@@ -2172,6 +2174,32 @@ class ServerImpl extends TcpDiscoveryImpl {
             initConnectionCheckFrequency();
         }
 
+        /**
+         * Adds message to queue.
+         *
+         * @param msg Message to add.
+         */
+        void addMessage(TcpDiscoveryAbstractMessage msg) {
+            if ((msg instanceof TcpDiscoveryStatusCheckMessage ||
+                msg instanceof TcpDiscoveryJoinRequestMessage ||
+                msg instanceof TcpDiscoveryCustomEventMessage ||
+                msg instanceof TcpDiscoveryClientReconnectMessage) &&
+                queue.contains(msg)) {
+                if (log.isDebugEnabled())
+                    log.debug("Ignoring duplicate message: " + msg);
+
+                return;
+            }
+
+            if (msg.highPriority())
+                queue.addFirst(msg);
+            else
+                queue.add(msg);
+
+            if (log.isDebugEnabled())
+                log.debug("Message has been added to queue: " + msg);
+        }
+
         /** {@inheritDoc} */
         @Override protected void body() throws InterruptedException {
             try {
@@ -2277,9 +2305,6 @@ class ServerImpl extends TcpDiscoveryImpl {
             else if (msg instanceof TcpDiscoveryNodeFailedMessage)
                 processNodeFailedMessage((TcpDiscoveryNodeFailedMessage)msg);
 
-            else if (msg instanceof TcpDiscoveryClientHeartbeatMessage)
-                processClientHeartbeatMessage((TcpDiscoveryClientHeartbeatMessage)msg);
-
             else if (msg instanceof TcpDiscoveryHeartbeatMessage)
                 processHeartbeatMessage((TcpDiscoveryHeartbeatMessage)msg);
 
@@ -2333,28 +2358,44 @@ class ServerImpl extends TcpDiscoveryImpl {
          */
         private void sendMessageToClients(TcpDiscoveryAbstractMessage msg) {
             if (redirectToClients(msg)) {
-                byte[] marshalledMsg = null;
+                byte[] msgBytes = null;
 
                 for (ClientMessageWorker clientMsgWorker : clientMsgWorkers.values()) {
-                    // Send a clone to client to avoid ConcurrentModificationException
-                    TcpDiscoveryAbstractMessage msgClone;
-
-                    try {
-                        if (marshalledMsg == null)
-                            marshalledMsg = spi.marsh.marshal(msg);
+                    if (msgBytes == null) {
+                        try {
+                            msgBytes = spi.marsh.marshal(msg);
+                        }
+                        catch (IgniteCheckedException e) {
+                            U.error(log, "Failed to marshal message: " + msg, e);
 
-                        msgClone = spi.marsh.unmarshal(marshalledMsg,
-                            U.resolveClassLoader(spi.ignite().configuration()));
+                            break;
+                        }
                     }
-                    catch (IgniteCheckedException e) {
-                        U.error(log, "Failed to marshal message: " + msg, e);
 
-                        msgClone = msg;
-                    }
+                    TcpDiscoveryAbstractMessage msg0 = msg;
+                    byte[] msgBytes0 = msgBytes;
 
-                    prepareNodeAddedMessage(msgClone, clientMsgWorker.clientNodeId, null, null, null);
+                    if (msg instanceof TcpDiscoveryNodeAddedMessage) {
+                        TcpDiscoveryNodeAddedMessage nodeAddedMsg = (TcpDiscoveryNodeAddedMessage)msg;
+
+                        TcpDiscoveryNode node = nodeAddedMsg.node();
+
+                        if (clientMsgWorker.clientNodeId.equals(node.id())) {
+                            try {
+                                msg0 = spi.marsh.unmarshal(msgBytes,
+                                    U.resolveClassLoader(spi.ignite().configuration()));
+
+                                prepareNodeAddedMessage(msg0, clientMsgWorker.clientNodeId, null, null, null);
 
-                    clientMsgWorker.addMessage(msgClone);
+                                msgBytes0 = null;
+                            }
+                            catch (IgniteCheckedException e) {
+                                U.error(log, "Failed to create message copy: " + msg, e);
+                            }
+                        }
+                    }
+
+                    clientMsgWorker.addMessage(msg0, msgBytes0);
                 }
             }
         }
@@ -4528,22 +4569,6 @@ class ServerImpl extends TcpDiscoveryImpl {
         }
 
         /**
-         * Processes client heartbeat message.
-         *
-         * @param msg Heartbeat message.
-         */
-        private void processClientHeartbeatMessage(TcpDiscoveryClientHeartbeatMessage msg) {
-            assert msg.client();
-
-            ClientMessageWorker wrk = clientMsgWorkers.get(msg.creatorNodeId());
-
-            if (wrk != null)
-                wrk.metrics(msg.metrics());
-            else if (log.isDebugEnabled())
-                log.debug("Received heartbeat message from unknown client node: " + msg);
-        }
-
-        /**
          * @param nodeId Node ID.
          * @param metrics Metrics.
          * @param cacheMetrics Cache metrics.
@@ -5448,7 +5473,12 @@ class ServerImpl extends TcpDiscoveryImpl {
                             continue;
                         }
 
-                        msgWorker.addMessage(msg);
+                        TcpDiscoveryClientHeartbeatMessage heartbeatMsg = null;
+
+                        if (msg instanceof TcpDiscoveryClientHeartbeatMessage)
+                            heartbeatMsg = (TcpDiscoveryClientHeartbeatMessage)msg;
+                        else
+                            msgWorker.addMessage(msg);
 
                         // Send receipt back.
                         if (clientMsgWrk != null) {
@@ -5460,6 +5490,9 @@ class ServerImpl extends TcpDiscoveryImpl {
                         }
                         else
                             spi.writeToSocket(msg, sock, RES_OK, socketTimeout);
+
+                        if (heartbeatMsg != null)
+                            processClientHeartbeatMessage(heartbeatMsg);
                     }
                     catch (IgniteCheckedException e) {
                         if (log.isDebugEnabled())
@@ -5527,6 +5560,22 @@ class ServerImpl extends TcpDiscoveryImpl {
         }
 
         /**
+         * Processes client heartbeat message.
+         *
+         * @param msg Heartbeat message.
+         */
+        private void processClientHeartbeatMessage(TcpDiscoveryClientHeartbeatMessage msg) {
+            assert msg.client();
+
+            ClientMessageWorker wrk = clientMsgWorkers.get(msg.creatorNodeId());
+
+            if (wrk != null)
+                wrk.metrics(msg.metrics());
+            else if (log.isDebugEnabled())
+                log.debug("Received heartbeat message from unknown client node: " + msg);
+        }
+
+        /**
          * @param msg Join request message.
          * @param clientMsgWrk Client message worker to start.
          * @return Whether connection was successful.
@@ -5653,16 +5702,13 @@ class ServerImpl extends TcpDiscoveryImpl {
 
     /**
      */
-    private class ClientMessageWorker extends MessageWorkerAdapter {
+    private class ClientMessageWorker extends MessageWorkerAdapter<T2<TcpDiscoveryAbstractMessage, byte[]>> {
         /** Node ID. */
         private final UUID clientNodeId;
 
         /** Socket. */
         private final Socket sock;
 
-        /** Output stream. */
-        private final OutputStream out;
-
         /** Current client metrics. */
         private volatile ClusterMetrics metrics;
 
@@ -5681,8 +5727,6 @@ class ServerImpl extends TcpDiscoveryImpl {
 
             this.sock = sock;
             this.clientNodeId = clientNodeId;
-
-            out = new BufferedOutputStream(sock.getOutputStream(), sock.getSendBufferSize());
         }
 
         /**
@@ -5706,11 +5750,43 @@ class ServerImpl extends TcpDiscoveryImpl {
             this.metrics = metrics;
         }
 
+        /**
+         * @param msg Message.
+         */
+        public void addMessage(TcpDiscoveryAbstractMessage msg) {
+            addMessage(msg, null);
+        }
+
+        /**
+         * @param msg Message.
+         * @param msgBytes Optional message bytes.
+         */
+        public void addMessage(TcpDiscoveryAbstractMessage msg, @Nullable byte[] msgBytes) {
+            T2 t = new T2<>(msg, msgBytes);
+
+            if (msg.highPriority())
+                queue.addFirst(t);
+            else
+                queue.add(t);
+
+            if (log.isDebugEnabled())
+                log.debug("Message has been added to client queue: " + msg);
+        }
+
         /** {@inheritDoc} */
-        @Override protected void processMessage(TcpDiscoveryAbstractMessage msg) {
+        @Override protected void processMessage(T2<TcpDiscoveryAbstractMessage, byte[]> msgT) {
+            boolean success = false;
+
+            TcpDiscoveryAbstractMessage msg = msgT.get1();
+
             try {
                 assert msg.verified() : msg;
 
+                byte[] msgBytes = msgT.get2();
+
+                if (msgBytes == null)
+                    msgBytes = spi.marsh.marshal(msg);
+
                 if (msg instanceof TcpDiscoveryClientAckResponse) {
                     if (clientVer == null) {
                         ClusterNode node = spi.getNode(clientNodeId);
@@ -5729,7 +5805,7 @@ class ServerImpl extends TcpDiscoveryImpl {
                             log.debug("Sending message ack to client [sock=" + sock + ", locNodeId="
                                 + getLocalNodeId() + ", rmtNodeId=" + clientNodeId + ", msg=" + msg + ']');
 
-                        spi.writeToSocket(sock, out, msg, spi.failureDetectionTimeoutEnabled() ?
+                        spi.writeToSocket(sock, msg, msgBytes, spi.failureDetectionTimeoutEnabled() ?
                             spi.failureDetectionTimeout() : spi.getSocketTimeout());
                     }
                 }
@@ -5740,9 +5816,11 @@ class ServerImpl extends TcpDiscoveryImpl {
 
                     assert topologyInitialized(msg) : msg;
 
-                    spi.writeToSocket(sock, out, msg, spi.failureDetectionTimeoutEnabled() ?
+                    spi.writeToSocket(sock, msg, msgBytes, spi.failureDetectionTimeoutEnabled() ?
                         spi.failureDetectionTimeout() : spi.getSocketTimeout());
                 }
+
+                success = true;
             }
             catch (IgniteCheckedException | IOException e) {
                 if (log.isDebugEnabled())
@@ -5751,12 +5829,15 @@ class ServerImpl extends TcpDiscoveryImpl {
 
                 onException("Client connection failed [sock=" + sock + ", locNodeId="
                     + getLocalNodeId() + ", rmtNodeId=" + clientNodeId + ", msg=" + msg + ']', e);
+            }
+            finally {
+                if (!success) {
+                    clientMsgWorkers.remove(clientNodeId, this);
 
-                clientMsgWorkers.remove(clientNodeId, this);
-
-                U.interrupt(this);
+                    U.interrupt(this);
 
-                U.closeQuiet(sock);
+                    U.closeQuiet(sock);
+                }
             }
         }
 
@@ -5846,9 +5927,9 @@ class ServerImpl extends TcpDiscoveryImpl {
     /**
      * Base class for message workers.
      */
-    protected abstract class MessageWorkerAdapter extends IgniteSpiThread {
+    protected abstract class MessageWorkerAdapter<T> extends IgniteSpiThread {
         /** Message queue. */
-        private final BlockingDeque<TcpDiscoveryAbstractMessage> queue = new LinkedBlockingDeque<>();
+        protected final BlockingDeque<T> queue = new LinkedBlockingDeque<>();
 
         /** Backed interrupted flag. */
         private volatile boolean interrupted;
@@ -5874,7 +5955,7 @@ class ServerImpl extends TcpDiscoveryImpl {
                 log.debug("Message worker started [locNodeId=" + getConfiguredNodeId() + ']');
 
             while (!isInterrupted()) {
-                TcpDiscoveryAbstractMessage msg = queue.poll(pollingTimeout, TimeUnit.MILLISECONDS);
+                T msg = queue.poll(pollingTimeout, TimeUnit.MILLISECONDS);
 
                 if (msg == null)
                     noMessageLoop();
@@ -5903,34 +5984,9 @@ class ServerImpl extends TcpDiscoveryImpl {
         }
 
         /**
-         * Adds message to queue.
-         *
-         * @param msg Message to add.
-         */
-        void addMessage(TcpDiscoveryAbstractMessage msg) {
-            if ((msg instanceof TcpDiscoveryStatusCheckMessage ||
-                msg instanceof TcpDiscoveryJoinRequestMessage ||
-                msg instanceof TcpDiscoveryCustomEventMessage) &&
-                queue.contains(msg)) {
-                if (log.isDebugEnabled())
-                    log.debug("Ignoring duplicate message: " + msg);
-
-                return;
-            }
-
-            if (msg.highPriority())
-                queue.addFirst(msg);
-            else
-                queue.add(msg);
-
-            if (log.isDebugEnabled())
-                log.debug("Message has been added to queue: " + msg);
-        }
-
-        /**
          * @param msg Message.
          */
-        protected abstract void processMessage(TcpDiscoveryAbstractMessage msg);
+        protected abstract void processMessage(T msg);
 
         /**
          * Called when there is no message to process giving ability to perform other activity.

http://git-wip-us.apache.org/repos/asf/ignite/blob/f0daea95/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
index 4351c64..c135b83 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
@@ -1267,7 +1267,7 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements DiscoverySpi, T
 
         sock.connect(resolved, (int)timeoutHelper.nextTimeoutChunk(sockTimeout));
 
-        writeToSocket(sock, U.IGNITE_HEADER, timeoutHelper.nextTimeoutChunk(sockTimeout));
+        writeToSocket(sock, null, U.IGNITE_HEADER, timeoutHelper.nextTimeoutChunk(sockTimeout));
 
         return sock;
     }
@@ -1297,12 +1297,13 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements DiscoverySpi, T
      * Writes message to the socket.
      *
      * @param sock Socket.
+     * @param msg Message.
      * @param data Raw data to write.
      * @param timeout Socket write timeout.
      * @throws IOException If IO failed or write timed out.
      */
     @SuppressWarnings("ThrowFromFinallyBlock")
-    private void writeToSocket(Socket sock, byte[] data, long timeout) throws IOException {
+    protected void writeToSocket(Socket sock, TcpDiscoveryAbstractMessage msg, byte[] data, long timeout) throws IOException {
         assert sock != null;
         assert data != null;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/f0daea95/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryClientHeartbeatMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryClientHeartbeatMessage.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryClientHeartbeatMessage.java
index 37b578c..3993de0 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryClientHeartbeatMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryClientHeartbeatMessage.java
@@ -38,6 +38,7 @@ public class TcpDiscoveryClientHeartbeatMessage extends TcpDiscoveryAbstractMess
      * Constructor.
      *
      * @param creatorNodeId Creator node.
+     * @param metrics Metrics.
      */
     public TcpDiscoveryClientHeartbeatMessage(UUID creatorNodeId, ClusterMetrics metrics) {
         super(creatorNodeId);

http://git-wip-us.apache.org/repos/asf/ignite/blob/f0daea95/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryClientReconnectMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryClientReconnectMessage.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryClientReconnectMessage.java
index 7c0cd5d..7cce78b 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryClientReconnectMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryClientReconnectMessage.java
@@ -20,6 +20,7 @@ package org.apache.ignite.spi.discovery.tcp.messages;
 import java.util.Collection;
 import java.util.UUID;
 import org.apache.ignite.internal.util.tostring.GridToStringExclude;
+import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.lang.IgniteUuid;
 
@@ -96,6 +97,21 @@ public class TcpDiscoveryClientReconnectMessage extends TcpDiscoveryAbstractMess
     }
 
     /** {@inheritDoc} */
+    @Override public boolean equals(Object obj) {
+        // NOTE!
+        // Do not call super. As IDs will differ, but we can ignore this.
+
+        if (!(obj instanceof TcpDiscoveryClientReconnectMessage))
+            return false;
+
+        TcpDiscoveryClientReconnectMessage other = (TcpDiscoveryClientReconnectMessage)obj;
+
+        return F.eq(creatorNodeId(), other.creatorNodeId()) &&
+            F.eq(routerNodeId, other.routerNodeId) &&
+            F.eq(lastMsgId, other.lastMsgId);
+    }
+
+    /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(TcpDiscoveryClientReconnectMessage.class, this, "super", super.toString());
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/f0daea95/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiSelfTest.java
index e01094c..331b581 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiSelfTest.java
@@ -1736,8 +1736,7 @@ public class TcpClientDiscoverySpiSelfTest extends GridCommonAbstractTest {
         final AtomicBoolean err = new AtomicBoolean(false);
 
         client.events().localListen(new IgnitePredicate<Event>() {
-            @Override
-            public boolean apply(Event evt) {
+            @Override public boolean apply(Event evt) {
                 if (evt.type() == EVT_CLIENT_NODE_DISCONNECTED) {
                     log.info("Disconnected event.");
 
@@ -2158,17 +2157,49 @@ public class TcpClientDiscoverySpiSelfTest extends GridCommonAbstractTest {
         }
 
         /** {@inheritDoc} */
-        @Override protected void writeToSocket(Socket sock, OutputStream out, TcpDiscoveryAbstractMessage msg,
+        @Override protected void writeToSocket(Socket sock,
+            OutputStream out,
+            TcpDiscoveryAbstractMessage msg,
             long timeout) throws IOException, IgniteCheckedException {
             waitFor(writeLock);
 
+            if (!onMessage(sock, msg))
+                return;
+
+            super.writeToSocket(sock, out, msg, timeout);
+
+            if (afterWrite != null)
+                afterWrite.apply(msg, sock);
+        }
+
+        /** {@inheritDoc} */
+        @Override protected void writeToSocket(Socket sock, TcpDiscoveryAbstractMessage msg, byte[] msgBytes,
+            long timeout) throws IOException {
+            waitFor(writeLock);
+
+            if (!onMessage(sock, msg))
+                return;
+
+            super.writeToSocket(sock, msg, msgBytes, timeout);
+
+            if (afterWrite != null)
+                afterWrite.apply(msg, sock);
+        }
+
+        /**
+         * @param sock Socket.
+         * @param msg Message.
+         * @return {@code False} if should not further process message.
+         * @throws IOException If failed.
+         */
+        private boolean onMessage(Socket sock, TcpDiscoveryAbstractMessage msg) throws IOException {
             boolean fail = false;
 
             if (skipNodeAdded &&
                 (msg instanceof TcpDiscoveryNodeAddedMessage || msg instanceof TcpDiscoveryNodeAddFinishedMessage)) {
                 log.info("Skip message: " + msg);
 
-                return;
+                return false;
             }
 
             if (msg instanceof TcpDiscoveryNodeAddedMessage)
@@ -2184,10 +2215,7 @@ public class TcpClientDiscoverySpiSelfTest extends GridCommonAbstractTest {
                 sock.close();
             }
 
-            super.writeToSocket(sock, out, msg, timeout);
-
-            if (afterWrite != null)
-                afterWrite.apply(msg, sock);
+            return true;
         }
 
         /** {@inheritDoc} */


[11/15] ignite git commit: IGNITE-3057 - Optimization for transactions that do not acquire locks (cherry picked from commit b476fdf)

Posted by sb...@apache.org.
IGNITE-3057 - Optimization for transactions that do not acquire locks
(cherry picked from commit b476fdf)


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

Branch: refs/heads/ignite-db-x-10884
Commit: fc0dd9a48079f99622b533ca0f4037e3e4185bd1
Parents: 34c03833
Author: sboikov <sb...@gridgain.com>
Authored: Wed Apr 27 14:04:24 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed May 4 08:58:37 2016 +0300

----------------------------------------------------------------------
 .../cache/distributed/near/GridNearTxLocal.java |  32 +++
 .../cache/transactions/IgniteTxManager.java     |  40 +++
 .../processors/cache/CacheTxFastFinishTest.java | 253 +++++++++++++++++++
 .../ignite/testsuites/IgniteCacheTestSuite.java |   3 +
 4 files changed, 328 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/fc0dd9a4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
index 4aee6ad..7f3ecd0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
@@ -72,6 +72,7 @@ import org.jetbrains.annotations.Nullable;
 
 import static org.apache.ignite.transactions.TransactionState.COMMITTED;
 import static org.apache.ignite.transactions.TransactionState.COMMITTING;
+import static org.apache.ignite.transactions.TransactionState.PREPARED;
 import static org.apache.ignite.transactions.TransactionState.PREPARING;
 import static org.apache.ignite.transactions.TransactionState.ROLLED_BACK;
 import static org.apache.ignite.transactions.TransactionState.ROLLING_BACK;
@@ -824,6 +825,18 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
         if (log.isDebugEnabled())
             log.debug("Committing near local tx: " + this);
 
+        if (fastFinish()) {
+            state(PREPARING);
+            state(PREPARED);
+            state(COMMITTING);
+
+            cctx.tm().fastFinishTx(this, true);
+
+            state(COMMITTED);
+
+            return new GridFinishedFuture<>((IgniteInternalTx)this);
+        }
+
         prepareAsync();
 
         GridNearTxFinishFuture fut = commitFut;
@@ -869,6 +882,18 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
         if (log.isDebugEnabled())
             log.debug("Rolling back near tx: " + this);
 
+        if (fastFinish()) {
+            state(PREPARING);
+            state(PREPARED);
+            state(ROLLING_BACK);
+
+            cctx.tm().fastFinishTx(this, false);
+
+            state(ROLLED_BACK);
+
+            return new GridFinishedFuture<>((IgniteInternalTx)this);
+        }
+
         GridNearTxFinishFuture fut = rollbackFut;
 
         if (fut != null)
@@ -917,6 +942,13 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
     }
 
     /**
+     * @return {@code True} if 'fast finish' path can be used for transaction completion.
+     */
+    private boolean fastFinish() {
+        return writeMap().isEmpty() && ((optimistic() && !serializable()) || readMap().isEmpty());
+    }
+
+    /**
      * Prepares next batch of entries in dht transaction.
      *
      * @param reads Read entries.

http://git-wip-us.apache.org/repos/asf/ignite/blob/fc0dd9a4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
index 7fbf253..ccfc4de 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
@@ -1186,6 +1186,46 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
     }
 
     /**
+     * Fast finish transaction. Can be used only if no locks were acquired.
+     *
+     * @param tx Transaction to finish.
+     * @param commit {@code True} if transaction is committed, {@code false} if rolled back.
+     */
+    public void fastFinishTx(IgniteInternalTx tx, boolean commit) {
+        assert tx != null;
+        assert tx.writeMap().isEmpty();
+        assert tx.optimistic() || tx.readMap().isEmpty();
+
+        ConcurrentMap<GridCacheVersion, IgniteInternalTx> txIdMap = transactionMap(tx);
+
+        if (txIdMap.remove(tx.xidVersion(), tx)) {
+            // 1. Notify evictions.
+            notifyEvitions(tx);
+
+            // 2. Remove obsolete entries.
+            removeObsolete(tx);
+
+            // 3. Remove from per-thread storage.
+            clearThreadMap(tx);
+
+            // 4. Clear context.
+            resetContext();
+
+            // 5. Update metrics.
+            if (!tx.dht() && tx.local()) {
+                if (!tx.system()) {
+                    if (commit)
+                        cctx.txMetrics().onTxCommit();
+                    else
+                        cctx.txMetrics().onTxRollback();
+                }
+
+                tx.txState().onTxEnd(cctx, tx, commit);
+            }
+        }
+    }
+
+    /**
      * Tries to minimize damage from partially-committed transaction.
      *
      * @param tx Tx to uncommit.

http://git-wip-us.apache.org/repos/asf/ignite/blob/fc0dd9a4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheTxFastFinishTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheTxFastFinishTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheTxFastFinishTest.java
new file mode 100644
index 0000000..35b1405
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheTxFastFinishTest.java
@@ -0,0 +1,253 @@
+/*
+ * 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.util.concurrent.atomic.AtomicReference;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteTransactions;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.NearCacheConfiguration;
+import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
+import org.apache.ignite.internal.processors.cache.transactions.TransactionProxyImpl;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+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;
+import static org.apache.ignite.cache.CacheMode.PARTITIONED;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
+import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC;
+import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
+import static org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED;
+import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
+import static org.apache.ignite.transactions.TransactionIsolation.SERIALIZABLE;
+
+/**
+ *
+ */
+public class CacheTxFastFinishTest extends GridCommonAbstractTest {
+    /** */
+    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+    /** */
+    private boolean client;
+
+    /** */
+    private boolean nearCache;
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);
+
+        CacheConfiguration ccfg = new CacheConfiguration();
+
+        ccfg.setCacheMode(PARTITIONED);
+        ccfg.setAtomicityMode(TRANSACTIONAL);
+        ccfg.setBackups(1);
+        ccfg.setWriteSynchronizationMode(FULL_SYNC);
+
+        if (nearCache)
+            ccfg.setNearConfiguration(new NearCacheConfiguration());
+
+        cfg.setCacheConfiguration(ccfg);
+
+        cfg.setClientMode(client);
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        super.afterTest();
+
+        stopAllGrids();
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testFastFinishTxNearCache() throws Exception {
+        nearCache = true;
+
+        fastFinishTx();
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testFastFinishTx() throws Exception {
+        fastFinishTx();
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    private void fastFinishTx() throws Exception {
+        startGrid(0);
+
+        fastFinishTx(ignite(0));
+
+        client = true;
+
+        startGrid(1);
+
+        for (int i = 0; i < 2; i++)
+            fastFinishTx(ignite(i));
+
+        client = false;
+
+        startGrid(2);
+
+        for (int i = 0; i < 3; i++)
+            fastFinishTx(ignite(i));
+
+        startGrid(3);
+
+        for (int i = 0; i < 4; i++)
+            fastFinishTx(ignite(i));
+
+        stopGrid(1);
+
+        for (int i = 0; i < 4; i++) {
+            if (i != 1)
+                fastFinishTx(ignite(i));
+        }
+    }
+
+    /**
+     * @param ignite Node.
+     */
+    private void fastFinishTx(Ignite ignite) {
+        IgniteTransactions txs = ignite.transactions();
+
+        IgniteCache cache = ignite.cache(null);
+
+        for (boolean commit : new boolean[]{true, false}) {
+            for (TransactionConcurrency c : TransactionConcurrency.values()) {
+                for (TransactionIsolation isolation : TransactionIsolation.values()) {
+                    try (Transaction tx = txs.txStart(c, isolation)) {
+                        checkFastTxFinish(tx, commit);
+                    }
+                }
+            }
+
+            for (int i = 0; i < 100; i++) {
+                try (Transaction tx = txs.txStart(OPTIMISTIC, REPEATABLE_READ)) {
+                    cache.get(i);
+
+                    checkFastTxFinish(tx, commit);
+                }
+
+                try (Transaction tx = txs.txStart(OPTIMISTIC, READ_COMMITTED)) {
+                    cache.get(i);
+
+                    checkFastTxFinish(tx, commit);
+                }
+            }
+
+            for (int i = 0; i < 100; i++) {
+                try (Transaction tx = txs.txStart(OPTIMISTIC, SERIALIZABLE)) {
+                    cache.get(i);
+
+                    checkNormalTxFinish(tx, commit);
+                }
+
+                try (Transaction tx = txs.txStart(PESSIMISTIC, REPEATABLE_READ)) {
+                    cache.get(i);
+
+                    checkNormalTxFinish(tx, commit);
+                }
+            }
+
+            for (int i = 0; i < 100; i++) {
+                for (TransactionConcurrency c : TransactionConcurrency.values()) {
+                    for (TransactionIsolation isolation : TransactionIsolation.values()) {
+                        try (Transaction tx = txs.txStart(c, isolation)) {
+                            cache.put(i, i);
+
+                            checkNormalTxFinish(tx, commit);
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * @param tx Transaction.
+     * @param commit Commit flag.
+     */
+    private void checkFastTxFinish(Transaction tx, boolean commit) {
+        if (commit)
+            tx.commit();
+        else
+            tx.rollback();
+
+        IgniteInternalTx tx0 = ((TransactionProxyImpl)tx).tx();
+
+        assertNull(fieldValue(tx0, "prepFut"));
+        assertNull(fieldValue(tx0, "commitFut"));
+        assertNull(fieldValue(tx0, "rollbackFut"));
+    }
+
+    /**
+     * @param tx Transaction.
+     * @param commit Commit flag.
+     */
+    private void checkNormalTxFinish(Transaction tx, boolean commit) {
+        IgniteInternalTx tx0 = ((TransactionProxyImpl)tx).tx();
+
+        if (commit) {
+            tx.commit();
+
+            assertNotNull(fieldValue(tx0, "prepFut"));
+            assertNotNull(fieldValue(tx0, "commitFut"));
+        }
+        else {
+            tx.rollback();
+
+            assertNotNull(fieldValue(tx0, "rollbackFut"));
+        }
+    }
+
+    /**
+     * @param obj Obejct.
+     * @param fieldName Field name.
+     * @return Field value.
+     */
+    private Object fieldValue(Object obj, String fieldName) {
+        Object val = GridTestUtils.getFieldValue(obj, fieldName);
+
+        if (val == null)
+            return null;
+
+        if (val instanceof AtomicReference)
+            return ((AtomicReference)val).get();
+
+        return val;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/fc0dd9a4/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 7edd0a0..3238786 100755
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
@@ -44,6 +44,7 @@ import org.apache.ignite.internal.processors.cache.CacheFutureExceptionSelfTest;
 import org.apache.ignite.internal.processors.cache.CacheNamesSelfTest;
 import org.apache.ignite.internal.processors.cache.CacheNamesWithSpecialCharactersTest;
 import org.apache.ignite.internal.processors.cache.CachePutEventListenerErrorSelfTest;
+import org.apache.ignite.internal.processors.cache.CacheTxFastFinishTest;
 import org.apache.ignite.internal.processors.cache.GridCacheAffinityApiSelfTest;
 import org.apache.ignite.internal.processors.cache.GridCacheAffinityMapperSelfTest;
 import org.apache.ignite.internal.processors.cache.GridCacheAffinityRoutingSelfTest;
@@ -302,6 +303,8 @@ public class IgniteCacheTestSuite extends TestSuite {
 
         suite.addTestSuite(IgniteTxConfigCacheSelfTest.class);
 
+        suite.addTestSuite(CacheTxFastFinishTest.class);
+
         return suite;
     }
 }


[10/15] ignite git commit: Fixed compilation.

Posted by sb...@apache.org.
Fixed compilation.


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

Branch: refs/heads/ignite-db-x-10884
Commit: 34c038337813e37d3aecc6a8f8520a9cbfc4ee01
Parents: e78ed8e
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Wed May 4 10:23:45 2016 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Wed May 4 10:23:45 2016 +0700

----------------------------------------------------------------------
 .../src/test/scala/org/apache/ignite/spark/IgniteRDDSpec.scala     | 2 --
 1 file changed, 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/34c03833/modules/spark/src/test/scala/org/apache/ignite/spark/IgniteRDDSpec.scala
----------------------------------------------------------------------
diff --git a/modules/spark/src/test/scala/org/apache/ignite/spark/IgniteRDDSpec.scala b/modules/spark/src/test/scala/org/apache/ignite/spark/IgniteRDDSpec.scala
index a41839d..a25eaac 100644
--- a/modules/spark/src/test/scala/org/apache/ignite/spark/IgniteRDDSpec.scala
+++ b/modules/spark/src/test/scala/org/apache/ignite/spark/IgniteRDDSpec.scala
@@ -17,8 +17,6 @@
 
 package org.apache.ignite.spark
 
-import java.time.LocalDate
-
 import org.apache.ignite.Ignition
 import org.apache.ignite.cache.query.annotations.{QueryTextField, QuerySqlField}
 import org.apache.ignite.configuration.{CacheConfiguration, IgniteConfiguration}


[13/15] ignite git commit: Merge remote-tracking branch 'remotes/origin/master' into ignite-db-x-10884

Posted by sb...@apache.org.
Merge remote-tracking branch 'remotes/origin/master' into ignite-db-x-10884


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

Branch: refs/heads/ignite-db-x-10884
Commit: 891d7066a94034b66a354ef460e0de922d3f3b3c
Parents: 2b9b1ba f0daea9
Author: sboikov <sb...@gridgain.com>
Authored: Wed May 4 10:18:46 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed May 4 10:18:46 2016 +0300

----------------------------------------------------------------------
 .../ignite/internal/IgniteComponentType.java    |   4 +-
 .../dht/GridClientPartitionTopology.java        |   6 +-
 .../dht/GridDhtPartitionTopology.java           |   2 +-
 .../dht/GridDhtPartitionTopologyImpl.java       |   6 +-
 .../dht/GridDhtTransactionalCacheAdapter.java   |   4 +-
 .../dht/atomic/GridDhtAtomicUpdateFuture.java   |   8 +-
 .../dht/atomic/GridNearAtomicUpdateFuture.java  |  10 +-
 .../cache/distributed/near/GridNearTxLocal.java |  32 ++
 .../continuous/CacheContinuousQueryHandler.java |   9 +
 .../cache/transactions/IgniteTxManager.java     |  40 +++
 .../datastructures/GridCacheLockState.java      |   2 +-
 .../platform/PlatformNoopProcessor.java         |   5 +
 .../processors/platform/PlatformProcessor.java  |   7 +
 .../platform/PlatformProcessorImpl.java         |  15 +
 .../processors/task/GridTaskWorker.java         |   2 +-
 .../java/org/apache/ignite/lang/IgniteUuid.java |   2 +-
 .../ignite/spi/discovery/tcp/ServerImpl.java    | 214 +++++++-----
 .../spi/discovery/tcp/TcpDiscoverySpi.java      |   5 +-
 .../TcpDiscoveryClientHeartbeatMessage.java     |   1 +
 .../TcpDiscoveryClientReconnectMessage.java     |  16 +
 .../internal/GridTaskExecutionSelfTest.java     |  76 +++-
 .../BinaryObjectOffHeapUnswapTemporaryTest.java |  12 +-
 .../processors/cache/CacheTxFastFinishTest.java | 253 ++++++++++++++
 ...gniteServiceConfigVariationsFullApiTest.java | 350 +++++++++++++++++++
 .../tcp/TcpClientDiscoverySpiSelfTest.java      |  44 ++-
 .../configvariations/VariationsTestsConfig.java |   2 +-
 .../IgniteConfigVariationsAbstractTest.java     |  72 +++-
 .../IgniteCacheDataStructuresSelfTestSuite.java |   6 +-
 .../ignite/testsuites/IgniteCacheTestSuite.java |   3 +
 ...ServiceConfigVariationsFullApiTestSuite.java |  92 +++++
 .../cpp/common/include/ignite/common/exports.h  |   1 +
 .../cpp/common/include/ignite/common/java.h     |   2 +
 .../platforms/cpp/common/project/vs/module.def  |   1 +
 modules/platforms/cpp/common/src/exports.cpp    |   4 +
 modules/platforms/cpp/common/src/java.cpp       |  11 +
 .../Cache/CacheAbstractTest.cs                  |  18 +
 .../dotnet/Apache.Ignite.Core/IIgnite.cs        |   8 +
 .../dotnet/Apache.Ignite.Core/Impl/Ignite.cs    |  18 +
 .../Apache.Ignite.Core/Impl/IgniteProxy.cs      |   7 +
 .../Impl/Unmanaged/IgniteJniNativeMethods.cs    |   3 +
 .../Impl/Unmanaged/UnmanagedUtils.cs            |   5 +
 .../org/apache/ignite/spark/IgniteRDDSpec.scala |  38 +-
 42 files changed, 1291 insertions(+), 125 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/891d7066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/ignite/blob/891d7066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/ignite/blob/891d7066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
----------------------------------------------------------------------


[04/15] ignite git commit: IGNITE-2957 .NET: Added IIgnite.CacheNames() method. This closes #675.

Posted by sb...@apache.org.
IGNITE-2957 .NET: Added IIgnite.CacheNames() method. This closes #675.


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

Branch: refs/heads/ignite-db-x-10884
Commit: 72df110499962c177857cbeff368528094535f5c
Parents: 8dd6f19
Author: Pavel Tupitsyn <pt...@gridgain.com>
Authored: Fri Apr 29 10:26:57 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Apr 29 10:26:57 2016 +0300

----------------------------------------------------------------------
 .../platform/PlatformNoopProcessor.java           |  5 +++++
 .../processors/platform/PlatformProcessor.java    |  7 +++++++
 .../platform/PlatformProcessorImpl.java           | 15 +++++++++++++++
 .../cpp/common/include/ignite/common/exports.h    |  1 +
 .../cpp/common/include/ignite/common/java.h       |  2 ++
 .../platforms/cpp/common/project/vs/module.def    |  1 +
 modules/platforms/cpp/common/src/exports.cpp      |  4 ++++
 modules/platforms/cpp/common/src/java.cpp         | 11 +++++++++++
 .../Cache/CacheAbstractTest.cs                    | 18 ++++++++++++++++++
 .../dotnet/Apache.Ignite.Core/IIgnite.cs          |  8 ++++++++
 .../dotnet/Apache.Ignite.Core/Impl/Ignite.cs      | 18 ++++++++++++++++++
 .../dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs |  7 +++++++
 .../Impl/Unmanaged/IgniteJniNativeMethods.cs      |  3 +++
 .../Impl/Unmanaged/UnmanagedUtils.cs              |  5 +++++
 14 files changed, 105 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/72df1104/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformNoopProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformNoopProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformNoopProcessor.java
index 155981c..cdf418f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformNoopProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformNoopProcessor.java
@@ -152,6 +152,11 @@ public class PlatformNoopProcessor extends GridProcessorAdapter implements Platf
     }
 
     /** {@inheritDoc} */
+    @Override public void getCacheNames(long memPtr) {
+        // No-op.
+    }
+
+    /** {@inheritDoc} */
     @Override public PlatformTarget atomicSequence(String name, long initVal, boolean create) throws IgniteException {
         return null;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/72df1104/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessor.java
index cca29d8..fc42b68 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessor.java
@@ -235,6 +235,13 @@ public interface PlatformProcessor extends GridProcessor {
     public void getIgniteConfiguration(long memPtr);
 
     /**
+     * Gets the cache names.
+     *
+     * @param memPtr Stream to write data to.
+     */
+    public void getCacheNames(long memPtr);
+
+    /**
      * Starts a near cache on local node if cache was previously started.
      *
      * @param cacheName Cache name.

http://git-wip-us.apache.org/repos/asf/ignite/blob/72df1104/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessorImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessorImpl.java
index e294735..5830d37 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessorImpl.java
@@ -415,6 +415,21 @@ public class PlatformProcessorImpl extends GridProcessorAdapter implements Platf
     }
 
     /** {@inheritDoc} */
+    @Override public void getCacheNames(long memPtr) {
+        PlatformOutputStream stream = platformCtx.memory().get(memPtr).output();
+        BinaryRawWriterEx writer = platformCtx.writer(stream);
+
+        Collection<String> names = ignite().cacheNames();
+
+        writer.writeInt(names.size());
+
+        for (String name : names)
+            writer.writeString(name);
+
+        stream.synchronize();
+    }
+
+    /** {@inheritDoc} */
     @Override public PlatformTarget createNearCache(@Nullable String cacheName, long memPtr) {
         NearCacheConfiguration cfg = getNearCacheConfiguration(memPtr);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/72df1104/modules/platforms/cpp/common/include/ignite/common/exports.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/include/ignite/common/exports.h b/modules/platforms/cpp/common/include/ignite/common/exports.h
index c62b365..5798c83 100644
--- a/modules/platforms/cpp/common/include/ignite/common/exports.h
+++ b/modules/platforms/cpp/common/include/ignite/common/exports.h
@@ -53,6 +53,7 @@ extern "C" {
     void* IGNITE_CALL IgniteProcessorAtomicSequence(gcj::JniContext* ctx, void* obj, char* name, long long initVal, bool create);
     void* IGNITE_CALL IgniteProcessorAtomicReference(gcj::JniContext* ctx, void* obj, char* name, long long memPtr, bool create);
     void IGNITE_CALL IgniteProcessorGetIgniteConfiguration(gcj::JniContext* ctx, void* obj, long long memPtr);
+    void IGNITE_CALL IgniteProcessorGetCacheNames(gcj::JniContext* ctx, void* obj, long long memPtr);
     
     long long IGNITE_CALL IgniteTargetInStreamOutLong(gcj::JniContext* ctx, void* obj, int opType, long long memPtr);
     void IGNITE_CALL IgniteTargetInStreamOutStream(gcj::JniContext* ctx, void* obj, int opType, long long inMemPtr, long long outMemPtr);

http://git-wip-us.apache.org/repos/asf/ignite/blob/72df1104/modules/platforms/cpp/common/include/ignite/common/java.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/include/ignite/common/java.h b/modules/platforms/cpp/common/include/ignite/common/java.h
index f2007cb..7deb5ef 100644
--- a/modules/platforms/cpp/common/include/ignite/common/java.h
+++ b/modules/platforms/cpp/common/include/ignite/common/java.h
@@ -319,6 +319,7 @@ namespace ignite
                 jmethodID m_PlatformProcessor_extensions;
                 jmethodID m_PlatformProcessor_atomicLong;
                 jmethodID m_PlatformProcessor_getIgniteConfiguration;
+                jmethodID m_PlatformProcessor_getCacheNames;
                 jmethodID m_PlatformProcessor_atomicSequence;
                 jmethodID m_PlatformProcessor_atomicReference;
 
@@ -537,6 +538,7 @@ namespace ignite
                 jobject ProcessorAtomicSequence(jobject obj, char* name, long long initVal, bool create);
                 jobject ProcessorAtomicReference(jobject obj, char* name, long long memPtr, bool create);
 				void ProcessorGetIgniteConfiguration(jobject obj, long long memPtr);
+				void ProcessorGetCacheNames(jobject obj, long long memPtr);
                 
                 long long TargetInStreamOutLong(jobject obj, int type, long long memPtr, JniErrorInfo* errInfo = NULL);
                 void TargetInStreamOutStream(jobject obj, int opType, long long inMemPtr, long long outMemPtr, JniErrorInfo* errInfo = NULL);

http://git-wip-us.apache.org/repos/asf/ignite/blob/72df1104/modules/platforms/cpp/common/project/vs/module.def
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/project/vs/module.def b/modules/platforms/cpp/common/project/vs/module.def
index 57e58f3..5f2e941 100644
--- a/modules/platforms/cpp/common/project/vs/module.def
+++ b/modules/platforms/cpp/common/project/vs/module.def
@@ -132,3 +132,4 @@ IgniteAtomicReferenceIsClosed @129
 IgniteAtomicReferenceClose @130
 IgniteProcessorCreateNearCache @131
 IgniteProcessorGetOrCreateNearCache @132
+IgniteProcessorGetCacheNames @133

http://git-wip-us.apache.org/repos/asf/ignite/blob/72df1104/modules/platforms/cpp/common/src/exports.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/src/exports.cpp b/modules/platforms/cpp/common/src/exports.cpp
index 0d951b6..43ccb7a 100644
--- a/modules/platforms/cpp/common/src/exports.cpp
+++ b/modules/platforms/cpp/common/src/exports.cpp
@@ -134,6 +134,10 @@ extern "C" {
         return ctx->ProcessorGetIgniteConfiguration(static_cast<jobject>(obj), memPtr);
     }
 
+	void IGNITE_CALL IgniteProcessorGetCacheNames(gcj::JniContext* ctx, void* obj, long long memPtr) {
+        return ctx->ProcessorGetCacheNames(static_cast<jobject>(obj), memPtr);
+    }
+
     long long IGNITE_CALL IgniteTargetInStreamOutLong(gcj::JniContext* ctx, void* obj, int opType, long long memPtr) {
         return ctx->TargetInStreamOutLong(static_cast<jobject>(obj), opType, memPtr);
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/72df1104/modules/platforms/cpp/common/src/java.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/src/java.cpp b/modules/platforms/cpp/common/src/java.cpp
index 081a606..663e2b1 100644
--- a/modules/platforms/cpp/common/src/java.cpp
+++ b/modules/platforms/cpp/common/src/java.cpp
@@ -208,6 +208,7 @@ namespace ignite
             JniMethod M_PLATFORM_PROCESSOR_ATOMIC_SEQUENCE = JniMethod("atomicSequence", "(Ljava/lang/String;JZ)Lorg/apache/ignite/internal/processors/platform/PlatformTarget;", false);
             JniMethod M_PLATFORM_PROCESSOR_ATOMIC_REFERENCE = JniMethod("atomicReference", "(Ljava/lang/String;JZ)Lorg/apache/ignite/internal/processors/platform/PlatformTarget;", false);            
             JniMethod M_PLATFORM_PROCESSOR_GET_IGNITE_CONFIGURATION = JniMethod("getIgniteConfiguration", "(J)V", false);
+            JniMethod M_PLATFORM_PROCESSOR_GET_CACHE_NAMES = JniMethod("getCacheNames", "(J)V", false);
 
             const char* C_PLATFORM_TARGET = "org/apache/ignite/internal/processors/platform/PlatformTarget";
             JniMethod M_PLATFORM_TARGET_IN_STREAM_OUT_LONG = JniMethod("inStreamOutLong", "(IJ)J", false);
@@ -679,6 +680,7 @@ namespace ignite
                 m_PlatformProcessor_atomicSequence = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_ATOMIC_SEQUENCE);
                 m_PlatformProcessor_atomicReference = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_ATOMIC_REFERENCE);
 				m_PlatformProcessor_getIgniteConfiguration = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_GET_IGNITE_CONFIGURATION);
+				m_PlatformProcessor_getCacheNames = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_GET_CACHE_NAMES);
 
                 c_PlatformTarget = FindClass(env, C_PLATFORM_TARGET);
                 m_PlatformTarget_inStreamOutLong = FindMethod(env, c_PlatformTarget, M_PLATFORM_TARGET_IN_STREAM_OUT_LONG);
@@ -1462,6 +1464,15 @@ namespace ignite
                 ExceptionCheck(env);
             }
 
+            void JniContext::ProcessorGetCacheNames(jobject obj, long long memPtr)
+            {
+                JNIEnv* env = Attach();
+
+                env->CallVoidMethod(obj, jvm->GetMembers().m_PlatformProcessor_getCacheNames, memPtr);
+
+                ExceptionCheck(env);
+            }
+
             long long JniContext::TargetInStreamOutLong(jobject obj, int opType, long long memPtr, JniErrorInfo* err) {
                 JNIEnv* env = Attach();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/72df1104/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
index 9f0528c..62dc2df 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
@@ -3062,8 +3062,10 @@ namespace Apache.Ignite.Core.Tests.Cache
 
             // Can't get non-existent cache with Cache method
             Assert.Throws<ArgumentException>(() => GetIgnite(0).GetCache<int, int>(randomName));
+            Assert.IsFalse(GetIgnite(0).GetCacheNames().Contains(randomName));
 
             var cache = GetIgnite(0).CreateCache<int, int>(randomName);
+            Assert.IsTrue(GetIgnite(0).GetCacheNames().Contains(randomName));
 
             cache.Put(1, 10);
 
@@ -3111,9 +3113,12 @@ namespace Apache.Ignite.Core.Tests.Cache
             var cache = ignite.CreateCache<int, int>(cacheName);
 
             Assert.IsNotNull(ignite.GetCache<int, int>(cacheName));
+            Assert.IsTrue(GetIgnite(0).GetCacheNames().Contains(cacheName));
 
             ignite.DestroyCache(cache.Name);
 
+            Assert.IsFalse(GetIgnite(0).GetCacheNames().Contains(cacheName));
+
             var ex = Assert.Throws<ArgumentException>(() => ignite.GetCache<int, int>(cacheName));
 
             Assert.IsTrue(ex.Message.StartsWith("Cache doesn't exist"));
@@ -3121,6 +3126,19 @@ namespace Apache.Ignite.Core.Tests.Cache
             Assert.Throws<InvalidOperationException>(() => cache.Get(1));
         }
 
+        [Test]
+        public void TestCacheNames()
+        {
+            var cacheNames = GetIgnite(0).GetCacheNames();
+            var expectedNames = new[]
+            {
+                "local", "local_atomic", "partitioned", "partitioned_atomic",
+                "partitioned_near", "partitioned_atomic_near", "replicated", "replicated_atomic"
+            };
+
+            Assert.AreEqual(0, expectedNames.Except(cacheNames).Count());
+        }
+
 
         [Test]
         public void TestIndexer()

http://git-wip-us.apache.org/repos/asf/ignite/blob/72df1104/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs b/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs
index 428c1a8..b45c625 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs
@@ -18,6 +18,7 @@
 namespace Apache.Ignite.Core
 {
     using System;
+    using System.Collections.Generic;
     using System.Diagnostics.CodeAnalysis;
     using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Cache;
@@ -266,5 +267,12 @@ namespace Apache.Ignite.Core
         /// <typeparam name="TV">Cache value type.</typeparam>
         /// <returns>Near cache instance.</returns>
         ICache<TK, TV> GetOrCreateNearCache<TK, TV>(string name, NearCacheConfiguration configuration);
+
+        /// <summary>
+        /// Gets the collection of names of currently available caches, or empty collection if there are no caches.
+        /// Note that null string is a valid cache name.
+        /// </summary>
+        /// <returns>Collection of names of currently available caches.</returns>
+        ICollection<string> GetCacheNames();
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/72df1104/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
index b84ff29..aee82a7 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
@@ -622,6 +622,24 @@ namespace Apache.Ignite.Core.Impl
             return GetOrCreateNearCache0<TK, TV>(name, configuration, UU.ProcessorGetOrCreateNearCache);
         }
 
+        /** <inheritdoc /> */
+        public ICollection<string> GetCacheNames()
+        {
+            using (var stream = IgniteManager.Memory.Allocate(1024).GetStream())
+            {
+                UU.ProcessorGetCacheNames(_proc, stream.MemoryPointer);
+                stream.SynchronizeInput();
+
+                var reader = _marsh.StartUnmarshal(stream);
+                var res = new string[stream.ReadInt()];
+
+                for (int i = 0; i < res.Length; i++)
+                    res[i] = reader.ReadString();
+
+                return res;
+            }
+        }
+
         /// <summary>
         /// Gets or creates near cache.
         /// </summary>

http://git-wip-us.apache.org/repos/asf/ignite/blob/72df1104/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs
index a767077..0ad056a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs
@@ -366,12 +366,19 @@ namespace Apache.Ignite.Core.Impl
             return _ignite.CreateNearCache<TK, TV>(name, configuration);
         }
 
+        /** <inheritdoc /> */
         public ICache<TK, TV> GetOrCreateNearCache<TK, TV>(string name, NearCacheConfiguration configuration)
         {
             return _ignite.GetOrCreateNearCache<TK, TV>(name, configuration);
         }
 
         /** <inheritdoc /> */
+        public ICollection<string> GetCacheNames()
+        {
+            return _ignite.GetCacheNames();
+        }
+
+        /** <inheritdoc /> */
         public IAtomicSequence GetAtomicSequence(string name, long initialValue, bool create)
         {
             return _ignite.GetAtomicSequence(name, initialValue, create);

http://git-wip-us.apache.org/repos/asf/ignite/blob/72df1104/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IgniteJniNativeMethods.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IgniteJniNativeMethods.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IgniteJniNativeMethods.cs
index 2603841..bb26382 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IgniteJniNativeMethods.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IgniteJniNativeMethods.cs
@@ -110,6 +110,9 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
         [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteProcessorGetIgniteConfiguration")]
         public static extern void ProcessorGetIgniteConfiguration(void* ctx, void* obj, long memPtr);
 
+        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteProcessorGetCacheNames")]
+        public static extern void ProcessorGetCacheNames(void* ctx, void* obj, long memPtr);
+
         [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteTargetInStreamOutLong")]
         public static extern long TargetInStreamOutLong(void* ctx, void* target, int opType, long memPtr);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/72df1104/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs
index f8b5256..a0abfaa 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs
@@ -356,6 +356,11 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
             JNI.ProcessorGetIgniteConfiguration(target.Context, target.Target, memPtr);
         }
 
+        internal static void ProcessorGetCacheNames(IUnmanagedTarget target, long memPtr)
+        {
+            JNI.ProcessorGetCacheNames(target.Context, target.Target, memPtr);
+        }
+
         #endregion
 
         #region NATIVE METHODS: TARGET


[06/15] ignite git commit: IGNITE-3041: Implement config variations test for IgniteServices

Posted by sb...@apache.org.
IGNITE-3041: Implement config variations test for IgniteServices


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

Branch: refs/heads/ignite-db-x-10884
Commit: 6c705daa9c9c3a6540d582f8ef1195cccf4e7849
Parents: 97facf3
Author: sboikov <sb...@gridgain.com>
Authored: Fri Apr 29 12:21:02 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Fri Apr 29 12:21:02 2016 +0300

----------------------------------------------------------------------
 ...gniteServiceConfigVariationsFullApiTest.java | 350 +++++++++++++++++++
 .../configvariations/VariationsTestsConfig.java |   2 +-
 .../IgniteConfigVariationsAbstractTest.java     |  72 +++-
 ...ServiceConfigVariationsFullApiTestSuite.java |  92 +++++
 4 files changed, 507 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/6c705daa/modules/core/src/test/java/org/apache/ignite/internal/processors/service/IgniteServiceConfigVariationsFullApiTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/IgniteServiceConfigVariationsFullApiTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/IgniteServiceConfigVariationsFullApiTest.java
new file mode 100644
index 0000000..4e6d1e6
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/IgniteServiceConfigVariationsFullApiTest.java
@@ -0,0 +1,350 @@
+/*
+ * 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.service;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.Serializable;
+import java.util.concurrent.ThreadLocalRandom;
+import javax.cache.configuration.Factory;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteServices;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryReader;
+import org.apache.ignite.binary.BinaryWriter;
+import org.apache.ignite.binary.Binarylizable;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.services.Service;
+import org.apache.ignite.services.ServiceConfiguration;
+import org.apache.ignite.services.ServiceContext;
+import org.apache.ignite.testframework.configvariations.Parameters;
+import org.apache.ignite.testframework.junits.IgniteConfigVariationsAbstractTest;
+
+/**
+ * Full API services test.
+ */
+public class IgniteServiceConfigVariationsFullApiTest extends IgniteConfigVariationsAbstractTest {
+    /** Test service name. */
+    private static final String SERVICE_NAME = "testService";
+
+    /** Test service name. */
+    private static final String CACHE_NAME = "testCache";
+
+    /** */
+    protected static final int CLIENT_NODE_IDX_2 = 4;
+
+    /** Test object id counter. */
+    private static int cntr;
+
+    /** Callable factories. */
+    @SuppressWarnings("unchecked")
+    private static final Factory[] serviceFactories = new Factory[] {
+        Parameters.factory(TestServiceImpl.class),
+        Parameters.factory(TestServiceImplExternalizable.class),
+        Parameters.factory(TestServiceImplBinarylizable.class)
+    };
+
+    /** {@inheritDoc} */
+    @Override protected boolean expectedClient(String testGridName) {
+        int i = testsCfg.gridCount();
+
+        if (i < 5)
+            return super.expectedClient(testGridName);
+
+        // Use two client nodes if grid index 5 or greater.
+        return getTestGridName(CLIENT_NODE_IDX).equals(testGridName)
+            || getTestGridName(CLIENT_NODE_IDX_2).equals(testGridName);
+    }
+
+    /**
+     * Test node singleton deployment
+     *
+     * @throws Exception If failed.
+     */
+    public void testNodeSingletonDeploy() throws Exception {
+        runInAllDataModes(new ServiceTestRunnable(true, new DeployClosure() {
+            @Override public void run(IgniteServices services, String svcName, TestService svc) {
+                services.deployNodeSingleton(svcName, (Service)svc);
+            }
+        }));
+    }
+
+    /**
+     * Test cluster singleton deployment
+     *
+     * @throws Exception If failed.
+     */
+    public void testClusterSingletonDeploy() throws Exception {
+        runInAllDataModes(new ServiceTestRunnable(false, new DeployClosure() {
+            @Override public void run(IgniteServices services, String svcName, TestService svc) {
+                services.deployClusterSingleton(svcName, (Service)svc);
+            }
+        }));
+    }
+
+    /**
+     * Test key affinity deployment
+     *
+     * @throws Exception If failed.
+     */
+    public void testKeyAffinityDeploy() throws Exception {
+        runInAllDataModes(new ServiceTestRunnable(false, new DeployClosure() {
+            @Override public void run(IgniteServices services, String svcName, TestService svc) {
+                IgniteCache<Object, Object> cache = grid(testedNodeIdx).getOrCreateCache(CACHE_NAME);
+
+                services.deployKeyAffinitySingleton(svcName, (Service)svc, cache.getName(), "1");
+            }
+        }));
+    }
+
+    /**
+     * Tests multiple deployment
+     *
+     * @throws Exception If failed.
+     */
+    public void testMultipleDeploy() throws Exception {
+        runInAllDataModes(new ServiceTestRunnable(true, new DeployClosure() {
+            @Override public void run(IgniteServices services, String svcName, TestService svc) {
+                services.deployMultiple(svcName, (Service)svc, 0, 1);
+            }
+        }));
+    }
+
+    /**
+     * Tests deployment.
+     *
+     * @throws Exception If failed.
+     */
+    public void testDeploy() throws Exception {
+        runInAllDataModes(new ServiceTestRunnable(false, new DeployClosure() {
+            @Override public void run(IgniteServices services, String svcName, TestService svc) {
+                services.deployClusterSingleton(svcName, (Service)svc);
+
+                ServiceConfiguration cfg = new ServiceConfiguration();
+
+                cfg.setName(svcName);
+
+                cfg.setService((Service)svc);
+
+                cfg.setTotalCount(1);
+
+                cfg.setMaxPerNodeCount(1);
+
+                cfg.setNodeFilter(services.clusterGroup().predicate());
+
+                services.deploy(cfg);
+            }
+        }));
+    }
+
+    /**
+     * Service test closure
+     */
+    private class ServiceTestRunnable implements TestRunnable {
+        /** Sticky. */
+        private final boolean sticky;
+
+        /** Deploy closure */
+        private final DeployClosure deployC;
+
+        /**
+         * Default constructor.
+         *
+         * @param sticky Sticky flag.
+         * @param deployC Closure.
+         */
+        public ServiceTestRunnable(boolean sticky, DeployClosure deployC) {
+            this.sticky = sticky;
+
+            this.deployC = deployC;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void run() throws Exception {
+            for (Factory factory : serviceFactories)
+                testService((TestService)factory.create(), sticky, deployC);
+        }
+    }
+
+    /**
+     *
+     */
+    interface DeployClosure {
+        /**
+         * @param services Services.
+         * @param svcName Service name.
+         * @param svc Service.
+         */
+        void run(IgniteServices services, String svcName, TestService svc);
+    }
+
+    /**
+     * Tests deployment and contract.
+     *
+     * @param svc Service.
+     * @param sticky Sticky.
+     * @param deployC Closure.
+     * @throws Exception If failed.
+     */
+    protected void testService(TestService svc, boolean sticky, DeployClosure deployC) throws Exception {
+        IgniteEx ignite = testedGrid();
+
+        IgniteServices services = ignite.services();
+
+        Object expected = value(++cntr);
+
+        // Put value for testing Service instance serialization.
+        svc.setValue(expected);
+
+        deployC.run(services, SERVICE_NAME, svc);
+
+        // Expect correct value from local instance.
+        assertEquals(expected, svc.getValue());
+
+        // Use stickiness to make sure data will be fetched from the same instance.
+        TestService proxy = services.serviceProxy(SERVICE_NAME, TestService.class, sticky);
+
+        // Expect that correct value is returned from deployed instance.
+        assertEquals(expected, proxy.getValue());
+
+        expected = value(++cntr);
+
+        // Change value.
+        proxy.setValue(expected);
+
+        // Expect correct value after being read back.
+        int r = 1000;
+
+        while(r-- > 0)
+            assertEquals(expected, proxy.getValue());
+
+        assertEquals("Expected 1 deployed service", 1, services.serviceDescriptors().size());
+
+        // Randomize stop method invocation
+        boolean tmp = ThreadLocalRandom.current().nextBoolean();
+
+        if (tmp)
+            services.cancelAll();
+        else
+            services.cancel(SERVICE_NAME);
+    }
+
+    /**
+     * Test service
+     */
+    public interface TestService {
+        /**
+         * @param o argument to set.
+         */
+        void setValue(Object o);
+
+        /**
+         * @return Argument
+         * @throws Exception If failed.
+         */
+        Object getValue() throws Exception;
+    }
+
+    /**
+     * Implementation for {@link TestService}
+     */
+    public static class TestServiceImpl implements Service, TestService, Serializable {
+        /** Test value. */
+        protected Object val;
+
+        /**
+         * Default constructor.
+         */
+        public TestServiceImpl() {
+            // No-op.
+        }
+
+        /** {@inheritDoc} */
+        @Override public Object getValue() throws Exception {
+            return val;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void cancel(ServiceContext ctx) {
+            // No-op
+        }
+
+        /** {@inheritDoc} */
+        @Override public void init(ServiceContext ctx) throws Exception {
+            // No-op
+        }
+
+        /** {@inheritDoc} */
+        @Override public void execute(ServiceContext ctx) throws Exception {
+            // No-op
+        }
+
+        /** {@inheritDoc} */
+        public void setValue(Object val) {
+            this.val = val;
+        }
+    }
+
+    /**
+     * Echo service, externalizable object
+     */
+    @SuppressWarnings({"PublicInnerClass"})
+    public static class TestServiceImplExternalizable extends TestServiceImpl implements Externalizable {
+        /**
+         * Default constructor.
+         */
+        public TestServiceImplExternalizable() {
+            // No-op.
+        }
+
+        /** {@inheritDoc} */
+        @Override public void writeExternal(ObjectOutput out) throws IOException {
+            out.writeObject(val);
+        }
+
+        /** {@inheritDoc} */
+        @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+            val = in.readObject();
+        }
+    }
+
+    /**
+     * Echo service, binarylizable object
+     */
+    @SuppressWarnings({"PublicInnerClass"})
+    public static class TestServiceImplBinarylizable extends TestServiceImpl implements Binarylizable {
+        /**
+         * Default constructor.
+         */
+        public TestServiceImplBinarylizable() {
+            // No-op.
+        }
+
+        /** {@inheritDoc} */
+        @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
+            writer.writeObject("arg", val);
+        }
+
+        /** {@inheritDoc} */
+        @Override public void readBinary(BinaryReader reader) throws BinaryObjectException {
+            val = reader.readObject("arg");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6c705daa/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/VariationsTestsConfig.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/VariationsTestsConfig.java b/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/VariationsTestsConfig.java
index 7bcfc7f..929b0c8 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/VariationsTestsConfig.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/VariationsTestsConfig.java
@@ -70,7 +70,7 @@ public class VariationsTestsConfig {
      * @param factory Factory.
      * @param desc Config description.
      * @param stopNodes Stope nodes.
-     * @param gridCnt Grdi count.
+     * @param gridCnt Grid count.
      */
     public VariationsTestsConfig(
         ConfigFactory factory,

http://git-wip-us.apache.org/repos/asf/ignite/blob/6c705daa/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteConfigVariationsAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteConfigVariationsAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteConfigVariationsAbstractTest.java
index 258eba8..3b8c046 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteConfigVariationsAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteConfigVariationsAbstractTest.java
@@ -27,6 +27,10 @@ import java.io.ObjectOutputStream;
 import java.io.Serializable;
 import org.apache.commons.io.FileUtils;
 import org.apache.ignite.Ignition;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryReader;
+import org.apache.ignite.binary.BinaryWriter;
+import org.apache.ignite.binary.Binarylizable;
 import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.internal.IgniteEx;
 import org.apache.ignite.internal.util.typedef.internal.U;
@@ -200,12 +204,12 @@ public abstract class IgniteConfigVariationsAbstractTest extends GridCommonAbstr
         for (int i = 0; i < DataMode.values().length; i++) {
             dataMode = DataMode.values()[i];
 
-            if ((getConfiguration().getMarshaller() instanceof JdkMarshaller)
-                && (dataMode == DataMode.PLANE_OBJECT)) {
-                info("Skip test for JdkMarshaller & PLANE_OBJECT data mode");
+            if (!isCompatible()) {
+                info("Skipping test in data mode: " + dataMode);
+
                 continue;
             }
-
+            
             info("Running test in data mode: " + dataMode);
 
             if (i != 0)
@@ -250,6 +254,8 @@ public abstract class IgniteConfigVariationsAbstractTest extends GridCommonAbstr
                 return new ExternalizableObject(keyId);
             case PLANE_OBJECT:
                 return new TestObject(keyId);
+            case BINARILIZABLE:
+                return new BinarylizableObject(keyId);
             default:
                 throw new IllegalArgumentException("mode: " + mode);
         }
@@ -279,6 +285,8 @@ public abstract class IgniteConfigVariationsAbstractTest extends GridCommonAbstr
                 return new ExternalizableObject(idx);
             case PLANE_OBJECT:
                 return new TestObject(idx);
+            case BINARILIZABLE:
+                return new BinarylizableObject(idx);
             default:
                 throw new IllegalArgumentException("mode: " + mode);
         }
@@ -395,7 +403,7 @@ public abstract class IgniteConfigVariationsAbstractTest extends GridCommonAbstr
         /**
          * Default constructor.
          */
-        public ExternalizableObject() {
+        ExternalizableObject() {
             super(-1);
         }
 
@@ -422,6 +430,37 @@ public abstract class IgniteConfigVariationsAbstractTest extends GridCommonAbstr
     }
 
     /**
+     *
+     */
+    public static class BinarylizableObject extends TestObject implements Binarylizable {
+        /**
+         * Default constructor.
+         */
+        public BinarylizableObject() {
+            super(-1);
+        }
+
+        /**
+         * @param val Value.
+         */
+        public BinarylizableObject(int val) {
+            super(val);
+        }
+
+        @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
+            writer.writeInt("val", val);
+            writer.writeString("strVal", strVal);
+            writer.writeEnum("enumVal", enumVal);
+        }
+
+        @Override public void readBinary(BinaryReader reader) throws BinaryObjectException {
+            val = reader.readInt("val");
+            strVal = reader.readString("strVal");
+            enumVal = reader.readEnum("enumVal");
+        }
+    }
+
+    /**
      * Data mode.
      */
     public enum DataMode {
@@ -432,7 +471,10 @@ public abstract class IgniteConfigVariationsAbstractTest extends GridCommonAbstr
         EXTERNALIZABLE,
 
         /** Objects without Serializable and Externalizable. */
-        PLANE_OBJECT
+        PLANE_OBJECT,
+
+        /** Binarylizable objects. Compatible only with binary marshaller */
+        BINARILIZABLE
     }
 
     /**
@@ -452,10 +494,24 @@ public abstract class IgniteConfigVariationsAbstractTest extends GridCommonAbstr
     /**
      *
      */
-    public static interface TestRunnable {
+    public interface TestRunnable {
         /**
          * @throws Exception If failed.
          */
-        public void run() throws Exception;
+        void run() throws Exception;
+    }
+
+    /**
+     * Check test compatibility with current data mode
+     * @return true if incompatible
+     * @throws Exception
+     */
+    protected boolean isCompatible() throws Exception {
+        switch (dataMode) {
+            case BINARILIZABLE:
+            case PLANE_OBJECT:
+                return !(getConfiguration().getMarshaller() instanceof JdkMarshaller);
+        }
+        return false;
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/6c705daa/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteServiceConfigVariationsFullApiTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteServiceConfigVariationsFullApiTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteServiceConfigVariationsFullApiTestSuite.java
new file mode 100644
index 0000000..328ae8d
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteServiceConfigVariationsFullApiTestSuite.java
@@ -0,0 +1,92 @@
+/*
+ * 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.testsuites;
+
+import junit.framework.TestSuite;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.binary.BinaryMarshaller;
+import org.apache.ignite.internal.processors.service.IgniteServiceConfigVariationsFullApiTest;
+import org.apache.ignite.marshaller.jdk.JdkMarshaller;
+import org.apache.ignite.testframework.configvariations.ConfigParameter;
+import org.apache.ignite.testframework.configvariations.ConfigVariations;
+import org.apache.ignite.testframework.configvariations.ConfigVariationsTestSuiteBuilder;
+import org.apache.ignite.testframework.configvariations.Parameters;
+
+/**
+ * Full API service test suit.
+ */
+public class IgniteServiceConfigVariationsFullApiTestSuite extends TestSuite {
+    /** */
+    @SuppressWarnings("unchecked")
+    private static final ConfigParameter<IgniteConfiguration>[][] PARAMS = new ConfigParameter[][] {
+        Parameters.objectParameters("setMarshaller",
+            Parameters.factory(JdkMarshaller.class),
+            Parameters.factory(BinaryMarshaller.class),
+            ConfigVariations.optimizedMarshallerFactory()
+        ),
+
+        Parameters.booleanParameters("setPeerClassLoadingEnabled")
+    };
+
+    /**
+     * @return Compute API test suite.
+     * @throws Exception If failed.
+     */
+    public static TestSuite suite() throws Exception {
+        TestSuite suite = new TestSuite("Service Deployment New Full API Test Suite");
+
+        suite.addTest(new ConfigVariationsTestSuiteBuilder(
+            "Single server",
+            IgniteServiceConfigVariationsFullApiTest.class)
+            .igniteParams(PARAMS)
+            .gridsCount(1)
+            .build());
+
+        // Tests run on server (node#0) & client(node#1).
+        suite.addTest(new ConfigVariationsTestSuiteBuilder(
+            "1 server, 1 client",
+            IgniteServiceConfigVariationsFullApiTest.class)
+            .igniteParams(PARAMS)
+            .gridsCount(2)
+            .testedNodesCount(2)
+            .withClients()
+            .build());
+
+        // Tests run on servers (node#0,node#2,node#3) & client(node#1).
+        suite.addTest(new ConfigVariationsTestSuiteBuilder(
+            "3 servers, 1 client",
+            IgniteServiceConfigVariationsFullApiTest.class)
+            .igniteParams(PARAMS)
+            .gridsCount(4)
+            .testedNodesCount(2)
+            .withClients()
+            .build());
+
+        // Tests run on servers (node#0,node#2,node#3) & client(node#1,node#4).
+        suite.addTest(new ConfigVariationsTestSuiteBuilder(
+            "3 servers, 2 clients",
+            IgniteServiceConfigVariationsFullApiTest.class)
+            .igniteParams(PARAMS)
+            .gridsCount(5)
+            .testedNodesCount(2)
+            .withClients()
+            .build());
+
+        return suite;
+    }
+}
\ No newline at end of file


[15/15] ignite git commit: ignite-db-x-10884

Posted by sb...@apache.org.
ignite-db-x-10884


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

Branch: refs/heads/ignite-db-x-10884
Commit: 43de3d67dbef5f503289728a6c6026c3106a39d3
Parents: 891d706
Author: sboikov <sb...@gridgain.com>
Authored: Wed May 4 11:02:11 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed May 4 17:21:59 2016 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheAdapter.java      |   11 +-
 .../processors/cache/GridCacheContext.java      |    9 +-
 .../processors/cache/GridCacheProcessor.java    |    5 -
 .../cache/IgniteCacheOffheapManager.java        |  492 ++++++---
 .../distributed/dht/GridDhtLocalPartition.java  |    3 +
 .../dht/preloader/GridDhtPartitionSupplier.java |   91 +-
 .../cache/query/GridCacheQueryManager.java      |  261 ++++-
 .../cache/query/GridCacheQueryResponse.java     |   49 +-
 .../processors/query/GridQueryIndexing.java     |   10 +-
 .../processors/query/GridQueryProcessor.java    |    4 +-
 .../cache/database/IgniteDbPutGetTest.java      |  121 ---
 .../database/IgniteDbMultiNodePutGetTest.java   |   33 +
 .../database/IgniteDbPutGetAbstractTest.java    | 1017 ++++++++++++++++++
 .../database/IgniteDbSingleNodePutGetTest.java  |   33 +
 .../loadtests/hashmap/GridCacheTestContext.java |    1 -
 .../testsuites/IgniteDatabaseTestSuite.java     |   40 +
 .../processors/query/h2/IgniteH2Indexing.java   |   29 +-
 .../IgniteDbMultiNodePutGetRestartSelfTest.java |   20 +-
 .../IgniteDbMultiNodePutGetSelfTest.java        |   25 -
 ...IgniteDbMultiNodeWithIndexingPutGetTest.java |   28 +
 .../IgniteDbSingleNodePutGetSelfTest.java       |  995 -----------------
 ...gniteDbSingleNodeWithIndexingPutGetTest.java |   28 +
 22 files changed, 1871 insertions(+), 1434 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/43de3d67/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
index 9916f5c..7bba295 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
@@ -3692,20 +3692,17 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
      */
     @Deprecated
     @Nullable public Cache.Entry<K, V> randomEntry() {
-        GridCloseableIterator<CacheDataRow> it;
+        GridCloseableIterator<Cache.Entry<K, V>> it;
 
         try {
-            it = ctx.offheap().iterator();
+            it = ctx.offheap().entriesIterator(true, true, ctx.affinity().affinityTopologyVersion());
         }
         catch (IgniteCheckedException e) {
             throw CU.convertToCacheException(e);
         }
 
-        if (it.hasNext()) {
-            CacheDataRow row = it.next();
-
-            return new CacheEntryImpl<>((K)row.key(), (V)row.value(), row.version());
-        }
+        if (it.hasNext())
+            return it.next();
 
         return null;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/43de3d67/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 54a4153..53fe3db 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
@@ -153,9 +153,6 @@ public class GridCacheContext<K, V> implements Externalizable {
     /** Continuous query manager. */
     private CacheContinuousQueryManager contQryMgr;
 
-    /** Swap manager. */
-    private GridCacheSwapManager swapMgr;
-
     /** Evictions manager. */
     private GridCacheEvictionManager evictMgr;
 
@@ -258,7 +255,6 @@ public class GridCacheContext<K, V> implements Externalizable {
      * @param affNode {@code True} if local node is affinity node.
      * @param updatesAllowed Updates allowed flag.
      * @param evtMgr Cache event manager.
-     * @param swapMgr Cache swap manager.
      * @param storeMgr Store manager.
      * @param evictMgr Cache eviction manager.
      * @param qryMgr Cache query manager.
@@ -285,7 +281,6 @@ public class GridCacheContext<K, V> implements Externalizable {
          */
 
         GridCacheEventManager evtMgr,
-        GridCacheSwapManager swapMgr,
         CacheStoreManager storeMgr,
         GridCacheEvictionManager evictMgr,
         GridCacheQueryManager<K, V> qryMgr,
@@ -303,7 +298,6 @@ public class GridCacheContext<K, V> implements Externalizable {
         assert cacheCfg != null;
 
         assert evtMgr != null;
-        assert swapMgr != null;
         assert storeMgr != null;
         assert evictMgr != null;
         assert qryMgr != null;
@@ -328,7 +322,6 @@ public class GridCacheContext<K, V> implements Externalizable {
          * ===========================
          */
         this.evtMgr = add(evtMgr);
-        this.swapMgr = add(swapMgr);
         this.storeMgr = add(storeMgr);
         this.evictMgr = add(evictMgr);
         this.qryMgr = add(qryMgr);
@@ -989,7 +982,7 @@ public class GridCacheContext<K, V> implements Externalizable {
      * @return Swap manager.
      */
     public GridCacheSwapManager swap() {
-        return swapMgr;
+        return null;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/43de3d67/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
index a4b0c83..cf28113 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
@@ -1308,8 +1308,6 @@ public class GridCacheProcessor extends GridProcessorAdapter {
 
         GridCacheAffinityManager affMgr = new GridCacheAffinityManager();
         GridCacheEventManager evtMgr = new GridCacheEventManager();
-        GridCacheSwapManager swapMgr = new GridCacheSwapManager(cfg.getCacheMode() == LOCAL ||
-            !GridCacheUtils.isNearEnabled(cfg));
         GridCacheEvictionManager evictMgr = new GridCacheEvictionManager();
         GridCacheQueryManager qryMgr = queryManager(cfg);
         CacheContinuousQueryManager contQryMgr = new CacheContinuousQueryManager();
@@ -1341,7 +1339,6 @@ public class GridCacheProcessor extends GridProcessorAdapter {
              * ===========================
              */
             evtMgr,
-            swapMgr,
             storeMgr,
             evictMgr,
             qryMgr,
@@ -1452,7 +1449,6 @@ public class GridCacheProcessor extends GridProcessorAdapter {
              * 7. GridCacheTtlManager.
              * ===============================================
              */
-            swapMgr = new GridCacheSwapManager(true);
             evictMgr = new GridCacheEvictionManager();
             evtMgr = new GridCacheEventManager();
             pluginMgr = new CachePluginManager(ctx, cfg);
@@ -1471,7 +1467,6 @@ public class GridCacheProcessor extends GridProcessorAdapter {
                  * ===========================
                  */
                 evtMgr,
-                swapMgr,
                 storeMgr,
                 evictMgr,
                 qryMgr,

http://git-wip-us.apache.org/repos/asf/ignite/blob/43de3d67/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManager.java
index bb2ef3e..1f8e3cb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManager.java
@@ -20,7 +20,6 @@ package org.apache.ignite.internal.processors.cache;
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.List;
 import javax.cache.Cache;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
@@ -40,13 +39,11 @@ import org.apache.ignite.internal.processors.cache.database.tree.io.BPlusInnerIO
 import org.apache.ignite.internal.processors.cache.database.tree.io.BPlusLeafIO;
 import org.apache.ignite.internal.processors.cache.database.tree.io.DataPageIO;
 import org.apache.ignite.internal.processors.cache.database.tree.io.IOVersions;
-import org.apache.ignite.internal.processors.cache.database.tree.io.PageIO;
 import org.apache.ignite.internal.processors.cache.database.tree.reuse.ReuseList;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtInvalidPartitionException;
 import org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager;
 import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
 import org.apache.ignite.internal.util.GridCloseableIteratorAdapter;
-import org.apache.ignite.internal.util.GridEmptyIterator;
 import org.apache.ignite.internal.util.lang.GridCloseableIterator;
 import org.apache.ignite.internal.util.lang.GridCursor;
 import org.apache.ignite.internal.util.lang.GridIterator;
@@ -92,66 +89,54 @@ public class IgniteCacheOffheapManager extends GridCacheManagerAdapter {
     @Override protected void start0() throws IgniteCheckedException {
         super.start0();
 
-        IgniteCacheDatabaseSharedManager dbMgr = cctx.shared().database();
+        if (cctx.affinityNode()) {
+            IgniteCacheDatabaseSharedManager dbMgr = cctx.shared().database();
 
-        IgniteBiTuple<FullPageId, Boolean> page = dbMgr.meta().getOrAllocateForIndex(cctx.cacheId(), cctx.namexx());
+            IgniteBiTuple<FullPageId, Boolean> page = dbMgr.meta().getOrAllocateForIndex(cctx.cacheId(), cctx.namexx());
 
-        int cpus = Runtime.getRuntime().availableProcessors();
+            int cpus = Runtime.getRuntime().availableProcessors();
 
-        reuseList = new ReuseList(cctx.cacheId(), dbMgr.pageMemory(), cpus * 2, dbMgr.meta());
-        freeList = new FreeList(cctx, reuseList);
+            reuseList = new ReuseList(cctx.cacheId(), dbMgr.pageMemory(), cpus * 2, dbMgr.meta());
+            freeList = new FreeList(cctx, reuseList);
 
-        rowStore = new CacheDataRowStore(cctx, freeList);
+            rowStore = new CacheDataRowStore(cctx, freeList);
 
-        dataTree = new CacheDataTree(reuseList,
-            rowStore,
-            cctx,
-            dbMgr.pageMemory(),
-            page.get1(),
-            page.get2());
-    }
-
-    public ReuseList reuseList() {
-        return reuseList;
-    }
-
-    public FreeList freeList() {
-        return freeList;
+            dataTree = new CacheDataTree(reuseList,
+                rowStore,
+                cctx,
+                dbMgr.pageMemory(),
+                page.get1(),
+                page.get2());
+        }
     }
 
     /**
-     * {@inheritDoc}
+     * @return Reuse list.
      */
-    @Override
-    protected void onKernalStart0() throws IgniteCheckedException {
-        super.onKernalStart0();
+    public ReuseList reuseList() {
+        return reuseList;
     }
 
     /**
-     * TODO: GG-10884, used on only from initialValue.
+     * @return Free list.
      */
-    public boolean containsKey(KeyCacheObject key, int part) {
-        try {
-            return read(key, part) != null;
-        } catch (IgniteCheckedException e) {
-            U.error(log, "Failed to read value", e);
-
-            return false;
-        }
+    public FreeList freeList() {
+        return freeList;
     }
 
     /**
      * @param key  Key.
      * @param val  Value.
      * @param ver  Version.
+     * @param expireTime Expire time.
      * @param part Partition.
      * @throws IgniteCheckedException If failed.
      */
     public void update(KeyCacheObject key,
-                       CacheObject val,
-                       GridCacheVersion ver,
-                       long expireTime,
-                       int part) throws IgniteCheckedException {
+        CacheObject val,
+        GridCacheVersion ver,
+        long expireTime,
+        int part) throws IgniteCheckedException {
         if (indexingEnabled) {
             GridCacheQueryManager qryMgr = cctx.queries();
 
@@ -170,9 +155,13 @@ public class IgniteCacheOffheapManager extends GridCacheManagerAdapter {
 
     /**
      * @param key Key.
+     * @param prevVal Previous value.
+     * @param prevVer Previous version.
+     * @param part Partition.
      * @throws IgniteCheckedException If failed.
      */
-    public void remove(KeyCacheObject key, CacheObject prevVal, GridCacheVersion prevVer, int part) throws IgniteCheckedException {
+    public void remove(KeyCacheObject key, CacheObject prevVal, GridCacheVersion prevVer, int part)
+        throws IgniteCheckedException {
         if (indexingEnabled) {
             GridCacheQueryManager qryMgr = cctx.queries();
 
@@ -182,7 +171,7 @@ public class IgniteCacheOffheapManager extends GridCacheManagerAdapter {
                 return;
         }
 
-        DataRow dataRow = dataTree.remove(new KeySearchRow(key));
+        DataRow dataRow = dataTree.remove(new KeySearchRow(key, 0));
 
         if (dataRow != null) {
             assert dataRow.link != 0 : dataRow;
@@ -199,14 +188,24 @@ public class IgniteCacheOffheapManager extends GridCacheManagerAdapter {
      */
     @Nullable public IgniteBiTuple<CacheObject, GridCacheVersion> read(KeyCacheObject key, int part)
         throws IgniteCheckedException {
-        if (indexingEnabled)
-            return cctx.queries().read(key, part);
+        if (indexingEnabled) {
+            IgniteBiTuple<CacheObject, GridCacheVersion> t = cctx.queries().read(key, part);
 
-        DataRow dataRow = dataTree.findOne(new KeySearchRow(key));
+            if (t != null)
+                return t.get1() != null ? t : null;
+        }
+
+        DataRow dataRow = dataTree.findOne(new KeySearchRow(key, 0));
 
         return dataRow != null ? F.t(dataRow.val, dataRow.ver) : null;
     }
 
+    /**
+     * @param key Key.
+     * @param part Partition.
+     * @return Value.
+     * @throws IgniteCheckedException If failed.
+     */
     @Nullable CacheObject readValue(KeyCacheObject key, int part) throws IgniteCheckedException {
         IgniteBiTuple<CacheObject, GridCacheVersion> t = read(key, part);
 
@@ -214,6 +213,20 @@ public class IgniteCacheOffheapManager extends GridCacheManagerAdapter {
     }
 
     /**
+     * TODO: GG-10884, used on only from initialValue.
+     */
+    public boolean containsKey(KeyCacheObject key, int part) {
+        try {
+            return read(key, part) != null;
+        }
+        catch (IgniteCheckedException e) {
+            U.error(log, "Failed to read value", e);
+
+            return false;
+        }
+    }
+
+    /**
      * Clears offheap entries.
      *
      * @param readers {@code True} to clear readers.
@@ -223,13 +236,17 @@ public class IgniteCacheOffheapManager extends GridCacheManagerAdapter {
             clear(dataTree, readers);
 
         if (indexingEnabled) {
-            List<BPlusTree<?, ? extends CacheDataRow>> idxs = cctx.queries().pkIndexes();
+            BPlusTree<?, ? extends CacheDataRow> idx = cctx.queries().pkIndex();
 
-            for (BPlusTree<?, ? extends CacheDataRow> tree : idxs)
-                clear(tree, readers);
+            if (idx != null)
+                clear(idx, readers);
         }
     }
 
+    /**
+     * @param ldr Class loader.
+     * @return Number of undeployed entries.
+     */
     public int onUndeploy(ClassLoader ldr) {
         // TODO: GG-10884.
         return 0;
@@ -261,18 +278,53 @@ public class IgniteCacheOffheapManager extends GridCacheManagerAdapter {
                     GridCacheEntryEx entry = cctx.cache().entryEx(key);
 
                     entry.clear(obsoleteVer, readers);
-                } catch (GridDhtInvalidPartitionException ignore) {
+                }
+                catch (GridDhtInvalidPartitionException ignore) {
                     // Ignore.
-                } catch (IgniteCheckedException e) {
+                }
+                catch (IgniteCheckedException e) {
                     U.error(log, "Failed to clear cache entry: " + key, e);
                 }
             }
-        } catch (IgniteCheckedException e) {
+        }
+        catch (IgniteCheckedException e) {
             U.error(log, "Failed to clear cache entries.", e);
         }
     }
 
     /**
+     * @param part Partition.
+     * @return Number of entries in given partition.
+     */
+    public long entriesCount(int part) {
+        return 0;
+    }
+
+    /**
+     * @param primary Include primary node keys.
+     * @param backup Include backup node keys.
+     * @param topVer Topology version.
+     * @return Entries count.
+     * @throws IgniteCheckedException If failed.
+     */
+    public long entriesCount(boolean primary, boolean backup, AffinityTopologyVersion topVer)
+        throws IgniteCheckedException {
+        long cnt = 0;
+
+        if (dataTree != null)
+            cnt += entriesCount(dataTree, primary, backup, topVer);
+
+        if (indexingEnabled) {
+            BPlusTree<?, ? extends CacheDataRow> idx = cctx.queries().pkIndex();
+
+            if (idx != null)
+                cnt += entriesCount(idx, primary, backup, topVer);
+        }
+
+        return cnt;
+    }
+
+    /**
      * @param tree    Tree.
      * @param primary Include primary node keys.
      * @param backup  Include backup node keys.
@@ -281,9 +333,9 @@ public class IgniteCacheOffheapManager extends GridCacheManagerAdapter {
      * @throws IgniteCheckedException If failed.
      */
     private long entriesCount(BPlusTree<?, ? extends CacheDataRow> tree,
-                              boolean primary,
-                              boolean backup,
-                              AffinityTopologyVersion topVer) throws IgniteCheckedException {
+        boolean primary,
+        boolean backup,
+        AffinityTopologyVersion topVer) throws IgniteCheckedException {
         GridCursor<? extends CacheDataRow> cur = tree.find(null, null);
 
         ClusterNode locNode = cctx.localNode();
@@ -310,160 +362,187 @@ public class IgniteCacheOffheapManager extends GridCacheManagerAdapter {
         return cnt;
     }
 
-    public long entriesCount(int part) {
+    public long offHeapAllocatedSize() {
+        // TODO GG-10884.
         return 0;
     }
 
     /**
-     * @param primary Include primary node keys.
-     * @param backup Include backup node keys.
-     * @param topVer Topology version.
-     * @return Entries count.
+     * @param primary {@code True} if need return primary entries.
+     * @param backup {@code True} if need return backup entries.
+     * @param topVer Topology version to use.
+     * @return Entries iterator.
      * @throws IgniteCheckedException If failed.
      */
-    public long entriesCount(boolean primary, boolean backup, AffinityTopologyVersion topVer)
+    @SuppressWarnings("unchecked")
+    public <K, V> GridCloseableIterator<Cache.Entry<K, V>> entriesIterator(final boolean primary,
+        final boolean backup,
+        final AffinityTopologyVersion topVer)
         throws IgniteCheckedException {
-        long cnt = 0;
-
-        if (dataTree != null)
-            cnt += entriesCount(dataTree, primary, backup, topVer);
-
-        if (indexingEnabled) {
-            List<BPlusTree<?, ? extends CacheDataRow>> idxs = cctx.queries().pkIndexes();
+        final GridCursor<CacheDataRow> cur = cursor();
 
-            for (BPlusTree<?, ? extends CacheDataRow> tree : idxs)
-                cnt += entriesCount(tree, primary, backup, topVer);
-        }
+        return new GridCloseableIteratorAdapter<Cache.Entry<K, V>>() {
+            /** */
+            private CacheEntryImplEx next;
 
-        return cnt;
-    }
+            @Override protected Cache.Entry<K, V> onNext() throws IgniteCheckedException {
+                CacheEntryImplEx ret = next;
 
-    public GridCloseableIterator<CacheDataRow> iterator() throws IgniteCheckedException {
-        final GridCursor<? extends CacheDataRow> cur = dataTree.find(null, null);
+                next = null;
 
-        return new GridCloseableIteratorAdapter<CacheDataRow>() {
-            @Override protected CacheDataRow onNext() throws IgniteCheckedException {
-                return cur.get();
+                return ret;
             }
 
             @Override protected boolean onHasNext() throws IgniteCheckedException {
-                return cur.next();
-            }
-        };
-    }
-
-    public long offHeapAllocatedSize() {
-        // TODO GG-10884.
-        return 0;
-    }
-
-    public <K, V> GridIterator<IgniteBiTuple<K, V>> scanQueryIterator(@Nullable final IgniteBiPredicate<K, V> filter, final boolean keepBinary)
-        throws IgniteCheckedException {
-        final GridCursor<? extends CacheDataRow> cur = dataTree.find(null, null);
-
-        return new GridCloseableIteratorAdapter<IgniteBiTuple<K, V>>() {
-            private IgniteBiTuple<K, V> next;
-
-            private void advance() throws IgniteCheckedException {
                 if (next != null)
-                    return;
+                    return true;
+
+                CacheDataRow nextRow = null;
 
-                CacheDataRow row = null;
+                while (cur.next()) {
+                    CacheDataRow row = cur.get();
 
-                if (filter != null) {
-                    while (cur.next()) {
-                        row = cur.get();
+                    boolean pass;
 
-                        K key = (K)cctx.unwrapBinaryIfNeeded(row.key(), keepBinary);
-                        V val = (V)cctx.unwrapBinaryIfNeeded(row.value(), keepBinary);
+                    if (primary && backup)
+                        pass = true;
+                    else if (primary)
+                        pass = cctx.affinity().primary(cctx.localNode(), row.partition(), topVer);
+                    else
+                        pass = cctx.affinity().backup(cctx.localNode(), row.partition(), topVer);
 
-                        if (!filter.apply(key, val))
-                            continue;
+                    if (pass) {
+                        nextRow = row;
 
                         break;
                     }
                 }
-                else {
-                    if (cur.next())
-                        row = cur.get();
+
+                if (nextRow != null) {
+                    next = new CacheEntryImplEx(nextRow.key(), nextRow.value(), nextRow.version());
+
+                    return true;
                 }
 
-                if (row != null)
-                    next = new IgniteBiTuple<>((K)row.key(), (V)row.value());
+                return false;
             }
+        };
+    }
+
+    /**
+     * @return Iterator.
+     * @throws IgniteCheckedException If failed.
+     */
+    public GridCloseableIterator<KeyCacheObject> keysIterator() throws IgniteCheckedException {
+        final GridCursor<CacheDataRow> cur = cursor();
+
+        return new GridCloseableIteratorAdapter<KeyCacheObject>() {
+            /** */
+            private KeyCacheObject next;
 
-            @Override protected IgniteBiTuple<K, V> onNext() throws IgniteCheckedException {
-                IgniteBiTuple<K, V> res = next;
+            @Override protected KeyCacheObject onNext() throws IgniteCheckedException {
+                KeyCacheObject ret = next;
 
                 next = null;
 
-                return res;
+                return ret;
             }
 
             @Override protected boolean onHasNext() throws IgniteCheckedException {
-                advance();
+                if (next != null)
+                    return true;
+
+                if (cur.next())
+                    next = cur.get().key();
 
                 return next != null;
             }
         };
     }
 
-    public <K, V> GridCloseableIterator<Cache.Entry<K, V>> entriesIterator(boolean primary, boolean backup, AffinityTopologyVersion topVer)
-        throws IgniteCheckedException {
-        final GridCursor<? extends CacheDataRow> cur = dataTree.find(null, null);
+    /**
+     * @param part Partition.
+     * @return Iterator.
+     * @throws IgniteCheckedException If failed.
+     */
+    public GridCloseableIterator<KeyCacheObject> keysIterator(final int part) throws IgniteCheckedException {
+        final GridCursor<CacheDataRow> cur = cursor();
 
-        return new GridCloseableIteratorAdapter<Cache.Entry<K, V>>() {
-            @Override protected Cache.Entry<K, V> onNext() throws IgniteCheckedException {
-                CacheDataRow row = cur.get();
+        return new GridCloseableIteratorAdapter<KeyCacheObject>() {
+            /** */
+            private KeyCacheObject next;
 
-                return new CacheEntryImplEx<>((K)row.key(), (V)row.value(), row.version());
+            @Override protected KeyCacheObject onNext() throws IgniteCheckedException {
+                KeyCacheObject res = next;
+
+                next = null;
+
+                return res;
             }
 
             @Override protected boolean onHasNext() throws IgniteCheckedException {
-                return cur.next();
-            }
-        };
-    }
+                if (next != null)
+                    return true;
 
-    public GridCloseableIterator<KeyCacheObject> keysIterator() throws IgniteCheckedException {
-        final GridCursor<? extends CacheDataRow> cur = dataTree.find(null, null);
+                while (cur.next()) {
+                    CacheDataRow row = cur.get();
 
-        return new GridCloseableIteratorAdapter<KeyCacheObject>() {
-            @Override protected KeyCacheObject onNext() throws IgniteCheckedException {
-                CacheDataRow row = cur.get();
+                    if (row.partition() == part) {
+                        next = row.key();
 
-                return row.key();
-            }
+                        break;
+                    }
+                }
 
-            @Override protected boolean onHasNext() throws IgniteCheckedException {
-                return cur.next();
+                return next != null;
             }
         };
     }
 
-    public GridCloseableIterator<KeyCacheObject> keysIterator(final int part) throws IgniteCheckedException {
-        final GridCursor<? extends CacheDataRow> cur = dataTree.find(null, null);
+    public GridIterator<CacheDataRow> iterator(final boolean backups, final AffinityTopologyVersion topVer)
+        throws IgniteCheckedException {
+        final GridCursor<CacheDataRow> cur = cursor();
 
-        return new GridCloseableIteratorAdapter<KeyCacheObject>() {
-            private KeyCacheObject next;
+        return new GridCloseableIteratorAdapter<CacheDataRow>() {
+            /** */
+            private CacheDataRow next;
+
+            @Override protected CacheDataRow onNext() throws IgniteCheckedException {
+                CacheDataRow res = next;
+
+                next = null;
+
+                return res;
+            }
 
-            private void advance() throws IgniteCheckedException {
+            @Override protected boolean onHasNext() throws IgniteCheckedException {
                 if (next != null)
-                    return;
+                    return true;
 
                 while (cur.next()) {
                     CacheDataRow row = cur.get();
 
-                    if (row.partition() == part) {
-                        next = row.key();
+                    if (backups || cctx.affinity().primary(cctx.localNode(), row.partition(), topVer)) {
+                        next = row;
 
                         break;
                     }
                 }
+
+                return next != null;
             }
+        };
+    }
 
-            @Override protected KeyCacheObject onNext() throws IgniteCheckedException {
-                KeyCacheObject res = next;
+    public GridIterator<CacheDataRow> iterator(final int part) throws IgniteCheckedException {
+        final GridCursor<CacheDataRow> cur = cursor();
+
+        return new GridCloseableIteratorAdapter<CacheDataRow>() {
+            /** */
+            private CacheDataRow next;
+
+            @Override protected CacheDataRow onNext() throws IgniteCheckedException {
+                CacheDataRow res = next;
 
                 next = null;
 
@@ -471,7 +550,18 @@ public class IgniteCacheOffheapManager extends GridCacheManagerAdapter {
             }
 
             @Override protected boolean onHasNext() throws IgniteCheckedException {
-                advance();
+                if (next != null)
+                    return true;
+
+                while (cur.next()) {
+                    CacheDataRow row = cur.get();
+
+                    if (row.partition() == part) {
+                        next = row;
+
+                        break;
+                    }
+                }
 
                 return next != null;
             }
@@ -479,17 +569,79 @@ public class IgniteCacheOffheapManager extends GridCacheManagerAdapter {
     }
 
     /**
+     * @return Cursor.
+     * @throws IgniteCheckedException If failed.
+     */
+    @SuppressWarnings("unchecked")
+    private GridCursor<CacheDataRow> cursor() throws IgniteCheckedException {
+        GridCursor<? extends CacheDataRow> cur1 = dataTree.find(null, null);
+
+        GridCursor<? extends CacheDataRow> cur2 = indexingEnabled ? cctx.queries().pkIndex().find(null, null) : null;
+
+        return cur2 != null ? new CompoundCursor(cur1, cur2) : cur1;
+    }
+
+    /**
+     *
+     */
+    static class CompoundCursor<T> implements GridCursor<T> {
+        /** */
+        private final GridCursor<T> c1;
+
+        /** */
+        private final GridCursor<T> c2;
+
+        /** */
+        private GridCursor<T> c;
+
+        /**
+         * @param c1 First cursor.
+         * @param c2 Second cursor.
+         */
+        public CompoundCursor(GridCursor<T> c1, GridCursor<T> c2) {
+            this.c1 = c1;
+            this.c2 = c2;
+
+            c = c1;
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean next() throws IgniteCheckedException {
+            if (c.next())
+                return true;
+
+            if (c == c1) {
+                c = c2;
+
+                return c.next();
+            }
+
+            return false;
+        }
+
+        /** {@inheritDoc} */
+        @Override public T get() throws IgniteCheckedException {
+            return c.get();
+        }
+    }
+
+    /**
      *
      */
     static class KeySearchRow {
         /** */
         protected final KeyCacheObject key;
 
+        /** */
+        protected long link;
+
         /**
          * @param key Key.
+         * @param link Link.
          */
-        public KeySearchRow(KeyCacheObject key) {
+        public KeySearchRow(KeyCacheObject key, long link) {
             this.key = key;
+            this.link = link;
         }
 
         /** {@inheritDoc} */
@@ -511,9 +663,6 @@ public class IgniteCacheOffheapManager extends GridCacheManagerAdapter {
         /** */
         private int part;
 
-        /** */
-        private long link;
-
         /**
          * @param key Key.
          * @param val Value.
@@ -522,12 +671,11 @@ public class IgniteCacheOffheapManager extends GridCacheManagerAdapter {
          * @param link Link.
          */
         public DataRow(KeyCacheObject key, CacheObject val, GridCacheVersion ver, int part, long link) {
-            super(key);
+            super(key, link);
 
             this.val = val;
             this.ver = ver;
             this.part = part;
-            this.link = link;
         }
 
         /** {@inheritDoc} */
@@ -577,6 +725,7 @@ public class IgniteCacheOffheapManager extends GridCacheManagerAdapter {
         private final GridCacheContext cctx;
 
         /**
+         * @param reuseList Reuse list.
          * @param rowStore Row store.
          * @param cctx Context.
          * @param pageMem Page memory.
@@ -603,14 +752,16 @@ public class IgniteCacheOffheapManager extends GridCacheManagerAdapter {
         }
 
         /** {@inheritDoc} */
-        @Override protected int compare(BPlusIO<KeySearchRow> io, ByteBuffer buf, int idx, KeySearchRow row) throws IgniteCheckedException {
+        @Override protected int compare(BPlusIO<KeySearchRow> io, ByteBuffer buf, int idx, KeySearchRow row)
+            throws IgniteCheckedException {
             KeySearchRow row0 = io.getLookupRow(this, buf, idx);
 
             return compareKeys(row0.key, row.key);
         }
 
         /** {@inheritDoc} */
-        @Override protected DataRow getRow(BPlusIO<KeySearchRow> io, ByteBuffer buf, int idx) throws IgniteCheckedException {
+        @Override protected DataRow getRow(BPlusIO<KeySearchRow> io, ByteBuffer buf, int idx)
+            throws IgniteCheckedException {
             long link = ((RowLinkIO)io).getLink(buf, idx);
 
             return rowStore.dataRow(link);
@@ -652,14 +803,30 @@ public class IgniteCacheOffheapManager extends GridCacheManagerAdapter {
             super(cctx, freeList);
         }
 
+        /**
+         * @param link Link.
+         * @return Search row.
+         * @throws IgniteCheckedException If failed.
+         */
         public KeySearchRow keySearchRow(long link) throws IgniteCheckedException {
             return getRow(link, KeyRowClosure.INSTANCE);
         }
 
+        /**
+         * @param link Link.
+         * @return Data row.
+         * @throws IgniteCheckedException If failed.
+         */
         public DataRow dataRow(long link) throws IgniteCheckedException {
             return getRow(link, DataRowClosure.INSTANCE);
         }
 
+        /**
+         * @param link Link.
+         * @param c Row closure.
+         * @return Row.
+         * @throws IgniteCheckedException If failed.
+         */
         private <T> T getRow(long link, RowClosure<T> c) throws IgniteCheckedException {
             try (Page page = page(pageId(link))) {
                 ByteBuffer buf = page.getForRead();
@@ -695,6 +862,13 @@ public class IgniteCacheOffheapManager extends GridCacheManagerAdapter {
          *
          */
         private interface RowClosure<T> {
+            /**
+             * @param buf Buffer.
+             * @param link Link.
+             * @param cctx Context.
+             * @return Row.
+             * @throws IgniteCheckedException If failed.
+             */
             T create(ByteBuffer buf, long link, GridCacheContext cctx) throws IgniteCheckedException;
         }
 
@@ -706,10 +880,11 @@ public class IgniteCacheOffheapManager extends GridCacheManagerAdapter {
             static final KeyRowClosure INSTANCE = new KeyRowClosure();
 
             /** {@inheritDoc} */
-            @Override public KeySearchRow create(ByteBuffer buf, long link, GridCacheContext cctx) throws IgniteCheckedException {
+            @Override public KeySearchRow create(ByteBuffer buf, long link, GridCacheContext cctx)
+                throws IgniteCheckedException {
                 KeyCacheObject key = cctx.cacheObjects().toKeyCacheObject(cctx.cacheObjectContext(), buf);
 
-                return new KeySearchRow(key);
+                return new KeySearchRow(key, link);
             }
         }
 
@@ -721,7 +896,8 @@ public class IgniteCacheOffheapManager extends GridCacheManagerAdapter {
             static final DataRowClosure INSTANCE = new DataRowClosure();
 
             /** {@inheritDoc} */
-            @Override public DataRow create(ByteBuffer buf, long link, GridCacheContext cctx) throws IgniteCheckedException {
+            @Override public DataRow create(ByteBuffer buf, long link, GridCacheContext cctx)
+                throws IgniteCheckedException {
                 KeyCacheObject key = cctx.cacheObjects().toKeyCacheObject(cctx.cacheObjectContext(), buf);
                 CacheObject val = cctx.cacheObjects().toCacheObject(cctx.cacheObjectContext(), buf);
 
@@ -774,11 +950,9 @@ public class IgniteCacheOffheapManager extends GridCacheManagerAdapter {
 
         /** {@inheritDoc} */
         @Override public void store(ByteBuffer buf, int idx, KeySearchRow row) {
-            DataRow row0 = (DataRow)row;
-
-            assert row0.link != 0;
+            assert row.link != 0;
 
-            setLink(buf, idx, row0.link);
+            setLink(buf, idx, row.link);
         }
 
         /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/43de3d67/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
index 6b5eac3..416d9ce 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
@@ -583,6 +583,9 @@ public class GridDhtLocalPartition implements Comparable<GridDhtLocalPartition>,
      * Clears swap entries for evicted partition.
      */
     private void clearSwap() {
+        if (true) // TODO GG-10884.
+            return;
+
         assert state() == EVICTED;
         assert !GridQueryProcessor.isEnabled(cctx.config()) : "Indexing needs to have unswapped values.";
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/43de3d67/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplier.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplier.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplier.java
index 130d403..78cc86f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplier.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplier.java
@@ -282,15 +282,7 @@ class GridDhtPartitionSupplier {
                     }
                 }
 
-                GridCacheEntryInfoCollectSwapListener swapLsnr = null;
-
                 try {
-                    if (phase == SupplyContextPhase.NEW && cctx.isOffHeapEnabled()) {
-                        swapLsnr = new GridCacheEntryInfoCollectSwapListener(log);
-
-                        cctx.swap().addOffHeapListener(part, swapLsnr);
-                    }
-
                     boolean partMissing = false;
 
                     if (phase == SupplyContextPhase.NEW)
@@ -321,12 +313,11 @@ class GridDhtPartitionSupplier {
                                         partIt,
                                         part,
                                         entIt,
-                                        swapLsnr,
+                                        null,
                                         loc,
                                         d.topologyVersion(),
                                         d.updateSequence());
 
-                                    swapLsnr = null;
                                     loc = null;
 
                                     reply(node, d, s, scId);
@@ -368,14 +359,14 @@ class GridDhtPartitionSupplier {
                                 phase,
                                 partIt,
                                 null,
-                                swapLsnr,
+                                null,
                                 part,
                                 loc,
                                 d.updateSequence());
                         }
                     }
 
-                    if (phase == SupplyContextPhase.SWAP && cctx.isOffHeapEnabled()) {
+                    if (phase == SupplyContextPhase.SWAP && false) {
                         GridCloseableIterator<Map.Entry<byte[], GridCacheSwapEntry>> iter =
                             sctx != null && sctx.entryIt != null ?
                                 (GridCloseableIterator<Map.Entry<byte[], GridCacheSwapEntry>>)sctx.entryIt :
@@ -407,12 +398,11 @@ class GridDhtPartitionSupplier {
                                             partIt,
                                             part,
                                             iter,
-                                            swapLsnr,
+                                            null,
                                             loc,
                                             d.topologyVersion(),
                                             d.updateSequence());
 
-                                        swapLsnr = null;
                                         loc = null;
 
                                         reply(node, d, s, scId);
@@ -476,15 +466,6 @@ class GridDhtPartitionSupplier {
                         }
                     }
 
-                    if (swapLsnr == null && sctx != null)
-                        swapLsnr = sctx.swapLsnr;
-
-                    // Stop receiving promote notifications.
-                    if (swapLsnr != null) {
-                        cctx.swap().removeOffHeapListener(part, swapLsnr);
-                        cctx.swap().removeSwapListener(part, swapLsnr);
-                    }
-
                     if (phase == SupplyContextPhase.SWAP) {
                         phase = SupplyContextPhase.EVICTED;
 
@@ -500,65 +481,6 @@ class GridDhtPartitionSupplier {
                         }
                     }
 
-                    if (phase == SupplyContextPhase.EVICTED && swapLsnr != null) {
-                        Collection<GridCacheEntryInfo> entries = swapLsnr.entries();
-
-                        swapLsnr = null;
-
-                        Iterator<GridCacheEntryInfo> lsnrIt = sctx != null && sctx.entryIt != null ?
-                            (Iterator<GridCacheEntryInfo>)sctx.entryIt : entries.iterator();
-
-                        while (lsnrIt.hasNext()) {
-                            if (!cctx.affinity().belongs(node, part, d.topologyVersion())) {
-                                // Demander no longer needs this partition,
-                                // so we send '-1' partition and move on.
-                                s.missed(part);
-
-                                if (log.isDebugEnabled())
-                                    log.debug("Demanding node does not need requested partition " +
-                                        "[part=" + part + ", nodeId=" + id + ']');
-
-                                // No need to continue iteration over swap entries.
-                                break;
-                            }
-
-                            if (s.messageSize() >= cctx.config().getRebalanceBatchSize()) {
-                                if (++bCnt >= maxBatchesCnt) {
-                                    saveSupplyContext(scId,
-                                        phase,
-                                        partIt,
-                                        part,
-                                        lsnrIt,
-                                        swapLsnr,
-                                        loc,
-                                        d.topologyVersion(),
-                                        d.updateSequence());
-
-                                    loc = null;
-
-                                    reply(node, d, s, scId);
-
-                                    return;
-                                }
-                                else {
-                                    if (!reply(node, d, s, scId))
-                                        return;
-
-                                    s = new GridDhtPartitionSupplyMessageV2(d.updateSequence(),
-                                        cctx.cacheId(), d.topologyVersion(), cctx.deploymentEnabled());
-                                }
-                            }
-
-                            GridCacheEntryInfo info = lsnrIt.next();
-
-                            if (preloadPred == null || preloadPred.apply(info))
-                                s.addEntry(part, info, cctx);
-                            else if (log.isDebugEnabled())
-                                log.debug("Rebalance predicate evaluated to false (will not sender cache entry): " +
-                                    info);
-                        }
-                    }
-
                     // Mark as last supply message.
                     s.last(part);
 
@@ -569,11 +491,6 @@ class GridDhtPartitionSupplier {
                 finally {
                     if (loc != null)
                         loc.release();
-
-                    if (swapLsnr != null) {
-                        cctx.swap().removeOffHeapListener(part, swapLsnr);
-                        cctx.swap().removeSwapListener(part, swapLsnr);
-                    }
                 }
             }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/43de3d67/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
index 17af4ba..75dc93b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
@@ -421,7 +421,7 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
      */
     public IgniteBiTuple<CacheObject, GridCacheVersion> read(KeyCacheObject key, int partId) throws IgniteCheckedException {
         if (!enterBusy())
-            return null; // Ignore index update when node is stopping.
+            return null;
 
         try {
             return qryProc.read(space, key, partId);
@@ -431,8 +431,8 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
         }
     }
 
-    public List<BPlusTree<?, ? extends CacheDataRow>> pkIndexes() {
-        return qryProc.pkIndexes(space);
+    public BPlusTree<?, ? extends CacheDataRow> pkIndex() {
+        return qryProc.pkIndex(space);
     }
 
     /**
@@ -839,6 +839,87 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
         try {
             injectResources(keyValFilter);
 
+            Integer part = qry.partition();
+
+            if (cctx.isLocal())
+                part = null;
+
+            if (part != null && (part < 0 || part >= cctx.affinity().partitions()))
+                return new GridEmptyCloseableIterator<>();
+
+            final ExpiryPolicy plc = cctx.expiry();
+
+            final AffinityTopologyVersion topVer = cctx.affinity().affinityTopologyVersion();
+
+            final boolean backups = qry.includeBackups() || cctx.isReplicated();
+
+            final GridDhtLocalPartition locPart;
+
+            final GridIterator<CacheDataRow> it;
+
+            if (part != null) {
+                final GridDhtCacheAdapter dht = cctx.isNear() ? cctx.near().dht() : cctx.dht();
+
+                GridDhtLocalPartition locPart0 = dht.topology().localPartition(part, topVer, false);
+
+                if (locPart0 == null || locPart0.state() != OWNING || !locPart0.reserve())
+                    throw new GridDhtUnreservedPartitionException(part, cctx.affinity().affinityTopologyVersion(),
+                        "Partition can not be reserved");
+
+                if (locPart0.state() != OWNING) {
+                    locPart0.release();
+
+                    throw new GridDhtUnreservedPartitionException(part, cctx.affinity().affinityTopologyVersion(),
+                        "Partition can not be reserved");
+                }
+
+                locPart = locPart0;
+
+                it = cctx.offheap().iterator(part);
+            }
+            else {
+                locPart = null;
+
+                it = cctx.offheap().iterator(backups, topVer);
+            }
+
+            return new PeekValueExpiryAwareIterator0(it, plc, topVer, keyValFilter, qry.keepBinary()) {
+                @Override protected void onClose() {
+                    super.onClose();
+
+                    if (locPart != null)
+                        locPart.release();
+
+                    closeScanFilter(keyValFilter);
+                }
+            };
+        }
+        catch (IgniteCheckedException | RuntimeException e) {
+            closeScanFilter(keyValFilter);
+
+            throw e;
+        }
+    }
+
+    /**
+     * @param qry Query.
+     * @return Full-scan row iterator.
+     * @throws IgniteCheckedException If failed to get iterator.
+     */
+    @SuppressWarnings({"unchecked"})
+    private GridCloseableIterator<IgniteBiTuple<K, V>> scanIterator0(final GridCacheQueryAdapter<?> qry)
+        throws IgniteCheckedException {
+        IgniteInternalCache<K, V> prj0 = cctx.cache();
+
+        prj0 = prj0.keepBinary();
+
+        final IgniteInternalCache prj = prj0;
+
+        final IgniteBiPredicate<K, V> keyValFilter = qry.scanFilter();
+
+        try {
+            injectResources(keyValFilter);
+
             final ExpiryPolicy plc = cctx.expiry();
 
             final AffinityTopologyVersion topVer = cctx.affinity().affinityTopologyVersion();
@@ -3281,4 +3362,178 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
             return true;
         }
     }
+
+    /**
+     *
+     */
+    private class PeekValueExpiryAwareIterator0 extends GridCloseableIteratorAdapter<IgniteBiTuple<K, V>> {
+        /** */
+        private static final long serialVersionUID = 0L;
+
+        /** */
+        private final ExpiryPolicy plc;
+
+        /** */
+        private final GridCacheAdapter cache;
+
+        /** */
+        private final AffinityTopologyVersion topVer;
+
+        /** */
+        private final GridDhtCacheAdapter dht;
+
+        /** */
+        private final IgniteBiPredicate<K, V> keyValFilter;
+
+        /** */
+        private final boolean keepBinary;
+
+        /** */
+        private IgniteBiTuple<K, V> next;
+
+        /** */
+        private IgniteCacheExpiryPolicy expiryPlc;
+
+        /** */
+        private GridIterator<CacheDataRow> it;
+
+        /**
+         * @param it Iterator.
+         * @param plc Expiry policy.
+         * @param topVer Topology version.
+         * @param keyValFilter Key-value filter.
+         * @param keepBinary Keep binary flag from the query.
+         */
+        private PeekValueExpiryAwareIterator0(
+            GridIterator<CacheDataRow> it,
+            ExpiryPolicy plc,
+            AffinityTopologyVersion topVer,
+            IgniteBiPredicate<K, V> keyValFilter,
+            boolean keepBinary
+        ) {
+            this.it = it;
+            this.plc = plc;
+            this.topVer = topVer;
+            this.keyValFilter = keyValFilter;
+
+            dht = cctx.isLocal() ? null : (cctx.isNear() ? cctx.near().dht() : cctx.dht());
+            cache = dht != null ? dht : cctx.cache();
+
+            this.keepBinary = keepBinary;
+            expiryPlc = cctx.cache().expiryPolicy(plc);
+
+            advance();
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean onHasNext() {
+            return next != null;
+        }
+
+        /** {@inheritDoc} */
+        @Override public IgniteBiTuple<K, V> onNext() {
+            if (next == null)
+                throw new NoSuchElementException();
+
+            IgniteBiTuple<K, V> next0 = next;
+
+            advance();
+
+            return next0;
+        }
+
+        /** {@inheritDoc} */
+        @Override protected void onClose() {
+            sendTtlUpdate();
+        }
+
+        /**
+         * Moves the iterator to the next cache entry.
+         */
+        private void advance() {
+            IgniteBiTuple<K, V> next0 = null;
+
+            while (it.hasNext()) {
+                CacheDataRow row = it.next();
+
+                KeyCacheObject key = row.key();
+
+                CacheObject val;
+
+                if (expiryPlc != null) {
+                    try {
+                        val = value(key);
+                    }
+                    catch (IgniteCheckedException e) {
+                        if (log.isDebugEnabled())
+                            log.debug("Failed to peek value: " + e);
+
+                        val = null;
+                    }
+
+                    if (dht != null && expiryPlc.readyToFlush(100)) {
+                        dht.sendTtlUpdateRequest(expiryPlc);
+
+                        expiryPlc = cctx.cache().expiryPolicy(plc);
+                    }
+                }
+                else
+                    val = row.value();
+
+                if (val != null) {
+                    if (keyValFilter != null) {
+                        K k0 = (K)cctx.unwrapBinaryIfNeeded(key, keepBinary);
+                        V v0 = (V)cctx.unwrapBinaryIfNeeded(val, keepBinary);
+
+                        if (!keyValFilter.apply(k0, v0))
+                            continue;
+                    }
+
+                    next0 = F.t((K)key, (V)val);
+
+                    break;
+                }
+            }
+
+            next = next0;
+
+            if (next == null)
+                sendTtlUpdate();
+        }
+
+        /**
+         * Sends TTL update.
+         */
+        private void sendTtlUpdate() {
+            if (dht != null && expiryPlc != null) {
+                dht.sendTtlUpdateRequest(expiryPlc);
+
+                expiryPlc = null;
+            }
+        }
+
+        /**
+         * @param key Key.
+         * @return Value.
+         * @throws IgniteCheckedException If failed to peek value.
+         */
+        private CacheObject value(KeyCacheObject key) throws IgniteCheckedException {
+            GridCacheEntryEx entry = null;
+
+            try {
+                entry = cache.entryEx(key);
+
+                entry.unswap();
+
+                return entry.peek(true, false, false, topVer, expiryPlc);
+            }
+            catch (GridCacheEntryRemovedException ignore) {
+                return null;
+            }
+            finally {
+                if (entry != null)
+                    cctx.evicts().touch(entry, topVer);
+            }
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/43de3d67/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java
index 9a03bdc..345f9b4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java
@@ -19,21 +19,25 @@ package org.apache.ignite.internal.processors.cache.query;
 
 import java.io.Externalizable;
 import java.nio.ByteBuffer;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.internal.GridDirectCollection;
 import org.apache.ignite.internal.GridDirectTransient;
+import org.apache.ignite.internal.processors.cache.CacheObjectContext;
 import org.apache.ignite.internal.processors.cache.GridCacheContext;
 import org.apache.ignite.internal.processors.cache.GridCacheDeployable;
 import org.apache.ignite.internal.processors.cache.GridCacheMessage;
 import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
+import org.apache.ignite.internal.processors.cache.KeyCacheObject;
 import org.apache.ignite.internal.processors.query.GridQueryFieldMetadata;
 import org.apache.ignite.internal.util.tostring.GridToStringInclude;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.marshaller.Marshaller;
 import org.apache.ignite.plugin.extensions.communication.MessageCollectionItemType;
 import org.apache.ignite.plugin.extensions.communication.MessageReader;
 import org.apache.ignite.plugin.extensions.communication.MessageWriter;
@@ -155,7 +159,50 @@ public class GridCacheQueryResponse extends GridCacheMessage implements GridCach
             metadata = unmarshalCollection(metaDataBytes, ctx, ldr);
 
         if (data == null)
-            data = unmarshalCollection(dataBytes, ctx, ldr);
+            data = unmarshalCollection0(dataBytes, ctx, ldr);
+    }
+
+    /**
+     * @param byteCol Collection to unmarshal.
+     * @param ctx Context.
+     * @param ldr Loader.
+     * @return Unmarshalled collection.
+     * @throws IgniteCheckedException If failed.
+     */
+    @Nullable protected <T> List<T> unmarshalCollection0(@Nullable Collection<byte[]> byteCol,
+        GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException {
+        assert ldr != null;
+        assert ctx != null;
+
+        if (byteCol == null)
+            return null;
+
+        List<T> col = new ArrayList<>(byteCol.size());
+
+        Marshaller marsh = ctx.marshaller();
+
+        ClassLoader ldr0 = U.resolveClassLoader(ldr, ctx.gridConfig());
+
+        CacheObjectContext cacheObjCtx = null;
+
+        for (byte[] bytes : byteCol) {
+            Object obj = bytes == null ? null : marsh.<T>unmarshal(bytes, ldr0);
+
+            if (obj instanceof Map.Entry) {
+                Object key = ((Map.Entry)obj).getKey();
+
+                if (key instanceof KeyCacheObject) {
+                    if (cacheObjCtx == null)
+                        cacheObjCtx = ctx.cacheContext(cacheId).cacheObjectContext();
+
+                    ((KeyCacheObject)key).finishUnmarshal(cacheObjCtx, ldr0);
+                }
+            }
+
+            col.add((T)obj);
+        }
+
+        return col;
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/43de3d67/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java
index 5972689..b294465 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java
@@ -210,11 +210,17 @@ public interface GridQueryIndexing {
     /**
      * @param space Space name.
      * @param key Key.
+     * @param partId Partition.
      * @return Read versioned value.
      */
-    IgniteBiTuple<CacheObject,GridCacheVersion> read(String space, KeyCacheObject key, int partId) throws IgniteCheckedException;
+    IgniteBiTuple<CacheObject, GridCacheVersion> read(String space, KeyCacheObject key, int partId)
+        throws IgniteCheckedException;
 
-    public List<BPlusTree<?, ? extends CacheDataRow>> pkIndexes(String space);
+    /**
+     * @param space Space name.
+     * @return Primary key index.
+     */
+    public BPlusTree<?, ? extends CacheDataRow> pkIndex(String space);
 
     /**
      * Will be called when entry with given key is swapped.

http://git-wip-us.apache.org/repos/asf/ignite/blob/43de3d67/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
index abfa15a..d2be065 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
@@ -730,7 +730,7 @@ public class GridQueryProcessor extends GridProcessorAdapter {
         }
     }
 
-    public List<BPlusTree<?, ? extends CacheDataRow>> pkIndexes(String space) {
+    public BPlusTree<?, ? extends CacheDataRow> pkIndex(String space) {
         if (idx == null)
             return null;
 
@@ -738,7 +738,7 @@ public class GridQueryProcessor extends GridProcessorAdapter {
             throw new IllegalStateException("Failed to write to index (grid is stopping).");
 
         try {
-            return idx.pkIndexes(space);
+            return idx.pkIndex(space);
         }
         finally {
             busyLock.leaveBusy();

http://git-wip-us.apache.org/repos/asf/ignite/blob/43de3d67/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/database/IgniteDbPutGetTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/database/IgniteDbPutGetTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/database/IgniteDbPutGetTest.java
deleted file mode 100644
index e938291..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/database/IgniteDbPutGetTest.java
+++ /dev/null
@@ -1,121 +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.database;
-
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.cache.CacheAtomicityMode;
-import org.apache.ignite.cache.CacheWriteSynchronizationMode;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.DatabaseConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-
-import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*;
-
-/**
- *
- */
-public class IgniteDbPutGetTest extends GridCommonAbstractTest {
-    /** */
-    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
-
-    /** {@inheritDoc} */
-    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
-        IgniteConfiguration cfg = super.getConfiguration(gridName);
-
-        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);
-
-        DatabaseConfiguration dbCfg = new DatabaseConfiguration();
-
-        dbCfg.setConcurrencyLevel(Runtime.getRuntime().availableProcessors() * 4);
-
-        dbCfg.setPageSize(256);
-
-        dbCfg.setPageCacheSize(100 * 1024 * 1024);
-
-        cfg.setDatabaseConfiguration(dbCfg);
-
-        CacheConfiguration ccfg = new CacheConfiguration();
-
-        ccfg.setWriteSynchronizationMode(FULL_SYNC);
-        ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
-
-        cfg.setCacheConfiguration(ccfg);
-
-        return cfg;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void beforeTestsStarted() throws Exception {
-        super.beforeTestsStarted();
-
-        startGrids(1);
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void afterTestsStopped() throws Exception {
-        stopAllGrids();
-
-        super.afterTestsStopped();
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testSizeClear() throws Exception {
-        Ignite ignite = ignite(0);
-
-        IgniteCache<Integer, Integer> cache = ignite.cache(null);
-
-        cache.put(1, 1);
-        cache.put(2, 2);
-
-        assertEquals(2, cache.size());
-
-        cache.clear();
-
-        assertNull(cache.get(1));
-        assertNull(cache.get(2));
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testPutGet() throws Exception {
-        Ignite ignite = ignite(0);
-
-        IgniteCache<Integer, Integer> cache = ignite.cache(null);
-
-        cache.put(1, 1);
-        cache.put(2, 2);
-
-        assertEquals(1, (Object)cache.get(1));
-
-        cache.remove(1);
-        assertNull(cache.get(1));
-        assertEquals(2, (Object)cache.get(2));
-
-        cache.remove(2);
-
-        assertNull(cache.get(2));
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/43de3d67/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMultiNodePutGetTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMultiNodePutGetTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMultiNodePutGetTest.java
new file mode 100644
index 0000000..0f880e9
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMultiNodePutGetTest.java
@@ -0,0 +1,33 @@
+/*
+ * 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.database;
+
+/**
+ *
+ */
+public class IgniteDbMultiNodePutGetTest extends IgniteDbPutGetAbstractTest {
+    /** {@inheritDoc} */
+    @Override protected int gridCount() {
+        return 3;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected boolean indexingEnabled() {
+        return false;
+    }
+}


[08/15] ignite git commit: Fixed JavaDoc.

Posted by sb...@apache.org.
Fixed JavaDoc.


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

Branch: refs/heads/ignite-db-x-10884
Commit: 9771833718271b91f4680b20f217540d018448bb
Parents: 01f12a2
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Fri Apr 29 16:19:11 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Apr 29 16:19:11 2016 +0300

----------------------------------------------------------------------
 .../internal/processors/datastructures/GridCacheLockState.java     | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/97718337/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheLockState.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheLockState.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheLockState.java
index 3feb9bf..675286d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheLockState.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheLockState.java
@@ -140,7 +140,7 @@ public final class GridCacheLockState implements GridCacheInternal, Externalizab
     }
 
     /**
-     * @return New owner node ID.
+     * @param id New owner node ID.
      */
     public void setId(UUID id) {
         this.id = id;


[09/15] ignite git commit: Added a test for IGNITE-3077

Posted by sb...@apache.org.
Added a test for IGNITE-3077


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

Branch: refs/heads/ignite-db-x-10884
Commit: e78ed8e278e36fe293c66b5efdd78801edc6539c
Parents: 9771833
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Fri Apr 29 18:14:46 2016 -0700
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Fri Apr 29 18:14:46 2016 -0700

----------------------------------------------------------------------
 .../org/apache/ignite/spark/IgniteRDDSpec.scala | 40 +++++++++++++++++++-
 1 file changed, 39 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/e78ed8e2/modules/spark/src/test/scala/org/apache/ignite/spark/IgniteRDDSpec.scala
----------------------------------------------------------------------
diff --git a/modules/spark/src/test/scala/org/apache/ignite/spark/IgniteRDDSpec.scala b/modules/spark/src/test/scala/org/apache/ignite/spark/IgniteRDDSpec.scala
index 071897a..a41839d 100644
--- a/modules/spark/src/test/scala/org/apache/ignite/spark/IgniteRDDSpec.scala
+++ b/modules/spark/src/test/scala/org/apache/ignite/spark/IgniteRDDSpec.scala
@@ -17,6 +17,8 @@
 
 package org.apache.ignite.spark
 
+import java.time.LocalDate
+
 import org.apache.ignite.Ignition
 import org.apache.ignite.cache.query.annotations.{QueryTextField, QuerySqlField}
 import org.apache.ignite.configuration.{CacheConfiguration, IgniteConfiguration}
@@ -165,6 +167,33 @@ class IgniteRDDSpec extends FunSpec with Matchers with BeforeAndAfterAll with Be
                 sc.stop()
             }
         }
+
+        it("should successfully query complex object fields") {
+            assert(false, "https://issues.apache.org/jira/browse/IGNITE-3077")
+
+            val sc = new SparkContext("local[*]", "test")
+
+            try {
+                val ic = new IgniteContext[Integer, WithObjectField](sc,
+                    () \u21d2 configuration("client", client = true))
+
+                val cache: IgniteRDD[Integer, WithObjectField] = ic.fromCache(PARTITIONED_CACHE_NAME)
+
+                cache.savePairs(sc.parallelize(0 to 1000, 2).map(i \u21d2 (i:java.lang.Integer, new WithObjectField(i, new Entity(i, "", i)))))
+
+                val df = cache.sql("select i, ts from WithLocalDate where i = ?", 50)
+
+                df.printSchema()
+
+                val res = df.collect()
+
+                assert(res.length == 1, "Invalid result length")
+                assert(50 == res(0)(0), "Invalid result")
+            }
+            finally {
+                sc.stop()
+            }
+        }
     }
 
     override protected def beforeEach() = {
@@ -188,6 +217,12 @@ class IgniteRDDSpec extends FunSpec with Matchers with BeforeAndAfterAll with Be
     }
 }
 
+case class WithObjectField(
+    @(QuerySqlField @field)(index = true) val i : Int,
+    @(QuerySqlField @field)(index = false) val ts : Object
+) {
+}
+
 /**
  * Constants and utility methods.
  */
@@ -242,7 +277,10 @@ object IgniteRDDSpec {
 
         ccfg.setName(PARTITIONED_CACHE_NAME)
 
-        ccfg.setIndexedTypes(classOf[String], classOf[Entity])
+        ccfg.setIndexedTypes(
+            classOf[String], classOf[Entity],
+            classOf[Integer], classOf[WithObjectField]
+        )
 
         ccfg
     }


[05/15] ignite git commit: Temporary disabled tests.

Posted by sb...@apache.org.
Temporary disabled tests.


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

Branch: refs/heads/ignite-db-x-10884
Commit: 97facf3c58aad65504e636a5eab7d807124cf8d5
Parents: 72df110
Author: sboikov <sb...@gridgain.com>
Authored: Fri Apr 29 11:06:55 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Fri Apr 29 11:07:34 2016 +0300

----------------------------------------------------------------------
 .../testsuites/IgniteCacheDataStructuresSelfTestSuite.java     | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/97facf3c/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheDataStructuresSelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheDataStructuresSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheDataStructuresSelfTestSuite.java
index 59a18e5..09e7c4d 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheDataStructuresSelfTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheDataStructuresSelfTestSuite.java
@@ -110,7 +110,7 @@ public class IgniteCacheDataStructuresSelfTestSuite extends TestSuite {
         suite.addTest(new TestSuite(GridCacheLocalAtomicQueueApiSelfTest.class));
         suite.addTest(new TestSuite(IgniteLocalCountDownLatchSelfTest.class));
         suite.addTest(new TestSuite(IgniteLocalSemaphoreSelfTest.class));
-        suite.addTest(new TestSuite(IgniteLocalLockSelfTest.class));
+        //suite.addTest(new TestSuite(IgniteLocalLockSelfTest.class));
 
         suite.addTest(new TestSuite(GridCacheReplicatedSequenceApiSelfTest.class));
         suite.addTest(new TestSuite(GridCacheReplicatedSequenceMultiNodeSelfTest.class));
@@ -121,7 +121,7 @@ public class IgniteCacheDataStructuresSelfTestSuite extends TestSuite {
         suite.addTest(new TestSuite(GridCacheReplicatedDataStructuresFailoverSelfTest.class));
         suite.addTest(new TestSuite(IgniteReplicatedCountDownLatchSelfTest.class));
         suite.addTest(new TestSuite(IgniteReplicatedSemaphoreSelfTest.class));
-        suite.addTest(new TestSuite(IgniteReplicatedLockSelfTest.class));
+        //suite.addTest(new TestSuite(IgniteReplicatedLockSelfTest.class));
         suite.addTest(new TestSuite(IgniteCacheAtomicReplicatedNodeRestartSelfTest.class));
 
         suite.addTest(new TestSuite(GridCachePartitionedSequenceApiSelfTest.class));
@@ -144,7 +144,7 @@ public class IgniteCacheDataStructuresSelfTestSuite extends TestSuite {
         suite.addTest(new TestSuite(IgnitePartitionedCountDownLatchSelfTest.class));
         suite.addTest(new TestSuite(IgniteDataStructureWithJobTest.class));
         suite.addTest(new TestSuite(IgnitePartitionedSemaphoreSelfTest.class));
-        suite.addTest(new TestSuite(IgnitePartitionedLockSelfTest.class));
+        //suite.addTest(new TestSuite(IgnitePartitionedLockSelfTest.class));
 
         suite.addTest(new TestSuite(GridCachePartitionedSetFailoverSelfTest.class));
         suite.addTest(new TestSuite(GridCachePartitionedOffheapSetFailoverSelfTest.class));