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

[01/24] ignite git commit: ignite-3116 Cancel force keys futures on node stop (cherry picked from commit 0428018)

Repository: ignite
Updated Branches:
  refs/heads/master 223708a89 -> b52edcaae


ignite-3116 Cancel force keys futures on node stop (cherry picked from commit 0428018)


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

Branch: refs/heads/master
Commit: db8a9b2b68ba505376c3be4abe789c84fc8e47cd
Parents: ea909bc
Author: sboikov <sb...@gridgain.com>
Authored: Mon May 16 09:08:14 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Mon May 16 09:44:28 2016 +0300

----------------------------------------------------------------------
 .../cache/distributed/dht/GridDhtGetFuture.java | 77 ++++++++++----------
 .../distributed/dht/GridDhtGetSingleFuture.java |  4 +
 .../dht/GridDhtTransactionalCacheAdapter.java   | 57 ++++++++++++++-
 .../dht/atomic/GridDhtAtomicCache.java          | 52 ++++++++++++-
 .../dht/preloader/GridDhtForceKeysFuture.java   |  6 +-
 .../dht/preloader/GridDhtPreloader.java         | 28 ++++++-
 .../communication/tcp/TcpCommunicationSpi.java  | 32 ++++----
 7 files changed, 198 insertions(+), 58 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/db8a9b2b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java
index fbfca82..e12e1ab 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java
@@ -29,6 +29,7 @@ import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteLogger;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.NodeStoppingException;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
 import org.apache.ignite.internal.processors.cache.CacheObject;
 import org.apache.ignite.internal.processors.cache.GridCacheContext;
@@ -44,6 +45,7 @@ import org.apache.ignite.internal.util.future.GridEmbeddedFuture;
 import org.apache.ignite.internal.util.future.GridFinishedFuture;
 import org.apache.ignite.internal.util.lang.GridClosureException;
 import org.apache.ignite.internal.util.typedef.C2;
+import org.apache.ignite.internal.util.typedef.CI1;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.T2;
 import org.apache.ignite.internal.util.typedef.internal.CU;
@@ -167,9 +169,44 @@ public final class GridDhtGetFuture<K, V> extends GridCompoundIdentityFuture<Col
      * Initializes future.
      */
     void init() {
-        map(keys);
+        GridDhtFuture<Object> fut = cctx.dht().dhtPreloader().request(keys.keySet(), topVer);
+
+        if (fut != null) {
+            if (!F.isEmpty(fut.invalidPartitions())) {
+                if (retries == null)
+                    retries = new HashSet<>();
+
+                retries.addAll(fut.invalidPartitions());
+            }
+
+            fut.listen(new CI1<IgniteInternalFuture<Object>>() {
+                @Override public void apply(IgniteInternalFuture<Object> fut) {
+                    try {
+                        fut.get();
+                    }
+                    catch (NodeStoppingException e) {
+                        return;
+                    }
+                    catch (IgniteCheckedException e) {
+                        if (log.isDebugEnabled())
+                            log.debug("Failed to request keys from preloader [keys=" + keys + ", err=" + e + ']');
+
+                        onDone(e);
+
+                        return;
+                    }
+
+                    map0(keys);
+
+                    markInitialized();
+                }
+            });
+        }
+        else {
+            map0(keys);
 
-        markInitialized();
+            markInitialized();
+        }
     }
 
     /** {@inheritDoc} */
@@ -205,42 +242,6 @@ public final class GridDhtGetFuture<K, V> extends GridCompoundIdentityFuture<Col
     }
 
     /**
-     * @param keys Keys.
-     */
-    private void map(final Map<KeyCacheObject, Boolean> keys) {
-        GridDhtFuture<Object> fut = cctx.dht().dhtPreloader().request(keys.keySet(), topVer);
-
-        if (fut != null) {
-            if (!F.isEmpty(fut.invalidPartitions())) {
-                if (retries == null)
-                    retries = new HashSet<>();
-
-                retries.addAll(fut.invalidPartitions());
-            }
-
-            add(new GridEmbeddedFuture<>(
-                new IgniteBiClosure<Object, Exception, Collection<GridCacheEntryInfo>>() {
-                    @Override public Collection<GridCacheEntryInfo> apply(Object o, Exception e) {
-                        if (e != null) { // Check error first.
-                            if (log.isDebugEnabled())
-                                log.debug("Failed to request keys from preloader [keys=" + keys + ", err=" + e + ']');
-
-                            onDone(e);
-                        }
-                        else
-                            map0(keys);
-
-                        // Finish this one.
-                        return Collections.emptyList();
-                    }
-                },
-                fut));
-        }
-        else
-            map0(keys);
-    }
-
-    /**
      * @param keys Keys to map.
      */
     private void map0(Map<KeyCacheObject, Boolean> keys) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/db8a9b2b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetSingleFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetSingleFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetSingleFuture.java
index 2de92b1..9394937 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetSingleFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetSingleFuture.java
@@ -27,6 +27,7 @@ import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteLogger;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.NodeStoppingException;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
 import org.apache.ignite.internal.processors.cache.CacheObject;
 import org.apache.ignite.internal.processors.cache.GridCacheContext;
@@ -220,6 +221,9 @@ public final class GridDhtGetSingleFuture<K, V> extends GridFutureAdapter<GridCa
                                     log.debug("Failed to request keys from preloader " +
                                         "[keys=" + key + ", err=" + e + ']');
 
+                                if (e instanceof NodeStoppingException)
+                                    return;
+
                                 onDone(e);
                             }
                             else

http://git-wip-us.apache.org/repos/asf/ignite/blob/db8a9b2b/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 7bace73..0a99621 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
@@ -29,6 +29,7 @@ import java.util.UUID;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.NodeStoppingException;
 import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
 import org.apache.ignite.internal.processors.cache.CacheEntryPredicate;
@@ -378,11 +379,38 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach
         IgniteInternalFuture<Object> keyFut = F.isEmpty(req.keys()) ? null :
             ctx.dht().dhtPreloader().request(req.keys(), req.topologyVersion());
 
-        if (keyFut == null || keyFut.isDone())
+        if (keyFut == null || keyFut.isDone()) {
+            if (keyFut != null) {
+                try {
+                    keyFut.get();
+                }
+                catch (NodeStoppingException e) {
+                    return;
+                }
+                catch (IgniteCheckedException e) {
+                    onForceKeysError(nodeId, req, e);
+
+                    return;
+                }
+            }
+
             processDhtLockRequest0(nodeId, req);
+        }
         else {
             keyFut.listen(new CI1<IgniteInternalFuture<Object>>() {
-                @Override public void apply(IgniteInternalFuture<Object> t) {
+                @Override public void apply(IgniteInternalFuture<Object> fut) {
+                    try {
+                        fut.get();
+                    }
+                    catch (NodeStoppingException e) {
+                        return;
+                    }
+                    catch (IgniteCheckedException e) {
+                        onForceKeysError(nodeId, req, e);
+
+                        return;
+                    }
+
                     processDhtLockRequest0(nodeId, req);
                 }
             });
@@ -392,6 +420,31 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach
     /**
      * @param nodeId Node ID.
      * @param req Request.
+     * @param e Error.
+     */
+    private void onForceKeysError(UUID nodeId, GridDhtLockRequest req, IgniteCheckedException e) {
+        GridDhtLockResponse res = new GridDhtLockResponse(ctx.cacheId(),
+            req.version(),
+            req.futureId(),
+            req.miniId(),
+            e,
+            ctx.deploymentEnabled());
+
+        try {
+            ctx.io().send(nodeId, res, ctx.ioPolicy());
+        }
+        catch (ClusterTopologyCheckedException e0) {
+            if (log.isDebugEnabled())
+                log.debug("Failed to send lock reply to remote node because it left grid: " + nodeId);
+        }
+        catch (IgniteCheckedException e0) {
+            U.error(log, "Failed to send lock reply to node: " + nodeId, e);
+        }
+    }
+
+    /**
+     * @param nodeId Node ID.
+     * @param req Request.
      */
     protected final void processDhtLockRequest0(UUID nodeId, GridDhtLockRequest req) {
         assert nodeId != null;

http://git-wip-us.apache.org/repos/asf/ignite/blob/db8a9b2b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
index 1f01a76..6a30f7f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
@@ -39,6 +39,7 @@ import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.NodeStoppingException;
 import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
 import org.apache.ignite.internal.processors.cache.CacheEntryPredicate;
@@ -1466,11 +1467,37 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
     ) {
         IgniteInternalFuture<Object> forceFut = preldr.request(req.keys(), req.topologyVersion());
 
-        if (forceFut == null || forceFut.isDone())
+        if (forceFut == null || forceFut.isDone()) {
+            try {
+                if (forceFut != null)
+                    forceFut.get();
+            }
+            catch (NodeStoppingException e) {
+                return;
+            }
+            catch (IgniteCheckedException e) {
+                onForceKeysError(nodeId, req, completionCb, e);
+
+                return;
+            }
+
             updateAllAsyncInternal0(nodeId, req, completionCb);
+        }
         else {
             forceFut.listen(new CI1<IgniteInternalFuture<Object>>() {
-                @Override public void apply(IgniteInternalFuture<Object> t) {
+                @Override public void apply(IgniteInternalFuture<Object> fut) {
+                    try {
+                        fut.get();
+                    }
+                    catch (NodeStoppingException e) {
+                        return;
+                    }
+                    catch (IgniteCheckedException e) {
+                        onForceKeysError(nodeId, req, completionCb, e);
+
+                        return;
+                    }
+
                     updateAllAsyncInternal0(nodeId, req, completionCb);
                 }
             });
@@ -1478,6 +1505,27 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
     }
 
     /**
+     * @param nodeId Node ID.
+     * @param req Update request.
+     * @param completionCb Completion callback.
+     * @param e Error.
+     */
+    private void onForceKeysError(final UUID nodeId,
+        final GridNearAtomicUpdateRequest req,
+        final CI2<GridNearAtomicUpdateRequest, GridNearAtomicUpdateResponse> completionCb,
+        IgniteCheckedException e
+    ) {
+        GridNearAtomicUpdateResponse res = new GridNearAtomicUpdateResponse(ctx.cacheId(),
+            nodeId,
+            req.futureVersion(),
+            ctx.deploymentEnabled());
+
+        res.addFailedKeys(req.keys(), e);
+
+        completionCb.apply(req, res);
+    }
+
+    /**
      * Executes local update after preloader fetched values.
      *
      * @param nodeId Node ID.

http://git-wip-us.apache.org/repos/asf/ignite/blob/db8a9b2b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysFuture.java
index 7970a44..4da1f38 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysFuture.java
@@ -246,7 +246,11 @@ public final class GridDhtForceKeysFuture<K, V> extends GridCompoundFuture<Objec
 
             int curTopVer = topCntr.get();
 
-            preloader.addFuture(this);
+            if (!preloader.addFuture(this)) {
+                assert isDone() : this;
+
+                return false;
+            }
 
             trackable = true;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/db8a9b2b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java
index 0de3197..09aec81 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java
@@ -32,6 +32,7 @@ import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.events.DiscoveryEvent;
 import org.apache.ignite.events.Event;
 import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.NodeStoppingException;
 import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
 import org.apache.ignite.internal.managers.eventstorage.GridLocalEventListener;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
@@ -115,6 +116,9 @@ public class GridDhtPreloader extends GridCachePreloaderAdapter {
     /** */
     private final AtomicInteger partsEvictOwning = new AtomicInteger();
 
+    /** */
+    private volatile boolean stopping;
+
     /** Discovery listener. */
     private final GridLocalEventListener discoLsnr = new GridLocalEventListener() {
         @Override public void onEvent(Event evt) {
@@ -210,6 +214,8 @@ public class GridDhtPreloader extends GridCachePreloaderAdapter {
         if (log.isDebugEnabled())
             log.debug("DHT rebalancer onKernalStop callback.");
 
+        stopping = true;
+
         cctx.events().removeListener(discoLsnr);
 
         // Acquire write busy lock.
@@ -221,8 +227,19 @@ public class GridDhtPreloader extends GridCachePreloaderAdapter {
         if (demander != null)
             demander.stop();
 
+        IgniteCheckedException err = stopError();
+
+        for (GridDhtForceKeysFuture fut : forceKeyFuts.values())
+            fut.onDone(err);
+
         top = null;
     }
+    /**
+     * @return Node stop exception.
+     */
+    private IgniteCheckedException stopError() {
+        return new NodeStoppingException("Operation has been cancelled (cache or node is stopping).");
+    }
 
     /** {@inheritDoc} */
     @Override public void onInitialExchangeComplete(@Nullable Throwable err) {
@@ -711,9 +728,18 @@ public class GridDhtPreloader extends GridCachePreloaderAdapter {
      * Adds future to future map.
      *
      * @param fut Future to add.
+     * @return {@code False} if node cache is stopping and future was completed with error.
      */
-    void addFuture(GridDhtForceKeysFuture<?, ?> fut) {
+    boolean addFuture(GridDhtForceKeysFuture<?, ?> fut) {
         forceKeyFuts.put(fut.futureId(), fut);
+
+        if (stopping) {
+            fut.onDone(stopError());
+
+            return false;
+        }
+
+        return true;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/db8a9b2b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
index 904047e..875131d 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
@@ -1381,25 +1381,29 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
 
     /** {@inheritDoc} */
     @Override public void dumpStats() {
-        StringBuilder sb = new StringBuilder("Communication SPI recovery descriptors: ").append(U.nl());
+        IgniteLogger log = this.log;
 
-        for (Map.Entry<ClientKey, GridNioRecoveryDescriptor> entry : recoveryDescs.entrySet()) {
-            GridNioRecoveryDescriptor desc = entry.getValue();
+        if (log != null) {
+            StringBuilder sb = new StringBuilder("Communication SPI recovery descriptors: ").append(U.nl());
 
-            sb.append("    [key=").append(entry.getKey())
-                .append(", msgsSent=").append(desc.sent())
-                .append(", msgsAckedByRmt=").append(desc.acked())
-                .append(", msgsRcvd=").append(desc.received())
-                .append(", descIdHash=").append(System.identityHashCode(desc))
-                .append(']').append(U.nl());
-        }
+            for (Map.Entry<ClientKey, GridNioRecoveryDescriptor> entry : recoveryDescs.entrySet()) {
+                GridNioRecoveryDescriptor desc = entry.getValue();
 
-        U.warn(log, sb.toString());
+                sb.append("    [key=").append(entry.getKey())
+                    .append(", msgsSent=").append(desc.sent())
+                    .append(", msgsAckedByRmt=").append(desc.acked())
+                    .append(", msgsRcvd=").append(desc.received())
+                    .append(", descIdHash=").append(System.identityHashCode(desc))
+                    .append(']').append(U.nl());
+            }
 
-        GridNioServer<Message> nioSrvr1 = nioSrvr;
+            U.warn(log, sb.toString());
+        }
 
-        if (nioSrvr1 != null)
-            nioSrvr1.dumpStats();
+        GridNioServer<Message> nioSrvr = this.nioSrvr;
+
+        if (nioSrvr != null)
+            nioSrvr.dumpStats();
     }
 
     /** {@inheritDoc} */


[20/24] ignite git commit: ignite-2921: ScanQueries over local partitions performance optimisation

Posted by ak...@apache.org.
ignite-2921: ScanQueries over local partitions performance optimisation


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

Branch: refs/heads/master
Commit: 0e8072f8bc831ea08cb4194c60b5b2d0449e671a
Parents: 9a9c35d
Author: ashutak <as...@gridgain.com>
Authored: Mon May 16 15:34:40 2016 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Mon May 16 15:34:40 2016 +0300

----------------------------------------------------------------------
 .../cache/CacheWeakQueryIteratorsHolder.java    | 169 ++++++-
 .../processors/cache/GridCacheAdapter.java      |  13 +-
 .../processors/cache/GridCacheSwapManager.java  |  12 +-
 .../processors/cache/IgniteCacheProxy.java      |  39 +-
 .../binary/CacheObjectBinaryProcessorImpl.java  |  16 +-
 .../processors/cache/query/CacheQuery.java      |  10 +-
 .../cache/query/CacheQueryFuture.java           |  13 +-
 .../query/GridCacheDistributedQueryManager.java | 100 +++-
 .../cache/query/GridCacheLocalQueryManager.java |  34 +-
 .../cache/query/GridCacheQueryAdapter.java      | 175 +++++--
 .../cache/query/GridCacheQueryErrorFuture.java  |  12 +-
 .../query/GridCacheQueryFutureAdapter.java      |  10 +-
 .../cache/query/GridCacheQueryManager.java      | 502 +++++++++++++-----
 .../datastructures/GridCacheSetImpl.java        |   9 +-
 .../service/GridServiceProcessor.java           |  49 +-
 ...achePartitionedPreloadLifecycleSelfTest.java | 102 +---
 ...CacheReplicatedPreloadLifecycleSelfTest.java | 132 +----
 .../ConfigVariationsTestSuiteBuilder.java       |   4 +-
 ...IgniteCacheConfigVariationsAbstractTest.java |   2 +-
 .../IgniteConfigVariationsAbstractTest.java     |  27 +-
 modules/indexing/pom.xml                        |   7 +
 .../CacheAbstractQueryMetricsSelfTest.java      |   4 +-
 .../cache/IgniteCacheAbstractQuerySelfTest.java |  34 +-
 .../IgniteCacheConfigVariationsQueryTest.java   | 505 +++++++++++++++++++
 ...gniteCacheConfigVariationQueryTestSuite.java |  41 ++
 25 files changed, 1449 insertions(+), 572 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/0e8072f8/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheWeakQueryIteratorsHolder.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheWeakQueryIteratorsHolder.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheWeakQueryIteratorsHolder.java
index 4c48e74..2e03b53 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheWeakQueryIteratorsHolder.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheWeakQueryIteratorsHolder.java
@@ -26,6 +26,7 @@ import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteLogger;
 import org.apache.ignite.internal.processors.cache.query.CacheQueryFuture;
 import org.apache.ignite.internal.util.GridCloseableIteratorAdapter;
+import org.apache.ignite.internal.util.lang.GridCloseableIterator;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.jsr166.ConcurrentHashMap8;
 
@@ -34,11 +35,10 @@ import org.jsr166.ConcurrentHashMap8;
  */
 public class CacheWeakQueryIteratorsHolder<V> {
     /** Iterators weak references queue. */
-    private final ReferenceQueue<WeakQueryFutureIterator> refQueue = new ReferenceQueue<>();
+    private final ReferenceQueue refQueue = new ReferenceQueue();
 
     /** Iterators futures. */
-    private final Map<WeakReference<WeakQueryFutureIterator>,CacheQueryFuture<V>> futs =
-        new ConcurrentHashMap8<>();
+    private final Map<WeakReference, AutoCloseable> refs = new ConcurrentHashMap8<>();
 
     /** Logger. */
     private final IgniteLogger log;
@@ -56,10 +56,27 @@ public class CacheWeakQueryIteratorsHolder<V> {
      * @param <T> Type for the iterator.
      * @return Iterator over the cache.
      */
-    public <T> WeakQueryFutureIterator iterator(CacheQueryFuture<V> fut, CacheIteratorConverter<T, V> convert) {
+    public <T> WeakReferenceCloseableIterator<T> iterator(final CacheQueryFuture<V> fut,
+        CacheIteratorConverter<T, V> convert) {
         WeakQueryFutureIterator it = new WeakQueryFutureIterator(fut, convert);
 
-        CacheQueryFuture<V> old = futs.put(it.weakReference(), fut);
+        AutoCloseable old = refs.put(it.weakReference(), fut);
+
+        assert old == null;
+
+        return it;
+    }
+
+    /**
+     * @param iter Closeable iterator.
+     * @param <T> Type for the iterator.
+     * @return Iterator over the cache.
+     */
+    public <T> WeakReferenceCloseableIterator<T> iterator(final GridCloseableIterator<V> iter,
+        CacheIteratorConverter<T, V> convert) {
+        WeakQueryCloseableIterator it = new WeakQueryCloseableIterator(iter, convert);
+
+        AutoCloseable old = refs.put(it.weakReference(), iter);
 
         assert old == null;
 
@@ -71,8 +88,8 @@ public class CacheWeakQueryIteratorsHolder<V> {
      *
      * @throws IgniteCheckedException If failed.
      */
-    public void removeIterator(WeakQueryFutureIterator it) throws IgniteCheckedException {
-        futs.remove(it.weakReference());
+    public void removeIterator(WeakReferenceCloseableIterator it) throws IgniteCheckedException {
+        refs.remove(it.weakReference());
 
         it.close();
     }
@@ -81,17 +98,17 @@ public class CacheWeakQueryIteratorsHolder<V> {
      * Closes unreachable iterators.
      */
     public void checkWeakQueue() {
-        for (Reference<? extends WeakQueryFutureIterator> itRef = refQueue.poll(); itRef != null;
+        for (Reference itRef = refQueue.poll(); itRef != null;
             itRef = refQueue.poll()) {
             try {
-                WeakReference<WeakQueryFutureIterator> weakRef = (WeakReference<WeakQueryFutureIterator>)itRef;
+                WeakReference weakRef = (WeakReference)itRef;
 
-                CacheQueryFuture<?> fut = futs.remove(weakRef);
+                AutoCloseable rsrc = refs.remove(weakRef);
 
-                if (fut != null)
-                    fut.cancel();
+                if (rsrc != null)
+                    rsrc.close();
             }
-            catch (IgniteCheckedException e) {
+            catch (Exception e) {
                 U.error(log, "Failed to close iterator.", e);
             }
         }
@@ -101,16 +118,16 @@ public class CacheWeakQueryIteratorsHolder<V> {
      * Cancel all cache queries.
      */
     public void clearQueries(){
-        for (CacheQueryFuture<?> fut : futs.values()) {
+        for (AutoCloseable rsrc : refs.values()) {
             try {
-                fut.cancel();
+                rsrc.close();
             }
-            catch (IgniteCheckedException e) {
+            catch (Exception e) {
                 U.error(log, "Failed to close iterator.", e);
             }
         }
 
-        futs.clear();
+        refs.clear();
     }
 
 
@@ -119,7 +136,8 @@ public class CacheWeakQueryIteratorsHolder<V> {
      *
      * @param <T> Type for iterator.
      */
-    public class WeakQueryFutureIterator<T> extends GridCloseableIteratorAdapter<T> {
+    private class WeakQueryFutureIterator<T> extends GridCloseableIteratorAdapter<T>
+        implements WeakReferenceCloseableIterator<T> {
         /** */
         private static final long serialVersionUID = 0L;
 
@@ -204,10 +222,8 @@ public class CacheWeakQueryIteratorsHolder<V> {
             cur = null;
         }
 
-        /**
-         * @return Iterator weak reference.
-         */
-        private WeakReference<WeakQueryFutureIterator<T>> weakReference() {
+        /** {@inheritDoc} */
+        @Override public WeakReference<WeakQueryFutureIterator<T>> weakReference() {
             return weakRef;
         }
 
@@ -217,7 +233,7 @@ public class CacheWeakQueryIteratorsHolder<V> {
         private void clearWeakReference() {
             weakRef.clear();
 
-            futs.remove(weakRef);
+            refs.remove(weakRef);
         }
 
         /**
@@ -233,4 +249,109 @@ public class CacheWeakQueryIteratorsHolder<V> {
             }
         }
     }
-}
\ No newline at end of file
+
+    /**
+     * @param <T> Type.
+     */
+    public class WeakQueryCloseableIterator<T> extends GridCloseableIteratorAdapter<T>
+        implements WeakReferenceCloseableIterator<T> {
+        /** */
+        private static final long serialVersionUID = 0;
+
+        /** */
+        private final GridCloseableIterator<V> iter;
+
+        /** */
+        private final CacheIteratorConverter<T, V> convert;
+
+        /** */
+        private final WeakReference weakRef;
+
+        /** */
+        private T cur;
+
+        /**
+         * @param iter Iterator.
+         * @param convert Converter.
+         */
+        WeakQueryCloseableIterator(GridCloseableIterator<V> iter, CacheIteratorConverter<T, V> convert) {
+            this.iter = iter;
+            this.convert = convert;
+
+            weakRef = new WeakReference(this, refQueue);
+       }
+
+
+        /** {@inheritDoc} */
+        @Override protected T onNext() throws IgniteCheckedException {
+            V next;
+
+            try {
+                next = iter.nextX();
+            }
+            catch (NoSuchElementException e){
+                clearWeakReference();
+
+                throw e;
+            }
+
+            if (next == null)
+                clearWeakReference();
+
+            cur = next != null ? convert.convert(next) : null;
+
+            return cur;
+        }
+
+        /** {@inheritDoc} */
+        @Override protected boolean onHasNext() throws IgniteCheckedException {
+            boolean hasNextX = iter.hasNextX();
+
+            if (!hasNextX)
+                clearWeakReference();
+
+            return hasNextX;
+        }
+
+        /** {@inheritDoc} */
+        @Override protected void onRemove() throws IgniteCheckedException {
+            if (cur == null)
+                throw new IllegalStateException();
+
+            convert.remove(cur);
+
+            cur = null;
+        }
+
+        /** {@inheritDoc} */
+        @Override protected void onClose() throws IgniteCheckedException {
+            iter.close();
+
+            clearWeakReference();
+        }
+
+        /**
+         * Clears weak reference.
+         */
+        private void clearWeakReference() {
+            weakRef.clear();
+
+            refs.remove(weakRef);
+        }
+
+        /** {@inheritDoc} */
+        @Override public WeakReference weakReference() {
+            return weakRef;
+        }
+    }
+
+    /**
+     *
+     */
+    public static interface WeakReferenceCloseableIterator<T> extends GridCloseableIterator<T> {
+        /**
+         * @return Iterator weak reference.
+         */
+        public WeakReference weakReference();
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0e8072f8/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 d81cbd2..a02db2c 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
@@ -86,7 +86,6 @@ import org.apache.ignite.internal.processors.cache.distributed.IgniteExternaliza
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheAdapter;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtInvalidPartitionException;
 import org.apache.ignite.internal.processors.cache.dr.GridCacheDrInfo;
-import org.apache.ignite.internal.processors.cache.query.CacheQueryFuture;
 import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
 import org.apache.ignite.internal.processors.cache.transactions.IgniteTxAdapter;
 import org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalAdapter;
@@ -105,6 +104,7 @@ import org.apache.ignite.internal.util.future.GridCompoundFuture;
 import org.apache.ignite.internal.util.future.GridEmbeddedFuture;
 import org.apache.ignite.internal.util.future.GridFinishedFuture;
 import org.apache.ignite.internal.util.future.GridFutureAdapter;
+import org.apache.ignite.internal.util.lang.GridCloseableIterator;
 import org.apache.ignite.internal.util.lang.GridClosureException;
 import org.apache.ignite.internal.util.tostring.GridToStringExclude;
 import org.apache.ignite.internal.util.typedef.C1;
@@ -2400,7 +2400,8 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
             validateCacheKeys(keys);
 
         IgniteInternalFuture<?> fut = asyncOp(new AsyncOp(keys) {
-            @Override public IgniteInternalFuture<GridCacheReturn> op(IgniteTxLocalAdapter tx, AffinityTopologyVersion readyTopVer) {
+            @Override public IgniteInternalFuture<GridCacheReturn> op(IgniteTxLocalAdapter tx,
+                AffinityTopologyVersion readyTopVer) {
                 Map<? extends K, EntryProcessor<K, V, Object>> invokeMap = F.viewAsMap(keys, new C1<K, EntryProcessor<K, V, Object>>() {
                     @Override public EntryProcessor apply(K k) {
                         return entryProcessor;
@@ -3961,7 +3962,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
     /**
      * @return Distributed ignite cache iterator.
      */
-    public Iterator<Cache.Entry<K, V>> igniteIterator() {
+    public Iterator<Cache.Entry<K, V>> igniteIterator() throws IgniteCheckedException {
         GridCacheContext ctx0 = ctx.isNear() ? ctx.near().dht().context() : ctx;
 
         final CacheOperationContext opCtx = ctx.operationContextPerCall();
@@ -3969,11 +3970,11 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
         if (!ctx0.isSwapOrOffheapEnabled() && ctx0.kernalContext().discovery().size() == 1)
             return localIteratorHonorExpirePolicy(opCtx);
 
-        CacheQueryFuture<Map.Entry<K, V>> fut = ctx0.queries().createScanQuery(null, null, ctx.keepBinary())
+        final GridCloseableIterator<Map.Entry<K, V>> iter = ctx0.queries().createScanQuery(null, null, ctx.keepBinary())
             .keepAll(false)
-            .execute();
+            .executeScanQuery();
 
-        return ctx.itHolder().iterator(fut, new CacheIteratorConverter<Cache.Entry<K, V>, Map.Entry<K, V>>() {
+        return ctx.itHolder().iterator(iter, new CacheIteratorConverter<Cache.Entry<K, V>, Map.Entry<K, V>>() {
             @Override protected Cache.Entry<K, V> convert(Map.Entry<K, V> e) {
                 return new CacheEntryImpl<>(e.getKey(), e.getValue());
             }

http://git-wip-us.apache.org/repos/asf/ignite/blob/0e8072f8/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
index 7901105..98251dd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
@@ -1848,7 +1848,7 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter {
      * @return Off-heap iterator.
      */
     public <T> GridCloseableIterator<T> rawOffHeapIterator(final CX2<T2<Long, Integer>, T2<Long, Integer>, T> c,
-        Integer part,
+        @Nullable Integer part,
         boolean primary,
         boolean backup)
     {
@@ -1859,8 +1859,12 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter {
 
         checkIteratorQueue();
 
-        if (primary && backup)
-            return offheap.iterator(spaceName, c);
+        if (primary && backup) {
+            if (part == null)
+                return offheap.iterator(spaceName, c);
+            else
+                return offheap.iterator(spaceName, c, part);
+        }
 
         AffinityTopologyVersion ver = cctx.affinity().affinityTopologyVersion();
 
@@ -1894,7 +1898,7 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter {
         if (!offheapEnabled || (!primary && !backup))
             return new GridEmptyCloseableIterator<>();
 
-        if (primary && backup)
+        if (primary && backup && part == null)
             return new GridCloseableIteratorAdapter<Map.Entry<byte[], byte[]>>() {
                 private GridCloseableIterator<IgniteBiTuple<byte[], byte[]>> it = offheap.iterator(spaceName);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/0e8072f8/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
index 5b78271..fc046af 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
@@ -21,7 +21,6 @@ import java.io.Externalizable;
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
-import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Date;
@@ -59,7 +58,6 @@ import org.apache.ignite.cache.query.SqlFieldsQuery;
 import org.apache.ignite.cache.query.SqlQuery;
 import org.apache.ignite.cache.query.TextQuery;
 import org.apache.ignite.cluster.ClusterGroup;
-import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.internal.AsyncSupportAdapter;
 import org.apache.ignite.internal.GridKernalContext;
@@ -72,6 +70,7 @@ import org.apache.ignite.internal.processors.query.GridQueryProcessor;
 import org.apache.ignite.internal.util.GridCloseableIteratorAdapter;
 import org.apache.ignite.internal.util.GridEmptyIterator;
 import org.apache.ignite.internal.util.future.IgniteFutureImpl;
+import org.apache.ignite.internal.util.lang.GridCloseableIterator;
 import org.apache.ignite.internal.util.lang.GridClosureException;
 import org.apache.ignite.internal.util.lang.IgniteOutClosureX;
 import org.apache.ignite.internal.util.tostring.GridToStringExclude;
@@ -86,7 +85,6 @@ import org.apache.ignite.lang.IgniteBiPredicate;
 import org.apache.ignite.lang.IgniteFuture;
 import org.apache.ignite.mxbean.CacheMetricsMXBean;
 import org.apache.ignite.plugin.security.SecurityPermission;
-import org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode;
 import org.jetbrains.annotations.Nullable;
 
 /**
@@ -468,7 +466,6 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
     private QueryCursor<Cache.Entry<K,V>> query(final Query filter, @Nullable ClusterGroup grp)
         throws IgniteCheckedException {
         final CacheQuery<Map.Entry<K,V>> qry;
-        final CacheQueryFuture<Map.Entry<K,V>> fut;
 
         boolean isKeepBinary = opCtx != null && opCtx.isKeepBinary();
 
@@ -480,14 +477,35 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
             if (grp != null)
                 qry.projection(grp);
 
-            fut = ctx.kernalContext().query().executeQuery(ctx,
-                new IgniteOutClosureX<CacheQueryFuture<Map.Entry<K, V>>>() {
-                    @Override public CacheQueryFuture<Map.Entry<K, V>> applyx() throws IgniteCheckedException {
-                        return qry.execute();
+            final GridCloseableIterator<Entry<K, V>> iter = ctx.kernalContext().query().executeQuery(ctx,
+                new IgniteOutClosureX<GridCloseableIterator<Entry<K,V>>>() {
+                    @Override public GridCloseableIterator<Entry<K,V>> applyx() throws IgniteCheckedException {
+                        final GridCloseableIterator<Map.Entry> iter0 = qry.executeScanQuery();
+
+                        return new GridCloseableIteratorAdapter<Cache.Entry<K, V>>() {
+                            @Override protected Cache.Entry<K, V> onNext() throws IgniteCheckedException {
+                                Map.Entry<K, V> next = iter0.nextX();
+
+                                return new CacheEntryImpl<>(next.getKey(), next.getValue());
+                            }
+
+                            @Override protected boolean onHasNext() throws IgniteCheckedException {
+                                return iter0.hasNextX();
+                            }
+
+                            @Override protected void onClose() throws IgniteCheckedException {
+                                iter0.close();
+                            }
+                        };
                     }
                 }, false);
+
+            return new QueryCursorImpl<>(iter);
         }
-        else if (filter instanceof TextQuery) {
+
+        final CacheQueryFuture<Map.Entry<K,V>> fut;
+
+        if (filter instanceof TextQuery) {
             TextQuery p = (TextQuery)filter;
 
             qry = ctx.queries().createFullTextQuery(p.getType(), p.getText(), isKeepBinary);
@@ -1810,6 +1828,9 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
         try {
             return ctx.cache().igniteIterator();
         }
+        catch (IgniteCheckedException e) {
+            throw cacheException(e);
+        }
         finally {
             onLeave(gate, prev);
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/0e8072f8/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
index c043bc7..18751c1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
@@ -79,11 +79,11 @@ import org.apache.ignite.internal.processors.cache.GridCacheUtils;
 import org.apache.ignite.internal.processors.cache.IgniteCacheProxy;
 import org.apache.ignite.internal.processors.cache.KeyCacheObject;
 import org.apache.ignite.internal.processors.cache.query.CacheQuery;
-import org.apache.ignite.internal.processors.cache.query.CacheQueryFuture;
 import org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager;
 import org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessorImpl;
 import org.apache.ignite.internal.util.GridUnsafe;
 import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.internal.util.lang.GridCloseableIterator;
 import org.apache.ignite.internal.util.lang.GridMapEntry;
 import org.apache.ignite.internal.util.tostring.GridToStringExclude;
 import org.apache.ignite.internal.util.typedef.C1;
@@ -295,16 +295,12 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
 
                 qry.projection(ctx.cluster().get().forNode(oldestSrvNode));
 
-                try {
-                    CacheQueryFuture<Map.Entry<BinaryMetadataKey, BinaryMetadata>> fut = qry.execute();
-
-                    Map.Entry<BinaryMetadataKey, BinaryMetadata> next;
-
-                    while ((next = fut.next()) != null) {
-                        assert next.getKey() != null : next;
-                        assert next.getValue() != null : next;
+                try (GridCloseableIterator<Map.Entry<BinaryMetadataKey, BinaryMetadata>> entries = qry.executeScanQuery()) {
+                    for (Map.Entry<BinaryMetadataKey, BinaryMetadata> e : entries) {
+                        assert e.getKey() != null : e;
+                        assert e.getValue() != null : e;
 
-                        addClientCacheMetaData(next.getKey(), next.getValue());
+                        addClientCacheMetaData(e.getKey(), e.getValue());
                     }
                 }
                 catch (IgniteCheckedException e) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/0e8072f8/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/CacheQuery.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/CacheQuery.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/CacheQuery.java
index 5f9dc61..47c6e89 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/CacheQuery.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/CacheQuery.java
@@ -17,6 +17,8 @@
 
 package org.apache.ignite.internal.processors.cache.query;
 
+import java.util.Map;
+import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.cache.affinity.AffinityKey;
 import org.apache.ignite.cache.query.Query;
 import org.apache.ignite.cache.query.QueryMetrics;
@@ -24,6 +26,7 @@ import org.apache.ignite.cache.query.annotations.QuerySqlField;
 import org.apache.ignite.cache.query.annotations.QuerySqlFunction;
 import org.apache.ignite.cache.query.annotations.QueryTextField;
 import org.apache.ignite.cluster.ClusterGroup;
+import org.apache.ignite.internal.util.lang.GridCloseableIterator;
 import org.apache.ignite.lang.IgniteClosure;
 import org.apache.ignite.lang.IgniteReducer;
 import org.jetbrains.annotations.Nullable;
@@ -289,4 +292,9 @@ public interface CacheQuery<T> {
      * Resets metrics for this query.
      */
     public void resetMetrics();
-}
\ No newline at end of file
+
+    /**
+     * @return Scan query iterator.
+     */
+    public <R extends Map.Entry> GridCloseableIterator<R> executeScanQuery() throws IgniteCheckedException;
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0e8072f8/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/CacheQueryFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/CacheQueryFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/CacheQueryFuture.java
index bb342b3..a0244d8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/CacheQueryFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/CacheQueryFuture.java
@@ -26,16 +26,7 @@ import org.jetbrains.annotations.Nullable;
  * Cache query future returned by query execution.
  * Refer to {@link CacheQuery} documentation for more information.
  */
-public interface CacheQueryFuture<T> extends IgniteInternalFuture<Collection<T>> {
-    /**
-     * Returns number of elements that are already fetched and can
-     * be returned from {@link #next()} method without blocking.
-     *
-     * @return Number of fetched elements which are available immediately.
-     * @throws IgniteCheckedException In case of error.
-     */
-    public int available() throws IgniteCheckedException;
-
+public interface CacheQueryFuture<T> extends IgniteInternalFuture<Collection<T>>, AutoCloseable {
     /**
      * Returns next element from result set.
      * <p>
@@ -62,4 +53,4 @@ public interface CacheQueryFuture<T> extends IgniteInternalFuture<Collection<T>>
      * @throws IgniteCheckedException {@inheritDoc}
      */
     @Override public boolean cancel() throws IgniteCheckedException;
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0e8072f8/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheDistributedQueryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheDistributedQueryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheDistributedQueryManager.java
index 353fbd3..5f6cb8f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheDistributedQueryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheDistributedQueryManager.java
@@ -21,6 +21,7 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
+import java.util.NoSuchElementException;
 import java.util.UUID;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ConcurrentMap;
@@ -35,6 +36,8 @@ import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
 import org.apache.ignite.internal.managers.eventstorage.GridLocalEventListener;
 import org.apache.ignite.internal.processors.query.GridQueryFieldMetadata;
 import org.apache.ignite.internal.util.GridBoundedConcurrentOrderedSet;
+import org.apache.ignite.internal.util.GridCloseableIteratorAdapter;
+import org.apache.ignite.internal.util.lang.GridCloseableIterator;
 import org.apache.ignite.internal.util.typedef.CI1;
 import org.apache.ignite.internal.util.typedef.CI2;
 import org.apache.ignite.internal.util.typedef.F;
@@ -55,7 +58,7 @@ import static org.apache.ignite.events.EventType.EVT_NODE_LEFT;
 import static org.apache.ignite.internal.GridTopic.TOPIC_CACHE;
 
 /**
- * Distributed query manager.
+ * Distributed query manager (for cache in REPLICATED / PARTITIONED cache mode).
  */
 public class GridCacheDistributedQueryManager<K, V> extends GridCacheQueryManager<K, V> {
     /** */
@@ -512,29 +515,8 @@ public class GridCacheDistributedQueryManager<K, V> extends GridCacheQueryManage
     }
 
     /** {@inheritDoc} */
-    @Override public CacheQueryFuture<?> queryLocal(GridCacheQueryBean qry) {
-        assert cctx.config().getCacheMode() != LOCAL;
-
-        if (log.isDebugEnabled())
-            log.debug("Executing query on local node: " + qry);
-
-        GridCacheLocalQueryFuture<K, V, ?> fut = new GridCacheLocalQueryFuture<>(cctx, qry);
-
-        try {
-            qry.query().validate();
-
-            fut.execute();
-        }
-        catch (IgniteCheckedException e) {
-            fut.onDone(e);
-        }
-
-        return fut;
-    }
-
-    /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
-    @Override public CacheQueryFuture<?> queryDistributed(GridCacheQueryBean qry, Collection<ClusterNode> nodes) {
+    @Override public CacheQueryFuture<?> queryDistributed(GridCacheQueryBean qry, final Collection<ClusterNode> nodes) {
         assert cctx.config().getCacheMode() != LOCAL;
 
         if (log.isDebugEnabled())
@@ -550,7 +532,7 @@ public class GridCacheDistributedQueryManager<K, V> extends GridCacheQueryManage
 
             String clsName = qry.query().queryClassName();
 
-            GridCacheQueryRequest req = new GridCacheQueryRequest(
+            final GridCacheQueryRequest req = new GridCacheQueryRequest(
                 cctx.cacheId(),
                 reqId,
                 cctx.name(),
@@ -595,6 +577,76 @@ public class GridCacheDistributedQueryManager<K, V> extends GridCacheQueryManage
     }
 
     /** {@inheritDoc} */
+    @SuppressWarnings({"unchecked", "serial"})
+    @Override public GridCloseableIterator<Map.Entry<K, V>> scanQueryDistributed(final GridCacheQueryAdapter qry,
+        Collection<ClusterNode> nodes) throws IgniteCheckedException {
+        assert !cctx.isLocal() : cctx.name();
+        assert qry.type() == GridCacheQueryType.SCAN: qry;
+
+        GridCloseableIterator<Map.Entry<K, V>> locIter0 = null;
+
+        for (ClusterNode node : nodes) {
+            if (node.isLocal()) {
+                locIter0 = (GridCloseableIterator)scanQueryLocal(qry, false);
+
+                Collection<ClusterNode> rmtNodes = new ArrayList<>(nodes.size() - 1);
+
+                for (ClusterNode n : nodes) {
+                    // Equals by reference can be used here.
+                    if (n != node)
+                        rmtNodes.add(n);
+                }
+
+                nodes = rmtNodes;
+
+                break;
+            }
+        }
+
+        final GridCloseableIterator<Map.Entry<K, V>> locIter = locIter0;
+
+        final GridCacheQueryBean bean = new GridCacheQueryBean(qry, null, null, null);
+
+        final CacheQueryFuture<Map.Entry<K, V>> fut = (CacheQueryFuture<Map.Entry<K, V>>)queryDistributed(bean, nodes);
+
+        return new GridCloseableIteratorAdapter<Map.Entry<K, V>>() {
+            /** */
+            private Map.Entry<K, V> cur;
+
+            @Override protected Map.Entry<K, V> onNext() throws IgniteCheckedException {
+                if (!onHasNext())
+                    throw new NoSuchElementException();
+
+                Map.Entry<K, V> e = cur;
+
+                cur = null;
+
+                return e;
+            }
+
+            @Override protected boolean onHasNext() throws IgniteCheckedException {
+                if (cur != null)
+                    return true;
+
+                if (locIter != null && locIter.hasNextX())
+                    cur = locIter.nextX();
+
+                return cur != null || (cur = fut.next()) != null;
+            }
+
+            @Override protected void onClose() throws IgniteCheckedException {
+                super.onClose();
+
+                if (locIter != null)
+                    locIter.close();
+
+                if (fut != null)
+                    fut.cancel();
+            }
+        };
+    }
+
+    /** {@inheritDoc} */
     @Override public void loadPage(long id, GridCacheQueryAdapter<?> qry, Collection<ClusterNode> nodes, boolean all) {
         assert cctx.config().getCacheMode() != LOCAL;
         assert qry != null;

http://git-wip-us.apache.org/repos/asf/ignite/blob/0e8072f8/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheLocalQueryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheLocalQueryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheLocalQueryManager.java
index 4e72f97..183abde 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheLocalQueryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheLocalQueryManager.java
@@ -19,16 +19,18 @@ package org.apache.ignite.internal.processors.cache.query;
 
 import java.util.Collection;
 import java.util.List;
+import java.util.Map;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.internal.processors.query.GridQueryFieldMetadata;
+import org.apache.ignite.internal.util.lang.GridCloseableIterator;
 import org.jetbrains.annotations.Nullable;
 
 import static org.apache.ignite.cache.CacheMode.LOCAL;
 
 /**
- * Local query manager.
+ * Local query manager (for cache in LOCAL cache mode).
  */
 public class GridCacheLocalQueryManager<K, V> extends GridCacheQueryManager<K, V> {
     /** {@inheritDoc} */
@@ -80,32 +82,20 @@ public class GridCacheLocalQueryManager<K, V> extends GridCacheQueryManager<K, V
     }
 
     /** {@inheritDoc} */
-    @Override public CacheQueryFuture<?> queryLocal(GridCacheQueryBean qry) {
+    @Override public CacheQueryFuture<?> queryDistributed(GridCacheQueryBean qry, Collection<ClusterNode> nodes) {
         assert cctx.config().getCacheMode() == LOCAL;
 
-        if (log.isDebugEnabled())
-            log.debug("Executing query on local node: " + qry);
-
-        GridCacheLocalQueryFuture<K, V, ?> fut = new GridCacheLocalQueryFuture<>(cctx, qry);
-
-        try {
-            qry.query().validate();
-
-            fut.execute();
-        }
-        catch (IgniteCheckedException e) {
-            fut.onDone(e);
-        }
-
-        return fut;
+        throw new IgniteException("Distributed queries are not available for local cache " +
+            "(use 'CacheQuery.execute(grid.forLocal())' instead) [cacheName=" + cctx.name() + ']');
     }
 
     /** {@inheritDoc} */
-    @Override public CacheQueryFuture<?> queryDistributed(GridCacheQueryBean qry, Collection<ClusterNode> nodes) {
-        assert cctx.config().getCacheMode() == LOCAL;
+    @Override public GridCloseableIterator<Map.Entry<K, V>> scanQueryDistributed(GridCacheQueryAdapter qry,
+        Collection<ClusterNode> nodes) throws IgniteCheckedException {
+        assert cctx.isLocal() : cctx.name();
 
-        throw new IgniteException("Distributed queries are not available for local cache " +
-            "(use 'CacheQuery.execute(grid.forLocal())' instead) [cacheName=" + cctx.name() + ']');
+        throw new IgniteException("Distributed scan query are not available for local cache " +
+            "(use 'CacheQuery.executeScanQuery(grid.forLocal())' instead) [cacheName=" + cctx.name() + ']');
     }
 
     /** {@inheritDoc} */
@@ -142,4 +132,4 @@ public class GridCacheLocalQueryManager<K, V> extends GridCacheQueryManager<K, V
         throw new IgniteException("Distributed queries are not available for local cache " +
             "(use 'CacheQuery.execute(grid.forLocal())' instead) [cacheName=" + cctx.name() + ']');
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0e8072f8/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryAdapter.java
index b948dc5..90e14f4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryAdapter.java
@@ -22,6 +22,8 @@ import java.util.Collections;
 import java.util.Deque;
 import java.util.HashSet;
 import java.util.LinkedList;
+import java.util.Map;
+import java.util.NoSuchElementException;
 import java.util.Queue;
 import java.util.Set;
 import java.util.UUID;
@@ -40,9 +42,12 @@ import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
 import org.apache.ignite.internal.processors.cache.GridCacheContext;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtUnreservedPartitionException;
 import org.apache.ignite.internal.processors.query.GridQueryProcessor;
-import org.apache.ignite.internal.util.future.GridFutureAdapter;
+import org.apache.ignite.internal.util.GridCloseableIteratorAdapter;
+import org.apache.ignite.internal.util.GridEmptyCloseableIterator;
+import org.apache.ignite.internal.util.lang.GridCloseableIterator;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.P1;
+import org.apache.ignite.internal.util.typedef.T2;
 import org.apache.ignite.internal.util.typedef.X;
 import org.apache.ignite.internal.util.typedef.internal.A;
 import org.apache.ignite.internal.util.typedef.internal.CU;
@@ -429,6 +434,8 @@ public class GridCacheQueryAdapter<T> implements CacheQuery<T> {
     @SuppressWarnings({"IfMayBeConditional", "unchecked"})
     private <R> CacheQueryFuture<R> execute(@Nullable IgniteReducer<T, R> rmtReducer,
         @Nullable IgniteClosure<T, R> rmtTransform, @Nullable Object... args) {
+        assert type != SCAN : this;
+
         Collection<ClusterNode> nodes;
 
         try {
@@ -440,7 +447,7 @@ public class GridCacheQueryAdapter<T> implements CacheQuery<T> {
 
         cctx.checkSecurity(SecurityPermission.CACHE_READ);
 
-        if (nodes.isEmpty() && (type != SCAN || part == null))
+        if (nodes.isEmpty())
             return new GridCacheQueryErrorFuture<>(cctx.kernalContext(), new ClusterGroupEmptyCheckedException());
 
         if (log.isDebugEnabled())
@@ -471,12 +478,44 @@ public class GridCacheQueryAdapter<T> implements CacheQuery<T> {
         if (type == SQL_FIELDS || type == SPI)
             return (CacheQueryFuture<R>)(loc ? qryMgr.queryFieldsLocal(bean) :
                 qryMgr.queryFieldsDistributed(bean, nodes));
-        else if (type == SCAN && part != null && !cctx.isLocal())
-            return new CacheQueryFallbackFuture<>(part, bean, qryMgr, cctx);
         else
             return (CacheQueryFuture<R>)(loc ? qryMgr.queryLocal(bean) : qryMgr.queryDistributed(bean, nodes));
     }
 
+    /** {@inheritDoc} */
+    @SuppressWarnings({"IfMayBeConditional", "unchecked"})
+    @Override public <R extends Map.Entry> GridCloseableIterator<R> executeScanQuery() throws IgniteCheckedException {
+        assert type == SCAN: "Wrong processing of qyery: " + type;
+
+        Collection<ClusterNode> nodes = nodes();
+
+        cctx.checkSecurity(SecurityPermission.CACHE_READ);
+
+        if (nodes.isEmpty() && part == null)
+            return new GridEmptyCloseableIterator();
+
+        if (log.isDebugEnabled())
+            log.debug("Executing query [query=" + this + ", nodes=" + nodes + ']');
+
+        if (cctx.deploymentEnabled())
+            cctx.deploy().registerClasses(filter);
+
+        if (subjId == null)
+            subjId = cctx.localNodeId();
+
+        taskHash = cctx.kernalContext().job().currentTaskNameHash();
+
+        final GridCacheQueryManager qryMgr = cctx.queries();
+
+        if (part != null && !cctx.isLocal())
+            return (GridCloseableIterator<R>)new ScanQueryFallbackClosableIterator(part, this, qryMgr, cctx);
+        else {
+            boolean loc = nodes.size() == 1 && F.first(nodes).id().equals(cctx.localNodeId());
+
+            return loc ? qryMgr.scanQueryLocal(this, true) : qryMgr.scanQueryDistributed(this, nodes);
+        }
+    }
+
     /**
      * @return Nodes to execute on.
      */
@@ -549,10 +588,12 @@ public class GridCacheQueryAdapter<T> implements CacheQuery<T> {
     /**
      * Wrapper for queries with fallback.
      */
-    private static class CacheQueryFallbackFuture<R> extends GridFutureAdapter<Collection<R>>
-        implements CacheQueryFuture<R> {
+    private static class ScanQueryFallbackClosableIterator extends GridCloseableIteratorAdapter<Map.Entry> {
+        /** */
+        private static final long serialVersionUID = 0L;
+
         /** Query future. */
-        private volatile GridCacheQueryFutureAdapter<?, ?, R> fut;
+        private volatile T2<GridCloseableIterator<Map.Entry>, GridCacheQueryFutureAdapter> tuple;
 
         /** Backups. */
         private volatile Queue<ClusterNode> nodes;
@@ -564,7 +605,7 @@ public class GridCacheQueryAdapter<T> implements CacheQuery<T> {
         private volatile int unreservedNodesRetryCnt = 5;
 
         /** Bean. */
-        private final GridCacheQueryBean bean;
+        private final GridCacheQueryAdapter qry;
 
         /** Query manager. */
         private final GridCacheQueryManager qryMgr;
@@ -578,15 +619,18 @@ public class GridCacheQueryAdapter<T> implements CacheQuery<T> {
         /** Flag indicating that a first item has been returned to a user. */
         private boolean firstItemReturned;
 
+        /** */
+        private Map.Entry cur;
+
         /**
          * @param part Partition.
-         * @param bean Bean.
+         * @param qry Query.
          * @param qryMgr Query manager.
          * @param cctx Cache context.
          */
-        private CacheQueryFallbackFuture(int part, GridCacheQueryBean bean,
+        private ScanQueryFallbackClosableIterator(int part, GridCacheQueryAdapter qry,
             GridCacheQueryManager qryMgr, GridCacheContext cctx) {
-            this.bean = bean;
+            this.qry = qry;
             this.qryMgr = qryMgr;
             this.cctx = cctx;
             this.part = part;
@@ -628,46 +672,82 @@ public class GridCacheQueryAdapter<T> implements CacheQuery<T> {
         private void init() {
             final ClusterNode node = nodes.poll();
 
-            fut = (GridCacheQueryFutureAdapter<?, ?, R>)(node.isLocal() ?
-                qryMgr.queryLocal(bean) :
-                qryMgr.queryDistributed(bean, Collections.singleton(node)));
-        }
+            if (node.isLocal()) {
+                try {
+                    GridCloseableIterator it = qryMgr.scanQueryLocal(qry, true);
 
-        /** {@inheritDoc} */
-        @Override public int available() {
-            return fut.available();
-        }
+                    tuple= new T2(it, null);
+                }
+                catch (IgniteClientDisconnectedCheckedException e) {
+                    throw CU.convertToCacheException(e);
+                }
+                catch (IgniteCheckedException e) {
+                    retryIfPossible(e);
+                }
+            }
+            else {
+                final GridCacheQueryBean bean = new GridCacheQueryBean(qry, null, null, null);
 
-        /** {@inheritDoc} */
-        @Override public boolean cancel() throws IgniteCheckedException {
-            return fut.cancel();
+                GridCacheQueryFutureAdapter fut =
+                    (GridCacheQueryFutureAdapter)qryMgr.queryDistributed(bean, Collections.singleton(node));
+
+                tuple = new T2(null, fut);
+            }
         }
 
         /** {@inheritDoc} */
-        @Override public Collection<R> get() throws IgniteCheckedException {
-            assert false;
+        @Override protected Map.Entry onNext() throws IgniteCheckedException {
+            if (!onHasNext())
+                throw new NoSuchElementException();
 
-            return super.get();
+            assert cur != null;
+
+            Map.Entry e = cur;
+
+            cur = null;
+
+            return e;
         }
 
         /** {@inheritDoc} */
-        @Override public R next() {
-            if (firstItemReturned)
-                return fut.next();
-
+        @Override protected boolean onHasNext() throws IgniteCheckedException {
             while (true) {
-                try {
-                    fut.awaitFirstPage();
+                if (cur != null)
+                    return true;
 
-                    firstItemReturned = true;
+                T2<GridCloseableIterator<Map.Entry>, GridCacheQueryFutureAdapter> t = tuple;
 
-                    return fut.next();
-                }
-                catch (IgniteClientDisconnectedCheckedException e) {
-                    throw CU.convertToCacheException(e);
+                GridCloseableIterator<Map.Entry> iter = t.get1();
+
+                if (iter != null) {
+                    boolean hasNext = iter.hasNext();
+
+                    if (hasNext)
+                        cur = iter.next();
+
+                    return hasNext;
                 }
-                catch (IgniteCheckedException e) {
-                    retryIfPossible(e);
+                else {
+                    GridCacheQueryFutureAdapter fut = t.get2();
+
+                    assert fut != null;
+
+                    if (firstItemReturned)
+                        return (cur = (Map.Entry)fut.next()) != null;
+
+                    try {
+                        fut.awaitFirstPage();
+
+                        firstItemReturned = true;
+
+                        return (cur = (Map.Entry)fut.next()) != null;
+                    }
+                    catch (IgniteClientDisconnectedCheckedException e) {
+                        throw CU.convertToCacheException(e);
+                    }
+                    catch (IgniteCheckedException e) {
+                        retryIfPossible(e);
+                    }
                 }
             }
         }
@@ -679,8 +759,10 @@ public class GridCacheQueryAdapter<T> implements CacheQuery<T> {
             try {
                 IgniteInternalFuture<?> retryFut;
 
-                if (e.hasCause(GridDhtUnreservedPartitionException.class)) {
-                    AffinityTopologyVersion waitVer = ((GridDhtUnreservedPartitionException)e.getCause()).topologyVersion();
+                GridDhtUnreservedPartitionException partErr = X.cause(e, GridDhtUnreservedPartitionException.class);
+
+                if (partErr != null) {
+                    AffinityTopologyVersion waitVer = partErr.topologyVersion();
 
                     assert waitVer != null;
 
@@ -720,5 +802,18 @@ public class GridCacheQueryAdapter<T> implements CacheQuery<T> {
                 throw CU.convertToCacheException(ex);
             }
         }
+
+        /** {@inheritDoc} */
+        @Override protected void onClose() throws IgniteCheckedException {
+            super.onClose();
+
+            T2<GridCloseableIterator<Map.Entry>, GridCacheQueryFutureAdapter> t = tuple;
+
+            if (t != null && t.get1() != null)
+                t.get1().close();
+
+            if (t != null && t.get2() != null)
+                t.get2().cancel();
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/0e8072f8/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryErrorFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryErrorFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryErrorFuture.java
index fd8c4d8..ac14ae6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryErrorFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryErrorFuture.java
@@ -36,14 +36,14 @@ public class GridCacheQueryErrorFuture<T> extends GridFinishedFuture<Collection<
     }
 
     /** {@inheritDoc} */
-    @Override public int available() throws IgniteCheckedException {
-        return 0;
-    }
-
-    /** {@inheritDoc} */
     @Nullable @Override public T next() throws IgniteCheckedException {
         get();
 
         return null;
     }
-}
\ No newline at end of file
+
+    /** {@inheritDoc} */
+    @Override public void close() throws Exception {
+        cancel();
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0e8072f8/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryFutureAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryFutureAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryFutureAdapter.java
index e3e5d98..db519f5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryFutureAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryFutureAdapter.java
@@ -161,11 +161,6 @@ public abstract class GridCacheQueryFutureAdapter<K, V, R> extends GridFutureAda
     }
 
     /** {@inheritDoc} */
-    @Override public int available() {
-        return cnt.get();
-    }
-
-    /** {@inheritDoc} */
     @Override public R next() {
         try {
             R next = unmaskNull(internalIterator().next());
@@ -571,6 +566,11 @@ public abstract class GridCacheQueryFutureAdapter<K, V, R> extends GridFutureAda
     }
 
     /** {@inheritDoc} */
+    @Override public void close() throws Exception {
+        cancel();
+    }
+
+    /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(GridCacheQueryFutureAdapter.class, this);
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/0e8072f8/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 8bcf564..3028208 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
@@ -38,6 +38,7 @@ import java.util.Queue;
 import java.util.UUID;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ConcurrentMap;
+import javax.cache.Cache;
 import javax.cache.expiry.ExpiryPolicy;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCheckedException;
@@ -466,7 +467,27 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
      * @param qry Query.
      * @return Query future.
      */
-    public abstract CacheQueryFuture<?> queryLocal(GridCacheQueryBean qry);
+    @SuppressWarnings("unchecked")
+    public CacheQueryFuture<?> queryLocal(GridCacheQueryBean qry) {
+        assert qry.query().type() != GridCacheQueryType.SCAN : qry;
+
+        if (log.isDebugEnabled())
+            log.debug("Executing query on local node: " + qry);
+
+        GridCacheLocalQueryFuture fut = new GridCacheLocalQueryFuture<>(cctx, qry);
+
+        try {
+            qry.query().validate();
+
+            fut.execute();
+        }
+        catch (IgniteCheckedException e) {
+            if (fut != null)
+                fut.onDone(e);
+        }
+
+        return fut;
+    }
 
     /**
      * Executes distributed query.
@@ -478,6 +499,17 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
     public abstract CacheQueryFuture<?> queryDistributed(GridCacheQueryBean qry, Collection<ClusterNode> nodes);
 
     /**
+     * Executes distributed SCAN query.
+     *
+     * @param qry Query.
+     * @param nodes Nodes.
+     * @return Iterator.
+     * @throws IgniteCheckedException If failed.
+     */
+    public abstract GridCloseableIterator<Map.Entry<K, V>> scanQueryDistributed(GridCacheQueryAdapter qry,
+        Collection<ClusterNode> nodes) throws IgniteCheckedException;
+
+    /**
      * Loads page.
      *
      * @param id Query ID.
@@ -591,7 +623,7 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
                             taskName));
                     }
 
-                    iter = scanIterator(qry);
+                    iter = scanIterator(qry, false);
 
                     break;
 
@@ -800,18 +832,13 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
 
     /**
      * @param qry Query.
+     * @param locNode Local node.
      * @return Full-scan row iterator.
      * @throws IgniteCheckedException If failed to get iterator.
      */
     @SuppressWarnings({"unchecked"})
-    private GridCloseableIterator<IgniteBiTuple<K, V>> scanIterator(final GridCacheQueryAdapter<?> qry)
+    private GridCloseableIterator<IgniteBiTuple<K, V>> scanIterator(final GridCacheQueryAdapter<?> qry, boolean locNode)
         throws IgniteCheckedException {
-        IgniteInternalCache<K, V> prj0 = cctx.cache();
-
-        prj0 = prj0.keepBinary();
-
-        final IgniteInternalCache prj = prj0;
-
         final IgniteBiPredicate<K, V> keyValFilter = qry.scanFilter();
 
         try {
@@ -823,56 +850,12 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
 
             final boolean backups = qry.includeBackups() || cctx.isReplicated();
 
-            Iterator<K> keyIter;
-
-            GridDhtLocalPartition locPart = null;
-
-            Integer part = qry.partition();
-
-            if (part == null || cctx.isLocal())
-                keyIter = backups ? prj.keySetx().iterator() : prj.primaryKeySet().iterator();
-            else if (part < 0 || part >= cctx.affinity().partitions())
-                keyIter = new GridEmptyIterator<>();
-            else {
-                final GridDhtCacheAdapter dht = cctx.isNear() ? cctx.near().dht() : cctx.dht();
-
-                locPart = dht.topology().localPartition(part, topVer, false);
-
-                // double check for owning state
-                if (locPart == null || locPart.state() != OWNING || !locPart.reserve() || locPart.state() != OWNING)
-                    throw new GridDhtUnreservedPartitionException(part, cctx.affinity().affinityTopologyVersion(),
-                        "Partition can not be reserved");
-
-                final GridDhtLocalPartition locPart0 = locPart;
-
-                keyIter = new Iterator<K>() {
-                    private Iterator<KeyCacheObject> iter0 = locPart0.keySet().iterator();
-
-                    @Override public boolean hasNext() {
-                        return iter0.hasNext();
-                    }
-
-                    @Override public K next() {
-                        return (K)iter0.next();
-                    }
-
-                    @Override public void remove() {
-                        iter0.remove();
-                    }
-                };
-            }
-
-            final GridDhtLocalPartition locPart0 = locPart;
-
-            final GridCloseableIteratorAdapter<IgniteBiTuple<K, V>> heapIt =
-                new PeekValueExpiryAwareIterator(keyIter, plc, topVer, keyValFilter, qry.keepBinary(), true) {
-                    @Override protected void onClose() {
-                        super.onClose();
-
-                        if (locPart0 != null)
-                            locPart0.release();
-                    }
-                };
+            final GridIterator<IgniteBiTuple<K, V>> heapIt = onheapIterator(qry,
+                topVer,
+                keyValFilter,
+                backups,
+                plc,
+                locNode);
 
             final GridIterator<IgniteBiTuple<K, V>> it;
 
@@ -882,10 +865,10 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
                 iters.add(heapIt);
 
                 if (cctx.isOffHeapEnabled())
-                    iters.add(offheapIterator(qry, topVer, backups, plc));
+                    iters.add(offheapIterator(qry, topVer, backups, plc, locNode));
 
                 if (cctx.swap().swapEnabled())
-                    iters.add(swapIterator(qry, topVer, backups, plc));
+                    iters.add(swapIterator(qry, topVer, backups, plc, locNode));
 
                 it = new CompoundIterator<>(iters);
             }
@@ -907,7 +890,8 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
 
                 @Override protected void onClose() throws IgniteCheckedException {
                     try {
-                        heapIt.close();
+                        if (heapIt instanceof IgniteSpiCloseableIterator)
+                            ((IgniteSpiCloseableIterator)heapIt).close();
                     }
                     finally {
                         closeScanFilter(keyValFilter);
@@ -915,8 +899,7 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
                 }
             };
         }
-        catch (IgniteCheckedException | RuntimeException e)
-        {
+        catch (IgniteCheckedException | RuntimeException e) {
             closeScanFilter(keyValFilter);
 
             throw e;
@@ -935,7 +918,10 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
 
     /**
      * @param qry Query.
+     * @param topVer Topology version.
      * @param backups Include backups.
+     * @param expPlc Expiry policy.
+     * @param locNode Local node.
      * @return Swap iterator.
      * @throws IgniteCheckedException If failed.
      */
@@ -943,8 +929,8 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
         GridCacheQueryAdapter<?> qry,
         AffinityTopologyVersion topVer,
         boolean backups,
-        ExpiryPolicy expPlc
-    ) throws IgniteCheckedException {
+        ExpiryPolicy expPlc,
+        boolean locNode) throws IgniteCheckedException {
         IgniteBiPredicate<K, V> filter = qry.scanFilter();
 
         Integer part = qry.partition();
@@ -958,22 +944,146 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
                 topVer,
                 filter,
                 expPlc,
-                qry.keepBinary());
+                qry.keepBinary(), locNode);
 
-        return scanIterator(it, filter, qry.keepBinary());
+        return scanIterator(it, filter, qry.keepBinary(), locNode);
     }
 
     /**
      * @param qry Query.
+     * @param topVer Topology version.
+     * @param keyValFilter Filter.
      * @param backups Include backups.
+     * @param plc Expiry policy.
+     * @param locNode Local node.
+     * @return Offheap iterator.
+     * @throws GridDhtUnreservedPartitionException If failed to reserve partition.
+     */
+    private GridIterator<IgniteBiTuple<K, V>> onheapIterator(
+        GridCacheQueryAdapter<?> qry,
+        AffinityTopologyVersion topVer,
+        final IgniteBiPredicate<K, V> keyValFilter,
+        boolean backups,
+        final ExpiryPolicy plc,
+        final boolean locNode) throws GridDhtUnreservedPartitionException {
+        Iterator<K> keyIter;
+
+        GridDhtLocalPartition locPart = null;
+
+        Integer part = qry.partition();
+
+        if (part == null || cctx.isLocal()) {
+            // Performance optimization.
+            if (locNode && plc == null && !cctx.isLocal()) {
+                GridDhtCacheAdapter<K, V> cache = cctx.isNear() ? cctx.near().dht() : cctx.dht();
+
+                final Iterator<Cache.Entry<K, V>> iter = cache.localEntriesIterator(true, backups);
+
+                return new GridIteratorAdapter<IgniteBiTuple<K, V>>() {
+                    /** */
+                    private IgniteBiTuple<K, V> next;
+
+                    {
+                        advance();
+                    }
+
+                    @Override public boolean hasNextX() throws IgniteCheckedException {
+                        return next != null;
+                    }
+
+                    @Override public IgniteBiTuple<K, V> nextX() throws IgniteCheckedException {
+                        if (next == null)
+                            throw new NoSuchElementException();
+
+                        IgniteBiTuple<K, V> next0 = next;
+
+                        advance();
+
+                        return next0;
+                    }
+
+                    @Override public void removeX() throws IgniteCheckedException {
+                        // No-op.
+                    }
+
+                    private void advance() {
+                        IgniteBiTuple<K, V> next0 = null;
+
+                        while (iter.hasNext()) {
+                            Cache.Entry<K, V> cacheEntry = iter.next();
+
+                            if (keyValFilter != null && !keyValFilter.apply(cacheEntry.getKey(), cacheEntry.getValue()))
+                                continue;
+
+                            next0 = new IgniteBiTuple<>(cacheEntry.getKey(), cacheEntry.getValue());
+
+                            break;
+                        }
+
+                        next = next0;
+                    }
+                };
+            }
+
+            IgniteInternalCache<K, V> keepBinaryCache = cctx.cache().keepBinary();
+
+            keyIter = backups ? keepBinaryCache.keySetx().iterator() : keepBinaryCache.primaryKeySet().iterator();
+        }
+        else if (part < 0 || part >= cctx.affinity().partitions())
+            keyIter = new GridEmptyIterator<>();
+        else {
+            final GridDhtCacheAdapter dht = cctx.isNear() ? cctx.near().dht() : cctx.dht();
+
+            locPart = dht.topology().localPartition(part, topVer, false);
+
+            // Double check for owning state.
+            if (locPart == null || locPart.state() != OWNING || !locPart.reserve() || locPart.state() != OWNING)
+                throw new GridDhtUnreservedPartitionException(part, cctx.affinity().affinityTopologyVersion(),
+                    "Partition can not be reserved.");
+
+            final GridDhtLocalPartition locPart0 = locPart;
+
+            keyIter = new Iterator<K>() {
+                private Iterator<KeyCacheObject> iter0 = locPart0.keySet().iterator();
+
+                @Override public boolean hasNext() {
+                    return iter0.hasNext();
+                }
+
+                @Override public K next() {
+                    return (K)iter0.next();
+                }
+
+                @Override public void remove() {
+                    iter0.remove();
+                }
+            };
+        }
+
+        final GridDhtLocalPartition locPart0 = locPart;
+
+        return new PeekValueExpiryAwareIterator(keyIter, plc, topVer, keyValFilter, qry.keepBinary(), locNode, true) {
+                @Override protected void onClose() {
+                    super.onClose();
+
+                    if (locPart0 != null)
+                        locPart0.release();
+                }
+            };
+    }
+
+    /**
+     * @param qry Query.
+     * @param backups Include backups.
+     * @param locNode Local node.
      * @return Offheap iterator.
      */
     private GridIterator<IgniteBiTuple<K, V>> offheapIterator(
         GridCacheQueryAdapter<?> qry,
         AffinityTopologyVersion topVer,
         boolean backups,
-        ExpiryPolicy expPlc
-    ) {
+        ExpiryPolicy expPlc,
+        boolean locNode) {
         IgniteBiPredicate<K, V> filter = qry.scanFilter();
 
         if (expPlc != null) {
@@ -982,18 +1092,18 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
                 topVer,
                 filter,
                 expPlc,
-                qry.keepBinary());
+                qry.keepBinary(), locNode);
         }
 
         if (cctx.offheapTiered() && filter != null) {
-            OffheapIteratorClosure c = new OffheapIteratorClosure(filter, qry.keepBinary());
+            OffheapIteratorClosure c = new OffheapIteratorClosure(filter, qry.keepBinary(), locNode);
 
             return cctx.swap().rawOffHeapIterator(c, qry.partition(), true, backups);
         }
         else {
             Iterator<Map.Entry<byte[], byte[]>> it = cctx.swap().rawOffHeapIterator(qry.partition(), true, backups);
 
-            return scanIterator(it, filter, qry.keepBinary());
+            return scanIterator(it, filter, qry.keepBinary(), locNode);
         }
     }
 
@@ -1001,12 +1111,14 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
      * @param it Lazy swap or offheap iterator.
      * @param filter Scan filter.
      * @param keepBinary Keep binary flag.
+     * @param locNode Local node.
      * @return Iterator.
      */
     private GridIteratorAdapter<IgniteBiTuple<K, V>> scanIterator(
         @Nullable final Iterator<Map.Entry<byte[], byte[]>> it,
         @Nullable final IgniteBiPredicate<K, V> filter,
-        final boolean keepBinary) {
+        final boolean keepBinary,
+        final boolean locNode) {
         if (it == null)
             return new GridEmptyCloseableIterator<>();
 
@@ -1042,15 +1154,18 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
                 while (it.hasNext()) {
                     final LazySwapEntry e = new LazySwapEntry(it.next());
 
-                    if (filter != null) {
-                        K key = (K)cctx.unwrapBinaryIfNeeded(e.key(), keepBinary);
-                        V val = (V)cctx.unwrapBinaryIfNeeded(e.value(), keepBinary);
+                    K key = e.key();
+                    V val = e.value();
 
-                        if (!filter.apply(key, val))
-                            continue;
+                    if (filter != null || locNode) {
+                        key = (K)cctx.unwrapBinaryIfNeeded(key, keepBinary);
+                        val = (V)cctx.unwrapBinaryIfNeeded(val, keepBinary);
                     }
 
-                    next = new IgniteBiTuple<>(e.key(), e.value());
+                    if (filter != null && !filter.apply(key, val))
+                        continue;
+
+                    next = new IgniteBiTuple<>(key, val);
 
                     break;
                 }
@@ -1064,6 +1179,7 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
      * @param filter Filter.
      * @param expPlc Expiry policy.
      * @param keepBinary Keep binary flag.
+     * @param locNode Local node.
      * @return Final key-value iterator.
      */
     private GridIterator<IgniteBiTuple<K,V>> scanExpiryIterator(
@@ -1071,8 +1187,8 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
         AffinityTopologyVersion topVer,
         @Nullable final IgniteBiPredicate<K, V> filter,
         ExpiryPolicy expPlc,
-        final boolean keepBinary
-    ) {
+        final boolean keepBinary,
+        boolean locNode) {
         Iterator <K> keyIter = new Iterator<K>() {
             /** {@inheritDoc} */
             @Override public boolean hasNext() {
@@ -1097,7 +1213,7 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
             }
         };
 
-        return new PeekValueExpiryAwareIterator(keyIter, expPlc, topVer, filter, keepBinary, false);
+        return new PeekValueExpiryAwareIterator(keyIter, expPlc, topVer, filter, keepBinary, locNode, false);
     }
 
     /**
@@ -1318,6 +1434,7 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
     @SuppressWarnings("unchecked")
     protected void runQuery(GridCacheQueryInfo qryInfo) {
         assert qryInfo != null;
+        assert qryInfo.query().type() != SCAN || !qryInfo.local() : qryInfo;
 
         if (!enterBusy()) {
             if (cctx.localNodeId().equals(qryInfo.senderId()))
@@ -1439,6 +1556,9 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
                     }
 
                     if (readEvt) {
+                        K key0  = (K)cctx.unwrapBinaryIfNeeded(key, qry.keepBinary());
+                        V val0  = (V)cctx.unwrapBinaryIfNeeded(val, qry.keepBinary());
+
                         switch (type) {
                             case SQL:
                                 cctx.gridEvents().record(new CacheQueryReadEvent<>(
@@ -1454,8 +1574,8 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
                                     qryInfo.arguments(),
                                     qry.subjectId(),
                                     taskName,
-                                    key,
-                                    val,
+                                    key0,
+                                    val0,
                                     null,
                                     null));
 
@@ -1475,8 +1595,8 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
                                     null,
                                     qry.subjectId(),
                                     taskName,
-                                    key,
-                                    val,
+                                    key0,
+                                    val0,
                                     null,
                                     null));
 
@@ -1496,8 +1616,8 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
                                     null,
                                     qry.subjectId(),
                                     taskName,
-                                    key,
-                                    val,
+                                    key0,
+                                    val0,
                                     null,
                                     null));
 
@@ -1589,12 +1709,127 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
     }
 
     /**
+     * Process local scan query.
+     *
+     * @param qry Query.
+     * @param updStatisticsIfNeeded Update statistics flag.
+     */
+    @SuppressWarnings({"unchecked", "serial"})
+    protected GridCloseableIterator<IgniteBiTuple<K, V>> scanQueryLocal(final GridCacheQueryAdapter qry,
+        final boolean updStatisticsIfNeeded) throws IgniteCheckedException {
+        if (!enterBusy())
+            throw new IllegalStateException("Failed to process query request (grid is stopping).");
+
+        final boolean statsEnabled = cctx.config().isStatisticsEnabled();
+
+        boolean needUpdStatistics = updStatisticsIfNeeded && statsEnabled;
+
+        long startTime = U.currentTimeMillis();
+
+        try {
+            assert qry.type() == SCAN;
+
+            if (log.isDebugEnabled())
+                log.debug("Running local SCAN query: " + qry);
+
+            final String taskName = cctx.kernalContext().task().resolveTaskName(qry.taskHash());
+            final IgniteBiPredicate filter = qry.scanFilter();
+            final String namex = cctx.namex();
+            final ClusterNode locNode = cctx.localNode();
+            final UUID subjId = qry.subjectId();
+
+            if (cctx.gridEvents().isRecordable(EVT_CACHE_QUERY_EXECUTED)) {
+                cctx.gridEvents().record(new CacheQueryExecutedEvent<>(
+                    locNode,
+                    "Scan query executed.",
+                    EVT_CACHE_QUERY_EXECUTED,
+                    CacheQueryType.SCAN.name(),
+                    namex,
+                    null,
+                    null,
+                    filter,
+                    null,
+                    null,
+                    subjId,
+                    taskName));
+            }
+
+            final GridCloseableIterator<IgniteBiTuple<K, V>> iter = scanIterator(qry, true);
+
+            if (updStatisticsIfNeeded) {
+                needUpdStatistics = false;
+
+                cctx.queries().onCompleted(U.currentTimeMillis() - startTime, false);
+            }
+
+            final boolean readEvt = cctx.gridEvents().isRecordable(EVT_CACHE_QUERY_OBJECT_READ);
+
+            return new GridCloseableIteratorAdapter<IgniteBiTuple<K, V>>() {
+                @Override protected IgniteBiTuple<K, V> onNext() throws IgniteCheckedException {
+                    long start = statsEnabled ? System.nanoTime() : 0L;
+
+                    IgniteBiTuple<K, V> next = iter.nextX();
+
+                    if (statsEnabled) {
+                        CacheMetricsImpl metrics = cctx.cache().metrics0();
+
+                        metrics.onRead(true);
+
+                        metrics.addGetTimeNanos(System.nanoTime() - start);
+                    }
+
+                    if (readEvt) {
+                        cctx.gridEvents().record(new CacheQueryReadEvent<>(
+                            cctx.localNode(),
+                            "Scan query entry read.",
+                            EVT_CACHE_QUERY_OBJECT_READ,
+                            CacheQueryType.SCAN.name(),
+                            namex,
+                            null,
+                            null,
+                            filter,
+                            null,
+                            null,
+                            subjId,
+                            taskName,
+                            next.getKey(),
+                            next.getValue(),
+                            null,
+                            null));
+                    }
+
+                    return next;
+                }
+
+                @Override protected boolean onHasNext() throws IgniteCheckedException {
+                    return iter.hasNextX();
+                }
+
+                @Override protected void onClose() throws IgniteCheckedException {
+                    iter.close();
+                }
+            };
+        }
+        catch (Exception e) {
+            if (needUpdStatistics)
+                cctx.queries().onCompleted(U.currentTimeMillis() - startTime, true);
+
+            throw e;
+        }
+        finally {
+            leaveBusy();
+        }
+    }
+
+    /**
      * @param qryInfo Info.
      * @param taskName Task name.
      * @return Iterator.
      * @throws IgniteCheckedException In case of error.
      */
-    private QueryResult<K, V> queryResult(GridCacheQueryInfo qryInfo, String taskName) throws IgniteCheckedException {
+    private QueryResult<K, V> queryResult(final GridCacheQueryInfo qryInfo, String taskName) throws IgniteCheckedException {
+        assert qryInfo != null;
+
         final UUID sndId = qryInfo.senderId();
 
         assert sndId != null;
@@ -1602,8 +1837,7 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
         Map<Long, GridFutureAdapter<QueryResult<K, V>>> futs = qryIters.get(sndId);
 
         if (futs == null) {
-            futs = new LinkedHashMap<Long, GridFutureAdapter<QueryResult<K, V>>>(
-                16, 0.75f, true) {
+            futs = new LinkedHashMap<Long, GridFutureAdapter<QueryResult<K, V>>>(16, 0.75f, true) {
                 @Override protected boolean removeEldestEntry(Map.Entry<Long, GridFutureAdapter<QueryResult<K, V>>> e) {
                     boolean rmv = size() > maxIterCnt;
 
@@ -1626,22 +1860,7 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
                 futs = old;
         }
 
-        return queryResult(futs, qryInfo, taskName);
-    }
-
-    /**
-     * @param futs Futures map.
-     * @param qryInfo Info.
-     * @return Iterator.
-     * @throws IgniteCheckedException In case of error.
-     */
-    @SuppressWarnings({
-        "SynchronizationOnLocalVariableOrMethodParameter",
-        "NonPrivateFieldAccessedInSynchronizedContext"})
-    private QueryResult<K, V> queryResult(Map<Long, GridFutureAdapter<QueryResult<K, V>>> futs,
-        GridCacheQueryInfo qryInfo, String taskName) throws IgniteCheckedException {
         assert futs != null;
-        assert qryInfo != null;
 
         GridFutureAdapter<QueryResult<K, V>> fut;
 
@@ -2584,17 +2803,23 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
         /** */
         private boolean keepBinary;
 
+        /** */
+        private boolean locNode;
+
         /**
          * @param filter Filter.
          * @param keepBinary Keep binary flag.
+         * @param locNode Local node.
          */
         private OffheapIteratorClosure(
             @Nullable IgniteBiPredicate<K, V> filter,
-            boolean keepBinary) {
+            boolean keepBinary,
+            boolean locNode) {
             assert filter != null;
 
             this.filter = filter;
             this.keepBinary = keepBinary;
+            this.locNode = locNode;
         }
 
         /** {@inheritDoc} */
@@ -2609,15 +2834,19 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
             if (!filter.apply(key, val))
                 return null;
 
-            if (key instanceof CacheObject)
-                ((CacheObject)key).prepareMarshal(cctx.cacheObjectContext());
+            if (locNode)
+                return new IgniteBiTuple<>(key, val);
+            else{
+                if (key instanceof CacheObject)
+                    ((CacheObject)key).prepareMarshal(cctx.cacheObjectContext());
 
-            val = (V)cctx.unwrapTemporary(e.value());
+                val = (V)cctx.unwrapTemporary(e.value());
 
-            if (val instanceof CacheObject)
-                ((CacheObject)val).prepareMarshal(cctx.cacheObjectContext());
+                if (val instanceof CacheObject)
+                    ((CacheObject)val).prepareMarshal(cctx.cacheObjectContext());
 
-            return new IgniteBiTuple<>(e.key(), val);
+                return new IgniteBiTuple<>(key, val);
+            }
         }
     }
 
@@ -3098,6 +3327,9 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
         /** */
         private final IgniteBiPredicate<K, V> keyValFilter;
 
+        /** */
+        private boolean locNode;
+
         /** Heap only flag. */
         private boolean heapOnly;
 
@@ -3119,6 +3351,8 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
          * @param topVer Topology version.
          * @param keyValFilter Key-value filter.
          * @param keepBinary Keep binary flag from the query.
+         * @param locNode Local node.
+         * @param heapOnly Heap only.
          */
         private PeekValueExpiryAwareIterator(
             Iterator<K> keyIt,
@@ -3126,12 +3360,14 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
             AffinityTopologyVersion topVer,
             IgniteBiPredicate<K, V> keyValFilter,
             boolean keepBinary,
+            boolean locNode,
             boolean heapOnly
         ) {
             this.keyIt = keyIt;
             this.plc = plc;
             this.topVer = topVer;
             this.keyValFilter = keyValFilter;
+            this.locNode = locNode;
             this.heapOnly = heapOnly;
 
             dht = cctx.isLocal() ? null : (cctx.isNear() ? cctx.near().dht() : cctx.dht());
@@ -3195,11 +3431,27 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
                 }
 
                 if (val != null) {
+                    boolean keepBinary0 = !locNode || keepBinary;
+
                     next0 = F.t(
-                        (K)cctx.unwrapBinaryIfNeeded(key, true),
-                        (V)cctx.unwrapBinaryIfNeeded(val, true));
+                        (K)cctx.unwrapBinaryIfNeeded(key, keepBinary0),
+                        (V)cctx.unwrapBinaryIfNeeded(val, keepBinary0));
+
+                    boolean passPred = true;
 
-                    if (checkPredicate(next0))
+                    if (keyValFilter != null) {
+                        Object key0 = next0.getKey();
+                        Object val0 = next0.getValue();
+
+                        if (keepBinary0 && !keepBinary) {
+                            key0 = (K)cctx.unwrapBinaryIfNeeded(key0, keepBinary);
+                            val0 = (V)cctx.unwrapBinaryIfNeeded(val0, keepBinary);
+                        }
+
+                        passPred = keyValFilter.apply((K)key0, (V)val0);
+                    }
+
+                    if (passPred)
                         break;
                     else
                         next0 = null;
@@ -3246,21 +3498,5 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
                 }
             }
         }
-
-        /**
-         * Check key-value predicate.
-         *
-         * @param e Entry to check.
-         * @return Filter evaluation result.
-         */
-        private boolean checkPredicate(Map.Entry<K, V> e) {
-            if (keyValFilter != null) {
-                Map.Entry<K, V> e0 = (Map.Entry<K, V>)cctx.unwrapBinaryIfNeeded(e, keepBinary);
-
-                return keyValFilter.apply(e0.getKey(), e0.getValue());
-            }
-
-            return true;
-        }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/0e8072f8/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSetImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSetImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSetImpl.java
index 5b74992..70232af 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSetImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSetImpl.java
@@ -30,8 +30,11 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.Callable;
-
-import org.apache.ignite.*;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteCompute;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.IgniteSet;
 import org.apache.ignite.cache.affinity.AffinityKeyMapped;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
@@ -417,7 +420,7 @@ public class GridCacheSetImpl<T> extends AbstractCollection<T> implements Ignite
 
             CacheQueryFuture<Map.Entry<T, ?>> fut = qry.execute();
 
-            CacheWeakQueryIteratorsHolder.WeakQueryFutureIterator it =
+            CacheWeakQueryIteratorsHolder.WeakReferenceCloseableIterator it =
                 ctx.itHolder().iterator(fut, new CacheIteratorConverter<T, Map.Entry<T, ?>>() {
                     @Override protected T convert(Map.Entry<T, ?> e) {
                         return e.getKey();


[07/24] ignite git commit: IGNITE-3112: .NET: Now top-level configuration could be merged with Spring beans. This closes #706.

Posted by ak...@apache.org.
IGNITE-3112: .NET: Now top-level configuration could be merged with Spring beans. This closes #706.


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

Branch: refs/heads/master
Commit: 341f12fb25b16206a82de32a96b900163cf4f043
Parents: 424cf89
Author: Pavel Tupitsyn <pt...@gridgain.com>
Authored: Mon May 16 11:47:39 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Mon May 16 11:47:39 2016 +0300

----------------------------------------------------------------------
 .../utils/PlatformConfigurationUtils.java       |  49 +++---
 .../Apache.Ignite.Core.Tests.csproj             |   3 +
 .../Binary/BinaryCompactFooterInteropTest.cs    |   1 -
 .../Continuous/ContinuousQueryJavaFilterTest.cs |   1 -
 .../Cache/Store/CacheStoreTest.cs               |   1 -
 .../Compute/ComputeApiTest.cs                   |   1 -
 .../Compute/MixedClusterTest.cs                 |   1 -
 .../Config/spring-test.xml                      |  46 +++++
 .../Apache.Ignite.Core.Tests/DeploymentTest.cs  |   1 -
 .../Apache.Ignite.Core.Tests/ExecutableTest.cs  |   1 -
 .../IgniteConfigurationSerializerTest.cs        |   3 +-
 .../IgniteConfigurationTest.cs                  |  20 ++-
 .../IgniteStartStopTest.cs                      |   1 -
 .../Apache.Ignite.Core.Tests/ReconnectTest.cs   |   1 -
 .../Services/ServicesTest.cs                    |   1 -
 .../Apache.Ignite.Core.csproj                   |   1 +
 .../Apache.Ignite.Core/IgniteConfiguration.cs   | 173 ++++++++++++-------
 .../dotnet/Apache.Ignite.Core/Ignition.cs       |   1 -
 .../Impl/Binary/BinaryReaderExtensions.cs       |  24 +++
 .../Impl/Binary/BinaryWriterExtensions.cs       |  78 +++++++++
 .../dotnet/Apache.Ignite.Core/Impl/Ignite.cs    |   1 -
 21 files changed, 298 insertions(+), 111 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/341f12fb/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
index e462d40..a7b1b17 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
@@ -351,22 +351,19 @@ public class PlatformConfigurationUtils {
      * @param cfg Configuration.
      */
     public static void readIgniteConfiguration(BinaryRawReaderEx in, IgniteConfiguration cfg) {
-        if (!in.readBoolean())
-            return;  // there is no config
-
-        cfg.setClientMode(in.readBoolean());
-        cfg.setIncludeEventTypes(in.readIntArray());
-        cfg.setMetricsExpireTime(in.readLong());
-        cfg.setMetricsHistorySize(in.readInt());
-        cfg.setMetricsLogFrequency(in.readLong());
-        cfg.setMetricsUpdateFrequency(in.readLong());
-        cfg.setNetworkSendRetryCount(in.readInt());
-        cfg.setNetworkSendRetryDelay(in.readLong());
-        cfg.setNetworkTimeout(in.readLong());
-        cfg.setWorkDirectory(in.readString());
-        cfg.setLocalHost(in.readString());
-        cfg.setDaemon(in.readBoolean());
-        cfg.setLateAffinityAssignment(in.readBoolean());
+        if (in.readBoolean()) cfg.setClientMode(in.readBoolean());
+        int[] eventTypes = in.readIntArray(); if (eventTypes != null) cfg.setIncludeEventTypes(eventTypes);
+        if (in.readBoolean()) cfg.setMetricsExpireTime(in.readLong());
+        if (in.readBoolean()) cfg.setMetricsHistorySize(in.readInt());
+        if (in.readBoolean()) cfg.setMetricsLogFrequency(in.readLong());
+        if (in.readBoolean()) cfg.setMetricsUpdateFrequency(in.readLong());
+        if (in.readBoolean()) cfg.setNetworkSendRetryCount(in.readInt());
+        if (in.readBoolean()) cfg.setNetworkSendRetryDelay(in.readLong());
+        if (in.readBoolean()) cfg.setNetworkTimeout(in.readLong());
+        String workDir = in.readString(); if (workDir != null) cfg.setWorkDirectory(workDir);
+        String localHost = in.readString(); if (localHost != null) cfg.setLocalHost(localHost);
+        if (in.readBoolean()) cfg.setDaemon(in.readBoolean());
+        if (in.readBoolean()) cfg.setLateAffinityAssignment(in.readBoolean());
 
         readCacheConfigurations(in, cfg);
         readDiscoveryConfiguration(in, cfg);
@@ -721,19 +718,19 @@ public class PlatformConfigurationUtils {
         assert w != null;
         assert cfg != null;
 
-        w.writeBoolean(cfg.isClientMode());
+        w.writeBoolean(true); w.writeBoolean(cfg.isClientMode());
         w.writeIntArray(cfg.getIncludeEventTypes());
-        w.writeLong(cfg.getMetricsExpireTime());
-        w.writeInt(cfg.getMetricsHistorySize());
-        w.writeLong(cfg.getMetricsLogFrequency());
-        w.writeLong(cfg.getMetricsUpdateFrequency());
-        w.writeInt(cfg.getNetworkSendRetryCount());
-        w.writeLong(cfg.getNetworkSendRetryDelay());
-        w.writeLong(cfg.getNetworkTimeout());
+        w.writeBoolean(true); w.writeLong(cfg.getMetricsExpireTime());
+        w.writeBoolean(true); w.writeInt(cfg.getMetricsHistorySize());
+        w.writeBoolean(true); w.writeLong(cfg.getMetricsLogFrequency());
+        w.writeBoolean(true); w.writeLong(cfg.getMetricsUpdateFrequency());
+        w.writeBoolean(true); w.writeInt(cfg.getNetworkSendRetryCount());
+        w.writeBoolean(true); w.writeLong(cfg.getNetworkSendRetryDelay());
+        w.writeBoolean(true); w.writeLong(cfg.getNetworkTimeout());
         w.writeString(cfg.getWorkDirectory());
         w.writeString(cfg.getLocalHost());
-        w.writeBoolean(cfg.isDaemon());
-        w.writeBoolean(cfg.isLateAffinityAssignment());
+        w.writeBoolean(true); w.writeBoolean(cfg.isDaemon());
+        w.writeBoolean(true); w.writeBoolean(cfg.isLateAffinityAssignment());
 
         CacheConfiguration[] cacheCfg = cfg.getCacheConfiguration();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/341f12fb/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
index ef774af..b937d28 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
@@ -230,6 +230,9 @@
     <Content Include="Config\Lifecycle\lifecycle-no-beans.xml">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </Content>
+    <Content Include="Config\spring-test.xml">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
     <Content Include="Config\marshaller-default.xml">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </Content>

http://git-wip-us.apache.org/repos/asf/ignite/blob/341f12fb/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryCompactFooterInteropTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryCompactFooterInteropTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryCompactFooterInteropTest.cs
index b01b65e..27b97fd 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryCompactFooterInteropTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryCompactFooterInteropTest.cs
@@ -15,7 +15,6 @@
  * limitations under the License.
  */
 
-#pragma warning disable 618   // SpringConfigUrl
 namespace Apache.Ignite.Core.Tests.Binary
 {
     using System.Collections;

http://git-wip-us.apache.org/repos/asf/ignite/blob/341f12fb/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryJavaFilterTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryJavaFilterTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryJavaFilterTest.cs
index 76be0fd..de829e2 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryJavaFilterTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryJavaFilterTest.cs
@@ -16,7 +16,6 @@
  */
 
 // ReSharper disable UnusedAutoPropertyAccessor.Local
-#pragma warning disable 618  // SpringConfigUrl
 namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
 {
     using System;

http://git-wip-us.apache.org/repos/asf/ignite/blob/341f12fb/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
index 76ec384..d6a7f60 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
@@ -15,7 +15,6 @@
  * limitations under the License.
  */
 
-#pragma warning disable 618
 namespace Apache.Ignite.Core.Tests.Cache.Store
 {
     using System;

http://git-wip-us.apache.org/repos/asf/ignite/blob/341f12fb/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
index 45fb4b4..2c5b31e 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
@@ -17,7 +17,6 @@
 
 // ReSharper disable SpecifyACultureInStringConversionExplicitly
 // ReSharper disable UnusedAutoPropertyAccessor.Global
-#pragma warning disable 618  // SpringConfigUrl
 namespace Apache.Ignite.Core.Tests.Compute
 {
     using System;

http://git-wip-us.apache.org/repos/asf/ignite/blob/341f12fb/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/MixedClusterTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/MixedClusterTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/MixedClusterTest.cs
index 0688440..ab4e6ab 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/MixedClusterTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/MixedClusterTest.cs
@@ -15,7 +15,6 @@
  * limitations under the License.
  */
 
-#pragma warning disable 618  // SpringConfigUrl
 namespace Apache.Ignite.Core.Tests.Compute
 {
     using System;

http://git-wip-us.apache.org/repos/asf/ignite/blob/341f12fb/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/spring-test.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/spring-test.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/spring-test.xml
new file mode 100644
index 0000000..2bf7478
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/spring-test.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans.xsd">
+    <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+        <property name="localHost" value="127.0.0.1"/>
+        <property name="connectorConfiguration"><null/></property>
+        <property name="networkSendRetryDelay" value="765"/>
+        <property name="networkTimeout" value="2999" />
+
+        <property name="discoverySpi">
+            <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+                <property name="ipFinder">
+                    <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+                        <property name="addresses">
+                            <list>
+                                <!-- In distributed environment, replace with actual host IP address. -->
+                                <value>127.0.0.1:47500</value>
+                            </list>
+                        </property>
+                    </bean>
+                </property>
+                <property name="socketTimeout" value="300" />
+            </bean>
+        </property>
+    </bean>
+</beans>

http://git-wip-us.apache.org/repos/asf/ignite/blob/341f12fb/modules/platforms/dotnet/Apache.Ignite.Core.Tests/DeploymentTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/DeploymentTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/DeploymentTest.cs
index bc764c7..cd23724 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/DeploymentTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/DeploymentTest.cs
@@ -17,7 +17,6 @@
 
 #pragma warning disable 649
 #pragma warning disable 169
-#pragma warning disable 618
 namespace Apache.Ignite.Core.Tests
 {
     using System;

http://git-wip-us.apache.org/repos/asf/ignite/blob/341f12fb/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExecutableTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExecutableTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExecutableTest.cs
index 9e6de05..299c987 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExecutableTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExecutableTest.cs
@@ -18,7 +18,6 @@
 // ReSharper disable UnusedVariable
 // ReSharper disable UnusedAutoPropertyAccessor.Global
 // ReSharper disable UnusedAutoPropertyAccessor.Local
-//#pragma warning disable 618
 namespace Apache.Ignite.Core.Tests
 {
     using System;

http://git-wip-us.apache.org/repos/asf/ignite/blob/341f12fb/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
index 62690c3..b6ee5cb 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
@@ -56,7 +56,7 @@ namespace Apache.Ignite.Core.Tests
         [Test]
         public void TestPredefinedXml()
         {
-            var xml = @"<igniteConfig workDirectory='c:' JvmMaxMemoryMb='1024' MetricsLogFrequency='0:0:10' isDaemon='true' isLateAffinityAssignment='false'>
+            var xml = @"<igniteConfig workDirectory='c:' JvmMaxMemoryMb='1024' MetricsLogFrequency='0:0:10' isDaemon='true' isLateAffinityAssignment='false' springConfigUrl='c:\myconfig.xml'>
                             <localhost>127.1.1.1</localhost>
                             <binaryConfiguration compactFooter='false'>
                                 <defaultNameMapper type='Apache.Ignite.Core.Tests.IgniteConfigurationSerializerTest+NameMapper, Apache.Ignite.Core.Tests' bar='testBar' />
@@ -130,6 +130,7 @@ namespace Apache.Ignite.Core.Tests
                 cfg.BinaryConfiguration.Types.Single());
             Assert.IsFalse(cfg.BinaryConfiguration.CompactFooter);
             Assert.AreEqual(new[] {42, EventType.TaskFailed, EventType.JobFinished}, cfg.IncludedEventTypes);
+            Assert.AreEqual(@"c:\myconfig.xml", cfg.SpringConfigUrl);
 
             Assert.AreEqual("secondCache", cfg.CacheConfiguration.Last().Name);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/341f12fb/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
index 9657c9b..9d11ad3 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
@@ -15,7 +15,6 @@
  * limitations under the License.
  */
 
-#pragma warning disable 618  // deprecated SpringConfigUrl
 namespace Apache.Ignite.Core.Tests
 {
     using System;
@@ -168,16 +167,25 @@ namespace Apache.Ignite.Core.Tests
         [Test]
         public void TestSpringXml()
         {
-            // When Spring XML is used, all properties are ignored.
-            var cfg = GetCustomConfig();
-
-            cfg.SpringConfigUrl = "config\\marshaller-default.xml";
+            // When Spring XML is used, .NET overrides Spring.
+            var cfg = new IgniteConfiguration(TestUtils.GetTestConfiguration())
+            {
+                SpringConfigUrl = @"config\spring-test.xml",
+                NetworkSendRetryDelay = TimeSpan.FromSeconds(45),
+                MetricsHistorySize = 57
+            };
 
             using (var ignite = Ignition.Start(cfg))
             {
                 var resCfg = ignite.GetConfiguration();
 
-                CheckDefaultProperties(resCfg);
+                Assert.AreEqual(45, resCfg.NetworkSendRetryDelay.TotalSeconds);  // .NET overrides XML
+                Assert.AreEqual(2999, resCfg.NetworkTimeout.TotalMilliseconds);  // Not set in .NET -> comes from XML
+                Assert.AreEqual(57, resCfg.MetricsHistorySize);  // Only set in .NET
+
+                var disco = resCfg.DiscoverySpi as TcpDiscoverySpi;
+                Assert.IsNotNull(disco);
+                Assert.AreEqual(TimeSpan.FromMilliseconds(300), disco.SocketTimeout);
             }
         }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/341f12fb/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteStartStopTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteStartStopTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteStartStopTest.cs
index 447c8b9..47212fc 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteStartStopTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteStartStopTest.cs
@@ -15,7 +15,6 @@
  * limitations under the License.
  */
 
-#pragma warning disable 618  // Deprecated SpringConfigUrl
 namespace Apache.Ignite.Core.Tests 
 {
     using System;

http://git-wip-us.apache.org/repos/asf/ignite/blob/341f12fb/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ReconnectTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ReconnectTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ReconnectTest.cs
index 7803110..2f8b205 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ReconnectTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ReconnectTest.cs
@@ -15,7 +15,6 @@
  * limitations under the License.
  */
 
-#pragma warning disable 618  // Deprecated SpringConfigUrl
 namespace Apache.Ignite.Core.Tests
 {
     using Apache.Ignite.Core.Cache;

http://git-wip-us.apache.org/repos/asf/ignite/blob/341f12fb/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs
index b06d6dd..3269651 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs
@@ -15,7 +15,6 @@
  * limitations under the License.
  */
 
-#pragma warning disable 618   // SpringConfigUrl
 namespace Apache.Ignite.Core.Tests.Services
 {
     using System;

http://git-wip-us.apache.org/repos/asf/ignite/blob/341f12fb/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
index 8943030..649de2e 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
@@ -152,6 +152,7 @@
     <Compile Include="Common\IgniteFutureCancelledException.cs" />
     <Compile Include="Common\IgniteGuid.cs" />
     <Compile Include="Common\Package-Info.cs" />
+    <Compile Include="Impl\Binary\BinaryWriterExtensions.cs" />
     <Compile Include="Impl\Common\Platform.cs" />
     <Compile Include="Impl\Cache\Event\JavaCacheEntryEventFilter.cs" />
     <Compile Include="Impl\Common\PlatformJavaObjectFactoryProxy.cs" />

http://git-wip-us.apache.org/repos/asf/ignite/blob/341f12fb/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs
index 62cad19..a505cca 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs
@@ -15,7 +15,6 @@
  * limitations under the License.
  */
 
-#pragma warning disable 618  // deprecated SpringConfigUrl
  namespace Apache.Ignite.Core
 {
     using System;
@@ -88,6 +87,36 @@
         /// </summary>
         public static readonly TimeSpan DefaultNetworkSendRetryDelay = TimeSpan.FromMilliseconds(1000);
 
+        /** */
+        private TimeSpan? _metricsExpireTime;
+
+        /** */
+        private int? _metricsHistorySize;
+
+        /** */
+        private TimeSpan? _metricsLogFrequency;
+
+        /** */
+        private TimeSpan? _metricsUpdateFrequency;
+
+        /** */
+        private int? _networkSendRetryCount;
+
+        /** */
+        private TimeSpan? _networkSendRetryDelay;
+
+        /** */
+        private TimeSpan? _networkTimeout;
+
+        /** */
+        private bool? _isDaemon;
+
+        /** */
+        private bool? _isLateAffinityAssignment;
+
+        /** */
+        private bool? _clientMode;
+
         /// <summary>
         /// Default network retry count.
         /// </summary>
@@ -105,15 +134,6 @@
         {
             JvmInitialMemoryMb = DefaultJvmInitMem;
             JvmMaxMemoryMb = DefaultJvmMaxMem;
-
-            MetricsExpireTime = DefaultMetricsExpireTime;
-            MetricsHistorySize = DefaultMetricsHistorySize;
-            MetricsLogFrequency = DefaultMetricsLogFrequency;
-            MetricsUpdateFrequency = DefaultMetricsUpdateFrequency;
-            NetworkTimeout = DefaultNetworkTimeout;
-            NetworkSendRetryCount = DefaultNetworkSendRetryCount;
-            NetworkSendRetryDelay = DefaultNetworkSendRetryDelay;
-            IsLateAffinityAssignment = DefaultIsLateAffinityAssignment;
         }
 
         /// <summary>
@@ -130,7 +150,7 @@
             {
                 var marsh = new Marshaller(configuration.BinaryConfiguration);
 
-                configuration.WriteCore(marsh.StartMarshal(stream));
+                configuration.Write(marsh.StartMarshal(stream));
 
                 stream.SynchronizeOutput();
 
@@ -157,40 +177,21 @@
         {
             Debug.Assert(writer != null);
 
-            if (!string.IsNullOrEmpty(SpringConfigUrl))
-            {
-                // Do not write details when there is Spring config.
-                writer.WriteBoolean(false);
-                return;
-            }
-
-            writer.WriteBoolean(true);  // details are present
-
-            WriteCore(writer);
-        }
-
-        /// <summary>
-        /// Writes this instance to a writer.
-        /// </summary>
-        /// <param name="writer">The writer.</param>
-        private void WriteCore(BinaryWriter writer)
-        {
             // Simple properties
-            writer.WriteBoolean(ClientMode);
+            writer.WriteBooleanNullable(_clientMode);
             writer.WriteIntArray(IncludedEventTypes == null ? null : IncludedEventTypes.ToArray());
 
-            writer.WriteLong((long) MetricsExpireTime.TotalMilliseconds);
-            writer.WriteInt(MetricsHistorySize);
-            writer.WriteLong((long) MetricsLogFrequency.TotalMilliseconds);
-            var metricsUpdateFreq = (long) MetricsUpdateFrequency.TotalMilliseconds;
-            writer.WriteLong(metricsUpdateFreq >= 0 ? metricsUpdateFreq : -1);
-            writer.WriteInt(NetworkSendRetryCount);
-            writer.WriteLong((long) NetworkSendRetryDelay.TotalMilliseconds);
-            writer.WriteLong((long) NetworkTimeout.TotalMilliseconds);
+            writer.WriteTimeSpanAsLongNullable(_metricsExpireTime);
+            writer.WriteIntNullable(_metricsHistorySize);
+            writer.WriteTimeSpanAsLongNullable(_metricsLogFrequency);
+            writer.WriteTimeSpanAsLongNullable(_metricsUpdateFrequency);
+            writer.WriteIntNullable(_networkSendRetryCount);
+            writer.WriteTimeSpanAsLongNullable(_networkSendRetryDelay);
+            writer.WriteTimeSpanAsLongNullable(_networkTimeout);
             writer.WriteString(WorkDirectory);
             writer.WriteString(Localhost);
-            writer.WriteBoolean(IsDaemon);
-            writer.WriteBoolean(IsLateAffinityAssignment);
+            writer.WriteBooleanNullable(_isDaemon);
+            writer.WriteBooleanNullable(_isLateAffinityAssignment);
 
             // Cache config
             var caches = CacheConfiguration;
@@ -297,20 +298,19 @@
         private void ReadCore(BinaryReader r)
         {
             // Simple properties
-            ClientMode = r.ReadBoolean();
+            _clientMode = r.ReadBooleanNullable();
             IncludedEventTypes = r.ReadIntArray();
-
-            MetricsExpireTime = r.ReadLongAsTimespan();
-            MetricsHistorySize = r.ReadInt();
-            MetricsLogFrequency = r.ReadLongAsTimespan();
-            MetricsUpdateFrequency = r.ReadLongAsTimespan();
-            NetworkSendRetryCount = r.ReadInt();
-            NetworkSendRetryDelay = r.ReadLongAsTimespan();
-            NetworkTimeout = r.ReadLongAsTimespan();
+            _metricsExpireTime = r.ReadTimeSpanNullable();
+            _metricsHistorySize = r.ReadIntNullable();
+            _metricsLogFrequency = r.ReadTimeSpanNullable();
+            _metricsUpdateFrequency = r.ReadTimeSpanNullable();
+            _networkSendRetryCount = r.ReadIntNullable();
+            _networkSendRetryDelay = r.ReadTimeSpanNullable();
+            _networkTimeout = r.ReadTimeSpanNullable();
             WorkDirectory = r.ReadString();
             Localhost = r.ReadString();
-            IsDaemon = r.ReadBoolean();
-            IsLateAffinityAssignment = r.ReadBoolean();
+            _isDaemon = r.ReadBooleanNullable();
+            _isLateAffinityAssignment = r.ReadBooleanNullable();
 
             // Cache config
             var cacheCfgCount = r.ReadInt();
@@ -425,11 +425,12 @@
         /// <summary>
         /// URL to Spring configuration file.
         /// <para />
-        /// Ignite.NET can be configured natively without Spring. 
-        /// Setting this property will ignore all other properties except <see cref="IgniteHome"/>, 
-        /// <see cref="Assemblies"/>, <see cref="SuppressWarnings"/>, <see cref="LifecycleBeans"/>, 
-        /// <see cref="JvmOptions"/>, <see cref="JvmDllPath"/>, <see cref="IgniteHome"/>, 
-        /// <see cref="JvmInitialMemoryMb"/>, <see cref="JvmMaxMemoryMb"/>.
+        /// Spring configuration is loaded first, then <see cref="IgniteConfiguration"/> properties are applied.
+        /// Null property values do not override Spring values.
+        /// Value-typed properties are tracked internally: if setter was not called, Spring value won't be overwritten.
+        /// <para />
+        /// This merging happens on the top level only; e. g. if there are cache configurations defined in Spring 
+        /// and in .NET, .NET caches will overwrite Spring caches.
         /// </summary>
         [SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings")]
         public string SpringConfigUrl { get; set; }
@@ -509,7 +510,11 @@
         /// Gets or sets a value indicating whether node should start in client mode.
         /// Client node cannot hold data in the caches.
         /// </summary>
-        public bool ClientMode { get; set; }
+        public bool ClientMode
+        {
+            get { return _clientMode ?? default(bool); }
+            set { _clientMode = value; }
+        }
 
         /// <summary>
         /// Gets or sets a set of event types (<see cref="EventType" />) to be recorded by Ignite. 
@@ -521,20 +526,32 @@
         /// Gets or sets the time after which a certain metric value is considered expired.
         /// </summary>
         [DefaultValue(typeof(TimeSpan), "10675199.02:48:05.4775807")]
-        public TimeSpan MetricsExpireTime { get; set; }
+        public TimeSpan MetricsExpireTime
+        {
+            get { return _metricsExpireTime ?? DefaultMetricsExpireTime; }
+            set { _metricsExpireTime = value; }
+        }
 
         /// <summary>
         /// Gets or sets the number of metrics kept in history to compute totals and averages.
         /// </summary>
         [DefaultValue(DefaultMetricsHistorySize)]
-        public int MetricsHistorySize { get; set; }
+        public int MetricsHistorySize
+        {
+            get { return _metricsHistorySize ?? DefaultMetricsHistorySize; }
+            set { _metricsHistorySize = value; }
+        }
 
         /// <summary>
         /// Gets or sets the frequency of metrics log print out.
         /// <see cref="TimeSpan.Zero"/> to disable metrics print out.
         /// </summary>
         [DefaultValue(typeof(TimeSpan), "00:01:00")]
-        public TimeSpan MetricsLogFrequency { get; set; }
+        public TimeSpan MetricsLogFrequency
+        {
+            get { return _metricsLogFrequency ?? DefaultMetricsLogFrequency; }
+            set { _metricsLogFrequency = value; }
+        }
 
         /// <summary>
         /// Gets or sets the job metrics update frequency.
@@ -542,25 +559,41 @@
         /// Negative value to never update metrics.
         /// </summary>
         [DefaultValue(typeof(TimeSpan), "00:00:02")]
-        public TimeSpan MetricsUpdateFrequency { get; set; }
+        public TimeSpan MetricsUpdateFrequency
+        {
+            get { return _metricsUpdateFrequency ?? DefaultMetricsUpdateFrequency; }
+            set { _metricsUpdateFrequency = value; }
+        }
 
         /// <summary>
         /// Gets or sets the network send retry count.
         /// </summary>
         [DefaultValue(DefaultNetworkSendRetryCount)]
-        public int NetworkSendRetryCount { get; set; }
+        public int NetworkSendRetryCount
+        {
+            get { return _networkSendRetryCount ?? DefaultNetworkSendRetryCount; }
+            set { _networkSendRetryCount = value; }
+        }
 
         /// <summary>
         /// Gets or sets the network send retry delay.
         /// </summary>
         [DefaultValue(typeof(TimeSpan), "00:00:01")]
-        public TimeSpan NetworkSendRetryDelay { get; set; }
+        public TimeSpan NetworkSendRetryDelay
+        {
+            get { return _networkSendRetryDelay ?? DefaultNetworkSendRetryDelay; }
+            set { _networkSendRetryDelay = value; }
+        }
 
         /// <summary>
         /// Gets or sets the network timeout.
         /// </summary>
         [DefaultValue(typeof(TimeSpan), "00:00:05")]
-        public TimeSpan NetworkTimeout { get; set; }
+        public TimeSpan NetworkTimeout
+        {
+            get { return _networkTimeout ?? DefaultNetworkTimeout; }
+            set { _networkTimeout = value; }
+        }
 
         /// <summary>
         /// Gets or sets the work directory.
@@ -589,7 +622,11 @@
         /// and needs to participate in the topology, but also needs to be excluded from the "normal" topology, 
         /// so that it won't participate in the task execution or in-memory data grid storage.
         /// </summary>
-        public bool IsDaemon { get; set; }
+        public bool IsDaemon
+        {
+            get { return _isDaemon ?? default(bool); }
+            set { _isDaemon = value; }
+        }
 
         /// <summary>
         /// Gets or sets the user attributes for this node.
@@ -634,6 +671,10 @@
         /// If not provided, default value is <see cref="DefaultIsLateAffinityAssignment"/>.
         /// </summary>
         [DefaultValue(DefaultIsLateAffinityAssignment)]
-        public bool IsLateAffinityAssignment { get; set; }
+        public bool IsLateAffinityAssignment
+        {
+            get { return _isLateAffinityAssignment ?? DefaultIsLateAffinityAssignment; }
+            set { _isLateAffinityAssignment = value; }
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/341f12fb/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs
index 94dab88..c551735 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs
@@ -15,7 +15,6 @@
  * limitations under the License.
  */
 
-#pragma warning disable 618  // deprecated SpringConfigUrl
 namespace Apache.Ignite.Core 
 {
     using System;

http://git-wip-us.apache.org/repos/asf/ignite/blob/341f12fb/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReaderExtensions.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReaderExtensions.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReaderExtensions.cs
index f3f8457..87de0eb 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReaderExtensions.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReaderExtensions.cs
@@ -67,5 +67,29 @@ namespace Apache.Ignite.Core.Impl.Binary
 
             return TimeSpan.FromMilliseconds(ms);
         }
+
+        /// <summary>
+        /// Reads the nullable TimeSpan.
+        /// </summary>
+        public static TimeSpan? ReadTimeSpanNullable(this IBinaryRawReader reader)
+        {
+            return reader.ReadBoolean() ? reader.ReadLongAsTimespan() : (TimeSpan?) null;
+        }
+        
+        /// <summary>
+        /// Reads the nullable int.
+        /// </summary>
+        public static int? ReadIntNullable(this IBinaryRawReader reader)
+        {
+            return reader.ReadBoolean() ? reader.ReadInt() : (int?) null;
+        }
+
+        /// <summary>
+        /// Reads the nullable bool.
+        /// </summary>
+        public static bool? ReadBooleanNullable(this IBinaryRawReader reader)
+        {
+            return reader.ReadBoolean() ? reader.ReadBoolean() : (bool?) null;
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/341f12fb/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriterExtensions.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriterExtensions.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriterExtensions.cs
new file mode 100644
index 0000000..b13a9ea
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriterExtensions.cs
@@ -0,0 +1,78 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Impl.Binary
+{
+    using System;
+
+    /// <summary>
+    /// Writer extensions.
+    /// </summary>
+    internal static class BinaryWriterExtensions
+    {
+        /// <summary>
+        /// Writes the nullable boolean.
+        /// </summary>
+        public static void WriteBooleanNullable(this BinaryWriter writer, bool? value)
+        {
+            if (value != null)
+            {
+                writer.WriteBoolean(true);
+                writer.WriteBoolean(value.Value);
+            }
+            else
+                writer.WriteBoolean(false);
+        }
+
+        /// <summary>
+        /// Writes the nullable boolean.
+        /// </summary>
+        public static void WriteIntNullable(this BinaryWriter writer, int? value)
+        {
+            if (value != null)
+            {
+                writer.WriteBoolean(true);
+                writer.WriteInt(value.Value);
+            }
+            else
+                writer.WriteBoolean(false);
+        }
+
+        /// <summary>
+        /// Writes the timespan.
+        /// </summary>
+        public static void WriteTimeSpanAsLong(this BinaryWriter writer, TimeSpan value)
+        {
+            writer.WriteLong((long) value.TotalMilliseconds);
+        }
+
+        /// <summary>
+        /// Writes the nullable boolean.
+        /// </summary>
+        public static void WriteTimeSpanAsLongNullable(this BinaryWriter writer, TimeSpan? value)
+        {
+            if (value != null)
+            {
+                writer.WriteBoolean(true);
+                writer.WriteTimeSpanAsLong(value.Value);
+            }
+            else
+                writer.WriteBoolean(false);
+        }
+
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/341f12fb/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 d64f52c..0706966 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
@@ -15,7 +15,6 @@
  * limitations under the License.
  */
 
-#pragma warning disable 618   // SpringConfigUrl
 namespace Apache.Ignite.Core.Impl
 {
     using System;


[09/24] ignite git commit: ignite-1.6 Removed assert (can fail in CacheContinuousQueryHandler .flushBackupQueue since queue can be concurrently cleared)

Posted by ak...@apache.org.
ignite-1.6 Removed assert (can fail in CacheContinuousQueryHandler .flushBackupQueue since queue can be concurrently cleared)


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

Branch: refs/heads/master
Commit: dcfd30e31f7f7f2a8f4ab964b66967ad758e549a
Parents: 796ee16
Author: sboikov <sb...@gridgain.com>
Authored: Mon May 16 14:25:37 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Mon May 16 14:25:37 2016 +0300

----------------------------------------------------------------------
 .../internal/processors/continuous/GridContinuousProcessor.java     | 1 -
 1 file changed, 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/dcfd30e3/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
index fd5e446..fb727cb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
@@ -1399,7 +1399,6 @@ public class GridContinuousProcessor extends GridProcessorAdapter {
          */
         GridContinuousBatch addAll(Collection<?> objs) {
             assert objs != null;
-            assert objs.size() > 0;
 
             GridContinuousBatch toSnd = null;
 


[21/24] ignite git commit: ignite-1.6 Added IgniteCacheEntryListenerExpiredEventsTest in suite.

Posted by ak...@apache.org.
ignite-1.6 Added IgniteCacheEntryListenerExpiredEventsTest in suite.


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

Branch: refs/heads/master
Commit: 92a41ba58ed34635ff7f543849babdc8d566dc05
Parents: 0e8072f
Author: sboikov <sb...@gridgain.com>
Authored: Mon May 16 15:44:57 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Mon May 16 15:44:57 2016 +0300

----------------------------------------------------------------------
 .../processors/cache/expiry/IgniteCacheExpiryPolicyTestSuite.java | 3 +++
 1 file changed, 3 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/92a41ba5/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyTestSuite.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyTestSuite.java
index e6e2a0e..aa3339f 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyTestSuite.java
@@ -19,6 +19,7 @@ package org.apache.ignite.internal.processors.cache.expiry;
 
 import junit.framework.TestSuite;
 import org.apache.ignite.cache.store.IgniteCacheExpiryStoreLoadSelfTest;
+import org.apache.ignite.internal.processors.cache.IgniteCacheEntryListenerExpiredEventsTest;
 
 /**
  *
@@ -65,6 +66,8 @@ public class IgniteCacheExpiryPolicyTestSuite extends TestSuite {
 
         suite.addTestSuite(IgniteCacheClientNearCacheExpiryTest.class);
 
+        suite.addTestSuite(IgniteCacheEntryListenerExpiredEventsTest.class);
+
         return suite;
     }
 }
\ No newline at end of file


[06/24] ignite git commit: ignite-3141 Disabled hanging test.

Posted by ak...@apache.org.
ignite-3141 Disabled hanging test.


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

Branch: refs/heads/master
Commit: f3deed19a33606adc69138a8953dbc5b624c81fd
Parents: 424cf89
Author: sboikov <sb...@gridgain.com>
Authored: Mon May 16 11:44:52 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Mon May 16 11:45:30 2016 +0300

----------------------------------------------------------------------
 .../ignite/testsuites/IgniteCacheDataStructuresSelfTestSuite.java | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/f3deed19/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..d62369c 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
@@ -144,7 +144,8 @@ 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));
+        // TODO IGNITE-3141, enabled when fixed.
+        // suite.addTest(new TestSuite(IgnitePartitionedLockSelfTest.class));
 
         suite.addTest(new TestSuite(GridCachePartitionedSetFailoverSelfTest.class));
         suite.addTest(new TestSuite(GridCachePartitionedOffheapSetFailoverSelfTest.class));


[15/24] ignite git commit: ignite-1.6 Fixed test IgniteCacheClientNodeChangingTopologyTest.testLock.

Posted by ak...@apache.org.
ignite-1.6 Fixed test IgniteCacheClientNodeChangingTopologyTest.testLock.


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

Branch: refs/heads/master
Commit: 90ae6023c4301840100c13e2a494c1c8ce401adf
Parents: 77e06a8
Author: sboikov <sb...@gridgain.com>
Authored: Mon May 16 15:23:09 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Mon May 16 15:23:42 2016 +0300

----------------------------------------------------------------------
 .../IgniteCacheClientNodeChangingTopologyTest.java          | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/90ae6023/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeChangingTopologyTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeChangingTopologyTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeChangingTopologyTest.java
index ce883b0..49c3289 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeChangingTopologyTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeChangingTopologyTest.java
@@ -1230,9 +1230,16 @@ public class IgniteCacheClientNodeChangingTopologyTest extends GridCommonAbstrac
 
         lockFut.get();
 
+        awaitPartitionMapExchange();
+
         boolean wait = GridTestUtils.waitForCondition(new GridAbsPredicate() {
             @Override public boolean apply() {
-                return unlocked(ignite0) && unlocked(ignite1);
+                for (int i = 0; i < 4; i++) {
+                    if (!unlocked(ignite(i)))
+                        return false;
+                }
+
+                return true;
             }
 
             private boolean unlocked(Ignite ignite) {


[19/24] ignite git commit: ignite-2921: ScanQueries over local partitions performance optimisation

Posted by ak...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/0e8072f8/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
index abfc325..06cbe79 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
@@ -71,6 +71,7 @@ import org.apache.ignite.internal.util.GridSpinBusyLock;
 import org.apache.ignite.internal.util.future.GridCompoundFuture;
 import org.apache.ignite.internal.util.future.GridFinishedFuture;
 import org.apache.ignite.internal.util.future.GridFutureAdapter;
+import org.apache.ignite.internal.util.lang.GridCloseableIterator;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.X;
 import org.apache.ignite.internal.util.typedef.internal.A;
@@ -1119,35 +1120,41 @@ public class GridServiceProcessor extends GridProcessorAdapter {
      */
     @SuppressWarnings("unchecked")
     private Iterator<Cache.Entry<Object, Object>> serviceEntries(IgniteBiPredicate<Object, Object> p) {
-        if (!cache.context().affinityNode()) {
-            ClusterNode oldestSrvNode =
-                CU.oldestAliveCacheServerNode(cache.context().shared(), AffinityTopologyVersion.NONE);
+        try {
+            if (!cache.context().affinityNode()) {
+                ClusterNode oldestSrvNode =
+                    CU.oldestAliveCacheServerNode(cache.context().shared(), AffinityTopologyVersion.NONE);
 
-            if (oldestSrvNode == null)
-                return new GridEmptyIterator<>();
+                if (oldestSrvNode == null)
+                    return new GridEmptyIterator<>();
 
-            GridCacheQueryManager qryMgr = cache.context().queries();
+                GridCacheQueryManager qryMgr = cache.context().queries();
 
-            CacheQuery<Map.Entry<Object, Object>> qry = qryMgr.createScanQuery(p, null, false);
+                CacheQuery<Map.Entry<Object, Object>> qry = qryMgr.createScanQuery(p, null, false);
 
-            qry.keepAll(false);
+                qry.keepAll(false);
 
-            qry.projection(ctx.cluster().get().forNode(oldestSrvNode));
+                qry.projection(ctx.cluster().get().forNode(oldestSrvNode));
 
-            return cache.context().itHolder().iterator(qry.execute(),
-                new CacheIteratorConverter<Object, Map.Entry<Object,Object>>() {
-                    @Override protected Object convert(Map.Entry<Object, Object> e) {
-                        return new CacheEntryImpl<>(e.getKey(), e.getValue());
-                    }
+                GridCloseableIterator<Map.Entry<Object, Object>> iter = qry.executeScanQuery();
 
-                    @Override protected void remove(Object item) {
-                        throw new UnsupportedOperationException();
-                    }
-                }
-            );
+                return cache.context().itHolder().iterator(iter,
+                    new CacheIteratorConverter<Cache.Entry<Object, Object>, Map.Entry<Object,Object>>() {
+                        @Override protected Cache.Entry<Object, Object> convert(Map.Entry<Object, Object> e) {
+                            return new CacheEntryImpl<>(e.getKey(), e.getValue());
+                        }
+
+                        @Override protected void remove(Cache.Entry<Object, Object> item) {
+                            throw new UnsupportedOperationException();
+                        }
+                    });
+            }
+            else
+                return cache.entrySetx().iterator();
+        }
+        catch (IgniteCheckedException e) {
+            throw new IgniteException(e);
         }
-        else
-            return cache.entrySetx().iterator();
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/0e8072f8/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedPreloadLifecycleSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedPreloadLifecycleSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedPreloadLifecycleSelfTest.java
index e434b49..0d45324 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedPreloadLifecycleSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedPreloadLifecycleSelfTest.java
@@ -17,19 +17,12 @@
 
 package org.apache.ignite.internal.processors.cache.distributed.near;
 
-import java.util.Map;
-import javax.cache.CacheException;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.IgniteKernal;
-import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
 import org.apache.ignite.internal.processors.cache.distributed.GridCachePreloadLifecycleAbstractTest;
-import org.apache.ignite.internal.processors.cache.query.CacheQuery;
-import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.G;
-import org.apache.ignite.lang.IgniteReducer;
 import org.apache.ignite.lifecycle.LifecycleBean;
 import org.apache.ignite.lifecycle.LifecycleEventType;
 import org.apache.ignite.resources.IgniteInstanceResource;
@@ -164,34 +157,6 @@ public class GridCachePartitionedPreloadLifecycleSelfTest extends GridCachePrelo
     }
 
     /**
-     * @param keys Keys.
-     * @throws Exception If failed.
-     */
-    public void checkScanQuery(Object[] keys) throws Exception {
-        preloadMode = SYNC;
-
-        lifecycleBean = lifecycleBean(keys);
-
-        for (int i = 0; i < gridCnt; i++) {
-            startGrid(i);
-
-            info("Checking '" + (i + 1) + "' nodes...");
-
-            for (int j = 0; j < G.allGrids().size(); j++) {
-                GridCacheAdapter<Object, MyValue> c2 = ((IgniteKernal)grid(j)).internalCache("two");
-
-                CacheQuery<Map.Entry<Object, MyValue>> qry = c2.context().queries().createScanQuery(null, null, false);
-
-                int totalCnt = F.sumInt(qry.execute(new EntryIntegerIgniteReducer()).get());
-
-                info("Total entry count [grid=" + j + ", totalCnt=" + totalCnt + ']');
-
-                assertEquals(keys.length / 2, totalCnt);
-            }
-        }
-    }
-
-    /**
      * @throws Exception If failed.
      */
     public void testLifecycleBean1() throws Exception {
@@ -218,69 +183,4 @@ public class GridCachePartitionedPreloadLifecycleSelfTest extends GridCachePrelo
     public void testLifecycleBean4() throws Exception {
         checkCache(keys(false, 500));
     }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testScanQuery1() throws Exception {
-        checkScanQuery(keys(true, DFLT_KEYS.length, DFLT_KEYS));
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testScanQuery2() throws Exception {
-        checkScanQuery(keys(false, DFLT_KEYS.length, DFLT_KEYS));
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testScanQuery3() throws Exception {
-        checkScanQuery(keys(true, 500));
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testScanQuery4() throws Exception {
-        checkScanQuery(keys(false, 500));
-    }
-
-    /**
-     *
-     */
-    private static class EntryIntegerIgniteReducer implements IgniteReducer<Map.Entry<Object, MyValue>, Integer> {
-        @IgniteInstanceResource
-        private Ignite grid;
-
-        private int cnt;
-
-        @Override public boolean collect(Map.Entry<Object, MyValue> e) {
-            Object key = e.getKey();
-
-            assertNotNull(e.getValue());
-
-            try {
-                Object v1 = e.getValue();
-                Object v2 = grid.cache("one").get(key);
-
-                assertNotNull(v2);
-                assertEquals(v1, v2);
-            }
-            catch (CacheException e1) {
-                e1.printStackTrace();
-
-                assert false;
-            }
-
-            cnt++;
-
-            return true;
-        }
-
-        @Override public Integer reduce() {
-            return cnt;
-        }
-    }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0e8072f8/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadLifecycleSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadLifecycleSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadLifecycleSelfTest.java
index 6a7a68b..f6799d8 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadLifecycleSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadLifecycleSelfTest.java
@@ -17,26 +17,17 @@
 
 package org.apache.ignite.internal.processors.cache.distributed.replicated.preloader;
 
-import java.util.Map;
 import javax.cache.Cache;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.IgniteLogger;
 import org.apache.ignite.cache.CachePeekMode;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.IgniteKernal;
-import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
 import org.apache.ignite.internal.processors.cache.distributed.GridCachePreloadLifecycleAbstractTest;
-import org.apache.ignite.internal.processors.cache.query.CacheQuery;
-import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.G;
-import org.apache.ignite.lang.IgniteReducer;
 import org.apache.ignite.lifecycle.LifecycleBean;
 import org.apache.ignite.lifecycle.LifecycleEventType;
 import org.apache.ignite.resources.IgniteInstanceResource;
-import org.apache.ignite.resources.LoggerResource;
 
 import static org.apache.ignite.cache.CacheMode.REPLICATED;
 import static org.apache.ignite.cache.CacheRebalanceMode.SYNC;
@@ -167,40 +158,6 @@ public class GridCacheReplicatedPreloadLifecycleSelfTest extends GridCachePreloa
         }
     }
 
-
-    /**
-     * @param keys Keys.
-     * @throws Exception If failed.
-     */
-    public void checkScanQuery(Object[] keys) throws Exception {
-        preloadMode = SYNC;
-
-        lifecycleBean = lifecycleBean(keys);
-
-        for (int i = 0; i < gridCnt; i++) {
-            startGrid(i);
-
-            info("Checking '" + (i + 1) + "' nodes...");
-
-            for (int j = 0; j < G.allGrids().size(); j++) {
-                GridCacheAdapter<Object, MyValue> c2 = ((IgniteKernal)grid(j)).internalCache("two");
-
-                CacheQuery<Map.Entry<Object, MyValue>> qry = c2.context().queries().createScanQuery(null, null, false);
-
-                final int i0 = j;
-                final int j0 = i;
-
-                qry = qry.projection(grid(j).cluster());
-
-                int totalCnt = F.sumInt(qry.execute(new EntryReducer(j0, i0)).get());
-
-                info("Total entry count [grid=" + j + ", totalCnt=" + totalCnt + ']');
-
-                assertEquals(keys.length * (i + 1) / 2, totalCnt);
-            }
-        }
-    }
-
     /**
      * @throws Exception If failed.
      */
@@ -228,91 +185,4 @@ public class GridCacheReplicatedPreloadLifecycleSelfTest extends GridCachePreloa
     public void testLifecycleBean4() throws Exception {
         checkCache(keys(false, 500));
     }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testScanQuery1() throws Exception {
-        checkScanQuery(keys(true, DFLT_KEYS.length, DFLT_KEYS));
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testScanQuery2() throws Exception {
-        checkScanQuery(keys(false, DFLT_KEYS.length, DFLT_KEYS));
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testScanQuery3() throws Exception {
-        checkScanQuery(keys(true, 500));
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testScanQuery4() throws Exception {
-        checkScanQuery(keys(false, 500));
-    }
-
-    private static class EntryReducer implements IgniteReducer<Map.Entry<Object, MyValue>, Integer> {
-        /** */
-        private final int j0;
-
-        /** */
-        private final int i0;
-
-        /** */
-        @IgniteInstanceResource
-        private Ignite grid;
-
-        /** */
-        @LoggerResource
-        private IgniteLogger log0;
-
-        /** */
-        private int cnt;
-
-        /**
-         */
-        public EntryReducer(int j0, int i0) {
-            this.j0 = j0;
-            this.i0 = i0;
-        }
-
-        /** {@inheritDoc} */
-        @Override public boolean collect(Map.Entry<Object, MyValue> e) {
-            if (!quiet && log0.isInfoEnabled())
-                log0.info("Collecting entry: " + e);
-
-            Object key = e.getKey();
-
-            assertNotNull(e.getValue());
-
-            try {
-                Object v1 = e.getValue();
-                Object v2 = ((IgniteKernal)grid).getCache("one").get(key);
-
-                assertNotNull("Cache c1 misses value for key [i=" + j0 + ", j=" + i0 + ", missedKey=" +
-                    key + ", cache=" + ((IgniteKernal)grid).getCache("one").values() + ']', v2);
-                assertEquals(v1, v2);
-            }
-            catch (IgniteCheckedException e1) {
-                e1.printStackTrace();
-
-                assert false;
-            }
-
-            cnt++;
-
-            return true;
-        }
-
-        /** {@inheritDoc} */
-        @Override public Integer reduce() {
-            return cnt;
-        }
-    }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0e8072f8/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/ConfigVariationsTestSuiteBuilder.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/ConfigVariationsTestSuiteBuilder.java b/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/ConfigVariationsTestSuiteBuilder.java
index 5c88f4e..b20cb0e 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/ConfigVariationsTestSuiteBuilder.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/ConfigVariationsTestSuiteBuilder.java
@@ -197,9 +197,9 @@ public class ConfigVariationsTestSuiteBuilder {
         TestSuite addedSuite;
 
         if (testedNodeCnt > 1)
-            addedSuite = createMultiNodeTestSuite((Class<? extends IgniteCacheConfigVariationsAbstractTest>)cls, 
+            addedSuite = createMultiNodeTestSuite((Class<? extends IgniteCacheConfigVariationsAbstractTest>)cls,
                 testCfg, testedNodeCnt, withClients, skipWaitPartMapExchange);
-        else
+       else
             addedSuite = new IgniteConfigVariationsTestSuite(cls, testCfg);
 
         return addedSuite;

http://git-wip-us.apache.org/repos/asf/ignite/blob/0e8072f8/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteCacheConfigVariationsAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteCacheConfigVariationsAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteCacheConfigVariationsAbstractTest.java
index acf4a05..6b52578 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteCacheConfigVariationsAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteCacheConfigVariationsAbstractTest.java
@@ -132,7 +132,7 @@ public abstract class IgniteCacheConfigVariationsAbstractTest extends IgniteConf
 
             info(">>> Starting set of tests [testedNodeIdx=" + testedNodeIdx
                 + ", id=" + grid(testedNodeIdx).localNode().id()
-                + ", isClient=" + grid(testedNodeIdx).configuration().isClientMode()
+                + ", isClient=" + isClientMode()
                 + ", nearEnabled=" + testedNodeNearEnabled + "]");
         }
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/0e8072f8/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 3370421..d70b606 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
@@ -58,7 +58,7 @@ public abstract class IgniteConfigVariationsAbstractTest extends GridCommonAbstr
     protected VariationsTestsConfig testsCfg;
 
     /** */
-    protected volatile DataMode dataMode;
+    protected volatile DataMode dataMode = DataMode.PLANE_OBJECT;
 
     /**
      * @param testsCfg Tests configuration.
@@ -198,6 +198,27 @@ public abstract class IgniteConfigVariationsAbstractTest extends GridCommonAbstr
     }
 
     /**
+     * @return Tested grid in client mode or not.
+     */
+    protected boolean isClientMode() {
+        return grid(testedNodeIdx).configuration().isClientMode();
+    }
+
+    /**
+     * @return Count of server nodes at topology.
+     */
+    protected int serversGridCount() {
+        int cnt = 0;
+
+        for (int i = 0; i < gridCount(); i++) {
+            if (!grid(i).configuration().isClientMode())
+                cnt++;
+        }
+
+        return cnt;
+    }
+
+    /**
      * Runs in all data modes.
      */
     protected void runInAllDataModes(TestRunnable call) throws Exception {
@@ -228,6 +249,7 @@ public abstract class IgniteConfigVariationsAbstractTest extends GridCommonAbstr
     /**
      * @param keyId Key Id.
      * @return Key.
+     * @see #valueOf(Object)
      */
     public Object key(int keyId) {
         return key(keyId, dataMode);
@@ -236,6 +258,7 @@ public abstract class IgniteConfigVariationsAbstractTest extends GridCommonAbstr
     /**
      * @param valId Key Id.
      * @return Value.
+     * @see #valueOf(Object)
      */
     public Object value(int valId) {
         return value(valId, dataMode);
@@ -272,7 +295,7 @@ public abstract class IgniteConfigVariationsAbstractTest extends GridCommonAbstr
         if (obj instanceof TestObject)
             return ((TestObject)obj).value();
         else
-            throw new IllegalStateException();
+            throw new IllegalArgumentException("Unknown tested object type: " + obj);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/0e8072f8/modules/indexing/pom.xml
----------------------------------------------------------------------
diff --git a/modules/indexing/pom.xml b/modules/indexing/pom.xml
index 22a52b2..899d4a7 100644
--- a/modules/indexing/pom.xml
+++ b/modules/indexing/pom.xml
@@ -68,6 +68,13 @@
         </dependency>
 
         <dependency>
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
+            <version>2.4</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
             <groupId>org.springframework</groupId>
             <artifactId>spring-core</artifactId>
             <version>${spring.version}</version>

http://git-wip-us.apache.org/repos/asf/ignite/blob/0e8072f8/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheAbstractQueryMetricsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheAbstractQueryMetricsSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheAbstractQueryMetricsSelfTest.java
index 28eef90..d2d8c4d 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheAbstractQueryMetricsSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheAbstractQueryMetricsSelfTest.java
@@ -84,6 +84,7 @@ public abstract class CacheAbstractQueryMetricsSelfTest extends GridCommonAbstra
         cacheCfg1.setCacheMode(cacheMode);
         cacheCfg1.setWriteSynchronizationMode(FULL_SYNC);
         cacheCfg1.setIndexedTypes(String.class, Integer.class);
+        cacheCfg1.setStatisticsEnabled(true);
 
         CacheConfiguration<String, Integer> cacheCfg2 = defaultCacheConfiguration();
 
@@ -91,6 +92,7 @@ public abstract class CacheAbstractQueryMetricsSelfTest extends GridCommonAbstra
         cacheCfg2.setCacheMode(cacheMode);
         cacheCfg2.setWriteSynchronizationMode(FULL_SYNC);
         cacheCfg2.setIndexedTypes(String.class, Integer.class);
+        cacheCfg2.setStatisticsEnabled(true);
 
         cfg.setCacheConfiguration(cacheCfg1, cacheCfg2);
 
@@ -347,4 +349,4 @@ public abstract class CacheAbstractQueryMetricsSelfTest extends GridCommonAbstra
             }
         }, 5000);
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0e8072f8/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
index 2b2020d..65d479d 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
@@ -867,7 +867,13 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
     public void testScanQuery() throws Exception {
         IgniteCache<Integer, String> c1 = ignite().cache(null);
 
-        c1.put(777, "value");
+        Map<Integer, String> map = new HashMap(){{
+            for (int i = 0; i < 5000; i++)
+                put(i, "str" + i);
+        }};
+
+        for (Map.Entry<Integer, String> e : map.entrySet())
+            c1.put(e.getKey(), e.getValue());
 
         // Scan query.
         QueryCursor<Cache.Entry<Integer, String>> qry = c1.query(new ScanQuery<Integer, String>());
@@ -876,16 +882,21 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
 
         assert iter != null;
 
-        int expCnt = 1;
+        int cnt = 0;
+
+        while (iter.hasNext()) {
+            Cache.Entry<Integer, String> e = iter.next();
+
+            String expVal = map.get(e.getKey());
+
+            assertNotNull(expVal);
 
-        for (int i = 0; i < expCnt; i++) {
-            Cache.Entry<Integer, String> e1 = iter.next();
+            assertEquals(expVal, e.getValue());
 
-            assertEquals(777, e1.getKey().intValue());
-            assertEquals("value", e1.getValue());
+            cnt++;
         }
 
-        assert !iter.hasNext();
+        assertEquals(map.size(), cnt);
     }
 
     /**
@@ -1308,13 +1319,6 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
      * @throws Exception If failed.
      */
     public void testScanQueryEvents() throws Exception {
-        checkScanQueryEvents();
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    private void checkScanQueryEvents() throws Exception {
         final Map<Integer, Integer> map = new ConcurrentHashMap8<>();
         final CountDownLatch latch = new CountDownLatch(10);
         final CountDownLatch execLatch = new CountDownLatch(cacheMode() == REPLICATED ? 1 : gridCount());
@@ -1980,4 +1984,4 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
         /** */
         TYPE_B
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0e8072f8/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigVariationsQueryTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigVariationsQueryTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigVariationsQueryTest.java
new file mode 100644
index 0000000..4e6af25
--- /dev/null
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigVariationsQueryTest.java
@@ -0,0 +1,505 @@
+/*
+ * 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.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CountDownLatch;
+import javax.cache.Cache;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.affinity.Affinity;
+import org.apache.ignite.cache.query.QueryCursor;
+import org.apache.ignite.cache.query.ScanQuery;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.events.CacheQueryExecutedEvent;
+import org.apache.ignite.events.CacheQueryReadEvent;
+import org.apache.ignite.events.Event;
+import org.apache.ignite.lang.IgniteBiPredicate;
+import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.testframework.junits.IgniteCacheConfigVariationsAbstractTest;
+
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static org.apache.ignite.cache.CacheMode.PARTITIONED;
+import static org.apache.ignite.cache.CacheMode.REPLICATED;
+import static org.apache.ignite.events.EventType.EVT_CACHE_QUERY_EXECUTED;
+import static org.apache.ignite.events.EventType.EVT_CACHE_QUERY_OBJECT_READ;
+import static org.apache.ignite.internal.processors.cache.query.CacheQueryType.SCAN;
+
+/**
+ * Config Variations query tests.
+ */
+public class IgniteCacheConfigVariationsQueryTest extends IgniteCacheConfigVariationsAbstractTest {
+    /** */
+    public static final int CNT = 50;
+
+    /** */
+    private Map<Object, Object> evtMap;
+
+    /** */
+    private CountDownLatch readEvtLatch;
+
+    /** */
+    private CountDownLatch execEvtLatch;
+
+    /** */
+    private IgnitePredicate[] objReadLsnrs;
+
+    /** */
+    private IgnitePredicate[] qryExecLsnrs;
+
+    /** */
+    private Map<Object, Object> expMap;
+
+    /**
+     * @throws Exception If failed.
+     */
+    @SuppressWarnings("serial")
+    public void testScanQuery() throws Exception {
+        runInAllDataModes(new TestRunnable() {
+            @Override public void run() throws Exception {
+                try {
+                    IgniteCache<Object, Object> cache = jcache();
+
+                    Map<Object, Object> map = new HashMap<Object, Object>() {{
+                        for (int i = 0; i < CNT; i++)
+                            put(key(i), value(i));
+                    }};
+
+                    registerEventListeners(map);
+
+                    for (Map.Entry<Object, Object> e : map.entrySet())
+                        cache.put(e.getKey(), e.getValue());
+
+                    // Scan query.
+                    QueryCursor<Cache.Entry<Object, Object>> qry = cache.query(new ScanQuery());
+
+                    checkQueryResults(map, qry);
+                }
+                finally {
+                    stopListeners();
+                }
+            }
+        });
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testScanPartitionQuery() throws Exception {
+        runInAllDataModes(new TestRunnable() {
+            @Override public void run() throws Exception {
+                IgniteCache<Object, Object> cache = jcache();
+
+                GridCacheContext cctx = ((IgniteCacheProxy)cache).context();
+
+                Map<Integer, Map<Object, Object>> entries = new HashMap<>();
+
+                for (int i = 0; i < CNT; i++) {
+                    Object key = key(i);
+                    Object val = value(i);
+
+                    cache.put(key, val);
+
+                    int part = cctx.affinity().partition(key);
+
+                    Map<Object, Object> partEntries = entries.get(part);
+
+                    if (partEntries == null)
+                        entries.put(part, partEntries = new HashMap<>());
+
+                    partEntries.put(key, val);
+                }
+
+                for (int i = 0; i < cctx.affinity().partitions(); i++) {
+                    try {
+                        Map<Object, Object> exp = entries.get(i);
+
+                        if (exp == null)
+                            System.out.println();
+
+                        registerEventListeners(exp);
+
+                        ScanQuery<Object, Object> scan = new ScanQuery<>(i);
+
+                        Collection<Cache.Entry<Object, Object>> actual = cache.query(scan).getAll();
+
+                        assertEquals("Failed for partition: " + i, exp == null ? 0 : exp.size(), actual.size());
+
+                        if (exp != null) {
+                            for (Cache.Entry<Object, Object> entry : actual)
+                                assertTrue(entry.getValue().equals(exp.get(entry.getKey())));
+                        }
+
+                        checkEvents();
+                    }
+                    finally {
+                        stopListeners();
+                    }
+                }
+            }
+        });
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    @SuppressWarnings("SubtractionInCompareTo")
+    public void testScanFilters() throws Exception {
+        runInAllDataModes(new TestRunnable() {
+            @Override public void run() throws Exception {
+                try {
+                    IgniteCache<Object, Object> cache = jcache();
+
+                    IgniteBiPredicate<Object, Object> p = new IgniteBiPredicate<Object, Object>() {
+                        @Override public boolean apply(Object k, Object v) {
+                            assertNotNull(k);
+                            assertNotNull(v);
+
+                            return valueOf(k) >= 20 && valueOf(v) < 40;
+                        }
+                    };
+
+                    Map<Object, Object> exp = new HashMap<>();
+
+                    for (int i = 0; i < CNT; i++) {
+                        Object key = key(i);
+                        Object val = value(i);
+
+                        cache.put(key, val);
+
+                        if (p.apply(key, val))
+                            exp.put(key, val);
+                    }
+
+                    registerEventListeners(exp, true);
+
+                    QueryCursor<Cache.Entry<Object, Object>> q = cache.query(new ScanQuery<>(p));
+
+                    checkQueryResults(exp, q);
+                }
+                finally {
+                    stopListeners();
+                }
+            }
+        });
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    @SuppressWarnings("SubtractionInCompareTo")
+    public void testLocalScanQuery() throws Exception {
+        runInAllDataModes(new TestRunnable() {
+            @Override public void run() throws Exception {
+                try {
+                    IgniteCache<Object, Object> cache = jcache();
+
+                    ClusterNode locNode = testedGrid().cluster().localNode();
+                    Affinity<Object> affinity = testedGrid().affinity(cacheName());
+
+                    Map<Object, Object> map = new HashMap<>();
+
+                    for (int i = 0; i < CNT; i++) {
+                        Object key = key(i);
+                        Object val = value(i);
+
+                        cache.put(key, val);
+
+                        if (!isClientMode() && (cacheMode() == REPLICATED || affinity.isPrimary(locNode, key)))
+                            map.put(key, val);
+                    }
+
+                    registerEventListeners(map);
+
+                    QueryCursor<Cache.Entry<Object, Object>> q = cache.query(new ScanQuery<>().setLocal(true));
+
+                    checkQueryResults(map, q);
+                }
+                finally {
+                    stopListeners();
+                }
+            }
+        });
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    @SuppressWarnings("SubtractionInCompareTo")
+    public void testScanQueryLocalFilter() throws Exception {
+        runInAllDataModes(new TestRunnable() {
+            @Override public void run() throws Exception {
+                try {
+                    IgniteCache<Object, Object> cache = jcache();
+
+                    ClusterNode locNode = testedGrid().cluster().localNode();
+
+                    Map<Object, Object> map = new HashMap<>();
+
+                    IgniteBiPredicate<Object, Object> filter = new IgniteBiPredicate<Object, Object>() {
+                        @Override public boolean apply(Object k, Object v) {
+                            assertNotNull(k);
+                            assertNotNull(v);
+
+                            return valueOf(k) >= 20 && valueOf(v) < 40;
+                        }
+                    };
+
+                    for (int i = 0; i < CNT; i++) {
+                        Object key = key(i);
+                        Object val = value(i);
+
+                        cache.put(key, val);
+
+                        if (!isClientMode() && (cacheMode() == REPLICATED
+                            || testedGrid().affinity(cacheName()).isPrimary(locNode, key)) && filter.apply(key, val))
+                            map.put(key, val);
+                    }
+
+                    registerEventListeners(map, true);
+
+                    QueryCursor<Cache.Entry<Object, Object>> q = cache.query(new ScanQuery<>(filter).setLocal(true));
+
+                    checkQueryResults(map, q);
+                }
+                finally {
+                    stopListeners();
+                }
+            }
+        });
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    @SuppressWarnings("SubtractionInCompareTo")
+    public void testScanQueryPartitionFilter() throws Exception {
+        runInAllDataModes(new TestRunnable() {
+            @Override public void run() throws Exception {
+                IgniteCache<Object, Object> cache = jcache();
+
+                Affinity<Object> affinity = testedGrid().affinity(cacheName());
+
+                Map<Integer, Map<Object, Object>> partMap = new HashMap<>();
+
+                IgniteBiPredicate<Object, Object> filter = new IgniteBiPredicate<Object, Object>() {
+                    @Override public boolean apply(Object k, Object v) {
+                        assertNotNull(k);
+                        assertNotNull(v);
+
+                        return valueOf(k) >= 20 && valueOf(v) < 40;
+                    }
+                };
+
+                for (int i = 0; i < CNT; i++) {
+                    Object key = key(i);
+                    Object val = value(i);
+
+                    cache.put(key, val);
+
+                    if (filter.apply(key, val)) {
+                        int part = affinity.partition(key);
+
+                        Map<Object, Object> map = partMap.get(part);
+
+                        if (map == null)
+                            partMap.put(part, map = new HashMap<>());
+
+                        map.put(key, val);
+                    }
+                }
+
+                for (int part = 0; part < affinity.partitions(); part++) {
+                    try {
+                        Map<Object, Object> expMap = partMap.get(part);
+
+                        expMap = expMap == null ? Collections.emptyMap() : expMap;
+
+                        registerEventListeners(expMap, true);
+
+                        QueryCursor<Cache.Entry<Object, Object>> q = cache.query(new ScanQuery<>(part, filter));
+
+                        checkQueryResults(expMap, q);
+                    }
+                    finally {
+                        stopListeners();
+                    }
+                }
+            }
+        });
+    }
+
+    /**
+     * @param expMap Expected map.
+     * @param cursor Query cursor.
+     */
+    private void checkQueryResults(Map<Object, Object> expMap, QueryCursor<Cache.Entry<Object, Object>> cursor)
+        throws InterruptedException {
+        Iterator<Cache.Entry<Object, Object>> iter = cursor.iterator();
+
+        try {
+            assertNotNull(iter);
+
+            int cnt = 0;
+
+            while (iter.hasNext()) {
+                Cache.Entry<Object, Object> e = iter.next();
+
+                assertNotNull(e.getKey());
+                assertNotNull(e.getValue());
+
+                Object expVal = expMap.get(e.getKey());
+
+                assertNotNull("Failed to resolve expected value for key: " + e.getKey(), expVal);
+
+                assertEquals(expVal, e.getValue());
+
+                cnt++;
+            }
+
+            assertEquals(expMap.size(), cnt);
+        }
+        finally {
+            cursor.close();
+        }
+
+        checkEvents();
+    }
+
+    /**
+     * Registers event listeners.
+     * @param expMap Expected read events count.
+     */
+    private void registerEventListeners(Map<Object, Object> expMap) {
+        registerEventListeners(expMap, false);
+    }
+
+    /**
+     * Registers event listeners.
+     * @param expMap Expected read events count.
+     * @param filterExp Scan query uses filter.
+     */
+    private void registerEventListeners(Map<Object, Object> expMap, final boolean filterExp) {
+        this.expMap = expMap != null ? expMap : Collections.emptyMap();
+
+        Set<ClusterNode> affNodes= new HashSet<>();
+
+        if (cacheMode() != REPLICATED) {
+            Affinity<Object> aff = testedGrid().affinity(cacheName());
+
+            for (Object key : this.expMap.keySet())
+                affNodes.add(aff.mapKeyToNode(key));
+        }
+
+        int execEvtCnt = cacheMode() == REPLICATED || (cacheMode() == PARTITIONED && affNodes.isEmpty()) ? 1 : affNodes.size();
+
+        evtMap = new ConcurrentHashMap<>();
+        readEvtLatch = new CountDownLatch(this.expMap.size());
+        execEvtLatch = new CountDownLatch(execEvtCnt);
+
+        objReadLsnrs = new IgnitePredicate[gridCount()];
+        qryExecLsnrs = new IgnitePredicate[gridCount()];
+
+        for (int i = 0; i < gridCount(); i++) {
+            IgnitePredicate<Event> pred = new IgnitePredicate<Event>() {
+                @Override public boolean apply(Event evt) {
+                    assertTrue("Event: " + evt, evt instanceof CacheQueryReadEvent);
+
+                    CacheQueryReadEvent<Object, Object> qe = (CacheQueryReadEvent<Object, Object>)evt;
+
+                    assertEquals(SCAN.name(), qe.queryType());
+                    assertEquals(cacheName(), qe.cacheName());
+
+                    assertNull(qe.className());
+                    assertNull(qe.clause());
+                    assertEquals(filterExp, qe.scanQueryFilter() != null);
+                    assertNull(qe.continuousQueryFilter());
+                    assertNull(qe.arguments());
+
+                    evtMap.put(qe.key(), qe.value());
+
+                    assertFalse(readEvtLatch.getCount() == 0);
+
+                    readEvtLatch.countDown();
+
+                    return true;
+                }
+            };
+
+            grid(i).events().localListen(pred, EVT_CACHE_QUERY_OBJECT_READ);
+
+            objReadLsnrs[i] = pred;
+
+            IgnitePredicate<Event> execPred = new IgnitePredicate<Event>() {
+                @Override public boolean apply(Event evt) {
+                    assertTrue("Event: " + evt, evt instanceof CacheQueryExecutedEvent);
+
+                    CacheQueryExecutedEvent qe = (CacheQueryExecutedEvent)evt;
+
+                    assertEquals(SCAN.name(), qe.queryType());
+                    assertEquals(cacheName(), qe.cacheName());
+
+                    assertNull(qe.className());
+                    assertNull(qe.clause());
+                    assertEquals(filterExp, qe.scanQueryFilter() != null);
+                    assertNull(qe.continuousQueryFilter());
+                    assertNull(qe.arguments());
+
+                    assertFalse("Too many events.", execEvtLatch.getCount() == 0);
+
+                    execEvtLatch.countDown();
+
+                    return true;
+                }
+            };
+
+            grid(i).events().localListen(execPred, EVT_CACHE_QUERY_EXECUTED);
+
+            qryExecLsnrs[i] = execPred;
+        }
+    }
+
+    /**
+     * Stops listenening.
+     */
+    private void stopListeners() {
+        for (int i = 0; i < gridCount(); i++) {
+            grid(i).events().stopLocalListen(objReadLsnrs[i]);
+            grid(i).events().stopLocalListen(qryExecLsnrs[i]);
+        }
+    }
+
+    /**
+     * @throws InterruptedException If failed.
+     */
+    private void checkEvents() throws InterruptedException {
+        assertTrue(execEvtLatch.await(1000, MILLISECONDS));
+        assertTrue(readEvtLatch.await(1000, MILLISECONDS));
+
+        assertEquals(expMap.size(), evtMap.size());
+
+        for (Map.Entry<Object, Object> e : expMap.entrySet())
+            assertEquals(e.getValue(), evtMap.get(e.getKey()));
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0e8072f8/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheConfigVariationQueryTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheConfigVariationQueryTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheConfigVariationQueryTestSuite.java
new file mode 100644
index 0000000..83ae27f
--- /dev/null
+++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheConfigVariationQueryTestSuite.java
@@ -0,0 +1,41 @@
+/*
+ * 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.cache.IgniteCacheConfigVariationsQueryTest;
+import org.apache.ignite.testframework.configvariations.ConfigVariationsTestSuiteBuilder;
+
+/**
+ * Test suite for cache queries.
+ */
+public class IgniteCacheConfigVariationQueryTestSuite extends TestSuite {
+    /**
+     * @return Test suite.
+     * @throws Exception If failed.
+     */
+    public static TestSuite suite() throws Exception {
+        return new ConfigVariationsTestSuiteBuilder(
+            "Cache Config Variations Query Test Suite",
+            IgniteCacheConfigVariationsQueryTest.class)
+            .withBasicCacheParams()
+            .gridsCount(5).backups(1)
+            .testedNodesCount(3).withClients()
+            .build();
+    }
+}


[22/24] ignite git commit: allowing to perform SQL querires over off-heap caches with one indexed type configured

Posted by ak...@apache.org.
allowing to perform SQL querires over off-heap caches with one indexed type configured


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

Branch: refs/heads/master
Commit: 9ea769a25bcda322f628f8d4fcb47f67579db026
Parents: 92a41ba
Author: Vladislav Pyatkov <vl...@gmail.com>
Authored: Mon May 16 16:48:55 2016 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Mon May 16 16:48:55 2016 +0300

----------------------------------------------------------------------
 .../cache/load/IgniteCacheRandomOperationBenchmark.java          | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/9ea769a2/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/IgniteCacheRandomOperationBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/IgniteCacheRandomOperationBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/IgniteCacheRandomOperationBenchmark.java
index 539d4d9..bcea03c 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/IgniteCacheRandomOperationBenchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/IgniteCacheRandomOperationBenchmark.java
@@ -199,7 +199,8 @@ public class IgniteCacheRandomOperationBenchmark extends IgniteAbstractBenchmark
             CacheConfiguration configuration = cache.getConfiguration(CacheConfiguration.class);
 
             if (isClassDefinedInConfig(configuration)) {
-                if (configuration.getMemoryMode() == CacheMemoryMode.OFFHEAP_TIERED) {
+                if (configuration.getMemoryMode() == CacheMemoryMode.OFFHEAP_TIERED &&
+                    configuration.getQueryEntities().size() > 2) {
                     throw new IgniteException("Off-heap mode is unsupported by the load test due to bugs IGNITE-2982" +
                         " and IGNITE-2997");
                 }
@@ -560,7 +561,6 @@ public class IgniteCacheRandomOperationBenchmark extends IgniteAbstractBenchmark
     }
 
     /**
-     * @param cacheName Ignite cache name.
      * @return Operation.
      */
     @NotNull private Operation nextRandomOperation() {


[17/24] ignite git commit: IGNITE-2435 Fixed "Integration with Mesos doesn't work with limited access to internet".

Posted by ak...@apache.org.
IGNITE-2435 Fixed "Integration with Mesos doesn't work with limited access to internet".


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

Branch: refs/heads/master
Commit: f65dd00ab95678260efdab1ba538079f70cf8201
Parents: cc58a63
Author: nikolay_tikhonov <nt...@gridgain.com>
Authored: Wed May 4 17:55:42 2016 +0300
Committer: nikolay_tikhonov <nt...@gridgain.com>
Committed: Mon May 16 15:29:24 2016 +0300

----------------------------------------------------------------------
 modules/mesos/pom.xml                           |  43 +++-
 .../apache/ignite/mesos/ClusterProperties.java  |  94 +++++----
 .../apache/ignite/mesos/IgniteFramework.java    |  15 +-
 .../ignite/mesos/resource/IgniteProvider.java   | 198 +++++++------------
 .../ignite/mesos/resource/ResourceProvider.java |  78 ++++++--
 5 files changed, 243 insertions(+), 185 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/f65dd00a/modules/mesos/pom.xml
----------------------------------------------------------------------
diff --git a/modules/mesos/pom.xml b/modules/mesos/pom.xml
index fa38265..f2f1acd 100644
--- a/modules/mesos/pom.xml
+++ b/modules/mesos/pom.xml
@@ -20,7 +20,8 @@
 <!--
     POM file.
 -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <modelVersion>4.0.0</modelVersion>
 
     <parent>
@@ -36,6 +37,8 @@
 
     <properties>
         <mesos.version>0.22.0</mesos.version>
+        <ignite.latest.url>http://ignite.run/download_ignite.php</ignite.latest.url>
+        <ignite.direct.url>https://archive.apache.org/dist/ignite/%s/apache-ignite-fabric-%s-bin.zip</ignite.direct.url>
     </properties>
 
     <dependencies>
@@ -73,6 +76,44 @@
             </plugin>
 
             <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-antrun-plugin</artifactId>
+                <version>1.7</version>
+                <executions>
+                    <execution>
+                        <id>update-versions</id>
+                        <goals>
+                            <goal>run</goal>
+                        </goals>
+                        <phase>generate-sources</phase>
+                        <configuration>
+                            <target>
+                                <echo message="Update download url in mesos module." />
+                                <echo message="Direct link ${ignite.direct.url}." />
+                                <echo message="Latest link ${ignite.latest.url}." />
+
+                                <replaceregexp byline="true" encoding="UTF-8">
+                                    <regexp pattern="(.*DOWNLOAD_LINK = &quot;)(.*)(&quot;.*)" />
+                                    <substitution expression="\1${ignite.latest.url}\3"/>
+                                    <fileset dir="${basedir}/">
+                                        <include name="**/IgniteProvider.java" />
+                                    </fileset>
+                                </replaceregexp>
+
+                                <replaceregexp byline="true" encoding="UTF-8">
+                                    <regexp pattern="(.*DOWNLOAD_URL_PATTERN = &quot;)(.*)(&quot;.*)" />
+                                    <substitution expression="\1${ignite.direct.url}\3"/>
+                                    <fileset dir="${basedir}/">
+                                        <include name="**/IgniteProvider.java" />
+                                    </fileset>
+                                </replaceregexp>
+                            </target>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+
+            <plugin>
                 <artifactId>maven-assembly-plugin</artifactId>
                 <version>2.4.1</version>
                 <configuration>

http://git-wip-us.apache.org/repos/asf/ignite/blob/f65dd00a/modules/mesos/src/main/java/org/apache/ignite/mesos/ClusterProperties.java
----------------------------------------------------------------------
diff --git a/modules/mesos/src/main/java/org/apache/ignite/mesos/ClusterProperties.java b/modules/mesos/src/main/java/org/apache/ignite/mesos/ClusterProperties.java
index e249a25..747fbe9 100644
--- a/modules/mesos/src/main/java/org/apache/ignite/mesos/ClusterProperties.java
+++ b/modules/mesos/src/main/java/org/apache/ignite/mesos/ClusterProperties.java
@@ -31,7 +31,11 @@ import java.util.regex.Pattern;
 import java.util.regex.PatternSyntaxException;
 
 /**
- * Cluster settings.
+ * The class defines cluster configuration. This configuration created from properties file
+ * that passed on startup or environment variables.
+ * <p>
+ * If Mesos cluster working in Intranet or behind NAT then an access to local resources can be set
+ * by {@link #ignitePackagePath()} or {@link #ignitePackageUrl()} which should be available from nodes.
  */
 public class ClusterProperties {
     /** */
@@ -68,7 +72,7 @@ public class ClusterProperties {
     public static final String IGNITE_HTTP_SERVER_HOST = "IGNITE_HTTP_SERVER_HOST";
 
     /** Http server host. */
-    private String httpServerHost = null;
+    private String httpSrvHost = null;
 
     /** */
     public static final String IGNITE_HTTP_SERVER_PORT = "IGNITE_HTTP_SERVER_PORT";
@@ -77,7 +81,7 @@ public class ClusterProperties {
     public static final String DEFAULT_HTTP_SERVER_PORT = "48610";
 
     /** Http server host. */
-    private int httpServerPort = Integer.valueOf(DEFAULT_HTTP_SERVER_PORT);
+    private int httpSrvPort = Integer.valueOf(DEFAULT_HTTP_SERVER_PORT);
 
     /** */
     public static final String IGNITE_TOTAL_CPU = "IGNITE_TOTAL_CPU";
@@ -152,7 +156,13 @@ public class ClusterProperties {
     public static final String IGNITE_PACKAGE_URL = "IGNITE_PACKAGE_URL";
 
     /** Ignite package url. */
-    private String ignitePackageUrl = null;
+    private String ignitePkgUrl;
+
+    /** */
+    public static final String IGNITE_PACKAGE_PATH = "IGNITE_PACKAGE_PATH";
+
+    /** Ignite package path. */
+    private String ignitePkgPath;
 
     /** */
     public static final String IGNITE_WORK_DIR = "IGNITE_WORK_DIR";
@@ -318,10 +328,10 @@ public class ClusterProperties {
     /**
      * Sets hostname constraint.
      *
-     * @param pattern Hostname pattern.
+     * @param ptrn Hostname pattern.
      */
-    public void hostnameConstraint(Pattern pattern) {
-        this.hostnameConstraint = pattern;
+    public void hostnameConstraint(Pattern ptrn) {
+        this.hostnameConstraint = ptrn;
     }
 
     /**
@@ -379,21 +389,34 @@ public class ClusterProperties {
      * @return Http server host.
      */
     public String httpServerHost() {
-        return httpServerHost;
+        return httpSrvHost;
     }
 
     /**
      * @return Http server port.
      */
     public int httpServerPort() {
-        return httpServerPort;
+        return httpSrvPort;
     }
 
     /**
+     * URL to ignite package. The URL should to point at valid apache ignite archive.
+     * This property can be useful if using own apache ignite build.
+     *
      * @return Url to ignite package.
      */
     public String ignitePackageUrl() {
-        return ignitePackageUrl;
+        return ignitePkgUrl;
+    }
+
+    /**
+     * Path on local file system to ignite archive. That can be useful when
+     * Mesos working in Intranet or behind NAT.
+     *
+     * @return Path on local host to ignite package.
+     */
+    public String ignitePackagePath() {
+        return ignitePkgPath;
     }
 
     /**
@@ -425,37 +448,38 @@ public class ClusterProperties {
     }
 
     /**
-     * @param config path to config file.
+     * @param cfg path to config file.
      * @return Cluster configuration.
      */
-    public static ClusterProperties from(String config) {
+    public static ClusterProperties from(String cfg) {
         try {
             Properties props = null;
 
-            if (config != null) {
+            if (cfg != null) {
                 props = new Properties();
 
-                props.load(new FileInputStream(config));
+                props.load(new FileInputStream(cfg));
             }
 
             ClusterProperties prop = new ClusterProperties();
 
             prop.mesosUrl = getStringProperty(MESOS_MASTER_URL, props, DEFAULT_MESOS_MASTER_URL);
 
-            prop.httpServerHost = getStringProperty(IGNITE_HTTP_SERVER_HOST, props, getNonLoopbackAddress());
+            prop.httpSrvHost = getStringProperty(IGNITE_HTTP_SERVER_HOST, props, getNonLoopbackAddress());
 
             String port = System.getProperty("PORT0");
 
             if (port != null && !port.isEmpty())
-                prop.httpServerPort = Integer.valueOf(port);
+                prop.httpSrvPort = Integer.valueOf(port);
             else
-                prop.httpServerPort = Integer.valueOf(getStringProperty(IGNITE_HTTP_SERVER_PORT, props,
+                prop.httpSrvPort = Integer.valueOf(getStringProperty(IGNITE_HTTP_SERVER_PORT, props,
                     DEFAULT_HTTP_SERVER_PORT));
 
             prop.clusterName = getStringProperty(IGNITE_CLUSTER_NAME, props, DEFAULT_CLUSTER_NAME);
 
             prop.userLibsUrl = getStringProperty(IGNITE_USERS_LIBS_URL, props, null);
-            prop.ignitePackageUrl = getStringProperty(IGNITE_PACKAGE_URL, props, null);
+            prop.ignitePkgUrl = getStringProperty(IGNITE_PACKAGE_URL, props, null);
+            prop.ignitePkgPath = getStringProperty(IGNITE_PACKAGE_PATH, props, null);
             prop.licenceUrl = getStringProperty(LICENCE_URL, props, null);
             prop.igniteCfgUrl = getStringProperty(IGNITE_CONFIG_XML_URL, props, null);
 
@@ -476,11 +500,11 @@ public class ClusterProperties {
             prop.igniteCfg = getStringProperty(IGNITE_CONFIG_XML, props, null);
             prop.userLibs = getStringProperty(IGNITE_USERS_LIBS, props, null);
 
-            String pattern = getStringProperty(IGNITE_HOSTNAME_CONSTRAINT, props, null);
+            String ptrn = getStringProperty(IGNITE_HOSTNAME_CONSTRAINT, props, null);
 
-            if (pattern != null) {
+            if (ptrn != null) {
                 try {
-                    prop.hostnameConstraint = Pattern.compile(pattern);
+                    prop.hostnameConstraint = Pattern.compile(ptrn);
                 }
                 catch (PatternSyntaxException e) {
                     log.log(Level.WARNING, "IGNITE_HOSTNAME_CONSTRAINT has invalid pattern. It will be ignore.", e);
@@ -499,16 +523,16 @@ public class ClusterProperties {
      * @param fileProps Property file.
      * @return Property value.
      */
-    private static double getDoubleProperty(String name, Properties fileProps, Double defaultVal) {
+    private static double getDoubleProperty(String name, Properties fileProps, Double dfltVal) {
         if (fileProps != null && fileProps.containsKey(name))
             return Double.valueOf(fileProps.getProperty(name));
 
-        String property = System.getProperty(name);
+        String prop = System.getProperty(name);
 
-        if (property == null)
-            property = System.getenv(name);
+        if (prop == null)
+            prop = System.getenv(name);
 
-        return property == null ? defaultVal : Double.valueOf(property);
+        return prop == null ? dfltVal : Double.valueOf(prop);
     }
 
     /**
@@ -516,16 +540,16 @@ public class ClusterProperties {
      * @param fileProps Property file.
      * @return Property value.
      */
-    private static String getStringProperty(String name, Properties fileProps, String defaultVal) {
+    private static String getStringProperty(String name, Properties fileProps, String dfltVal) {
         if (fileProps != null && fileProps.containsKey(name))
             return fileProps.getProperty(name);
 
-        String property = System.getProperty(name);
+        String prop = System.getProperty(name);
 
-        if (property == null)
-            property = System.getenv(name);
+        if (prop == null)
+            prop = System.getenv(name);
 
-        return property == null ? defaultVal : property;
+        return prop == null ? dfltVal : prop;
     }
 
     /**
@@ -540,16 +564,16 @@ public class ClusterProperties {
         while (ifaces.hasMoreElements()) {
             NetworkInterface iface = ifaces.nextElement();
 
-            Enumeration<InetAddress> addresses = iface.getInetAddresses();
+            Enumeration<InetAddress> addrs = iface.getInetAddresses();
 
-            while (addresses.hasMoreElements()) {
-                InetAddress addr = addresses.nextElement();
+            while (addrs.hasMoreElements()) {
+                InetAddress addr = addrs.nextElement();
 
                 if (addr instanceof Inet4Address && !addr.isLoopbackAddress())
                     return addr.getHostAddress();
             }
         }
 
-        throw new RuntimeException("Failed. Couldn't find non-loopback address");
+        throw new RuntimeException("Failed. Could not find non-loopback address");
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/f65dd00a/modules/mesos/src/main/java/org/apache/ignite/mesos/IgniteFramework.java
----------------------------------------------------------------------
diff --git a/modules/mesos/src/main/java/org/apache/ignite/mesos/IgniteFramework.java b/modules/mesos/src/main/java/org/apache/ignite/mesos/IgniteFramework.java
index 9f33f9a..0cd9efb 100644
--- a/modules/mesos/src/main/java/org/apache/ignite/mesos/IgniteFramework.java
+++ b/modules/mesos/src/main/java/org/apache/ignite/mesos/IgniteFramework.java
@@ -19,6 +19,7 @@ package org.apache.ignite.mesos;
 
 import com.google.protobuf.ByteString;
 import java.net.InetSocketAddress;
+import java.util.concurrent.TimeUnit;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import org.apache.ignite.mesos.resource.IgniteProvider;
@@ -43,6 +44,7 @@ public class IgniteFramework {
      * Main methods has only one optional parameter - path to properties files.
      *
      * @param args Args.
+     * @throws Exception If failed.
      */
     public static void main(String[] args) throws Exception {
         final int frameworkFailoverTimeout = 0;
@@ -63,9 +65,9 @@ public class IgniteFramework {
 
         String baseUrl = String.format("http://%s:%d", clusterProps.httpServerHost(), clusterProps.httpServerPort());
 
-        JettyServer httpServer = new JettyServer();
+        JettyServer httpSrv = new JettyServer();
 
-        httpServer.start(
+        httpSrv.start(
             new InetSocketAddress(clusterProps.httpServerHost(), clusterProps.httpServerPort()),
             new ResourceHandler(clusterProps.userLibs(), clusterProps.igniteCfg(), clusterProps.igniteWorkDir())
         );
@@ -79,8 +81,9 @@ public class IgniteFramework {
         // Create the scheduler.
         Scheduler scheduler = new IgniteScheduler(clusterProps, provider);
 
-        // create the driver
+        // Create the driver.
         MesosSchedulerDriver driver;
+
         if (System.getenv("MESOS_AUTHENTICATE") != null) {
             log.info("Enabling authentication for the framework");
 
@@ -96,7 +99,7 @@ public class IgniteFramework {
                 System.exit(1);
             }
 
-            Protos.Credential credential = Protos.Credential.newBuilder()
+            Protos.Credential cred = Protos.Credential.newBuilder()
                 .setPrincipal(System.getenv("DEFAULT_PRINCIPAL"))
                 .setSecret(ByteString.copyFrom(System.getenv("DEFAULT_SECRET").getBytes()))
                 .build();
@@ -104,7 +107,7 @@ public class IgniteFramework {
             frameworkBuilder.setPrincipal(System.getenv("DEFAULT_PRINCIPAL"));
 
             driver = new MesosSchedulerDriver(scheduler, frameworkBuilder.build(), clusterProps.masterUrl(),
-                credential);
+                cred);
         }
         else {
             frameworkBuilder.setPrincipal("ignite-framework-java");
@@ -114,7 +117,7 @@ public class IgniteFramework {
 
         int status = driver.run() == Protos.Status.DRIVER_STOPPED ? 0 : 1;
 
-        httpServer.stop();
+        httpSrv.stop();
 
         // Ensure that the driver process terminates.
         driver.stop();

http://git-wip-us.apache.org/repos/asf/ignite/blob/f65dd00a/modules/mesos/src/main/java/org/apache/ignite/mesos/resource/IgniteProvider.java
----------------------------------------------------------------------
diff --git a/modules/mesos/src/main/java/org/apache/ignite/mesos/resource/IgniteProvider.java b/modules/mesos/src/main/java/org/apache/ignite/mesos/resource/IgniteProvider.java
index 7510110..3d794db 100644
--- a/modules/mesos/src/main/java/org/apache/ignite/mesos/resource/IgniteProvider.java
+++ b/modules/mesos/src/main/java/org/apache/ignite/mesos/resource/IgniteProvider.java
@@ -23,27 +23,26 @@ import java.io.IOException;
 import java.net.HttpURLConnection;
 import java.net.URL;
 import java.nio.channels.Channels;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
+import org.apache.ignite.mesos.ClusterProperties;
 
 /**
  * Class downloads and stores Ignite.
  */
 public class IgniteProvider {
+    // This constants are set by maven-ant-plugin.
     /** */
-    public static final String DOWNLOAD_LINK = "http://tiny.cc/updater/download_community.php";
+    private static final String DOWNLOAD_LINK = "http://ignite.run/download_ignite.php";
 
     /** */
-    public static final String DIRECT_DOWNLOAD_LINK = "http://www.gridgain.com/media/gridgain-community-fabric-";
+    private static final String DOWNLOAD_URL_PATTERN = "https://archive.apache.org/dist/ignite/%s/apache-ignite-fabric-%s-bin.zip";
 
     /** */
     private String downloadFolder;
 
-    /** */
-    private String latestVersion = null;
-
     /**
      * @param downloadFolder Folder with ignite.
      */
@@ -52,158 +51,116 @@ public class IgniteProvider {
     }
 
     /**
-     * @return Latest ignite version.
+     * @param ver Ignite version.
+     * @throws IOException If downloading failed.
+     * @return Path to latest ignite.
      */
-    public String getIgnite() {
-        File folder = checkDownloadFolder();
-
-        if (latestVersion == null) {
-            List<String> files = findIgnites(folder);
-
-            if (!files.isEmpty()) {
-                if (files.size() == 1)
-                    latestVersion = parseVersion(files.get(0));
-                else
-                    latestVersion = parseVersion(Collections.max(files, new Comparator<String>() {
-                        @Override public int compare(String f1, String f2) {
-                            if (f1.equals(f2))
-                                return 0;
-
-                            String[] ver1 = parseVersion(f1).split("\\.");
-                            String[] ver2 = parseVersion(f2).split("\\.");
-
-                            if (Integer.valueOf(ver1[0]) >= Integer.valueOf(ver2[0])
-                                && Integer.valueOf(ver1[1]) >= Integer.valueOf(ver2[1])
-                                && Integer.valueOf(ver1[2]) >= Integer.valueOf(ver2[2]))
-
-                                return 1;
-                            else
-                                return -1;
-                        }
-                    }));
-            }
-        }
-
-        latestVersion = updateIgnite(latestVersion);
-
-        return "gridgain-community-fabric-" + latestVersion + ".zip";
+    public String getIgnite(String ver) throws IOException {
+        return downloadIgnite(ver);
     }
 
     /**
-     * @param folder Folder.
-     * @return Ignite archives.
+     * @param ver Ignite version which will be downloaded. If {@code null} will download the latest ignite version.
+     * @throws IOException If downloading failed.
+     * @return Ignite archive.
      */
-    private List<String> findIgnites(File folder) {
-        String[] files = folder.list();
+    public String downloadIgnite(String ver) throws IOException {
+        assert ver != null;
 
-        List<String> ignites = new ArrayList<>();
+        URL url;
 
-        if (files != null) {
-            for (String fileName : files) {
-                if (fileName.contains("gridgain-community-fabric-") && fileName.endsWith(".zip"))
-                    ignites.add(fileName);
-            }
-        }
+        if (ver.equals(ClusterProperties.DEFAULT_IGNITE_VERSION)) {
+            URL updateUrl = new URL(DOWNLOAD_LINK);
 
-        return ignites;
-    }
+            HttpURLConnection conn = (HttpURLConnection)updateUrl.openConnection();
 
-    /**
-     * @param version Ignite version.
-     * @return Ignite.
-     */
-    public String getIgnite(String version) {
-        File folder = checkDownloadFolder();
-
-        String[] ignites = folder.list();
-
-        String ignite = null;
+            int code = conn.getResponseCode();
 
-        if (ignites != null) {
-            for (String fileName : ignites) {
-                if (fileName.equals("gridgain-community-fabric-" + version + ".zip"))
-                    ignite = fileName;
-            }
+            if (code == 200)
+                url = conn.getURL();
+            else
+                throw new RuntimeException("Failed to download ignite distributive. Maybe set incorrect version? " +
+                    "[resCode:" + code + ", ver: " + ver + "]");
         }
+        else
+            url = new URL(String.format(DOWNLOAD_URL_PATTERN, ver.replace("-incubating", ""), ver));
 
-        if (ignite != null)
-            return ignite;
-
-        return downloadIgnite(version);
+        return downloadIgnite(url);
     }
 
     /**
-     * @param currentVersion The current latest version.
-     * @return Current version if the current version is latest; new ignite version otherwise.
+     * Downloads ignite by URL if this version wasn't downloaded before.
+     *
+     * @param url URL to Ignite.
+     * @return File name.
      */
-    private String updateIgnite(String currentVersion) {
-        try {
-            URL url;
-
-            if (currentVersion == null)
-                url = new URL(DOWNLOAD_LINK);
-            else
-                url = new URL(DOWNLOAD_LINK + "?version=" + currentVersion);
+    private String downloadIgnite(URL url) {
+        assert url != null;
 
+        try {
             HttpURLConnection conn = (HttpURLConnection)url.openConnection();
 
             int code = conn.getResponseCode();
 
             if (code == 200) {
-                String redirectUrl = conn.getURL().toString();
-
                 checkDownloadFolder();
 
-                FileOutputStream outFile = new FileOutputStream(downloadFolder + "/" + fileName(redirectUrl));
+                String fileName = fileName(url.toString());
+
+                if (fileExist(fileName))
+                    return fileName;
+
+                FileOutputStream outFile = new FileOutputStream(downloadFolder + fileName);
 
                 outFile.getChannel().transferFrom(Channels.newChannel(conn.getInputStream()), 0, Long.MAX_VALUE);
 
                 outFile.close();
 
-                return parseVersion(redirectUrl);
+                return fileName;
             }
-            else if (code == 304)
-                // This version is latest.
-                return currentVersion;
             else
                 throw new RuntimeException("Got unexpected response code. Response code: " + code);
         }
         catch (IOException e) {
-            throw new RuntimeException("Failed update ignite.", e);
+            throw new RuntimeException("Failed to download Ignite.", e);
         }
     }
 
     /**
-     * @param version The current latest version.
-     * @return Ignite archive.
+     * Checks that file exists.
+     *
+     * @param fileName File name.
+     * @return {@code True} if file exist otherwise {@code false}.
      */
-    public String downloadIgnite(String version) {
-        try {
-            URL url = new URL(DIRECT_DOWNLOAD_LINK + version + ".zip");
-
-            HttpURLConnection conn = (HttpURLConnection)url.openConnection();
+    private boolean fileExist(String fileName) {
+        String pathToIgnite = downloadFolder + (downloadFolder.endsWith("/") ? "" : '/') + fileName;
 
-            int code = conn.getResponseCode();
+        return new File(pathToIgnite).exists();
+    }
 
-            if (code == 200) {
-                checkDownloadFolder();
+    /**
+     * Copy file to working directory.
+     *
+     * @param filePath File path.
+     * @return File name.
+     * @throws IOException If coping failed.
+     */
+    String copyToWorkDir(String filePath) throws IOException {
+        Path srcFile = Paths.get(filePath);
 
-                String fileName = fileName(url.toString());
+        if (Files.exists(srcFile)) {
+            checkDownloadFolder();
 
-                FileOutputStream outFile = new FileOutputStream(downloadFolder + fileName);
+            Path newDir = Paths.get(downloadFolder);
 
-                outFile.getChannel().transferFrom(Channels.newChannel(conn.getInputStream()), 0, Long.MAX_VALUE);
+            Path fileName = srcFile.getFileName();
 
-                outFile.close();
+            Files.copy(srcFile, newDir.resolve(fileName), StandardCopyOption.REPLACE_EXISTING);
 
-                return fileName;
-            }
-            else
-                throw new RuntimeException("Got unexpected response code. Response code: " + code);
-        }
-        catch (IOException e) {
-            throw new RuntimeException("Failed update ignite.", e);
+            return fileName.toString();
         }
+
+        return null;
     }
 
     /**
@@ -215,17 +172,10 @@ public class IgniteProvider {
         if (!file.exists())
             file.mkdirs();
 
-        return file;
-    }
-
-    /**
-     * @param url URL.
-     * @return Ignite version.
-     */
-    public static String parseVersion(String url) {
-        String[] split = url.split("-");
+        if (!file.exists())
+            throw new IllegalArgumentException("Failed to create working directory: " + downloadFolder);
 
-        return split[split.length - 1].replaceAll(".zip", "");
+        return file;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/f65dd00a/modules/mesos/src/main/java/org/apache/ignite/mesos/resource/ResourceProvider.java
----------------------------------------------------------------------
diff --git a/modules/mesos/src/main/java/org/apache/ignite/mesos/resource/ResourceProvider.java b/modules/mesos/src/main/java/org/apache/ignite/mesos/resource/ResourceProvider.java
index 23945e1..1aa8863 100644
--- a/modules/mesos/src/main/java/org/apache/ignite/mesos/resource/ResourceProvider.java
+++ b/modules/mesos/src/main/java/org/apache/ignite/mesos/resource/ResourceProvider.java
@@ -18,9 +18,15 @@
 package org.apache.ignite.mesos.resource;
 
 import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 import org.apache.ignite.mesos.ClusterProperties;
 
 import static org.apache.ignite.mesos.resource.ResourceHandler.CONFIG_PREFIX;
@@ -32,6 +38,9 @@ import static org.apache.ignite.mesos.resource.ResourceHandler.LIBS_PREFIX;
  * Provides path to user's libs and config file.
  */
 public class ResourceProvider {
+    /** */
+    private static final Logger log = Logger.getLogger(ResourceProvider.class.getSimpleName());
+
     /** Ignite url. */
     private String igniteUrl;
 
@@ -39,26 +48,57 @@ public class ResourceProvider {
     private Collection<String> libsUris;
 
     /** Url config. */
-    private String configUrl;
+    private String cfgUrl;
 
     /** Config name. */
-    private String configName;
+    private String cfgName;
 
     /**
-     * @param properties Cluster properties.
+     * @param props Cluster properties.
      * @param provider Ignite provider.
      * @param baseUrl Base url.
      */
-    public void init(ClusterProperties properties, IgniteProvider provider, String baseUrl) {
-        // Downloading ignite.
-        if (properties.igniteVer().equals(ClusterProperties.DEFAULT_IGNITE_VERSION))
-            igniteUrl = baseUrl + IGNITE_PREFIX + provider.getIgnite();
-        else
-            igniteUrl = baseUrl + IGNITE_PREFIX + provider.getIgnite(properties.igniteVer());
+    public void init(ClusterProperties props, IgniteProvider provider, String baseUrl) throws IOException {
+        if (props.ignitePackageUrl() == null && props.ignitePackagePath() == null) {
+            // Downloading ignite.
+            try {
+                igniteUrl = baseUrl + IGNITE_PREFIX + provider.getIgnite(props.igniteVer());
+            }
+            catch (Exception e) {
+                log.log(Level.SEVERE, "Failed to download Ignite [err={0}, ver={1}].\n" +
+                    "If application working behind NAT or Intranet and does not have access to external resources " +
+                    "then you can use IGNITE_PACKAGE_URL or IGNITE_PACKAGE_PATH property that allow to use local " +
+                    "resources.",
+                    new Object[]{e, props.igniteVer()});
+            }
+        }
+
+        if (props.ignitePackagePath() != null) {
+            Path ignitePackPath = Paths.get(props.ignitePackagePath());
+
+            if (Files.exists(ignitePackPath) && !Files.isDirectory(ignitePackPath)) {
+                try {
+                    String fileName = provider.copyToWorkDir(props.ignitePackagePath());
+
+                    assert fileName != null;
+
+                    igniteUrl = baseUrl + IGNITE_PREFIX + fileName;
+                }
+                catch (Exception e) {
+                    log.log(Level.SEVERE, "Failed to copy Ignite to working directory [err={0}, path={1}].",
+                        new Object[] {e, props.ignitePackagePath()});
+
+                    throw e;
+                }
+            }
+            else
+                throw new IllegalArgumentException("Failed to find a ignite archive by path: "
+                    + props.ignitePackagePath());
+        }
 
         // Find all jar files into user folder.
-        if (properties.userLibs() != null && !properties.userLibs().isEmpty()) {
-            File libsDir = new File(properties.userLibs());
+        if (props.userLibs() != null && !props.userLibs().isEmpty()) {
+            File libsDir = new File(props.userLibs());
 
             List<String> libs = new ArrayList<>();
 
@@ -78,19 +118,19 @@ public class ResourceProvider {
         }
 
         // Set configuration url.
-        if (properties.igniteCfg() != null) {
-            File cfg = new File(properties.igniteCfg());
+        if (props.igniteCfg() != null) {
+            File cfg = new File(props.igniteCfg());
 
             if (cfg.isFile() && cfg.canRead()) {
-                configUrl = baseUrl + CONFIG_PREFIX + cfg.getName();
+                cfgUrl = baseUrl + CONFIG_PREFIX + cfg.getName();
 
-                configName = cfg.getName();
+                cfgName = cfg.getName();
             }
         }
         else {
-            configName = "ignite-default-config.xml";
+            cfgName = "ignite-default-config.xml";
 
-            configUrl = baseUrl + DEFAULT_CONFIG + configName;
+            cfgUrl = baseUrl + DEFAULT_CONFIG + cfgName;
         }
     }
 
@@ -98,7 +138,7 @@ public class ResourceProvider {
      * @return Config name.
      */
     public String configName() {
-        return configName;
+        return cfgName;
     }
 
     /**
@@ -119,6 +159,6 @@ public class ResourceProvider {
      * @return Url to config file.
      */
     public String igniteConfigUrl() {
-        return configUrl;
+        return cfgUrl;
     }
 }
\ No newline at end of file


[10/24] ignite git commit: IGNITE-3143 Implemented support for executing Visor tasks via REST HTTP.

Posted by ak...@apache.org.
IGNITE-3143 Implemented support for executing Visor tasks via REST HTTP.


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

Branch: refs/heads/master
Commit: 0c3f5d9b72ce7c911bb9e71ae99b043924318002
Parents: dcfd30e
Author: AKuznetsov <ak...@gridgain.com>
Authored: Mon May 16 18:45:33 2016 +0700
Committer: AKuznetsov <ak...@gridgain.com>
Committed: Mon May 16 18:45:33 2016 +0700

----------------------------------------------------------------------
 .../JettyRestProcessorAbstractSelfTest.java     | 716 ++++++++++++++++++-
 .../rest/JettyRestProcessorSignedSelfTest.java  |   5 +-
 .../JettyRestProcessorUnsignedSelfTest.java     |   5 +-
 .../visor/compute/VisorGatewayTask.java         | 361 ++++++++++
 .../internal/visor/util/VisorTaskUtils.java     |  10 +-
 .../http/jetty/GridJettyJsonConfig.java         | 288 +++++---
 .../http/jetty/GridJettyRestHandler.java        |   2 +-
 .../http/jetty/GridJettyRestProtocol.java       |   2 +-
 8 files changed, 1291 insertions(+), 98 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/0c3f5d9b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
index 4b1d47c..9fd3044 100644
--- a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
+++ b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
@@ -29,27 +29,77 @@ import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.UUID;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.regex.Pattern;
 import net.sf.json.JSONNull;
 import net.sf.json.JSONObject;
 import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheAtomicityMode;
 import org.apache.ignite.cache.CacheMode;
 import org.apache.ignite.cache.CachePeekMode;
+import org.apache.ignite.cache.CacheWriteSynchronizationMode;
 import org.apache.ignite.cache.query.SqlQuery;
 import org.apache.ignite.cache.query.annotations.QuerySqlField;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.FileSystemConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.igfs.IgfsGroupDataBlocksKeyMapper;
+import org.apache.ignite.igfs.IgfsIpcEndpointConfiguration;
 import org.apache.ignite.internal.processors.cache.IgniteCacheProxy;
 import org.apache.ignite.internal.processors.cache.query.GridCacheSqlIndexMetadata;
 import org.apache.ignite.internal.processors.cache.query.GridCacheSqlMetadata;
 import org.apache.ignite.internal.processors.rest.handlers.GridRestCommandHandler;
+import org.apache.ignite.internal.util.lang.GridTuple3;
+import org.apache.ignite.internal.util.typedef.C1;
 import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.internal.util.typedef.P1;
+import org.apache.ignite.internal.util.typedef.internal.SB;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.internal.visor.cache.VisorCacheClearTask;
+import org.apache.ignite.internal.visor.cache.VisorCacheConfigurationCollectorTask;
+import org.apache.ignite.internal.visor.cache.VisorCacheLoadTask;
+import org.apache.ignite.internal.visor.cache.VisorCacheMetadataTask;
+import org.apache.ignite.internal.visor.cache.VisorCacheMetricsCollectorTask;
+import org.apache.ignite.internal.visor.cache.VisorCacheNodesTask;
+import org.apache.ignite.internal.visor.cache.VisorCacheRebalanceTask;
+import org.apache.ignite.internal.visor.cache.VisorCacheResetMetricsTask;
+import org.apache.ignite.internal.visor.cache.VisorCacheStartTask;
+import org.apache.ignite.internal.visor.cache.VisorCacheStopTask;
+import org.apache.ignite.internal.visor.cache.VisorCacheSwapBackupsTask;
+import org.apache.ignite.internal.visor.compute.VisorComputeCancelSessionsTask;
+import org.apache.ignite.internal.visor.compute.VisorComputeResetMetricsTask;
+import org.apache.ignite.internal.visor.compute.VisorComputeToggleMonitoringTask;
+import org.apache.ignite.internal.visor.compute.VisorGatewayTask;
+import org.apache.ignite.internal.visor.debug.VisorThreadDumpTask;
+import org.apache.ignite.internal.visor.file.VisorFileBlockTask;
+import org.apache.ignite.internal.visor.file.VisorLatestTextFilesTask;
+import org.apache.ignite.internal.visor.igfs.VisorIgfsFormatTask;
+import org.apache.ignite.internal.visor.igfs.VisorIgfsProfilerClearTask;
+import org.apache.ignite.internal.visor.igfs.VisorIgfsProfilerTask;
+import org.apache.ignite.internal.visor.igfs.VisorIgfsResetMetricsTask;
+import org.apache.ignite.internal.visor.igfs.VisorIgfsSamplingStateTask;
+import org.apache.ignite.internal.visor.log.VisorLogSearchTask;
+import org.apache.ignite.internal.visor.misc.VisorAckTask;
+import org.apache.ignite.internal.visor.misc.VisorLatestVersionTask;
+import org.apache.ignite.internal.visor.misc.VisorResolveHostNameTask;
+import org.apache.ignite.internal.visor.node.VisorNodeConfigurationCollectorTask;
+import org.apache.ignite.internal.visor.node.VisorNodeDataCollectorTask;
+import org.apache.ignite.internal.visor.node.VisorNodeDataCollectorTaskArg;
+import org.apache.ignite.internal.visor.node.VisorNodeEventsCollectorTask;
+import org.apache.ignite.internal.visor.node.VisorNodeGcTask;
+import org.apache.ignite.internal.visor.node.VisorNodePingTask;
+import org.apache.ignite.internal.visor.node.VisorNodeSuppressedErrorsTask;
+import org.apache.ignite.internal.visor.query.VisorQueryArg;
+import org.apache.ignite.internal.visor.query.VisorQueryCleanupTask;
+import org.apache.ignite.internal.visor.query.VisorQueryNextPageTask;
+import org.apache.ignite.internal.visor.query.VisorQueryTask;
 import org.apache.ignite.lang.IgniteBiPredicate;
+import org.apache.ignite.lang.IgniteBiTuple;
 import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.lang.IgniteUuid;
 import org.apache.ignite.testframework.GridTestUtils;
 
 import static org.apache.ignite.IgniteSystemProperties.IGNITE_JETTY_PORT;
@@ -138,7 +188,7 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
      * @param ptrn Pattern to match.
      */
     @SuppressWarnings("TypeMayBeWeakened")
-    private void jsonEquals(String json, String ptrn) {
+    protected void jsonEquals(String json, String ptrn) {
         assertTrue("JSON mismatch [json=" + json + ", ptrn=" + ptrn + ']', Pattern.matches(ptrn, json));
     }
 
@@ -249,7 +299,7 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
      * @param success Success flag.
      * @return Regex pattern for JSON.
      */
-    private String pattern(String res, boolean success) {
+    protected String pattern(String res, boolean success) {
         return "\\{\\\"error\\\":\\\"" + (!success ? ".+" : "") + "\\\"\\," +
             "\\\"response\\\":" + res + "\\," +
             "\\\"sessionToken\\\":\\\"" + (securityEnabled() && success ? ".+" : "") + "\\\"," +
@@ -1172,6 +1222,414 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
     }
 
     /**
+     * Tests execution of Visor tasks via {@link VisorGatewayTask}.
+     *
+     * @throws Exception If failed.
+     */
+    public void testVisorGateway() throws Exception {
+        ClusterNode locNode = grid(1).localNode();
+
+        final String successRes = pattern(
+            "\\{\\\"error\\\":\\\"\\\",\\\"finished\\\":true,\\\"id\\\":\\\"[^\\\"]+\\\",\\\"result\\\":.+}", true);
+
+        final IgniteUuid cid = grid(1).context().cache().internalCache("person").context().dynamicDeploymentId();
+
+        String ret = content(new VisorGatewayArgument(VisorCacheConfigurationCollectorTask.class)
+            .forNode(locNode)
+            .collection(IgniteUuid.class, cid));
+
+        info("VisorCacheConfigurationCollectorTask result: " + ret);
+
+        assertNotNull(ret);
+        assertTrue(!ret.isEmpty());
+
+        jsonEquals(ret, successRes);
+
+        ret = content(new VisorGatewayArgument(VisorCacheNodesTask.class)
+            .forNode(locNode)
+            .argument("person"));
+
+        info("VisorCacheNodesTask result: " + ret);
+
+        assertNotNull(ret);
+        assertTrue(!ret.isEmpty());
+
+        jsonEquals(ret, successRes);
+
+        ret = content(new VisorGatewayArgument(VisorCacheLoadTask.class)
+            .forNode(locNode)
+            .tuple3(Set.class, Long.class, Object[].class, "person", 0, "null"));
+
+        info("VisorCacheLoadTask result: " + ret);
+
+        assertNotNull(ret);
+        assertTrue(!ret.isEmpty());
+
+        jsonEquals(ret, successRes);
+
+        ret = content(new VisorGatewayArgument(VisorCacheSwapBackupsTask.class)
+            .forNode(locNode)
+            .set(String.class, "person"));
+
+        info("VisorCacheSwapBackupsTask result: " + ret);
+
+        assertNotNull(ret);
+        assertTrue(!ret.isEmpty());
+
+        jsonEquals(ret, successRes);
+
+        ret = content(new VisorGatewayArgument(VisorCacheRebalanceTask.class)
+            .forNode(locNode)
+            .set(String.class, "person"));
+
+        info("VisorCacheRebalanceTask result: " + ret);
+
+        assertNotNull(ret);
+        assertTrue(!ret.isEmpty());
+
+        jsonEquals(ret, successRes);
+
+        ret = content(new VisorGatewayArgument(VisorCacheMetadataTask.class)
+            .forNode(locNode)
+            .argument("person"));
+
+        info("VisorCacheMetadataTask result: " + ret);
+
+        assertNotNull(ret);
+        assertTrue(!ret.isEmpty());
+
+        jsonEquals(ret, successRes);
+
+        ret = content(new VisorGatewayArgument(VisorCacheResetMetricsTask.class)
+            .forNode(locNode)
+            .argument("person"));
+
+        info("VisorCacheResetMetricsTask result: " + ret);
+
+        assertNotNull(ret);
+        assertTrue(!ret.isEmpty());
+
+        jsonEquals(ret, successRes);
+
+        ret = content(new VisorGatewayArgument(VisorIgfsSamplingStateTask.class)
+            .forNode(locNode)
+            .pair(String.class, Boolean.class, "igfs", false));
+
+        info("VisorIgfsSamplingStateTask result: " + ret);
+
+        assertNotNull(ret);
+        assertTrue(!ret.isEmpty());
+
+        jsonEquals(ret, successRes);
+
+        ret = content(new VisorGatewayArgument(VisorIgfsProfilerClearTask.class)
+            .forNode(locNode)
+            .argument("igfs"));
+
+        info("VisorIgfsProfilerClearTask result: " + ret);
+
+        assertNotNull(ret);
+        assertTrue(!ret.isEmpty());
+
+        jsonEquals(ret, successRes);
+
+        ret = content(new VisorGatewayArgument(VisorIgfsProfilerTask.class)
+            .forNode(locNode)
+            .argument("igfs"));
+
+        info("VisorIgfsProfilerTask result: " + ret);
+
+        assertNotNull(ret);
+        assertTrue(!ret.isEmpty());
+
+        jsonEquals(ret, successRes);
+
+        ret = content(new VisorGatewayArgument(VisorIgfsFormatTask.class)
+            .forNode(locNode)
+            .argument("igfs"));
+
+        info("VisorIgfsFormatTask result: " + ret);
+
+        assertNotNull(ret);
+        assertTrue(!ret.isEmpty());
+
+        jsonEquals(ret, successRes);
+
+        ret = content(new VisorGatewayArgument(VisorIgfsResetMetricsTask.class)
+            .forNode(locNode)
+            .set(String.class, "igfs"));
+
+        info("VisorIgfsResetMetricsTask result: " + ret);
+
+        assertNotNull(ret);
+        assertTrue(!ret.isEmpty());
+
+        jsonEquals(ret, successRes);
+
+        ret = content(new VisorGatewayArgument(VisorThreadDumpTask.class)
+            .forNode(locNode));
+
+        info("VisorThreadDumpTask result: " + ret);
+
+        assertNotNull(ret);
+        assertTrue(!ret.isEmpty());
+
+        jsonEquals(ret, successRes);
+
+        ret = content(new VisorGatewayArgument(VisorLatestTextFilesTask.class)
+            .forNode(locNode)
+            .pair(String.class, String.class, "", ""));
+
+        info("VisorLatestTextFilesTask result: " + ret);
+
+        assertNotNull(ret);
+        assertTrue(!ret.isEmpty());
+
+        jsonEquals(ret, successRes);
+
+        ret = content(new VisorGatewayArgument(VisorLatestVersionTask.class)
+            .forNode(locNode));
+
+        info("VisorLatestVersionTask result: " + ret);
+
+        assertNotNull(ret);
+        assertTrue(!ret.isEmpty());
+
+        jsonEquals(ret, successRes);
+
+        ret = content(new VisorGatewayArgument(VisorFileBlockTask.class)
+            .forNode(locNode)
+            .argument(VisorFileBlockTask.VisorFileBlockArg.class, "", 0L, 1, 0L));
+
+        info("VisorFileBlockTask result: " + ret);
+
+        assertNotNull(ret);
+        assertTrue(!ret.isEmpty());
+
+        jsonEquals(ret, successRes);
+
+        ret = content(new VisorGatewayArgument(VisorNodePingTask.class)
+            .forNode(locNode)
+            .argument(UUID.class, locNode.id()));
+
+        info("VisorNodePingTask result: " + ret);
+
+        assertNotNull(ret);
+        assertTrue(!ret.isEmpty());
+
+        jsonEquals(ret, successRes);
+
+        ret = content(new VisorGatewayArgument(VisorNodeConfigurationCollectorTask.class)
+            .forNode(locNode));
+
+        info("VisorNodeConfigurationCollectorTask result: " + ret);
+
+        assertNotNull(ret);
+        assertTrue(!ret.isEmpty());
+
+        jsonEquals(ret, successRes);
+
+        ret = content(new VisorGatewayArgument(VisorComputeResetMetricsTask.class)
+            .forNode(locNode));
+
+        info("VisorComputeResetMetricsTask result: " + ret);
+
+        assertNotNull(ret);
+        assertTrue(!ret.isEmpty());
+
+        jsonEquals(ret, successRes);
+
+        ret = content(new VisorGatewayArgument(VisorQueryTask.class)
+            .forNode(locNode)
+            .argument(VisorQueryArg.class, "person", URLEncoder.encode("select * from Person"), false, 1));
+
+        info("VisorQueryTask result: " + ret);
+
+        assertNotNull(ret);
+        assertTrue(!ret.isEmpty());
+
+        jsonEquals(ret, successRes);
+
+        JSONObject json = JSONObject.fromObject(ret);
+
+        final String qryId = (String)((Map)((Map)((Map)json.get("response")).get("result")).get("value")).get("queryId");
+
+        ret = content(new VisorGatewayArgument(VisorQueryNextPageTask.class)
+            .forNode(locNode)
+            .pair(String.class, Integer.class, qryId, 1));
+
+        info("VisorQueryNextPageTask result: " + ret);
+
+        assertNotNull(ret);
+        assertTrue(!ret.isEmpty());
+
+        jsonEquals(ret, successRes);
+
+        ret = content(new VisorGatewayArgument(VisorQueryCleanupTask.class)
+            .map(UUID.class, Set.class, F.asMap(locNode.id(), qryId)));
+
+        info("VisorQueryCleanupTask result: " + ret);
+
+        assertNotNull(ret);
+        assertTrue(!ret.isEmpty());
+
+        jsonEquals(ret, successRes);
+
+        ret = content(new VisorGatewayArgument(VisorResolveHostNameTask.class)
+            .forNode(locNode));
+
+        info("VisorResolveHostNameTask result: " + ret);
+
+        assertNotNull(ret);
+        assertTrue(!ret.isEmpty());
+
+        jsonEquals(ret, successRes);
+
+        // Multinode tasks
+
+        ret = content(new VisorGatewayArgument(VisorComputeCancelSessionsTask.class)
+            .map(UUID.class, Set.class, new HashMap()));
+
+        info("VisorComputeCancelSessionsTask result: " + ret);
+
+        assertNotNull(ret);
+        assertTrue(!ret.isEmpty());
+
+        jsonEquals(ret, successRes);
+
+        ret = content(new VisorGatewayArgument(VisorCacheMetricsCollectorTask.class)
+            .pair(Boolean.class, Set.class, false, "person"));
+
+        info("VisorCacheMetricsCollectorTask result: " + ret);
+
+        ret = content(new VisorGatewayArgument(VisorCacheMetricsCollectorTask.class)
+            .forNodes(grid(1).cluster().nodes())
+            .pair(Boolean.class, Set.class, false, "person"));
+
+        info("VisorCacheMetricsCollectorTask (with nodes) result: " + ret);
+
+        assertNotNull(ret);
+        assertTrue(!ret.isEmpty());
+
+        jsonEquals(ret, successRes);
+
+        ret = content(new VisorGatewayArgument(VisorLogSearchTask.class)
+            .argument(VisorLogSearchTask.VisorLogSearchArg.class, ".", ".", "abrakodabra.txt", 1));
+
+        info("VisorLogSearchTask result: " + ret);
+
+        assertNotNull(ret);
+        assertTrue(!ret.isEmpty());
+
+        jsonEquals(ret, successRes);
+
+        ret = content(new VisorGatewayArgument(VisorNodeGcTask.class));
+
+        info("VisorNodeGcTask result: " + ret);
+
+        assertNotNull(ret);
+        assertTrue(!ret.isEmpty());
+
+        jsonEquals(ret, successRes);
+
+        ret = content(new VisorGatewayArgument(VisorAckTask.class)
+            .argument("MSG"));
+
+        info("VisorAckTask result: " + ret);
+
+        assertNotNull(ret);
+        assertTrue(!ret.isEmpty());
+
+        jsonEquals(ret, successRes);
+
+        ret = content(new VisorGatewayArgument(VisorNodeEventsCollectorTask.class)
+            .argument(VisorNodeEventsCollectorTask.VisorNodeEventsCollectorTaskArg.class,
+                "null", "null", "null", "taskName", "null"));
+
+        info("VisorNodeEventsCollectorTask result: " + ret);
+
+        assertNotNull(ret);
+        assertTrue(!ret.isEmpty());
+
+        jsonEquals(ret, successRes);
+
+        ret = content(new VisorGatewayArgument(VisorNodeDataCollectorTask.class)
+            .argument(VisorNodeDataCollectorTaskArg.class, false,
+                "CONSOLE_" + UUID.randomUUID(), UUID.randomUUID(), 10, false));
+
+        info("VisorNodeDataCollectorTask result: " + ret);
+
+        assertNotNull(ret);
+        assertTrue(!ret.isEmpty());
+
+        jsonEquals(ret, successRes);
+
+        ret = content(new VisorGatewayArgument(VisorComputeToggleMonitoringTask.class)
+            .pair(String.class, Boolean.class, UUID.randomUUID(), false));
+
+        info("VisorComputeToggleMonitoringTask result: " + ret);
+
+        assertNotNull(ret);
+        assertTrue(!ret.isEmpty());
+
+        jsonEquals(ret, successRes);
+
+        ret = content(new VisorGatewayArgument(VisorNodeSuppressedErrorsTask.class)
+            .map(UUID.class, Long.class, new HashMap()));
+
+        info("VisorNodeSuppressedErrorsTask result: " + ret);
+
+        assertNotNull(ret);
+        assertTrue(!ret.isEmpty());
+
+        jsonEquals(ret, successRes);
+
+        ret = content(new VisorGatewayArgument(VisorCacheClearTask.class)
+            .forNode(locNode)
+            .argument("person"));
+
+        info("VisorCacheClearTask result: " + ret);
+
+        assertNotNull(ret);
+        assertTrue(!ret.isEmpty());
+
+        jsonEquals(ret, successRes);
+
+        /** Spring XML to start cache via Visor task. */
+        final String START_CACHE =
+            "<beans xmlns=\"http://www.springframework.org/schema/beans\"\n" +
+                    "    xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" +
+                    "    xsi:schemaLocation=\"http://www.springframework.org/schema/beans\n" +
+                    "        http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\">\n" +
+                    "    <bean id=\"cacheConfiguration\" class=\"org.apache.ignite.configuration.CacheConfiguration\">\n" +
+                    "        <property name=\"cacheMode\" value=\"PARTITIONED\"/>\n" +
+                    "        <property name=\"name\" value=\"c\"/>\n" +
+                    "   </bean>\n" +
+                    "</beans>";
+
+        ret = content(new VisorGatewayArgument(VisorCacheStartTask.class)
+            .argument(VisorCacheStartTask.VisorCacheStartArg.class, false, "person2", URLEncoder.encode(START_CACHE)));
+
+        info("VisorCacheStartTask result: " + ret);
+
+        assertNotNull(ret);
+        assertTrue(!ret.isEmpty());
+
+        jsonEquals(ret, successRes);
+
+        ret = content(new VisorGatewayArgument(VisorCacheStopTask.class)
+            .forNode(locNode)
+            .argument(String.class, "c"));
+
+        info("VisorCacheStopTask result: " + ret);
+
+        assertNotNull(ret);
+        assertTrue(!ret.isEmpty());
+
+        jsonEquals(ret, successRes);
+    }
+
+    /**
      * @throws Exception If failed.
      */
     public void testVersion() throws Exception {
@@ -1473,6 +1931,10 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
         assertFalse(queryCursorFound());
     }
 
+    /**
+     * @return Signature.
+     * @throws Exception If failed.
+     */
     protected abstract String signature() throws Exception;
 
     /**
@@ -1500,6 +1962,7 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
      */
     private void initCache() {
         CacheConfiguration<Integer, Person> personCacheCfg = new CacheConfiguration<>("person");
+
         personCacheCfg.setIndexedTypes(Integer.class, Person.class);
 
         IgniteCache<Integer, Person> personCache = grid(0).getOrCreateCache(personCacheCfg);
@@ -1615,4 +2078,251 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
             return n.id().equals(nid);
         }
     }
+
+    /**
+     * Helper for build {@link VisorGatewayTask} arguments.
+     */
+    public static class VisorGatewayArgument extends HashMap<String, String> {
+        /** Latest argument index. */
+        private int idx = 3;
+
+        /**
+         * Construct helper object.
+         *
+         * @param cls Class of executed task.
+         */
+        public VisorGatewayArgument(Class cls) {
+            super(F.asMap(
+                "cmd", GridRestCommand.EXE.key(),
+                "name", VisorGatewayTask.class.getName(),
+                "p1", "null",
+                "p2", cls.getName()
+            ));
+        }
+
+        /**
+         * Execute task on node.
+         *
+         * @param node Node.
+         * @return This helper for chaining method calls.
+         */
+        public VisorGatewayArgument forNode(ClusterNode node) {
+            put("p1", node.id().toString());
+
+            return this;
+        }
+
+        /**
+         * Prepare list of node IDs.
+         *
+         * @param nodes Collection of nodes.
+         * @return This helper for chaining method calls.
+         */
+        public VisorGatewayArgument forNodes(Collection<ClusterNode> nodes) {
+            put("p1", concat(F.transform(nodes, new C1<ClusterNode, UUID>() {
+                /** {@inheritDoc} */
+                @Override public UUID apply(ClusterNode node) {
+                    return node.id();
+                }
+            }).toArray(), ";"));
+
+            return this;
+        }
+
+        /**
+         * Add string argument.
+         *
+         * @param val Value.
+         * @return This helper for chaining method calls.
+         */
+        public VisorGatewayArgument argument(String val) {
+            put("p" + idx++, String.class.getName());
+            put("p" + idx++, val);
+
+            return this;
+        }
+
+        /**
+         * Add custom class argument.
+         *
+         * @param cls Class.
+         * @param vals Values.
+         * @return This helper for chaining method calls.
+         */
+        public VisorGatewayArgument argument(Class cls, Object ... vals) {
+            put("p" + idx++, cls.getName());
+
+            for (Object val : vals)
+                put("p" + idx++, val != null ? val.toString() : null);
+
+            return this;
+        }
+
+        /**
+         * Add collection argument.
+         *
+         * @param cls Class.
+         * @param vals Values.
+         * @return This helper for chaining method calls.
+         */
+        public VisorGatewayArgument collection(Class cls, Object ... vals) {
+            put("p" + idx++, Collection.class.getName());
+            put("p" + idx++, cls.getName());
+            put("p" + idx++, concat(vals, ";"));
+
+            return this;
+        }
+
+        /**
+         * Add tuple argument.
+         *
+         * @param keyCls Key class.
+         * @param valCls Values class.
+         * @param key Key.
+         * @param val Value.
+         * @return This helper for chaining method calls.
+         */
+        public VisorGatewayArgument pair(Class keyCls, Class valCls, Object key, Object val) {
+            put("p" + idx++, IgniteBiTuple.class.getName());
+            put("p" + idx++, keyCls.getName());
+            put("p" + idx++, valCls.getName());
+            put("p" + idx++, key != null ? key.toString() : "null");
+            put("p" + idx++, val != null ? val.toString() : "null");
+
+            return this;
+        }
+
+        /**
+         * Add tuple argument.
+         *
+         * @param firstCls Class of first argument.
+         * @param secondCls Class of second argument.
+         * @param thirdCls Class of third argument.
+         * @param first First argument.
+         * @param second Second argument.
+         * @param third Third argument.
+         * @return This helper for chaining method calls.
+         */
+        public VisorGatewayArgument tuple3(Class firstCls, Class secondCls, Class thirdCls,
+            Object first, Object second, Object third) {
+            put("p" + idx++, GridTuple3.class.getName());
+            put("p" + idx++, firstCls.getName());
+            put("p" + idx++, secondCls.getName());
+            put("p" + idx++, thirdCls.getName());
+            put("p" + idx++, first != null ? first.toString() : "null");
+            put("p" + idx++, second != null ? second.toString() : "null");
+            put("p" + idx++, third != null ? third.toString() : "null");
+
+            return this;
+        }
+
+        /**
+         * Add set argument.
+         *
+         * @param cls Class.
+         * @param vals Values.
+         * @return This helper for chaining method calls.
+         */
+        public VisorGatewayArgument set(Class cls, Object ... vals) {
+            put("p" + idx++, Set.class.getName());
+            put("p" + idx++, cls.getName());
+            put("p" + idx++, concat(vals, ";"));
+
+            return this;
+        }
+
+        /**
+         * Add map argument.
+         *
+         * @param keyCls Key class.
+         * @param valCls Value class.
+         * @param map Map.
+         */
+        public VisorGatewayArgument map(Class keyCls, Class valCls, Map<?, ?> map) {
+            put("p" + idx++, Map.class.getName());
+            put("p" + idx++, keyCls.getName());
+            put("p" + idx++, valCls.getName());
+
+            SB sb = new SB();
+
+            boolean first = true;
+
+            for (Map.Entry<?, ?> entry : map.entrySet()) {
+                if (!first)
+                    sb.a(";");
+
+                sb.a(entry.getKey());
+
+                if (entry.getValue() != null)
+                    sb.a("=").a(entry.getValue());
+
+                first = false;
+            }
+
+            put("p" + idx++, URLEncoder.encode(sb.toString()));
+
+            return this;
+        }
+
+        /**
+         * Concat object with delimiter.
+         *
+         * @param vals Values.
+         * @param delim Delimiter.
+         */
+        private static String concat(Object[] vals, String delim) {
+            SB sb = new SB();
+
+            boolean first = true;
+
+            for (Object val : vals) {
+                if (!first)
+                    sb.a(delim);
+
+                sb.a(val);
+
+                first = false;
+            }
+
+            return sb.toString();
+        };
+    }
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        CacheConfiguration cacheIgfs_data = new CacheConfiguration();
+
+        cacheIgfs_data.setName("igfs-data");
+        cacheIgfs_data.setCacheMode(CacheMode.PARTITIONED);
+        cacheIgfs_data.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
+        cacheIgfs_data.setBackups(0);
+
+        cacheIgfs_data.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
+
+        cacheIgfs_data.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(512));
+
+        CacheConfiguration cacheIgfs_meta = new CacheConfiguration();
+
+        cacheIgfs_meta.setName("igfs-meta");
+        cacheIgfs_meta.setCacheMode(CacheMode.REPLICATED);
+        cacheIgfs_meta.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
+
+        cacheIgfs_meta.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
+
+        cfg.setCacheConfiguration(cfg.getCacheConfiguration()[0], cacheIgfs_data, cacheIgfs_meta);
+
+        FileSystemConfiguration igfs = new FileSystemConfiguration();
+
+        igfs.setName("igfs");
+        igfs.setDataCacheName("igfs-data");
+        igfs.setMetaCacheName("igfs-meta");
+
+        igfs.setIpcEndpointConfiguration(new IgfsIpcEndpointConfiguration());
+
+        cfg.setFileSystemConfiguration(igfs);
+
+        return cfg;
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/0c3f5d9b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorSignedSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorSignedSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorSignedSelfTest.java
index cf9fa9e..ad00f52 100644
--- a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorSignedSelfTest.java
+++ b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorSignedSelfTest.java
@@ -78,10 +78,7 @@ public class JettyRestProcessorSignedSelfTest extends JettyRestProcessorAbstract
         assertEquals(200, ((HttpURLConnection)conn).getResponseCode());
     }
 
-    /**
-     * @return Signature.
-     * @throws Exception If failed.
-     */
+    /** {@inheritDoc} */
     @Override protected String signature() throws Exception {
         long ts = U.currentTimeMillis();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/0c3f5d9b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorUnsignedSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorUnsignedSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorUnsignedSelfTest.java
index e510ae8..988cedf 100644
--- a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorUnsignedSelfTest.java
+++ b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorUnsignedSelfTest.java
@@ -26,10 +26,7 @@ public class JettyRestProcessorUnsignedSelfTest extends JettyRestProcessorAbstra
         return 8091;
     }
 
-    /**
-     * @return Signature.
-     * @throws Exception If failed.
-     */
+    /** {@inheritDoc} */
     @Override protected String signature() throws Exception {
         return null;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/0c3f5d9b/modules/core/src/main/java/org/apache/ignite/internal/visor/compute/VisorGatewayTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/compute/VisorGatewayTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/compute/VisorGatewayTask.java
new file mode 100644
index 0000000..c59d299
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/compute/VisorGatewayTask.java
@@ -0,0 +1,361 @@
+/*
+ * 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.visor.compute;
+
+import java.lang.reflect.Constructor;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.compute.ComputeJob;
+import org.apache.ignite.compute.ComputeJobAdapter;
+import org.apache.ignite.compute.ComputeJobResult;
+import org.apache.ignite.compute.ComputeJobResultPolicy;
+import org.apache.ignite.compute.ComputeTask;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.processors.task.GridInternal;
+import org.apache.ignite.internal.util.lang.GridTuple3;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.visor.VisorTaskArgument;
+import org.apache.ignite.lang.IgniteBiTuple;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.resources.IgniteInstanceResource;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Task to run Visor tasks through http REST.
+ */
+@GridInternal
+public class VisorGatewayTask implements ComputeTask<Object[], Object> {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** Auto-injected grid instance. */
+    @IgniteInstanceResource
+    protected transient IgniteEx ignite;
+
+    /** {@inheritDoc} */
+    @Nullable @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid,
+        @Nullable Object[] args) throws IgniteException {
+        assert args != null;
+        assert args.length >= 2;
+
+        return Collections.singletonMap(new VisorGatewayJob(args), ignite.localNode());
+    }
+
+    /** {@inheritDoc} */
+    @Override public ComputeJobResultPolicy result(ComputeJobResult res,
+        List<ComputeJobResult> rcvd) throws IgniteException {
+        // Task should handle exceptions in reduce method.
+        return ComputeJobResultPolicy.WAIT;
+    }
+
+    /** {@inheritDoc} */
+    @Nullable @Override public Object reduce(List<ComputeJobResult> results) throws IgniteException {
+        assert results.size() == 1;
+
+        ComputeJobResult res = F.first(results);
+
+        assert res != null;
+
+        IgniteException ex = res.getException();
+
+        if (ex != null)
+            throw ex;
+
+        return res.getData();
+    }
+
+    /**
+     * Job to run Visor tasks through http REST.
+     */
+    private static class VisorGatewayJob extends ComputeJobAdapter {
+        /** */
+        private static final long serialVersionUID = 0L;
+
+        /** Auto-injected grid instance. */
+        @IgniteInstanceResource
+        protected transient IgniteEx ignite;
+
+        /** Arguments count. */
+        private final int argsCnt;
+
+        /**
+         * Create job with specified argument.
+         *
+         * @param args Job argument.
+         */
+        VisorGatewayJob(@Nullable Object[] args) {
+            super(args);
+
+            assert args != null;
+
+            argsCnt = args.length;
+        }
+
+        /**
+         * Cast argument to target class.
+         *
+         * @param cls Class.
+         * @param idx Argument index.
+         */
+        @Nullable private Object toObject(Class cls, int idx) throws ClassNotFoundException {
+            String arg = argument(idx);
+
+            if (cls == Collection.class || cls == Set.class) {
+                Class<?> itemsCls = Class.forName(arg);
+
+                Collection<Object> res = cls == Collection.class ? new ArrayList<>() : new HashSet<>();
+
+                String items = argument(idx + 1);
+
+                if (items != null) {
+                    for (String item : items.split(";"))
+                        res.add(toSimpleObject(itemsCls, item));
+                }
+
+                return res;
+            }
+
+            if (cls == IgniteBiTuple.class) {
+                Class<?> keyCls = Class.forName(arg);
+
+                String valClsName = argument(idx + 1);
+
+                assert valClsName != null;
+
+                Class<?> valCls = Class.forName(valClsName);
+
+                return new IgniteBiTuple<>(toSimpleObject(keyCls, (String)argument(idx + 2)),
+                    toSimpleObject(valCls, (String)argument(idx + 3)));
+            }
+
+            if (cls == Map.class) {
+                Class<?> keyCls = Class.forName(arg);
+
+                String valClsName = argument(idx + 1);
+
+                assert valClsName != null;
+
+                Class<?> valCls = Class.forName(valClsName);
+
+                Map<Object, Object> res = new HashMap<>();
+
+                String entries = argument(idx + 2);
+
+                if (entries != null) {
+                    for (String entry : entries.split(";")) {
+                        if (entry.length() > 0) {
+                            String[] values = entry.split("=");
+
+                            assert values.length >= 1;
+
+                            res.put(toSimpleObject(keyCls, values[0]),
+                                    values.length > 1 ? toSimpleObject(valCls, values[1]) : null);
+                        }
+                    }
+                }
+
+                return res;
+            }
+
+            if (cls == GridTuple3.class) {
+                String v2ClsName = argument(idx + 1);
+                String v3ClsName = argument(idx + 2);
+
+                assert v2ClsName != null;
+                assert v3ClsName != null;
+
+                Class<?> v1Cls = Class.forName(arg);
+                Class<?> v2Cls = Class.forName(v2ClsName);
+                Class<?> v3Cls = Class.forName(v3ClsName);
+
+                return new GridTuple3<>(toSimpleObject(v1Cls, (String)argument(idx + 3)), toSimpleObject(v2Cls,
+                    (String)argument(idx + 4)), toSimpleObject(v3Cls, (String)argument(idx + 5)));
+            }
+
+            return toSimpleObject(cls, arg);
+        }
+
+        /**
+         * Cast from string representation to target class.
+         *
+         * @param cls Target class.
+         * @return Object constructed from string.
+         */
+        @Nullable private Object toSimpleObject(Class cls, String val) {
+            if (val == null  || val.equals("null"))
+                return null;
+
+            if (String.class == cls)
+                return val;
+
+            if (Boolean.class == cls || Boolean.TYPE == cls)
+                return Boolean.parseBoolean(val);
+
+            if (Integer.class == cls || Integer.TYPE == cls)
+                return Integer.parseInt(val);
+
+            if (Long.class == cls || Long.TYPE == cls)
+                return Long.parseLong(val);
+
+            if (UUID.class == cls)
+                return UUID.fromString(val);
+
+            if (IgniteUuid.class == cls)
+                return IgniteUuid.fromString(val);
+
+            if (Byte.class == cls || Byte.TYPE == cls)
+                return Byte.parseByte(val);
+
+            if (Short.class == cls || Short.TYPE == cls)
+                return Short.parseShort(val);
+
+            if (Float.class == cls || Float.TYPE == cls)
+                return Float.parseFloat(val);
+
+            if (Double.class == cls || Double.TYPE == cls)
+                return Double.parseDouble(val);
+
+            if (BigDecimal.class == cls)
+                return new BigDecimal(val);
+
+            if (Collection.class == cls)
+                return Arrays.asList(val.split(";"));
+
+            if (Set.class == cls)
+                return new HashSet<>(Arrays.asList(val.split(";")));
+
+            if (Object[].class == cls)
+                return val.split(";");
+
+            if (byte[].class == cls) {
+                String[] els = val.split(";");
+
+                if (els.length == 0 || (els.length == 1 && els[0].length() == 0))
+                    return new byte[0];
+
+                byte[] res = new byte[els.length];
+
+                for (int i = 0; i < els.length; i ++)
+                    res[i] =  Byte.valueOf(els[i]);
+
+                return res;
+            }
+
+            return val;
+        }
+
+        /**
+         * Check if class is not a complex bean.
+         *
+         * @param cls Target class.
+         * @return {@code True} if class is primitive or build-in java type or IgniteUuid.
+         */
+        private static boolean isBuildInObject(Class cls) {
+            return cls.isPrimitive() || cls.getName().startsWith("java.") ||
+                IgniteUuid.class == cls || IgniteBiTuple.class == cls || GridTuple3.class == cls;
+        }
+
+        /** {@inheritDoc} */
+        @SuppressWarnings("unchecked")
+        @Override public Object execute() throws IgniteException {
+            String nidsArg = argument(0);
+            String taskName = argument(1);
+
+            Object jobArgs = null;
+
+            if (argsCnt > 2) {
+                String argClsName = argument(2);
+
+                assert argClsName != null;
+
+                try {
+                    Class<?> argCls = Class.forName(argClsName);
+
+                    if (argCls == Void.class)
+                        jobArgs = null;
+                    else if (isBuildInObject(argCls))
+                        jobArgs = toObject(argCls, 3);
+                    else {
+                        int beanArgsCnt = argsCnt - 3;
+
+                        for (Constructor ctor : argCls.getDeclaredConstructors()) {
+                            Class[] types = ctor.getParameterTypes();
+
+                            if (types.length == beanArgsCnt) {
+                                Object[] initargs = new Object[beanArgsCnt];
+
+                                for (int i = 0; i < beanArgsCnt; i++) {
+                                    String val = argument(i + 3);
+
+                                    initargs[i] = toSimpleObject(types[i], val);
+                                }
+
+                                jobArgs = ctor.newInstance(initargs);
+
+                                break;
+                            }
+                        }
+
+                        if (jobArgs == null)
+                            throw new IgniteException("Failed to execute task [task name=" + taskName + "]");
+                    }
+                }
+                catch (Exception e) {
+                    throw new IgniteException("Failed to execute task [task name=" + taskName + "]", e);
+                }
+            }
+
+            final Collection<UUID> nids;
+
+            if (nidsArg == null || nidsArg.equals("null") || nidsArg.equals("")) {
+                Collection<ClusterNode> nodes = ignite.cluster().nodes();
+
+                nids = new ArrayList<>(nodes.size());
+
+                for (ClusterNode node : nodes)
+                    nids.add(node.id());
+            }
+            else {
+                String[] items = nidsArg.split(";");
+
+                nids = new ArrayList<>(items.length);
+
+                for (String item : items) {
+                    try {
+                        nids.add(UUID.fromString(item));
+                    } catch (IllegalArgumentException ignore) {
+                        // No-op.
+                    }
+                }
+            }
+
+            return ignite.compute().execute(taskName, new VisorTaskArgument<>(nids, jobArgs, false));
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0c3f5d9b/modules/core/src/main/java/org/apache/ignite/internal/visor/util/VisorTaskUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/util/VisorTaskUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/util/VisorTaskUtils.java
index 9be8c35..7eebbf1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/util/VisorTaskUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/util/VisorTaskUtils.java
@@ -70,6 +70,7 @@ import org.jetbrains.annotations.Nullable;
 
 import static java.lang.System.getProperty;
 import static org.apache.ignite.configuration.FileSystemConfiguration.DFLT_IGFS_LOG_DIR;
+import static org.apache.ignite.events.EventType.EVTS_DISCOVERY;
 import static org.apache.ignite.events.EventType.EVT_CLASS_DEPLOY_FAILED;
 import static org.apache.ignite.events.EventType.EVT_JOB_CANCELLED;
 import static org.apache.ignite.events.EventType.EVT_JOB_FAILED;
@@ -392,8 +393,13 @@ public class VisorTaskUtils {
      */
     public static Collection<VisorGridEvent> collectEvents(Ignite ignite, String evtOrderKey, String evtThrottleCntrKey,
         final boolean all) {
-        return collectEvents(ignite, evtOrderKey, evtThrottleCntrKey, all ? VISOR_ALL_EVTS : VISOR_NON_TASK_EVTS,
-            EVT_MAPPER);
+        int[] evtTypes = all ? VISOR_ALL_EVTS : VISOR_NON_TASK_EVTS;
+
+        // Collect discovery events for Web Console.
+        if (evtOrderKey.startsWith("CONSOLE_"))
+            evtTypes = concat(evtTypes, EVTS_DISCOVERY);
+
+        return collectEvents(ignite, evtOrderKey, evtThrottleCntrKey, evtTypes, EVT_MAPPER);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/0c3f5d9b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyJsonConfig.java
----------------------------------------------------------------------
diff --git a/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyJsonConfig.java b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyJsonConfig.java
index 0adbc14..c2795a4 100644
--- a/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyJsonConfig.java
+++ b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyJsonConfig.java
@@ -17,42 +17,64 @@
 
 package org.apache.ignite.internal.processors.rest.protocols.http.jetty;
 
+import java.lang.reflect.Method;
 import java.text.DateFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
 import java.util.UUID;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
 import net.sf.json.JSONObject;
 import net.sf.json.JsonConfig;
 import net.sf.json.processors.JsonBeanProcessor;
 import net.sf.json.processors.JsonBeanProcessorMatcher;
 import net.sf.json.processors.JsonValueProcessor;
-
-import java.util.*;
 import net.sf.json.processors.JsonValueProcessorMatcher;
+import org.apache.ignite.IgniteLogger;
 import org.apache.ignite.internal.processors.cache.query.GridCacheSqlIndexMetadata;
 import org.apache.ignite.internal.processors.cache.query.GridCacheSqlMetadata;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.internal.visor.cache.VisorCache;
+import org.apache.ignite.lang.IgniteBiTuple;
+import org.apache.ignite.lang.IgniteUuid;
 
 /**
  * Jetty protocol json configuration.
  */
-public class GridJettyJsonConfig extends JsonConfig {
+class GridJettyJsonConfig extends JsonConfig {
+    /** Logger. */
+    private final IgniteLogger log;
+
     /**
-     * Constructs default jetty json config.
+     * Class for finding a matching JsonBeanProcessor.
      */
-    public GridJettyJsonConfig() {
-        registerJsonValueProcessor(UUID.class, new UUIDToStringJsonProcessor());
-        registerJsonValueProcessor(Date.class, new DateToStringJsonProcessor());
-        registerJsonValueProcessor(java.sql.Date.class, new DateToStringJsonProcessor());
-
-        registerJsonBeanProcessor(GridCacheSqlMetadata.class, new GridCacheSqlMetadataBeanProcessor());
-        registerJsonValueProcessor(GridCacheSqlIndexMetadata.class, new GridCacheSqlIndexMetadataToJson());
+    private static final JsonBeanProcessorMatcher LESS_NAMING_BEAN_MATCHER = new JsonBeanProcessorMatcher() {
+        /** {@inheritDoc} */
+        @Override public Object getMatch(Class target, Set keys) {
+            return GridJettyJsonConfig.getMatch(target, keys);
+        }
+    };
 
-        setJsonBeanProcessorMatcher(new GridJettyJsonBeanProcessorMatcher());
-        setJsonValueProcessorMatcher(new GridJettyJsonValueProcessorMatcher());
-    }
+    /**
+     * Class for finding a matching JsonValueProcessor.
+     */
+    private static final JsonValueProcessorMatcher LESS_NAMING_VALUE_MATCHER = new JsonValueProcessorMatcher() {
+        /** {@inheritDoc} */
+        @Override public Object getMatch(Class target, Set keys) {
+            return GridJettyJsonConfig.getMatch(target, keys);
+        }
+    };
 
     /**
      * Helper class for simple to-string conversion for {@link UUID}.
      */
-    private static class UUIDToStringJsonProcessor implements JsonValueProcessor {
+    private static JsonValueProcessor UUID_PROCESSOR = new JsonValueProcessor() {
         /** {@inheritDoc} */
         @Override public Object processArrayValue(Object val, JsonConfig jsonCfg) {
             if (val == null)
@@ -68,128 +90,228 @@ public class GridJettyJsonConfig extends JsonConfig {
         @Override public Object processObjectValue(String key, Object val, JsonConfig jsonCfg) {
             return processArrayValue(val, jsonCfg);
         }
-    }
+    };
 
     /**
-     * Helper class for simple to-string conversion for {@link Date}.
+     * Helper class for simple to-string conversion for {@link UUID}.
      */
-    private static class DateToStringJsonProcessor implements JsonValueProcessor {
-        private final DateFormat enUsFormat
-            =  DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT, Locale.US);
-
+    private static JsonValueProcessor IGNITE_BI_TUPLE_PROCESSOR = new JsonValueProcessor() {
         /** {@inheritDoc} */
-        @Override public synchronized Object processArrayValue(Object val, JsonConfig jsonCfg) {
+        @Override public Object processArrayValue(Object val, JsonConfig jsonCfg) {
             if (val == null)
                 return new JSONObject(true);
 
-            if (val instanceof Date)
-                return enUsFormat.format(val);
+            if (val instanceof IgniteBiTuple) {
+                IgniteBiTuple t2 = (IgniteBiTuple)val;
+
+                final JSONObject ret = new JSONObject();
+
+                ret.element("key", t2.getKey(), jsonCfg);
+                ret.element("value", t2.getValue(), jsonCfg);
+
+                return ret;
+            }
 
             throw new UnsupportedOperationException("Serialize value to json is not supported: " + val);
         }
 
         /** {@inheritDoc} */
-        @Override public synchronized Object processObjectValue(String key, Object val, JsonConfig jsonCfg) {
+        @Override public Object processObjectValue(String key, Object val, JsonConfig jsonCfg) {
             return processArrayValue(val, jsonCfg);
         }
-    }
+    };
 
     /**
-     * Helper class for simple to-json conversion for {@link GridCacheSqlMetadata}.
+     * Helper class for simple to-string conversion for {@link IgniteUuid}.
      */
-    private static class GridCacheSqlMetadataBeanProcessor implements JsonBeanProcessor {
+    private static JsonValueProcessor IGNITE_UUID_PROCESSOR = new JsonValueProcessor() {
         /** {@inheritDoc} */
-        @Override public JSONObject processBean(Object bean, JsonConfig jsonCfg) {
-            if (bean == null)
+        @Override public Object processArrayValue(Object val, JsonConfig jsonCfg) {
+            if (val == null)
                 return new JSONObject(true);
 
-            if (bean instanceof GridCacheSqlMetadata) {
-                GridCacheSqlMetadata r = (GridCacheSqlMetadata) bean;
+            if (val instanceof IgniteUuid)
+                return val.toString();
 
-                return new JSONObject()
-                    .element("cacheName", r.cacheName(), jsonCfg)
-                    .element("types", r.types(), jsonCfg)
-                    .element("keyClasses", r.keyClasses(), jsonCfg)
-                    .element("valClasses", r.valClasses(), jsonCfg)
-                    .element("fields", r.fields(), jsonCfg)
-                    .element("indexes", r.indexes(), jsonCfg);
-            }
+            throw new UnsupportedOperationException("Serialize value to json is not supported: " + val);
+        }
 
-            throw new UnsupportedOperationException("Serialize bean to json is not supported: " + bean);
+        /** {@inheritDoc} */
+        @Override public Object processObjectValue(String key, Object val, JsonConfig jsonCfg) {
+            return processArrayValue(val, jsonCfg);
         }
-    }
+    };
 
     /**
-     * Helper class for simple to-json conversion for {@link GridCacheSqlIndexMetadata}.
+     * Helper class for simple to-string conversion for {@link Date}.
      */
-    private static class GridCacheSqlIndexMetadataToJson implements JsonValueProcessor {
+    private static JsonValueProcessor DATE_PROCESSOR = new JsonValueProcessor() {
+        /** Thread local US date format. */
+        private final ThreadLocal<DateFormat> dateFmt = new ThreadLocal<DateFormat>() {
+            @Override protected DateFormat initialValue() {
+                return DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT, Locale.US);
+            }
+        };
+
         /** {@inheritDoc} */
-        @Override public Object processArrayValue(Object val, JsonConfig jsonCfg) {
+        @Override public synchronized Object processArrayValue(Object val, JsonConfig jsonCfg) {
             if (val == null)
                 return new JSONObject(true);
 
-            if (val instanceof GridCacheSqlIndexMetadata) {
-                GridCacheSqlIndexMetadata r = (GridCacheSqlIndexMetadata) val;
-
-                return new JSONObject()
-                    .element("name", r.name())
-                    .element("fields", r.fields())
-                    .element("descendings", r.descendings())
-                    .element("unique", r.unique());
-            }
+            if (val instanceof Date)
+                return dateFmt.get().format(val);
 
-            throw new UnsupportedOperationException("Serialize array to string is not supported: " + val);
+            throw new UnsupportedOperationException("Serialize value to json is not supported: " + val);
         }
 
         /** {@inheritDoc} */
-        @Override public Object processObjectValue(String key, Object value, JsonConfig jsonCfg) {
-            return processArrayValue(value, jsonCfg);
+        @Override public synchronized Object processObjectValue(String key, Object val, JsonConfig jsonCfg) {
+            return processArrayValue(val, jsonCfg);
         }
-    }
+    };
 
     /**
-     * Class for finding a matching JsonBeanProcessor. Matches the target class with instanceOf.
+     * Constructs default jetty json config.
      */
-    private static final class GridJettyJsonBeanProcessorMatcher extends JsonBeanProcessorMatcher {
-        /** {@inheritDoc} */
-        @Override public Object getMatch(Class target, Set keys) {
-            if (target == null || keys == null)
-                return null;
+    GridJettyJsonConfig(IgniteLogger log) {
+        this.log = log;
 
-            if (keys.contains(target))
-                return target;
+        setAllowNonStringKeys(true);
 
-            for (Object key : keys) {
-                Class<?> clazz = (Class<?>) key;
+        registerJsonValueProcessor(IgniteBiTuple.class, IGNITE_BI_TUPLE_PROCESSOR);
+        registerJsonValueProcessor(UUID.class, UUID_PROCESSOR);
+        registerJsonValueProcessor(IgniteUuid.class, IGNITE_UUID_PROCESSOR);
+        registerJsonValueProcessor(Date.class, DATE_PROCESSOR);
+        registerJsonValueProcessor(java.sql.Date.class, DATE_PROCESSOR);
 
-                if (clazz.isAssignableFrom(target))
-                    return key;
-            }
+        final LessNamingProcessor lessNamingProcessor = new LessNamingProcessor();
+
+        registerJsonBeanProcessor(LessNamingProcessor.class, lessNamingProcessor);
+        registerJsonValueProcessor(LessNamingProcessor.class, lessNamingProcessor);
+
+        setJsonBeanProcessorMatcher(LESS_NAMING_BEAN_MATCHER);
+        setJsonValueProcessorMatcher(LESS_NAMING_VALUE_MATCHER);
+    }
 
+    /**
+     * Returns the matching class calculated with the target class and the provided set. Matches the target class with
+     * instanceOf, for Visor classes return custom processor class.
+     *
+     * @param target the target class to match
+     * @param keys a set of possible matches
+     */
+    private static Object getMatch(Class target, Set keys) {
+        if (target == null || keys == null)
             return null;
+
+        if (target.getSimpleName().startsWith("Visor") ||
+            GridCacheSqlMetadata.class.isAssignableFrom(target) ||
+            GridCacheSqlIndexMetadata.class.isAssignableFrom(target))
+            return LessNamingProcessor.class;
+
+        if (keys.contains(target))
+            return target;
+
+        for (Object key : keys) {
+            Class<?> clazz = (Class<?>)key;
+
+            if (clazz.isAssignableFrom(target))
+                return key;
         }
+
+        return null;
     }
 
     /**
-     * Class for finding a matching JsonValueProcessor. Matches the target class with instanceOf.
+     * Helper class for simple to-json conversion for Visor classes.
      */
-    private static final class GridJettyJsonValueProcessorMatcher extends JsonValueProcessorMatcher {
+    private class LessNamingProcessor implements JsonBeanProcessor, JsonValueProcessor {
+        /** Methods to exclude. */
+        private final Collection<String> exclMtds = Arrays.asList("toString", "hashCode", "clone", "getClass");
+
+        /** */
+        private final Map<Class<?>, Collection<Method>> clsCache = new HashMap<>();
+
+        /** */
+        private final ReadWriteLock rwLock = new ReentrantReadWriteLock();
+
         /** {@inheritDoc} */
-        @Override public Object getMatch(Class target, Set keys) {
-            if (target == null || keys == null)
-                return null;
+        @Override public JSONObject processBean(Object bean, JsonConfig jsonCfg) {
+            if (bean == null)
+                return new JSONObject(true);
 
-            if (keys.contains(target))
-                return target;
+            final JSONObject ret = new JSONObject();
 
-            for (Object key : keys) {
-                Class<?> clazz = (Class<?>) key;
+            Collection<Method> methods;
 
-                if (clazz.isAssignableFrom(target))
-                    return key;
+            Class<?> cls = bean.getClass();
+
+            // Get descriptor from cache.
+            rwLock.readLock().lock();
+
+            try {
+                methods = clsCache.get(cls);
+            }
+            finally {
+                rwLock.readLock().unlock();
             }
 
-            return null;
+            // If missing in cache - build descriptor
+            if (methods == null) {
+                Method[] publicMtds = cls.getMethods();
+
+                methods = new ArrayList<>(publicMtds.length);
+
+                for (Method mtd : publicMtds) {
+                    Class retType = mtd.getReturnType();
+
+                    if (mtd.getParameterTypes().length != 0 ||
+                        retType == void.class ||
+                        retType == cls ||
+                        exclMtds.contains(mtd.getName()) ||
+                        (retType == VisorCache.class && mtd.getName().equals("history")))
+                        continue;
+
+                    mtd.setAccessible(true);
+
+                    methods.add(mtd);
+                }
+
+                /*
+                 * Allow multiple puts for the same class - they will simply override.
+                 */
+                rwLock.writeLock().lock();
+
+                try {
+                    clsCache.put(cls, methods);
+                }
+                finally {
+                    rwLock.writeLock().unlock();
+                }
+            }
+
+            // Extract fields values using descriptor and build JSONObject.
+            for (Method mtd : methods) {
+                try {
+                    ret.element(mtd.getName(), mtd.invoke(bean), jsonCfg);
+                }
+                catch (Exception e) {
+                    U.error(log, "Failed to read object property [type= " + cls.getName()
+                        + ", property=" + mtd.getName() + "]", e);
+                }
+            }
+
+            return ret;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Object processArrayValue(Object val, JsonConfig jsonCfg) {
+            return processBean(val, jsonCfg);
+        }
+
+        /** {@inheritDoc} */
+        @Override public Object processObjectValue(String key, Object val, JsonConfig jsonCfg) {
+            return processArrayValue(val, jsonCfg);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/0c3f5d9b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java
----------------------------------------------------------------------
diff --git a/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java
index 5f2c4ba..b6a386b 100644
--- a/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java
+++ b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java
@@ -368,7 +368,7 @@ public class GridJettyRestHandler extends AbstractHandler {
                 throw (Error)e;
         }
 
-        JsonConfig cfg = new GridJettyJsonConfig();
+        JsonConfig cfg = new GridJettyJsonConfig(log);
 
         // Workaround for not needed transformation of string into JSON object.
         if (cmdRes.getResponse() instanceof String)

http://git-wip-us.apache.org/repos/asf/ignite/blob/0c3f5d9b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestProtocol.java
----------------------------------------------------------------------
diff --git a/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestProtocol.java b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestProtocol.java
index 0440783..9caadf4 100644
--- a/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestProtocol.java
+++ b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestProtocol.java
@@ -280,7 +280,7 @@ public class GridJettyRestProtocol extends GridRestProtocolAdapter {
             int srvPort;
 
             try {
-                srvPort = Integer.valueOf(srvPortStr);
+                srvPort = Integer.parseInt(srvPortStr);
             }
             catch (NumberFormatException ignore) {
                 throw new IgniteCheckedException("Failed to start Jetty server because IGNITE_JETTY_PORT system property " +


[02/24] ignite git commit: ignite-3090 Implemented stmCache cleanup.

Posted by ak...@apache.org.
ignite-3090 Implemented stmCache cleanup.


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

Branch: refs/heads/master
Commit: 38d9e91b0585591f714331aaf9e2da3561e37a9d
Parents: db8a9b2
Author: sboikov <sb...@gridgain.com>
Authored: Mon May 16 11:00:18 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Mon May 16 11:00:18 2016 +0300

----------------------------------------------------------------------
 .../apache/ignite/IgniteSystemProperties.java   |  20 ++
 .../processors/query/h2/IgniteH2Indexing.java   |  59 +++++
 .../IgniteCacheQueryH2IndexingLeakTest.java     | 214 +++++++++++++++++++
 .../IgniteCacheQuerySelfTestSuite.java          |   2 +
 4 files changed, 295 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/38d9e91b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
index 804cd43..35d190f 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
@@ -404,6 +404,26 @@ public final class IgniteSystemProperties {
     public static final String IGNITE_NO_SELECTOR_OPTS = "IGNITE_NO_SELECTOR_OPTS";
 
     /**
+     * System property to specify period in milliseconds between calls of the SQL statements cache cleanup task.
+     * <p>
+     * Cleanup tasks clears cache for terminated threads and for threads which did not perform SQL queries within
+     * timeout configured via {@link #IGNITE_H2_INDEXING_CACHE_THREAD_USAGE_TIMEOUT} property.
+     * <p>
+     * Default value is {@code 10,000ms}.
+     */
+    public static final String IGNITE_H2_INDEXING_CACHE_CLEANUP_PERIOD = "IGNITE_H2_INDEXING_CACHE_CLEANUP_PERIOD";
+
+    /**
+     * System property to specify timeout in milliseconds after which thread's SQL statements cache is cleared by
+     * cleanup task if the thread does not perform any query.
+     * <p>
+     * Default value is {@code 600,000ms}.
+     */
+    public static final String IGNITE_H2_INDEXING_CACHE_THREAD_USAGE_TIMEOUT =
+        "IGNITE_H2_INDEXING_CACHE_THREAD_USAGE_TIMEOUT";
+
+
+    /**
      * Enforces singleton.
      */
     private IgniteSystemProperties() {

http://git-wip-us.apache.org/repos/asf/ignite/blob/38d9e91b/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 caf49e8..74d3e74 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
@@ -95,6 +95,7 @@ import org.apache.ignite.internal.processors.query.h2.opt.GridLuceneIndex;
 import org.apache.ignite.internal.processors.query.h2.sql.GridSqlQuerySplitter;
 import org.apache.ignite.internal.processors.query.h2.twostep.GridMapQueryExecutor;
 import org.apache.ignite.internal.processors.query.h2.twostep.GridReduceQueryExecutor;
+import org.apache.ignite.internal.processors.timeout.GridTimeoutProcessor;
 import org.apache.ignite.internal.util.GridBoundedConcurrentLinkedHashMap;
 import org.apache.ignite.internal.util.GridEmptyCloseableIterator;
 import org.apache.ignite.internal.util.GridSpinBusyLock;
@@ -153,6 +154,8 @@ import org.jetbrains.annotations.Nullable;
 import org.jsr166.ConcurrentHashMap8;
 
 import static org.apache.ignite.IgniteSystemProperties.IGNITE_H2_DEBUG_CONSOLE;
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_H2_INDEXING_CACHE_CLEANUP_PERIOD;
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_H2_INDEXING_CACHE_THREAD_USAGE_TIMEOUT;
 import static org.apache.ignite.IgniteSystemProperties.getString;
 import static org.apache.ignite.internal.processors.query.GridQueryIndexType.FULLTEXT;
 import static org.apache.ignite.internal.processors.query.GridQueryIndexType.GEO_SPATIAL;
@@ -202,6 +205,16 @@ public class IgniteH2Indexing implements GridQueryIndexing {
     /** */
     private static final String ESC_STR = ESC_CH + "" + ESC_CH;
 
+    /** The period of clean up the {@link #stmtCache}. */
+    private final Long CLEANUP_STMT_CACHE_PERIOD = Long.getLong(IGNITE_H2_INDEXING_CACHE_CLEANUP_PERIOD, 10_000);
+
+    /** The timeout to remove entry from the {@link #stmtCache} if the thread doesn't perform any queries. */
+    private final Long STATEMENT_CACHE_THREAD_USAGE_TIMEOUT =
+        Long.getLong(IGNITE_H2_INDEXING_CACHE_THREAD_USAGE_TIMEOUT, 600 * 1000);
+
+    /** */
+    private GridTimeoutProcessor.CancelableTask stmtCacheCleanupTask;
+
     /**
      * Command in H2 prepared statement.
      */
@@ -333,6 +346,8 @@ public class IgniteH2Indexing implements GridQueryIndexing {
                     cache = cache0;
             }
 
+            cache.updateLastUsage();
+
             PreparedStatement stmt = cache.get(sql);
 
             if (stmt != null && !stmt.isClosed()) {
@@ -1382,6 +1397,23 @@ public class IgniteH2Indexing implements GridQueryIndexing {
     }
 
     /**
+     * Called periodically by {@link GridTimeoutProcessor} to clean up the {@link #stmtCache}.
+     */
+    private void cleanupStatementCache() {
+        long cur = U.currentTimeMillis();
+
+        for(Iterator<Map.Entry<Thread, StatementCache>> it = stmtCache.entrySet().iterator(); it.hasNext(); ) {
+            Map.Entry<Thread, StatementCache> entry = it.next();
+
+            Thread t = entry.getKey();
+
+            if (t.getState() == Thread.State.TERMINATED
+                || cur - entry.getValue().lastUsage() > STATEMENT_CACHE_THREAD_USAGE_TIMEOUT)
+                it.remove();
+        }
+    }
+
+    /**
      * Gets space name from database schema.
      *
      * @param schemaName Schema name. Could not be null. Could be empty.
@@ -1503,6 +1535,12 @@ public class IgniteH2Indexing implements GridQueryIndexing {
 
             mapQryExec.start(ctx, this);
             rdcQryExec.start(ctx, this);
+
+            stmtCacheCleanupTask = ctx.timeout().schedule(new Runnable() {
+                @Override public void run() {
+                    cleanupStatementCache();
+                }
+            }, CLEANUP_STMT_CACHE_PERIOD, CLEANUP_STMT_CACHE_PERIOD);
         }
 
         // TODO https://issues.apache.org/jira/browse/IGNITE-2139
@@ -1591,6 +1629,9 @@ public class IgniteH2Indexing implements GridQueryIndexing {
             U.error(log, "Failed to shutdown database.", e);
         }
 
+        if (stmtCacheCleanupTask != null)
+            stmtCacheCleanupTask.close();
+
         if (log.isDebugEnabled())
             log.debug("Cache query index stopped.");
     }
@@ -2533,6 +2574,9 @@ public class IgniteH2Indexing implements GridQueryIndexing {
         /** */
         private int size;
 
+        /** Last usage. */
+        private volatile long lastUsage;
+
         /**
          * @param size Size.
          */
@@ -2554,5 +2598,20 @@ public class IgniteH2Indexing implements GridQueryIndexing {
 
             return rmv;
         }
+
+        /**
+         * The timestamp of the last usage of the cache. Used by {@link #cleanupStatementCache()} to remove unused caches.
+         * @return last usage timestamp
+         */
+        private long lastUsage() {
+            return lastUsage;
+        }
+
+        /**
+         * Updates the {@link #lastUsage} timestamp by current time.
+         */
+        private void updateLastUsage() {
+            lastUsage = U.currentTimeMillis();
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/38d9e91b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheQueryH2IndexingLeakTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheQueryH2IndexingLeakTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheQueryH2IndexingLeakTest.java
new file mode 100644
index 0000000..5d6556e
--- /dev/null
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheQueryH2IndexingLeakTest.java
@@ -0,0 +1,214 @@
+/*
+ * 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.ConcurrentMap;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicBoolean;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.cache.query.SqlQuery;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.processors.query.GridQueryProcessor;
+import org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing;
+import org.apache.ignite.internal.util.lang.GridAbsPredicate;
+import org.apache.ignite.internal.util.typedef.CAX;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_H2_INDEXING_CACHE_CLEANUP_PERIOD;
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_H2_INDEXING_CACHE_THREAD_USAGE_TIMEOUT;
+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;
+
+/**
+ * Tests leaks at the IgniteH2Indexing
+ */
+public class IgniteCacheQueryH2IndexingLeakTest extends GridCommonAbstractTest {
+    /** */
+    private static final long TEST_TIMEOUT = 2 * 60 * 1000;
+
+    /** Threads to parallel execute queries */
+    private static final int THREAD_COUNT = 10;
+
+    /** Timeout */
+    private static final long STMT_CACHE_CLEANUP_TIMEOUT = 1000;
+
+    /** Orig cleanup period. */
+    private static String origCacheCleanupPeriod;
+
+    /** Orig usage timeout. */
+    private static String origCacheThreadUsageTimeout;
+
+    /** */
+    private static final int ITERATIONS = 5;
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        cfg.setCacheConfiguration(cacheConfiguration());
+
+        return cfg;
+    }
+
+    /**
+     * @return Cache configuration.
+     */
+    protected CacheConfiguration cacheConfiguration() {
+        CacheConfiguration<?,?> cacheCfg = defaultCacheConfiguration();
+
+        cacheCfg.setCacheMode(PARTITIONED);
+        cacheCfg.setAtomicityMode(TRANSACTIONAL);
+        cacheCfg.setWriteSynchronizationMode(FULL_SYNC);
+
+        cacheCfg.setIndexedTypes(
+            Integer.class, Integer.class
+        );
+
+        return cacheCfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected long getTestTimeout() {
+        return TEST_TIMEOUT + 60_000;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        origCacheCleanupPeriod = System.getProperty(IGNITE_H2_INDEXING_CACHE_CLEANUP_PERIOD);
+        origCacheThreadUsageTimeout = System.getProperty(IGNITE_H2_INDEXING_CACHE_THREAD_USAGE_TIMEOUT);
+
+        System.setProperty(IGNITE_H2_INDEXING_CACHE_CLEANUP_PERIOD, Long.toString(STMT_CACHE_CLEANUP_TIMEOUT));
+        System.setProperty(IGNITE_H2_INDEXING_CACHE_THREAD_USAGE_TIMEOUT, Long.toString(STMT_CACHE_CLEANUP_TIMEOUT));
+
+        startGrid(0);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTestsStopped() throws Exception {
+        stopAllGrids();
+
+        System.setProperty(IGNITE_H2_INDEXING_CACHE_CLEANUP_PERIOD,
+            origCacheCleanupPeriod != null ? origCacheCleanupPeriod : "");
+
+        System.setProperty(IGNITE_H2_INDEXING_CACHE_THREAD_USAGE_TIMEOUT,
+            origCacheThreadUsageTimeout != null ? origCacheThreadUsageTimeout : "");
+    }
+
+    /**
+     * @param qryProcessor Query processor.
+     * @return size of statement cache.
+     */
+    private static int getStatementCacheSize(GridQueryProcessor qryProcessor) {
+        IgniteH2Indexing h2Idx = GridTestUtils.getFieldValue(qryProcessor, GridQueryProcessor.class, "idx");
+
+        ConcurrentMap stmtCache = GridTestUtils.getFieldValue(h2Idx, IgniteH2Indexing.class, "stmtCache");
+
+        return stmtCache.size();
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    @SuppressWarnings({"TooBroadScope"})
+    public void testLeaksInIgniteH2IndexingOnTerminatedThread() throws Exception {
+        final IgniteCache<Integer, Integer> c = grid(0).cache(null);
+
+        for(int i = 0; i < ITERATIONS; ++i) {
+            info("Iteration #" + i);
+
+            final AtomicBoolean stop = new AtomicBoolean();
+
+            // Open iterator on the created cursor: add entries to the cache.
+            IgniteInternalFuture<?> fut = multithreadedAsync(
+                new CAX() {
+                    @Override public void applyx() throws IgniteCheckedException {
+                        while (!stop.get()) {
+                            c.query(new SqlQuery(Integer.class, "_val >= 0")).getAll();
+
+                            c.query(new SqlQuery(Integer.class, "_val >= 1")).getAll();
+                        }
+                    }
+                }, THREAD_COUNT);
+
+            final GridQueryProcessor qryProc = grid(0).context().query();
+
+            try {
+                // Wait for stmt cache entry is created for each thread.
+                assertTrue(GridTestUtils.waitForCondition(new GridAbsPredicate() {
+                    @Override public boolean apply() {
+                        return getStatementCacheSize(qryProc) == THREAD_COUNT;
+                    }
+                }, STMT_CACHE_CLEANUP_TIMEOUT));
+            }
+            finally {
+                stop.set(true);
+            }
+
+            fut.get();
+
+            // Wait for stmtCache is cleaned up because all user threads are terminated.
+            assertTrue(GridTestUtils.waitForCondition(new GridAbsPredicate() {
+                @Override public boolean apply() {
+                    return getStatementCacheSize(qryProc) == 0;
+                }
+            }, STMT_CACHE_CLEANUP_TIMEOUT * 2));
+        }
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testLeaksInIgniteH2IndexingOnUnusedThread() throws Exception {
+        final IgniteCache<Integer, Integer> c = grid(0).cache(null);
+
+        final CountDownLatch latch = new CountDownLatch(1);
+
+        for(int i = 0; i < ITERATIONS; ++i) {
+            info("Iteration #" + i);
+
+            // Open iterator on the created cursor: add entries to the cache
+            IgniteInternalFuture<?> fut = multithreadedAsync(
+                new CAX() {
+                    @Override public void applyx() throws IgniteCheckedException {
+                        c.query(new SqlQuery(Integer.class, "_val >= 0")).getAll();
+
+                        U.await(latch);
+                    }
+                }, THREAD_COUNT);
+
+            Thread.sleep(STMT_CACHE_CLEANUP_TIMEOUT);
+
+            // Wait for stmtCache is cleaned up because all user threads don't perform queries a lot of time.
+            assertTrue(GridTestUtils.waitForCondition(new GridAbsPredicate() {
+                @Override public boolean apply() {
+                    return getStatementCacheSize(grid(0).context().query()) == 0;
+                }
+            }, STMT_CACHE_CLEANUP_TIMEOUT * 2));
+
+            latch.countDown();
+
+            fut.get();
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/38d9e91b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
index 04885ce..ebad581 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
@@ -32,6 +32,7 @@ import org.apache.ignite.internal.processors.cache.IgniteCacheOffheapEvictQueryT
 import org.apache.ignite.internal.processors.cache.IgniteCacheOffheapTieredMultithreadedSelfTest;
 import org.apache.ignite.internal.processors.cache.IgniteCachePartitionedQueryMultiThreadedSelfTest;
 import org.apache.ignite.internal.processors.cache.IgniteCacheQueryEvictsMultiThreadedSelfTest;
+import org.apache.ignite.internal.processors.cache.IgniteCacheQueryH2IndexingLeakTest;
 import org.apache.ignite.internal.processors.cache.IgniteCacheQueryIndexSelfTest;
 import org.apache.ignite.internal.processors.cache.IgniteCacheQueryLoadSelfTest;
 import org.apache.ignite.internal.processors.cache.IgniteCacheQueryMultiThreadedOffHeapTieredSelfTest;
@@ -109,6 +110,7 @@ public class IgniteCacheQuerySelfTestSuite extends TestSuite {
         suite.addTestSuite(GridCacheQuerySerializationSelfTest.class);
         suite.addTestSuite(IgniteBinaryObjectFieldsQuerySelfTest.class);
         suite.addTestSuite(IgniteBinaryWrappedObjectFieldsQuerySelfTest.class);
+        suite.addTestSuite(IgniteCacheQueryH2IndexingLeakTest.class);
 
         return suite;
     }


[12/24] ignite git commit: Fixed XmlGeneratorTest.

Posted by ak...@apache.org.
Fixed XmlGeneratorTest.


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

Branch: refs/heads/master
Commit: 5a831519624fdf60b8755f2857e207a619db9683
Parents: 6bd0453
Author: AKuznetsov <ak...@gridgain.com>
Authored: Mon May 16 19:01:09 2016 +0700
Committer: AKuznetsov <ak...@gridgain.com>
Committed: Mon May 16 19:01:09 2016 +0700

----------------------------------------------------------------------
 .../ignite/schema/test/model/ignite-type-metadata.xml   | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/5a831519/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/ignite-type-metadata.xml
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/ignite-type-metadata.xml b/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/ignite-type-metadata.xml
index fd14ae2..514445f 100644
--- a/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/ignite-type-metadata.xml
+++ b/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/ignite-type-metadata.xml
@@ -507,9 +507,9 @@
             </util:map>
         </property>
         <property name="aliases">
-            <util:map map-class="java.util.LinkedHashMap">
+            <map>
                 <entry key="fieldWithAlias" value="FIELD_WITH_ALIAS"/>
-            </util:map>
+            </map>
         </property>
         <property name="indexes">
             <list>
@@ -551,9 +551,9 @@
             </util:map>
         </property>
         <property name="aliases">
-            <util:map map-class="java.util.LinkedHashMap">
+            <map>
                 <entry key="fieldWithAlias" value="FIELD_WITH_ALIAS"/>
-            </util:map>
+            </map>
         </property>
         <property name="indexes">
             <list>
@@ -595,9 +595,9 @@
             </util:map>
         </property>
         <property name="aliases">
-            <util:map map-class="java.util.LinkedHashMap">
+            <map>
                 <entry key="fieldWithAlias" value="FIELD_WITH_ALIAS"/>
-            </util:map>
+            </map>
         </property>
         <property name="indexes">
             <list>


[04/24] ignite git commit: IGNITE-3130: .NET: Added missing properties to TcpDiscoverySpi. This closes #715.

Posted by ak...@apache.org.
IGNITE-3130: .NET: Added missing properties to TcpDiscoverySpi. This closes #715.


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

Branch: refs/heads/master
Commit: 5a43025088dfb1648fc63591198c4a1808a47617
Parents: dc7b37f
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Mon May 16 11:39:59 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Mon May 16 11:39:59 2016 +0300

----------------------------------------------------------------------
 .../utils/PlatformConfigurationUtils.java       |  28 ++++
 .../IgniteConfigurationSerializerTest.cs        |  19 ++-
 .../IgniteConfigurationTest.cs                  |  27 +++-
 .../Discovery/Tcp/TcpDiscoverySpi.cs            | 161 +++++++++++++++++++
 .../IgniteConfigurationSection.xsd              |  13 ++
 5 files changed, 244 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/5a430250/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
index 30e45ef..d2eab1e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
@@ -515,6 +515,20 @@ public class PlatformConfigurationUtils {
         disco.setNetworkTimeout(in.readLong());
         disco.setJoinTimeout(in.readLong());
 
+        disco.setForceServerMode(in.readBoolean());
+        disco.setClientReconnectDisabled(in.readBoolean());
+        disco.setLocalAddress(in.readString());
+        disco.setReconnectCount(in.readInt());
+        disco.setLocalPort(in.readInt());
+        disco.setLocalPortRange(in.readInt());
+        disco.setMaxMissedHeartbeats(in.readInt());
+        disco.setMaxMissedClientHeartbeats(in.readInt());
+        disco.setStatisticsPrintFrequency(in.readLong());
+        disco.setIpFinderCleanFrequency(in.readLong());
+        disco.setThreadPriority(in.readInt());
+        disco.setHeartbeatFrequency(in.readLong());
+        disco.setTopHistorySize(in.readInt());
+
         cfg.setDiscoverySpi(disco);
     }
 
@@ -852,6 +866,20 @@ public class PlatformConfigurationUtils {
         w.writeLong(tcp.getMaxAckTimeout());
         w.writeLong(tcp.getNetworkTimeout());
         w.writeLong(tcp.getJoinTimeout());
+
+        w.writeBoolean(tcp.isForceServerMode());
+        w.writeBoolean(tcp.isClientReconnectDisabled());
+        w.writeString(tcp.getLocalAddress());
+        w.writeInt(tcp.getReconnectCount());
+        w.writeInt(tcp.getLocalPort());
+        w.writeInt(tcp.getLocalPortRange());
+        w.writeInt(tcp.getMaxMissedHeartbeats());
+        w.writeInt(tcp.getMaxMissedClientHeartbeats());
+        w.writeLong(tcp.getStatisticsPrintFrequency());
+        w.writeLong(tcp.getIpFinderCleanFrequency());
+        w.writeInt(tcp.getThreadPriority());
+        w.writeLong(tcp.getHeartbeatFrequency());
+        w.writeInt((int)tcp.getTopHistorySize());
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/5a430250/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
index e3507b8..72ca7f5 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
@@ -63,7 +63,7 @@ namespace Apache.Ignite.Core.Tests
                                     <string>Apache.Ignite.Core.Tests.IgniteConfigurationSerializerTest+FooClass, Apache.Ignite.Core.Tests</string>
                                 </types>
                             </binaryConfiguration>
-                            <discoverySpi type='TcpDiscoverySpi' joinTimeout='0:1:0'>
+                            <discoverySpi type='TcpDiscoverySpi' joinTimeout='0:1:0' localAddress='192.168.1.1' localPort='6655'>
                                 <ipFinder type='TcpDiscoveryMulticastIpFinder' addressRequestAttempts='7' />
                             </discoverySpi>
                             <communicationSpi type='TcpCommunicationSpi' ackSendThreshold='33' idleConnectionTimeout='0:1:2' />
@@ -113,6 +113,8 @@ namespace Apache.Ignite.Core.Tests
             Assert.AreEqual(1024, cfg.JvmMaxMemoryMb);
             Assert.AreEqual(TimeSpan.FromSeconds(10), cfg.MetricsLogFrequency);
             Assert.AreEqual(TimeSpan.FromMinutes(1), ((TcpDiscoverySpi)cfg.DiscoverySpi).JoinTimeout);
+            Assert.AreEqual("192.168.1.1", ((TcpDiscoverySpi)cfg.DiscoverySpi).LocalAddress);
+            Assert.AreEqual(6655, ((TcpDiscoverySpi)cfg.DiscoverySpi).LocalPort);
             Assert.AreEqual(7,
                 ((TcpDiscoveryMulticastIpFinder) ((TcpDiscoverySpi) cfg.DiscoverySpi).IpFinder).AddressRequestAttempts);
             Assert.AreEqual(new[] { "-Xms1g", "-Xmx4g" }, cfg.JvmOptions);
@@ -420,7 +422,20 @@ namespace Apache.Ignite.Core.Tests
                         ResponseTimeout = TimeSpan.FromDays(1),
                         LocalAddress = "127.0.0.2",
                         Endpoints = new[] {"", "abc"}
-                    }
+                    },
+                    ClientReconnectDisabled = true,
+                    ForceServerMode = true,
+                    HeartbeatFrequency = TimeSpan.FromSeconds(3),
+                    IpFinderCleanFrequency = TimeSpan.FromMinutes(7),
+                    LocalAddress = "127.0.0.1",
+                    LocalPort = 49900,
+                    LocalPortRange = 13,
+                    MaxMissedClientHeartbeats = 9,
+                    MaxMissedHeartbeats = 7,
+                    ReconnectCount = 11,
+                    StatisticsPrintFrequency = TimeSpan.FromSeconds(20),
+                    ThreadPriority = 6,
+                    TopologyHistorySize = 1234567
                 },
                 IgniteHome = "igniteHome",
                 IncludedEventTypes = EventType.CacheQueryAll,

http://git-wip-us.apache.org/repos/asf/ignite/blob/5a430250/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
index 3e5e877..465ba27 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
@@ -92,6 +92,16 @@ namespace Apache.Ignite.Core.Tests
                 Assert.AreEqual(disco.SocketTimeout, resDisco.SocketTimeout);
                 Assert.AreEqual(disco.JoinTimeout, resDisco.JoinTimeout);
 
+                Assert.AreEqual(disco.LocalAddress, resDisco.LocalAddress);
+                Assert.AreEqual(disco.LocalPort, resDisco.LocalPort);
+                Assert.AreEqual(disco.LocalPortRange, resDisco.LocalPortRange);
+                Assert.AreEqual(disco.MaxMissedClientHeartbeats, resDisco.MaxMissedClientHeartbeats);
+                Assert.AreEqual(disco.MaxMissedHeartbeats, resDisco.MaxMissedHeartbeats);
+                Assert.AreEqual(disco.ReconnectCount, resDisco.ReconnectCount);
+                Assert.AreEqual(disco.StatisticsPrintFrequency, resDisco.StatisticsPrintFrequency);
+                Assert.AreEqual(disco.ThreadPriority, resDisco.ThreadPriority);
+                Assert.AreEqual(disco.TopologyHistorySize, resDisco.TopologyHistorySize);
+
                 var ip = (TcpDiscoveryStaticIpFinder) disco.IpFinder;
                 var resIp = (TcpDiscoveryStaticIpFinder) resDisco.IpFinder;
 
@@ -375,8 +385,21 @@ namespace Apache.Ignite.Core.Tests
                     JoinTimeout = TimeSpan.FromSeconds(5),
                     IpFinder = new TcpDiscoveryStaticIpFinder
                     {
-                        Endpoints = new[] { "127.0.0.1:47500", "127.0.0.1:47501" }
-                    }
+                        Endpoints = new[] { "127.0.0.1:49900", "127.0.0.1:49901" }
+                    },
+                    ClientReconnectDisabled = true,
+                    ForceServerMode = true,
+                    HeartbeatFrequency = TimeSpan.FromSeconds(3),
+                    IpFinderCleanFrequency = TimeSpan.FromMinutes(7),
+                    LocalAddress = "127.0.0.1",
+                    LocalPort = 49900,
+                    LocalPortRange = 13,
+                    MaxMissedClientHeartbeats = 9,
+                    MaxMissedHeartbeats = 7,
+                    ReconnectCount = 11,
+                    StatisticsPrintFrequency = TimeSpan.FromSeconds(20),
+                    ThreadPriority = 6,
+                    TopologyHistorySize = 1234567
                 },
                 GridName = "gridName1",
                 IncludedEventTypes = EventType.SwapspaceAll,

http://git-wip-us.apache.org/repos/asf/ignite/blob/5a430250/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/TcpDiscoverySpi.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/TcpDiscoverySpi.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/TcpDiscoverySpi.cs
index ea946e8..e03be3c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/TcpDiscoverySpi.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/TcpDiscoverySpi.cs
@@ -53,6 +53,51 @@ namespace Apache.Ignite.Core.Discovery.Tcp
         public static readonly TimeSpan DefaultJoinTimeout = TimeSpan.Zero;
 
         /// <summary>
+        /// Default value for the <see cref="ReconnectCount"/> property.
+        /// </summary>
+        public const int DefaultReconnectCount = 10;
+
+        /// <summary>
+        /// Default value for the <see cref="LocalPort"/> property.
+        /// </summary>
+        public const int DefaultLocalPort = 47500;
+
+        /// <summary>
+        /// Default value for the <see cref="LocalPortRange"/> property.
+        /// </summary>
+        public const int DefaultLocalPortRange = 100;
+
+        /// <summary>
+        /// Default value for the <see cref="MaxMissedHeartbeats"/> property.
+        /// </summary>
+        public const int DefaultMaxMissedHeartbeats = 1;
+
+        /// <summary>
+        /// Default value for the <see cref="MaxMissedClientHeartbeats"/> property.
+        /// </summary>
+        public const int DefaultMaxMissedClientHeartbeats = 5;
+
+        /// <summary>
+        /// Default value for the <see cref="IpFinderCleanFrequency"/> property.
+        /// </summary>
+        public static readonly TimeSpan DefaultIpFinderCleanFrequency = TimeSpan.FromSeconds(60);
+
+        /// <summary>
+        /// Default value for the <see cref="ThreadPriority"/> property.
+        /// </summary>
+        public const int DefaultThreadPriority = 10;
+
+        /// <summary>
+        /// Default value for the <see cref="HeartbeatFrequency"/> property.
+        /// </summary>
+        public static readonly TimeSpan DefaultHeartbeatFrequency = TimeSpan.FromSeconds(2);
+        
+        /// <summary>
+        /// Default value for the <see cref="TopologyHistorySize"/> property.
+        /// </summary>
+        public const int DefaultTopologyHistorySize = 1000;
+
+        /// <summary>
         /// Initializes a new instance of the <see cref="TcpDiscoverySpi"/> class.
         /// </summary>
         public TcpDiscoverySpi()
@@ -62,6 +107,15 @@ namespace Apache.Ignite.Core.Discovery.Tcp
             MaxAckTimeout = DefaultMaxAckTimeout;
             NetworkTimeout = DefaultNetworkTimeout;
             JoinTimeout = DefaultJoinTimeout;
+            ReconnectCount = DefaultReconnectCount;
+            LocalPort = DefaultLocalPort;
+            LocalPortRange = DefaultLocalPortRange;
+            MaxMissedHeartbeats = DefaultMaxMissedHeartbeats;
+            MaxMissedClientHeartbeats = DefaultMaxMissedClientHeartbeats;
+            IpFinderCleanFrequency = DefaultIpFinderCleanFrequency;
+            ThreadPriority = DefaultThreadPriority;
+            HeartbeatFrequency = DefaultHeartbeatFrequency;
+            TopologyHistorySize = DefaultTopologyHistorySize;
         }
 
         /// <summary>
@@ -77,6 +131,20 @@ namespace Apache.Ignite.Core.Discovery.Tcp
             MaxAckTimeout = reader.ReadLongAsTimespan();
             NetworkTimeout = reader.ReadLongAsTimespan();
             JoinTimeout = reader.ReadLongAsTimespan();
+
+            ForceServerMode = reader.ReadBoolean();
+            ClientReconnectDisabled = reader.ReadBoolean();
+            LocalAddress = reader.ReadString();
+            ReconnectCount = reader.ReadInt();
+            LocalPort = reader.ReadInt();
+            LocalPortRange = reader.ReadInt();
+            MaxMissedHeartbeats = reader.ReadInt();
+            MaxMissedClientHeartbeats = reader.ReadInt();
+            StatisticsPrintFrequency = reader.ReadLongAsTimespan();
+            IpFinderCleanFrequency = reader.ReadLongAsTimespan();
+            ThreadPriority = reader.ReadInt();
+            HeartbeatFrequency = reader.ReadLongAsTimespan();
+            TopologyHistorySize = reader.ReadInt();
         }
 
         /// <summary>
@@ -114,6 +182,85 @@ namespace Apache.Ignite.Core.Discovery.Tcp
         public TimeSpan JoinTimeout { get; set; }
 
         /// <summary>
+        /// Gets or sets a value indicating whether TcpDiscoverySpi is started in server mode 
+        /// regardless of <see cref="IgniteConfiguration.ClientMode"/> setting.
+        /// </summary>
+        public bool ForceServerMode { get; set; }
+
+        /// <summary>
+        /// Gets or sets a value indicating whether client does not try to reconnect after
+        /// server detected client node failure.
+        /// </summary>
+        public bool ClientReconnectDisabled { get; set; }
+
+        /// <summary>
+        /// Gets or sets the local host IP address that discovery SPI uses.
+        /// </summary>
+        public string LocalAddress { get; set; }
+
+        /// <summary>
+        /// Gets or sets the number of times node tries to (re)establish connection to another node.
+        /// </summary>
+        [DefaultValue(DefaultReconnectCount)]
+        public int ReconnectCount { get; set; }
+
+        /// <summary>
+        /// Gets or sets the local port to listen to.
+        /// </summary>
+        [DefaultValue(DefaultLocalPort)]
+        public int LocalPort { get; set; }
+
+        /// <summary>
+        /// Gets or sets the range for local ports. Local node will try to bind on first available port starting from
+        /// <see cref="LocalPort"/> up until (<see cref="LocalPort"/> + <see cref="LocalPortRange"/>).
+        /// </summary>
+        [DefaultValue(DefaultLocalPortRange)]
+        public int LocalPortRange { get; set; }
+
+        /// <summary>
+        /// Gets or sets the maximum heartbeats count node can miss without initiating status check.
+        /// </summary>
+        [DefaultValue(DefaultMaxMissedHeartbeats)]
+        public int MaxMissedHeartbeats { get; set; }
+
+        /// <summary>
+        /// Gets or sets the maximum heartbeats count node can miss without failing client node.
+        /// </summary>
+        [DefaultValue(DefaultMaxMissedClientHeartbeats)]
+        public int MaxMissedClientHeartbeats { get; set; }
+
+        /// <summary>
+        /// Gets or sets the statistics print frequency.
+        /// <see cref="TimeSpan.Zero"/> for no statistics.
+        /// </summary>
+        public TimeSpan StatisticsPrintFrequency { get; set; }
+
+        /// <summary>
+        /// Gets or sets the IP finder clean frequency.
+        /// </summary>
+        [DefaultValue(typeof(TimeSpan), "0:1:0")]
+        public TimeSpan IpFinderCleanFrequency { get; set; }
+
+        /// <summary>
+        /// Sets thread priority, 1 (lowest) to 10 (highest). All threads within SPI will be started with it.
+        /// </summary>
+        [DefaultValue(DefaultThreadPriority)]
+        public int ThreadPriority { get; set; }
+
+        /// <summary>
+        /// Gets or sets delay between issuing of heartbeat messages. SPI sends heartbeat messages
+        /// in configurable time interval to other nodes to notify them about its state.
+        /// </summary>
+        [DefaultValue(typeof(TimeSpan), "0:0:2")]
+        public TimeSpan HeartbeatFrequency { get; set; }
+
+        /// <summary>
+        /// Gets or sets the size of topology snapshots history.
+        /// </summary>
+        [DefaultValue(DefaultTopologyHistorySize)]
+        public int TopologyHistorySize { get; set; }
+
+        /// <summary>
         /// Writes this instance to the specified writer.
         /// </summary>
         internal void Write(IBinaryRawWriter writer)
@@ -139,6 +286,20 @@ namespace Apache.Ignite.Core.Discovery.Tcp
             writer.WriteLong((long) MaxAckTimeout.TotalMilliseconds);
             writer.WriteLong((long) NetworkTimeout.TotalMilliseconds);
             writer.WriteLong((long) JoinTimeout.TotalMilliseconds);
+
+            writer.WriteBoolean(ForceServerMode);
+            writer.WriteBoolean(ClientReconnectDisabled);
+            writer.WriteString(LocalAddress);
+            writer.WriteInt(ReconnectCount);
+            writer.WriteInt(LocalPort);
+            writer.WriteInt(LocalPortRange);
+            writer.WriteInt(MaxMissedHeartbeats);
+            writer.WriteInt(MaxMissedClientHeartbeats);
+            writer.WriteLong((long) StatisticsPrintFrequency.TotalMilliseconds);
+            writer.WriteLong((long) IpFinderCleanFrequency.TotalMilliseconds);
+            writer.WriteInt(ThreadPriority);
+            writer.WriteLong((long) HeartbeatFrequency.TotalMilliseconds);
+            writer.WriteInt(TopologyHistorySize);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/5a430250/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
index 29074e7..cd16c1c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
@@ -259,6 +259,19 @@
                         <xs:attribute name="maxAckTimeout" type="xs:string" />
                         <xs:attribute name="networkTimeout" type="xs:string" />
                         <xs:attribute name="joinTimeout" type="xs:string" />
+                        <xs:attribute name="clientReconnectDisabled" type="xs:boolean" />
+                        <xs:attribute name="forceServerMode" type="xs:boolean" />
+                        <xs:attribute name="heartbeatFrequency" type="xs:string" />
+                        <xs:attribute name="ipFinderCleanFrequency" type="xs:string" />
+                        <xs:attribute name="localAddress" type="xs:string" />
+                        <xs:attribute name="localPort" type="xs:int" />
+                        <xs:attribute name="localPortRange" type="xs:int" />
+                        <xs:attribute name="maxMissedClientHeartbeats" type="xs:int" />
+                        <xs:attribute name="maxMissedHeartbeats" type="xs:int" />
+                        <xs:attribute name="reconnectCount" type="xs:int" />
+                        <xs:attribute name="statisticsPrintFrequency" type="xs:string" />
+                        <xs:attribute name="threadPriority" type="xs:int" />
+                        <xs:attribute name="topologyHistorySize" type="xs:int" />
                         <xs:attribute name="type" type="xs:string" use="required" />
                     </xs:complexType>
                 </xs:element>


[08/24] ignite git commit: Merge remote-tracking branch 'origin/ignite-1.6' into ignite-1.6

Posted by ak...@apache.org.
Merge remote-tracking branch 'origin/ignite-1.6' into ignite-1.6


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

Branch: refs/heads/master
Commit: 796ee160da1023437ea6e3006db59a1094fdc45d
Parents: 341f12f f3deed1
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Mon May 16 11:47:52 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Mon May 16 11:47:52 2016 +0300

----------------------------------------------------------------------
 .../ignite/testsuites/IgniteCacheDataStructuresSelfTestSuite.java | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------



[24/24] ignite git commit: Merge branches 'ignite-1.6' and 'master' of https://git-wip-us.apache.org/repos/asf/ignite

Posted by ak...@apache.org.
Merge branches 'ignite-1.6' and 'master' of https://git-wip-us.apache.org/repos/asf/ignite


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

Branch: refs/heads/master
Commit: b52edcaae59819e0ed8be25e9aa7c9c61394b501
Parents: 223708a 1dc1d85
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Tue May 17 11:01:48 2016 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Tue May 17 11:01:48 2016 +0700

----------------------------------------------------------------------
 .../JettyRestProcessorAbstractSelfTest.java     | 716 ++++++++++++++++++-
 .../rest/JettyRestProcessorSignedSelfTest.java  |   5 +-
 .../JettyRestProcessorUnsignedSelfTest.java     |   5 +-
 .../apache/ignite/IgniteSystemProperties.java   |  20 +
 .../cache/CacheWeakQueryIteratorsHolder.java    | 169 ++++-
 .../processors/cache/GridCacheAdapter.java      |  13 +-
 .../processors/cache/GridCacheSwapManager.java  |  12 +-
 .../processors/cache/IgniteCacheProxy.java      |  39 +-
 .../binary/CacheObjectBinaryProcessorImpl.java  |  16 +-
 .../cache/distributed/dht/GridDhtGetFuture.java |  77 +-
 .../distributed/dht/GridDhtGetSingleFuture.java |   4 +
 .../dht/GridDhtTransactionalCacheAdapter.java   |  57 +-
 .../dht/atomic/GridDhtAtomicCache.java          |  52 +-
 .../dht/preloader/GridDhtForceKeysFuture.java   |   6 +-
 .../dht/preloader/GridDhtPreloader.java         |  28 +-
 .../processors/cache/query/CacheQuery.java      |  10 +-
 .../cache/query/CacheQueryFuture.java           |  13 +-
 .../query/GridCacheDistributedQueryManager.java | 100 ++-
 .../cache/query/GridCacheLocalQueryManager.java |  34 +-
 .../cache/query/GridCacheQueryAdapter.java      | 175 +++--
 .../cache/query/GridCacheQueryErrorFuture.java  |  12 +-
 .../query/GridCacheQueryFutureAdapter.java      |  10 +-
 .../cache/query/GridCacheQueryManager.java      | 502 +++++++++----
 .../continuous/GridContinuousProcessor.java     |   1 -
 .../datastructures/GridCacheSetImpl.java        |   9 +-
 .../utils/PlatformConfigurationUtils.java       | 111 ++-
 .../service/GridServiceProcessor.java           |  49 +-
 .../visor/compute/VisorGatewayTask.java         | 361 ++++++++++
 .../internal/visor/util/VisorTaskUtils.java     |  10 +-
 .../communication/tcp/TcpCommunicationSpi.java  |  32 +-
 .../GridCacheAbstractLocalStoreSelfTest.java    |   2 +
 .../CacheLateAffinityAssignmentTest.java        |   2 +-
 ...niteCacheClientNodeChangingTopologyTest.java |   9 +-
 .../dht/GridCacheTxNodeFailureSelfTest.java     |   2 +
 ...achePartitionedPreloadLifecycleSelfTest.java | 102 +--
 ...CacheReplicatedPreloadLifecycleSelfTest.java | 132 +---
 .../IgniteCacheExpiryPolicyTestSuite.java       |   3 +
 .../ConfigVariationsTestSuiteBuilder.java       |   4 +-
 ...IgniteCacheConfigVariationsAbstractTest.java |   2 +-
 .../IgniteConfigVariationsAbstractTest.java     |  27 +-
 .../IgniteCacheDataStructuresSelfTestSuite.java |   3 +-
 modules/indexing/pom.xml                        |   7 +
 .../processors/query/h2/IgniteH2Indexing.java   |  59 ++
 .../CacheAbstractQueryMetricsSelfTest.java      |   4 +-
 .../cache/IgniteCacheAbstractQuerySelfTest.java |  34 +-
 .../IgniteCacheConfigVariationsQueryTest.java   | 505 +++++++++++++
 .../IgniteCacheQueryH2IndexingLeakTest.java     | 214 ++++++
 ...gniteCacheConfigVariationQueryTestSuite.java |  41 ++
 .../IgniteCacheQuerySelfTestSuite.java          |   2 +
 modules/mesos/pom.xml                           |  43 +-
 .../apache/ignite/mesos/ClusterProperties.java  |  94 ++-
 .../apache/ignite/mesos/IgniteFramework.java    |  15 +-
 .../ignite/mesos/resource/IgniteProvider.java   | 198 ++---
 .../ignite/mesos/resource/ResourceProvider.java |  78 +-
 modules/platforms/cpp/DEVNOTES.txt              |  10 +
 modules/platforms/cpp/Makefile.am               |   5 +-
 modules/platforms/cpp/Makefile.amrel            |   5 +-
 modules/platforms/cpp/examples/README.txt       |   1 +
 modules/platforms/cpp/odbc/README.txt           |   7 +-
 .../cpp/odbc/install/install_amd64.cmd          |  35 +-
 .../platforms/cpp/odbc/install/install_x86.cmd  |  17 +-
 .../Apache.Ignite.Core.Tests.csproj             |   3 +
 .../Binary/BinaryCompactFooterInteropTest.cs    |   1 -
 .../Cache/CacheConfigurationTest.cs             |   7 +
 .../Continuous/ContinuousQueryJavaFilterTest.cs |   1 -
 .../Cache/Store/CacheStoreTest.cs               |   1 -
 .../Compute/ComputeApiTest.cs                   |   1 -
 .../Compute/MixedClusterTest.cs                 |   1 -
 .../Config/spring-test.xml                      |  46 ++
 .../Apache.Ignite.Core.Tests/DeploymentTest.cs  |   1 -
 .../Apache.Ignite.Core.Tests/ExecutableTest.cs  |   1 -
 .../IgniteConfigurationSerializerTest.cs        |  57 +-
 .../IgniteConfigurationTest.cs                  |  48 +-
 .../IgniteStartStopTest.cs                      |   1 -
 .../Apache.Ignite.Core.Tests/ReconnectTest.cs   |   1 -
 .../Services/ServicesTest.cs                    |   1 -
 .../Apache.Ignite.Core.csproj                   |   1 +
 .../Cache/Configuration/CacheConfiguration.cs   |  11 +
 .../Discovery/Tcp/TcpDiscoverySpi.cs            | 161 +++++
 .../Apache.Ignite.Core/IgniteConfiguration.cs   | 173 +++--
 .../IgniteConfigurationSection.xsd              |  36 +
 .../dotnet/Apache.Ignite.Core/Ignition.cs       |   1 -
 .../Impl/Binary/BinaryReaderExtensions.cs       |  24 +
 .../Impl/Binary/BinaryWriterExtensions.cs       |  78 ++
 .../dotnet/Apache.Ignite.Core/Impl/Ignite.cs    |   1 -
 .../http/jetty/GridJettyJsonConfig.java         | 288 +++++---
 .../http/jetty/GridJettyRestHandler.java        |   2 +-
 .../http/jetty/GridJettyRestProtocol.java       |   2 +-
 .../schema/test/model/ignite-type-metadata.xml  |  12 +-
 .../IgniteCacheRandomOperationBenchmark.java    |   4 +-
 pom.xml                                         |   2 +-
 91 files changed, 4205 insertions(+), 1072 deletions(-)
----------------------------------------------------------------------



[16/24] ignite git commit: ignite-1.6 Fixed test CacheLateAffinityAssignmentTest.testCacheStartDestroy

Posted by ak...@apache.org.
ignite-1.6 Fixed test CacheLateAffinityAssignmentTest.testCacheStartDestroy


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

Branch: refs/heads/master
Commit: cc58a63d1024c6c76b865731ab9f96cedcd0c9e6
Parents: 90ae602
Author: sboikov <sb...@gridgain.com>
Authored: Mon May 16 15:28:20 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Mon May 16 15:28:20 2016 +0300

----------------------------------------------------------------------
 .../cache/distributed/CacheLateAffinityAssignmentTest.java         | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/cc58a63d/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLateAffinityAssignmentTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLateAffinityAssignmentTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLateAffinityAssignmentTest.java
index 664f2ee..4fb17e8 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLateAffinityAssignmentTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLateAffinityAssignmentTest.java
@@ -1280,7 +1280,7 @@ public class CacheLateAffinityAssignmentTest extends GridCommonAbstractTest {
 
         client.destroyCache(CACHE_NAME2);
 
-        checkAffinity(4, topVer(4, 2), true);
+        checkAffinity(4, topVer(4, 3), true);
     }
 
     /**


[14/24] ignite git commit: Javadoc error fixed

Posted by ak...@apache.org.
Javadoc error fixed


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

Branch: refs/heads/master
Commit: 77e06a8072f3a2d61cadad8fa63e412fb5b2c4a4
Parents: 5a2aae7
Author: ashutak <as...@gridgain.com>
Authored: Mon May 16 15:22:44 2016 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Mon May 16 15:22:44 2016 +0300

----------------------------------------------------------------------
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/77e06a80/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index d9ed20c..d5ee939 100644
--- a/pom.xml
+++ b/pom.xml
@@ -205,7 +205,7 @@
                                     <reportOutputDirectory>${basedir}/target/javadoc</reportOutputDirectory>
                                     <destDir>core</destDir>
                                     <stylesheetfile>${basedir}/assembly/docfiles/javadoc.css</stylesheetfile>
-                                    <subpackages>org.apache.ignite -exclude org.apache.ignite.client:org.apache.ignite.codegen:org.apache.ignite.examples:org.apache.ignite.internal:org.apache.ignite.schema:org.apache.ignite.tests:org.apache.ignite.tools:org.apache.ignite.util:org.apache.ignite.spi.discovery.tcp.messages:org.apache.ignite.spi.discovery.tcp.internal:org.apache.ignite.spi.deployment.uri.scanners:org.apache.ignite.spi.deployment.uri.tasks:org.apache.ignite.yardstick</subpackages>
+                                    <subpackages>org.apache.ignite -exclude org.apache.ignite.client:org.apache.ignite.codegen:org.apache.ignite.examples:org.apache.ignite.internal:org.apache.ignite.schema:org.apache.ignite.tests:org.apache.ignite.tools:org.apache.ignite.util:org.apache.ignite.spi.discovery.tcp.messages:org.apache.ignite.spi.discovery.tcp.internal:org.apache.ignite.spi.deployment.uri.scanners:org.apache.ignite.spi.deployment.uri.tasks:org.apache.ignite.yardstick:org.apache.ignite.webtest</subpackages>
                                 </configuration>
                             </execution>
                         </executions>


[05/24] ignite git commit: IGNITE-3118: .NET: Pass EvictionPolicy configuration back and forth. This closes #710.

Posted by ak...@apache.org.
IGNITE-3118: .NET: Pass EvictionPolicy configuration back and forth. This closes #710.


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

Branch: refs/heads/master
Commit: 424cf8937e25f2f9f3095a56a87a47c2ecfea4be
Parents: 5a43025
Author: Pavel Tupitsyn <pt...@gridgain.com>
Authored: Mon May 16 11:43:29 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Mon May 16 11:43:29 2016 +0300

----------------------------------------------------------------------
 .../utils/PlatformConfigurationUtils.java       | 34 +++++++++++++++----
 .../Cache/CacheConfigurationTest.cs             |  7 ++++
 .../IgniteConfigurationSerializerTest.cs        | 35 +++++++++++++++++++-
 .../IgniteConfigurationTest.cs                  |  1 +
 .../Cache/Configuration/CacheConfiguration.cs   | 11 ++++++
 .../IgniteConfigurationSection.xsd              | 23 +++++++++++++
 6 files changed, 103 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/424cf893/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
index d2eab1e..e462d40 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
@@ -174,6 +174,8 @@ public class PlatformConfigurationUtils {
         if (in.readBoolean())
             ccfg.setNearConfiguration(readNearConfiguration(in));
 
+        ccfg.setEvictionPolicy(readEvictionPolicy(in));
+
         return ccfg;
     }
 
@@ -185,8 +187,20 @@ public class PlatformConfigurationUtils {
      */
     public static NearCacheConfiguration readNearConfiguration(BinaryRawReader in) {
         NearCacheConfiguration cfg = new NearCacheConfiguration();
+
         cfg.setNearStartSize(in.readInt());
+        cfg.setNearEvictionPolicy(readEvictionPolicy(in));
+
+        return cfg;
+    }
 
+    /**
+     * Reads the eviction policy.
+     *
+     * @param in Stream.
+     * @return Eviction policy.
+     */
+    public static EvictionPolicy readEvictionPolicy(BinaryRawReader in) {
         byte plcTyp = in.readByte();
 
         switch (plcTyp) {
@@ -197,22 +211,20 @@ public class PlatformConfigurationUtils {
                 p.setBatchSize(in.readInt());
                 p.setMaxSize(in.readInt());
                 p.setMaxMemorySize(in.readLong());
-                cfg.setNearEvictionPolicy(p);
-                break;
+                return p;
             }
             case 2: {
                 LruEvictionPolicy p = new LruEvictionPolicy();
                 p.setBatchSize(in.readInt());
                 p.setMaxSize(in.readInt());
                 p.setMaxMemorySize(in.readLong());
-                cfg.setNearEvictionPolicy(p);
-                break;
+                return p;
             }
             default:
                 assert false;
         }
 
-        return cfg;
+        return null;
     }
 
     /**
@@ -226,9 +238,15 @@ public class PlatformConfigurationUtils {
         assert cfg != null;
 
         out.writeInt(cfg.getNearStartSize());
+        writeEvictionPolicy(out, cfg.getNearEvictionPolicy());
+    }
 
-        EvictionPolicy p = cfg.getNearEvictionPolicy();
-
+    /**
+     * Writes the eviction policy.
+     * @param out Stream.
+     * @param p Policy.
+     */
+    private static void writeEvictionPolicy(BinaryRawWriter out, EvictionPolicy p) {
         if (p instanceof FifoEvictionPolicy) {
             out.writeByte((byte)1);
 
@@ -610,6 +628,8 @@ public class PlatformConfigurationUtils {
         }
         else
             writer.writeBoolean(false);
+
+        writeEvictionPolicy(writer, ccfg.getEvictionPolicy());
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/424cf893/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheConfigurationTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheConfigurationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheConfigurationTest.cs
index d474f38..8a91f88 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheConfigurationTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheConfigurationTest.cs
@@ -239,6 +239,7 @@ namespace Apache.Ignite.Core.Tests.Cache
 
             AssertConfigsAreEqual(x.QueryEntities, y.QueryEntities);
             AssertConfigsAreEqual(x.NearConfiguration, y.NearConfiguration);
+            AssertConfigsAreEqual(x.EvictionPolicy, y.EvictionPolicy);
         }
 
         /// <summary>
@@ -509,6 +510,12 @@ namespace Apache.Ignite.Core.Tests.Cache
                         MaxMemorySize = 2500,
                         BatchSize = 3
                     }
+                },
+                EvictionPolicy = new FifoEvictionPolicy
+                {
+                    MaxSize = 26,
+                    MaxMemorySize = 2501,
+                    BatchSize = 33
                 }
             };
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/424cf893/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
index 72ca7f5..62690c3 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
@@ -31,6 +31,7 @@ namespace Apache.Ignite.Core.Tests
     using System.Xml.Schema;
     using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Cache.Configuration;
+    using Apache.Ignite.Core.Cache.Eviction;
     using Apache.Ignite.Core.Cache.Store;
     using Apache.Ignite.Core.Common;
     using Apache.Ignite.Core.Communication.Tcp;
@@ -90,6 +91,10 @@ namespace Apache.Ignite.Core.Tests
                                             </indexes>
                                         </queryEntity>
                                     </queryEntities>
+                                    <evictionPolicy type='LruEvictionPolicy' batchSize='1' maxSize='2' maxMemorySize='3' />
+                                    <nearConfiguration nearStartSize='7'>
+                                        <evictionPolicy type='FifoEvictionPolicy' batchSize='10' maxSize='20' maxMemorySize='30' />
+                                    </nearConfiguration>
                                 </cacheConfiguration>
                                 <cacheConfiguration name='secondCache' />
                             </cacheConfiguration>
@@ -145,6 +150,22 @@ namespace Apache.Ignite.Core.Tests
             Assert.AreEqual("indexFld", queryEntity.Indexes.Single().Fields.Single().Name);
             Assert.AreEqual(true, queryEntity.Indexes.Single().Fields.Single().IsDescending);
 
+            var nearCfg = cacheCfg.NearConfiguration;
+            Assert.IsNotNull(nearCfg);
+            Assert.AreEqual(7, nearCfg.NearStartSize);
+
+            var plc = nearCfg.EvictionPolicy as FifoEvictionPolicy;
+            Assert.IsNotNull(plc);
+            Assert.AreEqual(10, plc.BatchSize);
+            Assert.AreEqual(20, plc.MaxSize);
+            Assert.AreEqual(30, plc.MaxMemorySize);
+
+            var plc2 = cacheCfg.EvictionPolicy as LruEvictionPolicy;
+            Assert.IsNotNull(plc2);
+            Assert.AreEqual(1, plc2.BatchSize);
+            Assert.AreEqual(2, plc2.MaxSize);
+            Assert.AreEqual(3, plc2.MaxMemorySize);
+
             Assert.AreEqual(new Dictionary<string, object> {{"myNode", "true"}}, cfg.UserAttributes);
 
             var atomicCfg = cfg.AtomicConfiguration;
@@ -402,7 +423,19 @@ namespace Apache.Ignite.Core.Tests
                         WriteBehindFlushFrequency = TimeSpan.FromSeconds(5),
                         WriteBehindFlushSize = 66,
                         WriteBehindFlushThreadCount = 2,
-                        WriteSynchronizationMode = CacheWriteSynchronizationMode.FullAsync
+                        WriteSynchronizationMode = CacheWriteSynchronizationMode.FullAsync,
+                        NearConfiguration = new NearCacheConfiguration
+                        {
+                            NearStartSize = 5,
+                            EvictionPolicy = new FifoEvictionPolicy
+                            {
+                                BatchSize = 19, MaxMemorySize = 1024, MaxSize = 555
+                            }
+                        },
+                        EvictionPolicy = new LruEvictionPolicy
+                        {
+                            BatchSize = 18, MaxMemorySize = 1023, MaxSize = 554
+                        }
                     }
                 },
                 ClientMode = true,

http://git-wip-us.apache.org/repos/asf/ignite/blob/424cf893/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
index 465ba27..9657c9b 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
@@ -374,6 +374,7 @@ namespace Apache.Ignite.Core.Tests
         /// </summary>
         private static IgniteConfiguration GetCustomConfig()
         {
+            // CacheConfiguration is not tested here - see CacheConfigurationTest
             return new IgniteConfiguration
             {
                 DiscoverySpi = new TcpDiscoverySpi

http://git-wip-us.apache.org/repos/asf/ignite/blob/424cf893/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheConfiguration.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheConfiguration.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheConfiguration.cs
index e5fcdb1..627e244 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheConfiguration.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheConfiguration.cs
@@ -27,6 +27,7 @@ namespace Apache.Ignite.Core.Cache.Configuration
     using System.Linq;
     using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Cache;
+    using Apache.Ignite.Core.Cache.Eviction;
     using Apache.Ignite.Core.Cache.Store;
     using Apache.Ignite.Core.Common;
     using Apache.Ignite.Core.Impl.Binary;
@@ -269,6 +270,8 @@ namespace Apache.Ignite.Core.Cache.Configuration
             QueryEntities = count == 0 ? null : Enumerable.Range(0, count).Select(x => new QueryEntity(reader)).ToList();
 
             NearConfiguration = reader.ReadBoolean() ? new NearCacheConfiguration(reader) : null;
+
+            EvictionPolicy = EvictionPolicyBase.Read(reader);
         }
 
         /// <summary>
@@ -339,6 +342,8 @@ namespace Apache.Ignite.Core.Cache.Configuration
             }
             else
                 writer.WriteBoolean(false);
+
+            EvictionPolicyBase.Write(writer, EvictionPolicy);
         }
 
         /// <summary>
@@ -648,5 +653,11 @@ namespace Apache.Ignite.Core.Cache.Configuration
         /// Gets or sets the near cache configuration.
         /// </summary>
         public NearCacheConfiguration NearConfiguration { get; set; }
+
+        /// <summary>
+        /// Gets or sets the eviction policy.
+        /// Null value means disabled evictions.
+        /// </summary>
+        public IEvictionPolicy EvictionPolicy { get; set; }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/424cf893/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
index cd16c1c..6bc2e8f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
@@ -166,6 +166,29 @@
                                                 </xs:sequence>
                                             </xs:complexType>
                                         </xs:element>
+                                        <xs:element name="nearConfiguration" minOccurs="0">
+                                            <xs:complexType>
+                                                <xs:all>
+                                                    <xs:element name="evictionPolicy" minOccurs="0">
+                                                        <xs:complexType>
+                                                            <xs:attribute name="batchSize" type="xs:int" />
+                                                            <xs:attribute name="maxSize" type="xs:int" />
+                                                            <xs:attribute name="maxMemorySize" type="xs:int" />
+                                                            <xs:attribute name="type" type="xs:string" use="required" />
+                                                        </xs:complexType>
+                                                    </xs:element>
+                                                </xs:all>
+                                                <xs:attribute name="nearStartSize" type="xs:int" />
+                                            </xs:complexType>
+                                        </xs:element>
+                                        <xs:element name="evictionPolicy" minOccurs="0">
+                                            <xs:complexType>
+                                                <xs:attribute name="batchSize" type="xs:int" />
+                                                <xs:attribute name="maxSize" type="xs:int" />
+                                                <xs:attribute name="maxMemorySize" type="xs:int" />
+                                                <xs:attribute name="type" type="xs:string" use="required" />
+                                            </xs:complexType>
+                                        </xs:element>
                                     </xs:all>
                                     <xs:attribute name="name" type="xs:string" />
                                     <xs:attribute name="cacheMode" type="xs:string" />


[11/24] ignite git commit: ignite-2382 JDBC drivers improvements

Posted by ak...@apache.org.
ignite-2382 JDBC drivers improvements


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

Branch: refs/heads/master
Commit: 6bd0453382293b30df718ec03efa8ecdf347cc0e
Parents: 0c3f5d9
Author: agura <ag...@gridgain.com>
Authored: Mon May 16 00:19:46 2016 +0300
Committer: agura <ag...@gridgain.com>
Committed: Mon May 16 14:56:16 2016 +0300

----------------------------------------------------------------------
 modules/clients/src/test/config/jdbc-config.xml |   3 +-
 .../internal/jdbc2/JdbcConnectionSelfTest.java  |   2 +
 .../internal/jdbc2/JdbcNoDefaultCacheTest.java  | 161 +++++++++++++++++++
 .../ignite/jdbc/JdbcNoDefaultCacheTest.java     | 161 +++++++++++++++++++
 .../jdbc/suite/IgniteJdbcDriverTestSuite.java   |   3 +
 .../org/apache/ignite/IgniteJdbcDriver.java     |   2 +-
 .../ignite/internal/jdbc2/JdbcConnection.java   |  21 ++-
 .../ignite/internal/jdbc2/JdbcQueryTask.java    |  15 ++
 .../processors/cache/GridCacheProcessor.java    |  45 +++++-
 .../query/jdbc/GridCacheQueryJdbcTask.java      |  59 ++++++-
 .../jdbc/GridCacheQueryJdbcValidationTask.java  |   7 +-
 11 files changed, 462 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/6bd04533/modules/clients/src/test/config/jdbc-config.xml
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/config/jdbc-config.xml b/modules/clients/src/test/config/jdbc-config.xml
index 980eaf1..5e6e12c 100644
--- a/modules/clients/src/test/config/jdbc-config.xml
+++ b/modules/clients/src/test/config/jdbc-config.xml
@@ -26,7 +26,8 @@
         http://www.springframework.org/schema/beans
         http://www.springframework.org/schema/beans/spring-beans.xsd">
     <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
-        <property name="clientMode" value="true"/>
+        <!-- JDBC driver should force true value -->
+        <property name="clientMode" value="false"/>
 
         <property name="localHost" value="127.0.0.1"/>
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/6bd04533/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcConnectionSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcConnectionSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcConnectionSelfTest.java
index 951890e..8c05df3 100644
--- a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcConnectionSelfTest.java
+++ b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcConnectionSelfTest.java
@@ -108,10 +108,12 @@ public class JdbcConnectionSelfTest extends GridCommonAbstractTest {
 
         try (Connection conn = DriverManager.getConnection(url)) {
             assertNotNull(conn);
+            assertTrue(((JdbcConnection)conn).ignite().configuration().isClientMode());
         }
 
         try (Connection conn = DriverManager.getConnection(url + '/')) {
             assertNotNull(conn);
+            assertTrue(((JdbcConnection)conn).ignite().configuration().isClientMode());
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/6bd04533/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcNoDefaultCacheTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcNoDefaultCacheTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcNoDefaultCacheTest.java
new file mode 100644
index 0000000..0acaa05
--- /dev/null
+++ b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcNoDefaultCacheTest.java
@@ -0,0 +1,161 @@
+/*
+ * 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.jdbc2;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.Statement;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.configuration.CacheConfiguration;
+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 org.jetbrains.annotations.Nullable;
+
+import static org.apache.ignite.IgniteJdbcDriver.CFG_URL_PREFIX;
+
+/**
+ *
+ */
+public class JdbcNoDefaultCacheTest extends GridCommonAbstractTest {
+    /** IP finder. */
+    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+    /** First cache name. */
+    private static final String CACHE1_NAME = "cache1";
+
+    /** Second cache name. */
+    private static final String CACHE2_NAME = "cache2";
+
+    /** Ignite configuration URL. */
+    private static final String CFG_URL = "modules/clients/src/test/config/jdbc-config.xml";
+
+    /** Grid count. */
+    private static final int GRID_CNT = 2;
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        cfg.setCacheConfiguration(cacheConfiguration(CACHE1_NAME), cacheConfiguration(CACHE2_NAME));
+
+        TcpDiscoverySpi disco = new TcpDiscoverySpi();
+
+        disco.setIpFinder(IP_FINDER);
+
+        cfg.setDiscoverySpi(disco);
+
+        return cfg;
+    }
+
+    /**
+     * @param name Cache name.
+     * @return Cache configuration.
+     * @throws Exception In case of error.
+     */
+    private CacheConfiguration cacheConfiguration(@Nullable String name) throws Exception {
+        CacheConfiguration cfg = defaultCacheConfiguration();
+
+        cfg.setIndexedTypes(Integer.class, Integer.class);
+
+        cfg.setName(name);
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        startGridsMultiThreaded(GRID_CNT);
+
+        Class.forName("org.apache.ignite.IgniteJdbcDriver");
+
+        Ignite ignite = ignite(0);
+
+        IgniteCache<Integer, Integer> cache1 = ignite.cache(CACHE1_NAME);
+        IgniteCache<Integer, Integer> cache2 = ignite.cache(CACHE2_NAME);
+
+        for (int i = 0; i < 10; i++) {
+            cache1.put(i, i * 2);
+            cache2.put(i, i * 3);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTestsStopped() throws Exception {
+        stopAllGrids();
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testDefaults() throws Exception {
+        String url = CFG_URL_PREFIX + CFG_URL;
+
+        try (Connection conn = DriverManager.getConnection(url)) {
+            assertNotNull(conn);
+            assertTrue(((JdbcConnection)conn).ignite().configuration().isClientMode());
+        }
+
+        try (Connection conn = DriverManager.getConnection(url + '/')) {
+            assertNotNull(conn);
+            assertTrue(((JdbcConnection)conn).ignite().configuration().isClientMode());
+        }
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testNoCacheNameQuery() throws Exception {
+        Statement stmt;
+
+        stmt = DriverManager.getConnection(CFG_URL_PREFIX + CFG_URL).createStatement();
+
+        assertNotNull(stmt);
+        assertFalse(stmt.isClosed());
+
+        stmt.execute("select t._key, t._val from \"cache1\".Integer t");
+
+        ResultSet rs = stmt.getResultSet();
+
+        while(rs.next())
+            assertEquals(rs.getInt(2), rs.getInt(1) * 2);
+
+        stmt.execute("select t._key, t._val from \"cache2\".Integer t");
+
+        rs = stmt.getResultSet();
+
+        while(rs.next())
+            assertEquals(rs.getInt(2), rs.getInt(1) * 3);
+
+        stmt.execute("select t._key, t._val, v._val " +
+            "from \"cache1\".Integer t join \"cache2\".Integer v on t._key = v._key");
+
+        rs = stmt.getResultSet();
+
+        while(rs.next()) {
+            assertEquals(rs.getInt(2), rs.getInt(1) * 2);
+            assertEquals(rs.getInt(3), rs.getInt(1) * 3);
+        }
+
+        stmt.close();
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6bd04533/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcNoDefaultCacheTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcNoDefaultCacheTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcNoDefaultCacheTest.java
new file mode 100644
index 0000000..48748ba
--- /dev/null
+++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcNoDefaultCacheTest.java
@@ -0,0 +1,161 @@
+/*
+ * 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.jdbc;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.Statement;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.ConnectorConfiguration;
+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 org.jetbrains.annotations.Nullable;
+
+/**
+ *
+ */
+public class JdbcNoDefaultCacheTest extends GridCommonAbstractTest {
+    /** IP finder. */
+    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+    /** First cache name. */
+    private static final String CACHE1_NAME = "cache1";
+
+    /** Second cache name. */
+    private static final String CACHE2_NAME = "cache2";
+
+    /** URL. */
+    private static final String URL = "jdbc:ignite://127.0.0.1/";
+
+    /** Grid count. */
+    private static final int GRID_CNT = 2;
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        cfg.setCacheConfiguration(cacheConfiguration(CACHE1_NAME), cacheConfiguration(CACHE2_NAME));
+
+        TcpDiscoverySpi disco = new TcpDiscoverySpi();
+
+        disco.setIpFinder(IP_FINDER);
+
+        cfg.setDiscoverySpi(disco);
+
+        cfg.setConnectorConfiguration(new ConnectorConfiguration());
+
+        return cfg;
+    }
+
+    /**
+     * @param name Cache name.
+     * @return Cache configuration.
+     * @throws Exception In case of error.
+     */
+    @SuppressWarnings("unchecked")
+    private CacheConfiguration cacheConfiguration(@Nullable String name) throws Exception {
+        CacheConfiguration cfg = defaultCacheConfiguration();
+
+        cfg.setIndexedTypes(Integer.class, Integer.class);
+
+        cfg.setName(name);
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        startGridsMultiThreaded(GRID_CNT);
+
+        Class.forName("org.apache.ignite.IgniteJdbcDriver");
+
+        Ignite ignite = ignite(0);
+
+        IgniteCache<Integer, Integer> cache1 = ignite.cache(CACHE1_NAME);
+        IgniteCache<Integer, Integer> cache2 = ignite.cache(CACHE2_NAME);
+
+        for (int i = 0; i < 10; i++) {
+            cache1.put(i, i * 2);
+            cache2.put(i, i * 3);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTestsStopped() throws Exception {
+        stopAllGrids();
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testDefaults() throws Exception {
+        String url = URL;
+
+        try (Connection conn = DriverManager.getConnection(url)) {
+            assertNotNull(conn);
+        }
+
+        try (Connection conn = DriverManager.getConnection(url + '/')) {
+            assertNotNull(conn);
+        }
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testNoCacheNameQuery() throws Exception {
+        Statement stmt;
+
+        stmt = DriverManager.getConnection(URL).createStatement();
+
+        assertNotNull(stmt);
+        assertFalse(stmt.isClosed());
+
+        stmt.execute("select t._key, t._val from \"cache1\".Integer t");
+
+        ResultSet rs = stmt.getResultSet();
+
+        while(rs.next())
+            assertEquals(rs.getInt(2), rs.getInt(1) * 2);
+
+        stmt.execute("select t._key, t._val from \"cache2\".Integer t");
+
+        rs = stmt.getResultSet();
+
+        while(rs.next())
+            assertEquals(rs.getInt(2), rs.getInt(1) * 3);
+
+        stmt.execute("select t._key, t._val, v._val " +
+            "from \"cache1\".Integer t join \"cache2\".Integer v on t._key = v._key");
+
+        rs = stmt.getResultSet();
+
+        while(rs.next()) {
+            assertEquals(rs.getInt(2), rs.getInt(1) * 2);
+            assertEquals(rs.getInt(3), rs.getInt(1) * 3);
+        }
+
+        stmt.close();
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6bd04533/modules/clients/src/test/java/org/apache/ignite/jdbc/suite/IgniteJdbcDriverTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/suite/IgniteJdbcDriverTestSuite.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/suite/IgniteJdbcDriverTestSuite.java
index bac2f60..603ee81 100644
--- a/modules/clients/src/test/java/org/apache/ignite/jdbc/suite/IgniteJdbcDriverTestSuite.java
+++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/suite/IgniteJdbcDriverTestSuite.java
@@ -23,6 +23,7 @@ import org.apache.ignite.jdbc.JdbcConnectionSelfTest;
 import org.apache.ignite.jdbc.JdbcEmptyCacheSelfTest;
 import org.apache.ignite.jdbc.JdbcLocalCachesSelfTest;
 import org.apache.ignite.jdbc.JdbcMetadataSelfTest;
+import org.apache.ignite.jdbc.JdbcNoDefaultCacheTest;
 import org.apache.ignite.jdbc.JdbcPreparedStatementSelfTest;
 import org.apache.ignite.jdbc.JdbcResultSetSelfTest;
 import org.apache.ignite.jdbc.JdbcStatementSelfTest;
@@ -47,6 +48,7 @@ public class IgniteJdbcDriverTestSuite extends TestSuite {
         suite.addTest(new TestSuite(JdbcMetadataSelfTest.class));
         suite.addTest(new TestSuite(JdbcEmptyCacheSelfTest.class));
         suite.addTest(new TestSuite(JdbcLocalCachesSelfTest.class));
+        suite.addTest(new TestSuite(JdbcNoDefaultCacheTest.class));
 
         // Ignite client node based driver tests
         suite.addTest(new TestSuite(org.apache.ignite.internal.jdbc2.JdbcConnectionSelfTest.class));
@@ -57,6 +59,7 @@ public class IgniteJdbcDriverTestSuite extends TestSuite {
         suite.addTest(new TestSuite(org.apache.ignite.internal.jdbc2.JdbcMetadataSelfTest.class));
         suite.addTest(new TestSuite(org.apache.ignite.internal.jdbc2.JdbcEmptyCacheSelfTest.class));
         suite.addTest(new TestSuite(org.apache.ignite.internal.jdbc2.JdbcLocalCachesSelfTest.class));
+        suite.addTest(new TestSuite(org.apache.ignite.internal.jdbc2.JdbcNoDefaultCacheTest.class));
 
         return suite;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/6bd04533/modules/core/src/main/java/org/apache/ignite/IgniteJdbcDriver.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteJdbcDriver.java b/modules/core/src/main/java/org/apache/ignite/IgniteJdbcDriver.java
index 7f8b523..567ff9f 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteJdbcDriver.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteJdbcDriver.java
@@ -461,7 +461,7 @@ public class IgniteJdbcDriver implements Driver {
 
         if (url.startsWith(URL_PREFIX) && url.length() > URL_PREFIX.length())
             return parseJdbcUrl(url, props);
-        else if (url.startsWith(CFG_URL_PREFIX) && url.length() > CFG_URL_PREFIX.length())
+        else if (url.startsWith(CFG_URL_PREFIX) && url.length() >= CFG_URL_PREFIX.length())
             return parseJdbcConfigUrl(url, props);
 
         return false;

http://git-wip-us.apache.org/repos/asf/ignite/blob/6bd04533/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcConnection.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcConnection.java b/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcConnection.java
index 00eb6b5..2d2ce5d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcConnection.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcConnection.java
@@ -76,6 +76,9 @@ import static org.apache.ignite.IgniteJdbcDriver.PROP_NODE_ID;
  * JDBC connection implementation.
  */
 public class JdbcConnection implements Connection {
+    /** Null stub. */
+    private static final String NULL = "null";
+
     /**
      * Ignite nodes cache.
      *
@@ -136,7 +139,9 @@ public class JdbcConnection implements Connection {
             this.nodeId = UUID.fromString(nodeIdProp);
 
         try {
-            cfg = props.getProperty(PROP_CFG);
+            String cfgUrl = props.getProperty(PROP_CFG);
+
+            cfg = cfgUrl == null || cfgUrl.isEmpty() ? NULL : cfgUrl;
 
             ignite = getIgnite(cfg);
 
@@ -169,7 +174,15 @@ public class JdbcConnection implements Connection {
                     fut = old;
                 else {
                     try {
-                        Ignite ignite = Ignition.start(loadConfiguration(cfgUrl));
+                        Ignite ignite;
+
+                        if (NULL.equals(cfg)) {
+                            Ignition.setClientMode(true);
+
+                            ignite = Ignition.start();
+                        }
+                        else
+                            ignite = Ignition.start(loadConfiguration(cfgUrl));
 
                         fut.onDone(ignite);
                     }
@@ -201,6 +214,8 @@ public class JdbcConnection implements Connection {
             if (cfg.getGridName() == null)
                 cfg.setGridName("ignite-jdbc-driver-" + UUID.randomUUID().toString());
 
+            cfg.setClientMode(true); // Force client mode.
+
             return cfg;
         }
         catch (IgniteCheckedException e) {
@@ -733,7 +748,7 @@ public class JdbcConnection implements Connection {
 
         /** {@inheritDoc} */
         @Override public Boolean call() {
-            return ignite.cache(cacheName) != null;
+            return cacheName == null || ignite.cache(cacheName) != null;
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/6bd04533/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcQueryTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcQueryTask.java b/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcQueryTask.java
index ac711b8..1a5793a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcQueryTask.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcQueryTask.java
@@ -18,6 +18,7 @@
 package org.apache.ignite.internal.jdbc2;
 
 import java.io.Serializable;
+import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Iterator;
@@ -34,6 +35,7 @@ import org.apache.ignite.IgniteJdbcDriver;
 import org.apache.ignite.IgniteSystemProperties;
 import org.apache.ignite.cache.query.QueryCursor;
 import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.internal.IgniteKernal;
 import org.apache.ignite.internal.processors.cache.QueryCursorImpl;
 import org.apache.ignite.internal.processors.query.GridQueryFieldMetadata;
 import org.apache.ignite.internal.util.typedef.CAX;
@@ -127,6 +129,19 @@ class JdbcQueryTask implements IgniteCallable<JdbcQueryTask.QueryResult> {
         if (first = (cursor == null)) {
             IgniteCache<?, ?> cache = ignite.cache(cacheName);
 
+            // Don't create caches on server nodes in order to avoid of data rebalancing.
+            boolean start = ignite.configuration().isClientMode();
+
+            if (cache == null && cacheName == null)
+                cache = ((IgniteKernal)ignite).context().cache().getOrStartPublicCache(start, !loc && locQry);
+
+            if (cache == null) {
+                if (cacheName == null)
+                    throw new SQLException("Failed to execute query. No suitable caches found.");
+                else
+                    throw new SQLException("Cache not found [cacheName=" + cacheName + ']');
+            }
+
             SqlFieldsQuery qry = new SqlFieldsQuery(sql).setArgs(args);
 
             qry.setPageSize(fetchSize);

http://git-wip-us.apache.org/repos/asf/ignite/blob/6bd04533/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 0f8e3f6..5711366 100755
--- 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
@@ -105,7 +105,6 @@ import org.apache.ignite.internal.util.future.GridFinishedFuture;
 import org.apache.ignite.internal.util.future.GridFutureAdapter;
 import org.apache.ignite.internal.util.lang.IgniteOutClosureX;
 import org.apache.ignite.internal.util.tostring.GridToStringInclude;
-import org.apache.ignite.internal.util.typedef.CIX1;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.X;
 import org.apache.ignite.internal.util.typedef.internal.CU;
@@ -1521,6 +1520,42 @@ public class GridCacheProcessor extends GridProcessorAdapter {
     }
 
     /**
+     * Gets public cache that can be used for query execution.
+     * If cache isn't created on current node it will be started.
+     *
+     * @param start Start cache.
+     * @param inclLoc Include local caches.
+     * @return Cache or {@code null} if there is no suitable cache.
+     */
+    public IgniteCacheProxy<?, ?> getOrStartPublicCache(boolean start, boolean inclLoc) throws IgniteCheckedException {
+        // Try to find started cache first.
+        for (Map.Entry<String, GridCacheAdapter<?, ?>> e : caches.entrySet()) {
+            CacheConfiguration ccfg = e.getValue().configuration();
+
+            String cacheName = ccfg.getName();
+
+            if ((inclLoc || ccfg.getCacheMode() != LOCAL) && GridQueryProcessor.isEnabled(ccfg))
+                return publicJCache(cacheName);
+        }
+
+        if (start) {
+            for (Map.Entry<String, DynamicCacheDescriptor> e : registeredCaches.entrySet()) {
+                DynamicCacheDescriptor desc = e.getValue();
+
+                CacheConfiguration ccfg = desc.cacheConfiguration();
+
+                if (ccfg.getCacheMode() != LOCAL && GridQueryProcessor.isEnabled(ccfg)) {
+                    dynamicStartCache(null, ccfg.getName(), null, false, true, true).get();
+
+                    return publicJCache(ccfg.getName());
+                }
+            }
+        }
+
+        return null;
+    }
+
+    /**
      * Gets a collection of currently started public cache names.
      *
      * @return Collection of currently started public cache names
@@ -3384,9 +3419,11 @@ public class GridCacheProcessor extends GridProcessorAdapter {
      * @throws IgniteCheckedException In case of error.
      */
     public void createMissingCaches() throws IgniteCheckedException {
-        for (String cacheName : registeredCaches.keySet()) {
-            if (!CU.isSystemCache(cacheName) && !caches.containsKey(cacheName))
-                dynamicStartCache(null, cacheName, null, false, true, true).get();
+        for (Map.Entry<String, DynamicCacheDescriptor> e : registeredCaches.entrySet()) {
+            CacheConfiguration ccfg = e.getValue().cacheConfiguration();
+
+            if (!caches.containsKey(maskNull(ccfg.getName())) && GridQueryProcessor.isEnabled(ccfg))
+                dynamicStartCache(null, ccfg.getName(), null, false, true, true).get();
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/6bd04533/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcTask.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcTask.java
index 5c60762..26d4b82 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcTask.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcTask.java
@@ -55,6 +55,7 @@ import org.apache.ignite.marshaller.Marshaller;
 import org.apache.ignite.marshaller.jdk.JdkMarshaller;
 import org.apache.ignite.resources.IgniteInstanceResource;
 import org.apache.ignite.resources.LoggerResource;
+import org.jetbrains.annotations.Nullable;
 
 import static org.apache.ignite.compute.ComputeJobResultPolicy.WAIT;
 
@@ -74,6 +75,7 @@ public class GridCacheQueryJdbcTask extends ComputeTaskAdapter<byte[], byte[]> {
     /** Scheduler. */
     private static final ScheduledExecutorService SCHEDULER = Executors.newScheduledThreadPool(1);
 
+    /** Ignite. */
     @IgniteInstanceResource
     private Ignite ignite;
 
@@ -104,14 +106,22 @@ public class GridCacheQueryJdbcTask extends ComputeTaskAdapter<byte[], byte[]> {
             else {
                 String cache = (String)args.get("cache");
 
-                GridDiscoveryManager discoMgr = ((IgniteKernal)ignite).context().discovery();
+                Map<? extends ComputeJob, ClusterNode> node = mapToNode(subgrid, args, first, cache);
 
-                for (ClusterNode n : subgrid) {
-                    if (discoMgr.cacheAffinityNode(n, cache))
-                        return F.asMap(new JdbcDriverJob(args, first), n);
+                if (node == null && cache == null) {
+                    boolean start = ignite.configuration().isClientMode();
+
+                    IgniteCache<?, ?> cache0 =
+                            ((IgniteKernal)ignite).context().cache().getOrStartPublicCache(start, false);
+
+                    if (cache0 != null)
+                        node = mapToNode(subgrid, args, first, cache0.getName());
                 }
 
-                throw new IgniteException("Can't find node with cache: " + cache);
+                if (node != null)
+                    return node;
+                else
+                    throw new IgniteException("Can't find node with cache: " + cache);
             }
         }
         catch (IgniteCheckedException e) {
@@ -119,6 +129,31 @@ public class GridCacheQueryJdbcTask extends ComputeTaskAdapter<byte[], byte[]> {
         }
     }
 
+    /**
+     * @param subgrid Subgrid.
+     * @param args Args.
+     * @param first First.
+     * @param cache Cache.
+     */
+    @Nullable private Map<? extends ComputeJob, ClusterNode> mapToNode(
+        List<ClusterNode> subgrid,
+        Map<String, Object> args,
+        boolean first,
+        String cache
+    ) {
+        GridDiscoveryManager discoMgr = ((IgniteKernal)ignite).context().discovery();
+
+        for (ClusterNode n : subgrid) {
+            if (discoMgr.cacheAffinityNode(n, cache)) {
+                args.put("cache", cache);
+
+                return F.asMap(new JdbcDriverJob(args, first), n);
+            }
+        }
+
+        return null;
+    }
+
     /** {@inheritDoc} */
     @Override public byte[] reduce(List<ComputeJobResult> results) throws IgniteException {
         try {
@@ -215,6 +250,20 @@ public class GridCacheQueryJdbcTask extends ComputeTaskAdapter<byte[], byte[]> {
 
                 IgniteCache<?, ?> cache = ignite.cache(cacheName);
 
+                if (cache == null && cacheName == null) {
+                    try {
+                        boolean start = ignite.configuration().isClientMode();
+
+                        cache = ((IgniteKernal)ignite).context().cache().getOrStartPublicCache(start, false);
+                    }
+                    catch (IgniteCheckedException e) {
+                        throw new IgniteException(e);
+                    }
+                }
+
+                if (cache == null)
+                    throw new IgniteException(new SQLException("Cache not found [cacheName=" + cacheName + ']'));
+
                 SqlFieldsQuery qry = new SqlFieldsQuery(sql).setArgs(args.toArray());
 
                 qry.setPageSize(pageSize);

http://git-wip-us.apache.org/repos/asf/ignite/blob/6bd04533/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcValidationTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcValidationTask.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcValidationTask.java
index 692d01c..886211d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcValidationTask.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcValidationTask.java
@@ -40,14 +40,15 @@ public class GridCacheQueryJdbcValidationTask extends ComputeTaskSplitAdapter<St
     private static final long serialVersionUID = 0L;
 
     /** {@inheritDoc} */
-    @Override protected Collection<? extends ComputeJob> split(int gridSize,
-        @Nullable final String cacheName) {
-        // Register big data usage.
+    @Override protected Collection<? extends ComputeJob> split(int gridSize, @Nullable final String cacheName) {
         return Collections.singleton(new ComputeJobAdapter() {
             @IgniteInstanceResource
             private Ignite ignite;
 
             @Override public Object execute() {
+                if (cacheName == null)
+                    return true;
+
                 GridDiscoveryManager discoMgr = ((IgniteKernal)ignite).context().discovery();
 
                 for (ClusterNode n : ignite.cluster().nodes())


[23/24] ignite git commit: Hanging tests fixed

Posted by ak...@apache.org.
Hanging tests fixed


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

Branch: refs/heads/master
Commit: 1dc1d85611492739d077e53cfd3e4db710040180
Parents: 9ea769a
Author: agura <ag...@gridgain.com>
Authored: Mon May 16 18:32:07 2016 +0300
Committer: agura <ag...@gridgain.com>
Committed: Mon May 16 18:32:07 2016 +0300

----------------------------------------------------------------------
 .../cache/transactions/TxDeadlockDetectionTest.java     | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/1dc1d856/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionTest.java
index 87539b2..3d0beac 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionTest.java
@@ -96,7 +96,7 @@ public class TxDeadlockDetectionTest extends GridCommonAbstractTest {
     @Override protected void beforeTestsStarted() throws Exception {
         super.beforeTestsStarted();
 
-        startGrids(NODES_CNT);
+        startGridsMultiThreaded(NODES_CNT);
     }
 
     /** {@inheritDoc} */
@@ -151,7 +151,7 @@ public class TxDeadlockDetectionTest extends GridCommonAbstractTest {
 
                         IgniteCache<Integer, Integer> cache = ignite.cache(CACHE);
 
-                        try (Transaction tx = ignite.transactions().txStart(PESSIMISTIC, REPEATABLE_READ, 500, 0)) {
+                        try (Transaction tx = ignite.transactions().txStart(PESSIMISTIC, REPEATABLE_READ, 700, 0)) {
                             ThreadLocalRandom8 rnd = ThreadLocalRandom8.current();
 
                             for (int i = 0; i < 50; i++) {
@@ -198,7 +198,7 @@ public class TxDeadlockDetectionTest extends GridCommonAbstractTest {
 
         final CyclicBarrier barrier = new CyclicBarrier(2);
 
-        final int timeout = 500;
+        final long timeout = 500;
 
         IgniteInternalFuture<Long> fut = GridTestUtils.runMultiThreadedAsync(new Runnable() {
             @Override public void run() {
@@ -257,7 +257,7 @@ public class TxDeadlockDetectionTest extends GridCommonAbstractTest {
 
             final CyclicBarrier barrier = new CyclicBarrier(threads);
 
-            final int timeout = 500;
+            final long timeout = 500;
 
             IgniteInternalFuture<Long> fut = GridTestUtils.runMultiThreadedAsync(new Runnable() {
                 @Override public void run() {
@@ -336,7 +336,7 @@ public class TxDeadlockDetectionTest extends GridCommonAbstractTest {
         try {
             final int txCnt = 2;
 
-            final CyclicBarrier barrier = new CyclicBarrier(2);
+            final CyclicBarrier barrier = new CyclicBarrier(txCnt);
 
             final AtomicInteger threadCnt = new AtomicInteger();
 
@@ -381,7 +381,7 @@ public class TxDeadlockDetectionTest extends GridCommonAbstractTest {
                         deadlock.compareAndSet(false, hasCause(e, TransactionDeadlockException.class));
                     }
                 }
-            }, 2, "tx-thread");
+            }, txCnt, "tx-thread");
 
             fut.get();
 


[18/24] ignite git commit: IGNITE-3115: CPP: Minor fixes to docs. This closes #714.

Posted by ak...@apache.org.
IGNITE-3115: CPP: Minor fixes to docs. This closes #714.


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

Branch: refs/heads/master
Commit: 9a9c35dbe1652abbe5f483edb065e53310a0a3dd
Parents: f65dd00
Author: isapego <is...@gridgain.com>
Authored: Mon May 16 15:32:55 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Mon May 16 15:32:55 2016 +0300

----------------------------------------------------------------------
 modules/platforms/cpp/DEVNOTES.txt              | 10 ++++++
 modules/platforms/cpp/Makefile.am               |  5 ++-
 modules/platforms/cpp/Makefile.amrel            |  5 ++-
 modules/platforms/cpp/examples/README.txt       |  1 +
 modules/platforms/cpp/odbc/README.txt           |  7 ++--
 .../cpp/odbc/install/install_amd64.cmd          | 35 +++++++++++++-------
 .../platforms/cpp/odbc/install/install_x86.cmd  | 17 ++++++----
 7 files changed, 57 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/9a9c35db/modules/platforms/cpp/DEVNOTES.txt
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/DEVNOTES.txt b/modules/platforms/cpp/DEVNOTES.txt
index fa664ef..cd0a154 100644
--- a/modules/platforms/cpp/DEVNOTES.txt
+++ b/modules/platforms/cpp/DEVNOTES.txt
@@ -29,6 +29,13 @@ Ignite-specific options:
  * --enable-odbc - build included ODBC driver. Disabled by default.
  * --enable-core - build Ignite core library. Enabled by default.
  * --enable-node - build stand-alone node executable. Enabled by default.
+ 
+If you only need to build ODBC driver and do not want to build anything else you may just
+use configure script with the following arguments:
+ ./configure --enable-odbc --disable-core --disable-node
+
+With the config like that you should not have any ignite dependencies as jvm.dll installed
+to build ODBC driver.
 
 NOTE: You may want to use "make install" command to install Ignite libraries and heasders
 for your operation system. Note however that this action may require superuser privileges.
@@ -48,6 +55,9 @@ Building binaries:
 
  * Open and build %IGNITE_HOME%\platforms\cpp\project\vs\ignite.sln (or ignite_86.sln if
    you are running 32-bit platform).
+ * If you want to build ODBC driver then you should explicitly build it as it is disabled
+   in the solution file by default. In IDE it can be done by clicking on the ODBC project
+   with the right mouse button and choosing "Build" option.
 
 Building in later versions of Visual Studio:
  * Open project\vs\ignite.sln or project\vs\ignite_86.sln in Visual Studio

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a9c35db/modules/platforms/cpp/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/Makefile.am b/modules/platforms/cpp/Makefile.am
index 5213d0c..6b643bc 100644
--- a/modules/platforms/cpp/Makefile.am
+++ b/modules/platforms/cpp/Makefile.am
@@ -27,6 +27,7 @@ endif
 
 if COND_CORE
   MAYBE_CORE = core
+  MAYBE_JNI = jni
 
 if COND_TESTS
     MAYBE_CORE_TESTS = core-test
@@ -34,13 +35,15 @@ endif
 endif
 
 if COND_NODE
+  MAYBE_CORE = core
+  MAYBE_JNI = jni
   MAYBE_NODE = ignite
 endif
 
 SUBDIRS = \
     common \
     binary \
-    jni \
+    $(MAYBE_JNI) \
     $(MAYBE_ODBC) \
     $(MAYBE_CORE) \
     $(MAYBE_NODE) \

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a9c35db/modules/platforms/cpp/Makefile.amrel
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/Makefile.amrel b/modules/platforms/cpp/Makefile.amrel
index 6172d06..ae34b03 100644
--- a/modules/platforms/cpp/Makefile.amrel
+++ b/modules/platforms/cpp/Makefile.amrel
@@ -23,16 +23,19 @@ endif
 
 if COND_CORE
   MAYBE_CORE = core
+  MAYBE_JNI = jni
 endif
 
 if COND_NODE
+  MAYBE_CORE = core
+  MAYBE_JNI = jni
   MAYBE_NODE = ignite
 endif
 
 SUBDIRS = \
     common \
     binary \
-    jni \
+    $(MAYBE_JNI) \
     $(MAYBE_ODBC) \
     $(MAYBE_CORE) \
     $(MAYBE_NODE)

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a9c35db/modules/platforms/cpp/examples/README.txt
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/examples/README.txt b/modules/platforms/cpp/examples/README.txt
index b985f07..29df732 100644
--- a/modules/platforms/cpp/examples/README.txt
+++ b/modules/platforms/cpp/examples/README.txt
@@ -16,6 +16,7 @@ Prerequisites:
  * GCC, g++, autotools, automake, and libtool must be installed.
 
 To build examples execute the following commands one by one from examples root directory:
+ * libtoolize && aclocal && autoheader && automake --add-missing && autoreconf
  * ./configure
  * make
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a9c35db/modules/platforms/cpp/odbc/README.txt
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/README.txt b/modules/platforms/cpp/odbc/README.txt
index e9d423f..8f0c805 100644
--- a/modules/platforms/cpp/odbc/README.txt
+++ b/modules/platforms/cpp/odbc/README.txt
@@ -44,6 +44,8 @@ ODBC driver you should perfrom the following steps:
    can check it using "ldd" command like this (assuming ODBC driver is located
    under /usr/local/lib):
    $ ldd /usr/local/lib/libignite-odbc.so.
+   If there is unresolved links to other libraries you may want to add
+   directories with these libraries to the LD_LIBRARY_PATH.
    
 2. Edit file $IGNITE_HOME/platforms/cpp/odbc/install/ignite-odbc-install.ini
    and ensure that "Driver" parameter of the "Apache Ignite" section points
@@ -66,7 +68,8 @@ dependencies can be resolved i.e. they can be found either in the %PATH% or
 in the same directory as the driver.
 
 After that you should use one of the install scripts from the directory 
-%IGNITE_HOME%/platforms/cpp/odbc/install:
+%IGNITE_HOME%/platforms/cpp/odbc/install. Note that most likely you will
+need OS administrator privileges to execute these scripts.
 
 For the 32-bit Windows you should use file install_x86.cmd like that:
 $ install_x86 <absolute_path_to_32_bit_driver>
@@ -74,8 +77,6 @@ $ install_x86 <absolute_path_to_32_bit_driver>
 For the 64-bit Windows you should use file install_amd64.cmd like that:
 $ install_amd64 <absolute_path_to_64_bit_driver> [<absolute_path_to_32_bit_driver>]
 
-Most likely you will need OS administrator privileges to execute these scripts.
-
 Thats it. Your driver/drivers are installed.
 
 After the installation

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a9c35db/modules/platforms/cpp/odbc/install/install_amd64.cmd
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/install/install_amd64.cmd b/modules/platforms/cpp/odbc/install/install_amd64.cmd
index 15b7bd8..8a0391f 100644
--- a/modules/platforms/cpp/odbc/install/install_amd64.cmd
+++ b/modules/platforms/cpp/odbc/install/install_amd64.cmd
@@ -1,29 +1,40 @@
 @echo off
 
-set ODBC_AMD64="%1"
-set ODBC_X86="%2"
+set ODBC_AMD64=%1
+set ODBC_X86=%2
 
-if exist %ODBC_AMD64% (
-	:: Installing 64-bit driver.
+if [%ODBC_AMD64%] == [] (
+	echo error: 64-bit driver is not specified. Call format: install_amd64 abs_path_to_64_bit_driver [abs_path_to_32_bit_driver]
+	pause
+	exit /b 1
+) else if exist "%ODBC_AMD64%" (
+	if exist "%ODBC_AMD64%\" (
+		echo warning: The path you have specified seems to be a directory. Note that you have to specify path to driver file itself instead.
+	)
+	echo Installing 64-bit driver: "%ODBC_AMD64%"
 	reg add "HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\Apache Ignite" /v DriverODBCVer /t REG_SZ /d "03.80" /f
 	reg add "HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\Apache Ignite" /v UsageCount /t REG_DWORD /d 00000001 /f
 	reg add "HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\Apache Ignite" /v Driver /t REG_SZ /d "%ODBC_AMD64%" /f
-	reg add "HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\Apache Ignite" /v Setup /t REG_SZ /d "%ODBC_AMD64%" /f
 	reg add "HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers" /v "Apache Ignite" /t REG_SZ /d "Installed" /f    
 ) else (
-	echo 64-bit driver can not be found: %ODBC_AMD64%
-	echo Call format: install_amd64 path_to_64_bit_driver [path_to_32_bit_driver]
+	echo 64-bit driver can not be found: "%ODBC_AMD64%"
+	echo Call format: install_amd64 abs_path_to_64_bit_driver [abs_path_to_32_bit_driver]
 	pause
 	exit /b 1
 )
 
-if exist %ODBC_X86% (
-	rem Installing 32-bit driver.
+if [%ODBC_X86%] == [] (
+	echo warning: 32-bit driver is not specified. If you want to install 32-bit driver please specify path to it as a second argument.
+) else if exist "%ODBC_X86%" (
+	if exist "%ODBC_X86%\" (
+		echo warning: The path you have specified seems to be a directory. Note that you have to specify path to driver file itself instead.
+	)
+	echo Installing 32-bit driver: "%ODBC_X86%"
 	reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI\Apache Ignite" /v DriverODBCVer /t REG_SZ /d "03.80" /f
 	reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI\Apache Ignite" /v UsageCount /t REG_DWORD /d 00000001 /f
 	reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI\Apache Ignite" /v Driver /t REG_SZ /d "%ODBC_X86%" /f
-	reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI\Apache Ignite" /v Setup /t REG_SZ /d "%ODBC_X86%" /f
 	reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI\ODBC Drivers" /v "Apache Ignite" /t REG_SZ /d "Installed" /f    
 ) else (
-	echo 32-bit driver can not be found: %ODBC_X86%
-)
\ No newline at end of file
+	echo warning: 32-bit driver can not be found: "%ODBC_X86%"
+)
+

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a9c35db/modules/platforms/cpp/odbc/install/install_x86.cmd
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/install/install_x86.cmd b/modules/platforms/cpp/odbc/install/install_x86.cmd
index 077589d..74eea0a 100644
--- a/modules/platforms/cpp/odbc/install/install_x86.cmd
+++ b/modules/platforms/cpp/odbc/install/install_x86.cmd
@@ -1,16 +1,21 @@
 @echo off
 
-set ODBC="%1"
+set ODBC=%1
 
-if exist %ODBC% (
-	:: Installing driver.
+if [%ODBC%] == [] (
+	echo error: driver is not specified. Call format: install_x86 abs_path_to_driver.
+	pause
+) else if exist "%ODBC%" (
+	if exist "%ODBC%\" (
+		echo warning: The path you have specified seems to be a directory. Note that you have to specify path to driver file itself instead.
+	)
+	echo Installing driver: "%ODBC%"
 	reg add "HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\Apache Ignite" /v DriverODBCVer /t REG_SZ /d "03.80" /f
 	reg add "HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\Apache Ignite" /v UsageCount /t REG_DWORD /d 00000001 /f
 	reg add "HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\Apache Ignite" /v Driver /t REG_SZ /d "%ODBC%" /f
-	reg add "HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\Apache Ignite" /v Setup /t REG_SZ /d "%ODBC%" /f
 	reg add "HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers" /v "Apache Ignite" /t REG_SZ /d "Installed" /f    
 ) else (
-	echo Driver can not be found: %ODBC%
-	echo Call format: install_x86 path_to_driver
+	echo Driver can not be found: "%ODBC%"
+	echo Call format: install_x86 abs_path_to_driver
 	pause
 )


[13/24] ignite git commit: ignite-1.6 Added topology wait in GridCacheTxNodeFailureSelfTest to avoid potential race.

Posted by ak...@apache.org.
ignite-1.6 Added topology wait in GridCacheTxNodeFailureSelfTest  to avoid potential race.


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

Branch: refs/heads/master
Commit: 5a2aae71b11ae34a3cec5f7f525c4c9befce955e
Parents: 5a83151
Author: sboikov <sb...@gridgain.com>
Authored: Mon May 16 15:11:23 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Mon May 16 15:11:23 2016 +0300

----------------------------------------------------------------------
 .../cache/distributed/dht/GridCacheTxNodeFailureSelfTest.java      | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/5a2aae71/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheTxNodeFailureSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheTxNodeFailureSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheTxNodeFailureSelfTest.java
index ad122e6..7fe1d61 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheTxNodeFailureSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheTxNodeFailureSelfTest.java
@@ -305,6 +305,8 @@ public class GridCacheTxNodeFailureSelfTest extends GridCommonAbstractTest {
             // Check that thread successfully finished.
             fut.get();
 
+            ((IgniteKernal)ignite(0)).context().discovery().topologyFuture(gridCount() + 1).get();
+
             awaitPartitionMapExchange();
 
             // Check there are no hanging transactions.


[03/24] ignite git commit: IGNITE-2864 Need update local store from primary and backups Tests @1.6 hotfix.

Posted by ak...@apache.org.
 IGNITE-2864  Need update local store from primary and backups
 Tests @1.6 hotfix.


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

Branch: refs/heads/master
Commit: dc7b37f0dafecd20da2866312f42a68a15f39a8d
Parents: 38d9e91
Author: Anton Vinogradov <av...@apache.org>
Authored: Mon May 16 11:24:13 2016 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Mon May 16 11:24:13 2016 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheAbstractLocalStoreSelfTest.java      | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/dc7b37f0/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractLocalStoreSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractLocalStoreSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractLocalStoreSelfTest.java
index 7426f48..26ab625 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractLocalStoreSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractLocalStoreSelfTest.java
@@ -329,6 +329,8 @@ public abstract class GridCacheAbstractLocalStoreSelfTest extends GridCommonAbst
         Ignite ignite1 = startGrid(1);
         Ignite ignite2 = startGrid(2);
 
+        awaitPartitionMapExchange();
+
         String name = BACKUP_CACHE_2;
 
         int key1 = -1;