You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by av...@apache.org on 2015/08/14 18:37:55 UTC

[01/34] incubator-ignite git commit: ignite-1189: clearing grid information on stop even when grid's state is not STARTED

Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-1093 50e188df2 -> 64319443a


ignite-1189: clearing grid information on stop even when grid's state is not STARTED


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

Branch: refs/heads/ignite-1093
Commit: ac6d75dc55eab0ce909c972a1124bf5fb42a5e3d
Parents: aec9764
Author: Denis Magda <dm...@gridgain.com>
Authored: Mon Aug 3 12:44:45 2015 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Mon Aug 3 12:44:45 2015 +0300

----------------------------------------------------------------------
 .../org/apache/ignite/internal/IgnitionEx.java  | 21 +++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ac6d75dc/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
index 5cbe377..d355085 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
@@ -261,8 +261,11 @@ public class IgnitionEx {
     public static boolean stop(@Nullable String name, boolean cancel) {
         IgniteNamedInstance grid = name != null ? grids.get(name) : dfltGrid;
 
-        if (grid != null && grid.state() == STARTED) {
-            grid.stop(cancel);
+        if (grid != null) {
+            IgniteState state = grid.state();
+
+            if (state == STARTED)
+                grid.stop(cancel);
 
             boolean fireEvt;
 
@@ -277,10 +280,18 @@ public class IgnitionEx {
                 }
             }
 
-            if (fireEvt)
-                notifyStateChange(grid.getName(), grid.state());
+            if (state == STARTED) {
+                if (fireEvt)
+                    notifyStateChange(grid.getName(), grid.state());
 
-            return true;
+                return true;
+            }
+            else {
+                U.warn(null, "Ignoring stopping grid instance (has not been in STARTED state): [grid=" + name +
+                    ", state=" + state + ']');
+
+                return false;
+            }
         }
 
         // We don't have log at this point...


[28/34] incubator-ignite git commit: # Fixed potential NPE in GridCachePartitionExchangeManager.dumpPendingObjects

Posted by av...@apache.org.
# Fixed potential NPE in GridCachePartitionExchangeManager.dumpPendingObjects


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

Branch: refs/heads/ignite-1093
Commit: ae11e9b5aa9af4d0d58e2a16dd3a3331969961df
Parents: 19fb305
Author: sboikov <sb...@gridgain.com>
Authored: Tue Aug 11 09:42:02 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Tue Aug 11 09:42:43 2015 +0300

----------------------------------------------------------------------
 .../GridCachePartitionExchangeManager.java      | 32 ++++++++++++--------
 1 file changed, 20 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ae11e9b5/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
index cf49197..e00d3b7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
@@ -984,25 +984,33 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
      *
      */
     public void dumpPendingObjects() {
-        U.warn(log, "Pending transactions:");
+        IgniteTxManager tm = cctx.tm();
 
-        for (IgniteInternalTx tx : cctx.tm().activeTransactions())
-            U.warn(log, ">>> " + tx);
+        if (tm != null) {
+            U.warn(log, "Pending transactions:");
 
-        U.warn(log, "Pending explicit locks:");
+            for (IgniteInternalTx tx : tm.activeTransactions())
+                U.warn(log, ">>> " + tx);
+        }
 
-        for (GridCacheExplicitLockSpan lockSpan : cctx.mvcc().activeExplicitLocks())
-            U.warn(log, ">>> " + lockSpan);
+        GridCacheMvccManager mvcc = cctx.mvcc();
 
-        U.warn(log, "Pending cache futures:");
+        if (mvcc != null) {
+            U.warn(log, "Pending explicit locks:");
 
-        for (GridCacheFuture<?> fut : cctx.mvcc().activeFutures())
-            U.warn(log, ">>> " + fut);
+            for (GridCacheExplicitLockSpan lockSpan : mvcc.activeExplicitLocks())
+                U.warn(log, ">>> " + lockSpan);
 
-        U.warn(log, "Pending atomic cache futures:");
+            U.warn(log, "Pending cache futures:");
 
-        for (GridCacheFuture<?> fut : cctx.mvcc().atomicFutures())
-            U.warn(log, ">>> " + fut);
+            for (GridCacheFuture<?> fut : mvcc.activeFutures())
+                U.warn(log, ">>> " + fut);
+
+            U.warn(log, "Pending atomic cache futures:");
+
+            for (GridCacheFuture<?> fut : mvcc.atomicFutures())
+                U.warn(log, ">>> " + fut);
+        }
     }
 
     /**


[22/34] incubator-ignite git commit: IGNITE-1189 Removed unnecessary comment.

Posted by av...@apache.org.
IGNITE-1189 Removed unnecessary comment.


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

Branch: refs/heads/ignite-1093
Commit: e42f954f043b6690dfcc10b7eb8817194eb898e2
Parents: 6770606
Author: nikolay_tikhonov <nt...@gridgain.com>
Authored: Mon Aug 10 13:33:28 2015 +0300
Committer: nikolay_tikhonov <nt...@gridgain.com>
Committed: Mon Aug 10 13:33:28 2015 +0300

----------------------------------------------------------------------
 .../java/org/apache/ignite/configuration/IgniteConfiguration.java   | 1 -
 1 file changed, 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e42f954f/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
index e1aff25..546c382 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
@@ -194,7 +194,6 @@ public class IgniteConfiguration {
 
     /** Default failure detection timeout in millis. */
     @SuppressWarnings("UnnecessaryBoxing")
-//    public static final Long DFLT_FAILURE_DETECTION_TIMEOUT = new Long(10_000);
     public static final Long DFLT_FAILURE_DETECTION_TIMEOUT = new Long(10_000);
 
     /** Optional grid name. */


[12/34] incubator-ignite git commit: msg format

Posted by av...@apache.org.
msg format


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

Branch: refs/heads/ignite-1093
Commit: 5ce8bc692cdc5e7662ccd6ac5f6e8f5b2fd493e4
Parents: d7623b4
Author: Yakov Zhdanov <yz...@gridgain.com>
Authored: Thu Aug 6 12:52:59 2015 +0300
Committer: Yakov Zhdanov <yz...@gridgain.com>
Committed: Thu Aug 6 12:52:59 2015 +0300

----------------------------------------------------------------------
 .../main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5ce8bc69/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
index d5d6ea2..5e81a3e 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
@@ -418,8 +418,7 @@ class ClientImpl extends TcpDiscoveryImpl {
                             "Please check IP finder configuration" +
                             (spi.ipFinder instanceof TcpDiscoveryMulticastIpFinder ?
                                 " and make sure multicast works on your network. " : ". ") +
-                            "Will retry every 2 secs."
-                            + spi.ipFinder, true);
+                            "Will retry every 2 secs.", true);
 
                     Thread.sleep(2000);
                 }


[13/34] incubator-ignite git commit: master ignite-1207

Posted by av...@apache.org.
master ignite-1207


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

Branch: refs/heads/ignite-1093
Commit: 33e174bb9a8c9d79c66962449cf0d5403b921aed
Parents: 2173b0e
Author: Anton Vinogradov <vi...@gmail.com>
Authored: Thu Aug 6 13:03:44 2015 +0300
Committer: Anton Vinogradov <vi...@gmail.com>
Committed: Thu Aug 6 13:03:44 2015 +0300

----------------------------------------------------------------------
 assembly/release-hadoop.xml | 5 +++++
 1 file changed, 5 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/33e174bb/assembly/release-hadoop.xml
----------------------------------------------------------------------
diff --git a/assembly/release-hadoop.xml b/assembly/release-hadoop.xml
index 7b94144..3f61ec9 100644
--- a/assembly/release-hadoop.xml
+++ b/assembly/release-hadoop.xml
@@ -58,6 +58,11 @@
             <source>modules/hadoop/config/hive-site.ignite.xml</source>
             <outputDirectory>/config/hadoop</outputDirectory>
         </file>
+
+        <file>
+            <source>modules/hadoop/docs/HADOOP_README.txt</source>
+            <outputDirectory>/</outputDirectory>
+        </file>
     </files>
 
     <fileSets>


[31/34] incubator-ignite git commit: ignite-1093

Posted by av...@apache.org.
ignite-1093


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

Branch: refs/heads/ignite-1093
Commit: 6640c9a58dd5c2db0a87d7b3307d95d27109b5c1
Parents: 8f36482
Author: Anton Vinogradov <vi...@gmail.com>
Authored: Wed Aug 12 14:32:25 2015 +0300
Committer: Anton Vinogradov <vi...@gmail.com>
Committed: Wed Aug 12 14:32:25 2015 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheMassiveRebalancingSelfTest.java       | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6640c9a5/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMassiveRebalancingSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMassiveRebalancingSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMassiveRebalancingSelfTest.java
index ca95905..0771509 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMassiveRebalancingSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMassiveRebalancingSelfTest.java
@@ -120,6 +120,7 @@ public class GridCacheMassiveRebalancingSelfTest extends GridCommonAbstractTest
 
         stopGrid(0);
 
+        //TODO: refactor to get futures by topology
         while (f1 == ((GridCacheAdapter)grid(1).context().cache().internalCache(CACHE_NAME_DHT)).preloader().syncFuture() ||
             f2 == ((GridCacheAdapter)grid(2).context().cache().internalCache(CACHE_NAME_DHT)).preloader().syncFuture())
             U.sleep(100);


[24/34] incubator-ignite git commit: # Fixed potential NPE in GridCachePartitionExchangeManager.dumpDebugInfo

Posted by av...@apache.org.
# Fixed potential NPE in GridCachePartitionExchangeManager.dumpDebugInfo


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

Branch: refs/heads/ignite-1093
Commit: bd770a54a554c8c22f36ea00f8c735218c29b330
Parents: d9acbd1
Author: sboikov <sb...@gridgain.com>
Authored: Mon Aug 10 16:08:10 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Mon Aug 10 16:08:10 2015 +0300

----------------------------------------------------------------------
 .../cache/GridCachePartitionExchangeManager.java    | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bd770a54/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
index c26f5c3..cf49197 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
@@ -962,15 +962,19 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
         for (GridDhtPartitionsExchangeFuture fut : pendingExchangeFuts)
             U.warn(log, ">>> " + fut);
 
-        U.warn(log, "Last 10 exchange futures (total: " + exchFuts.size() + "):");
+        ExchangeFutureSet exchFuts = this.exchFuts;
 
-        int cnt = 0;
+        if (exchFuts != null) {
+            U.warn(log, "Last 10 exchange futures (total: " + exchFuts.size() + "):");
 
-        for (GridDhtPartitionsExchangeFuture fut : exchFuts) {
-            U.warn(log, ">>> " + fut);
+            int cnt = 0;
+
+            for (GridDhtPartitionsExchangeFuture fut : exchFuts) {
+                U.warn(log, ">>> " + fut);
 
-            if (++cnt == 10)
-                break;
+                if (++cnt == 10)
+                    break;
+            }
         }
 
         dumpPendingObjects();


[14/34] incubator-ignite git commit: Merge remote-tracking branch 'origin/master'

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


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

Branch: refs/heads/ignite-1093
Commit: b03152504cb5d8da0d57b3a712cadd9a4aea4a83
Parents: 33e174b 5ce8bc6
Author: Anton Vinogradov <vi...@gmail.com>
Authored: Thu Aug 6 13:05:43 2015 +0300
Committer: Anton Vinogradov <vi...@gmail.com>
Committed: Thu Aug 6 13:05:43 2015 +0300

----------------------------------------------------------------------
 .../ignite/spi/discovery/tcp/ClientImpl.java    | 28 +++++++++++++++-----
 1 file changed, 21 insertions(+), 7 deletions(-)
----------------------------------------------------------------------



[16/34] incubator-ignite git commit: Added comment in benchmark-multicast.properties

Posted by av...@apache.org.
Added comment in benchmark-multicast.properties


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

Branch: refs/heads/ignite-1093
Commit: b94c13026e9097adb2d318548832ce870152c95f
Parents: 6e496e6
Author: nikolay_tikhonov <nt...@gridgain.com>
Authored: Thu Aug 6 15:39:54 2015 +0300
Committer: nikolay_tikhonov <nt...@gridgain.com>
Committed: Thu Aug 6 15:39:54 2015 +0300

----------------------------------------------------------------------
 modules/yardstick/config/benchmark-multicast.properties | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b94c1302/modules/yardstick/config/benchmark-multicast.properties
----------------------------------------------------------------------
diff --git a/modules/yardstick/config/benchmark-multicast.properties b/modules/yardstick/config/benchmark-multicast.properties
index 74b152c..82bf766 100644
--- a/modules/yardstick/config/benchmark-multicast.properties
+++ b/modules/yardstick/config/benchmark-multicast.properties
@@ -45,6 +45,7 @@ BENCHMARK_DEFAULT_PROBES=ThroughputLatencyProbe,PercentileProbe,DStatProbe
 # Packages where the specified benchmark is searched by reflection mechanism.
 BENCHMARK_PACKAGES=org.yardstickframework,org.apache.ignite.yardstick
 
+# Restart servers for each benchmark.
 RESTART_SERVERS=true
 
 # Probe point writer class name.


[11/34] incubator-ignite git commit: msg format

Posted by av...@apache.org.
msg format


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

Branch: refs/heads/ignite-1093
Commit: d7623b47abea23c685856b36ade75027efbb3cc5
Parents: 2173b0e
Author: Yakov Zhdanov <yz...@gridgain.com>
Authored: Thu Aug 6 12:38:24 2015 +0300
Committer: Yakov Zhdanov <yz...@gridgain.com>
Committed: Thu Aug 6 12:38:24 2015 +0300

----------------------------------------------------------------------
 .../ignite/spi/discovery/tcp/ClientImpl.java    | 27 +++++++++++++++-----
 1 file changed, 21 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d7623b47/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
index 0f9c100..d5d6ea2 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
@@ -29,6 +29,7 @@ import org.apache.ignite.lang.*;
 import org.apache.ignite.spi.*;
 import org.apache.ignite.spi.discovery.*;
 import org.apache.ignite.spi.discovery.tcp.internal.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.*;
 import org.apache.ignite.spi.discovery.tcp.messages.*;
 import org.jetbrains.annotations.*;
 import org.jsr166.*;
@@ -159,7 +160,9 @@ class ClientImpl extends TcpDiscoveryImpl {
 
     /** {@inheritDoc} */
     @Override public void spiStart(@Nullable String gridName) throws IgniteSpiException {
-        spi.initLocalNode(0, true);
+        spi.initLocalNode(
+            0,
+            true);
 
         locNode = spi.locNode;
 
@@ -190,7 +193,10 @@ class ClientImpl extends TcpDiscoveryImpl {
             throw new IgniteSpiException("Thread has been interrupted.", e);
         }
 
-        timer.schedule(new HeartbeatSender(), spi.hbFreq, spi.hbFreq);
+        timer.schedule(
+            new HeartbeatSender(),
+            spi.hbFreq,
+            spi.hbFreq);
 
         spi.printStartInfo();
     }
@@ -408,7 +414,11 @@ class ClientImpl extends TcpDiscoveryImpl {
                     if (timeout > 0 && (U.currentTimeMillis() - startTime) > timeout)
                         return null;
 
-                    LT.warn(log, null, "No addresses registered in the IP finder (will retry in 2000ms): "
+                    LT.warn(log, null, "IP finder returned empty addresses list. " +
+                            "Please check IP finder configuration" +
+                            (spi.ipFinder instanceof TcpDiscoveryMulticastIpFinder ?
+                                " and make sure multicast works on your network. " : ". ") +
+                            "Will retry every 2 secs."
                             + spi.ipFinder, true);
 
                     Thread.sleep(2000);
@@ -460,7 +470,7 @@ class ClientImpl extends TcpDiscoveryImpl {
                     return null;
 
                 LT.warn(log, null, "Failed to connect to any address from IP finder (will retry to join topology " +
-                    "in 2000ms): " + toOrderedList(addrs0), true);
+                    "every 2 secs): " + toOrderedList(addrs0), true);
 
                 Thread.sleep(2000);
             }
@@ -682,7 +692,9 @@ class ClientImpl extends TcpDiscoveryImpl {
         U.interrupt(msgWorker);
 
         U.join(sockWriter, log);
-        U.join(msgWorker, log);
+        U.join(
+            msgWorker,
+            log);
     }
 
     /** {@inheritDoc} */
@@ -987,7 +999,10 @@ class ClientImpl extends TcpDiscoveryImpl {
                         }
                     }
 
-                    spi.writeToSocket(sock, msg, socketTimeout);
+                    spi.writeToSocket(
+                        sock,
+                        msg,
+                        socketTimeout);
 
                     msg = null;
 


[15/34] incubator-ignite git commit: License generation hotfix

Posted by av...@apache.org.
License generation hotfix


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

Branch: refs/heads/ignite-1093
Commit: 6e496e67e7b3a1c7cd6e31555a3198a833252f1d
Parents: b031525
Author: Anton Vinogradov <vi...@gmail.com>
Authored: Thu Aug 6 13:44:36 2015 +0300
Committer: Anton Vinogradov <vi...@gmail.com>
Committed: Thu Aug 6 13:44:36 2015 +0300

----------------------------------------------------------------------
 parent/pom.xml | 97 ++++++++++++++++++++++++++---------------------------
 1 file changed, 48 insertions(+), 49 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6e496e67/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index e703502..efa6494 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -140,6 +140,13 @@
             <version>4.11</version>
             <scope>test</scope>
         </dependency>
+
+        <dependency>
+            <groupId>org.apache.ignite</groupId>
+            <artifactId>ignite-apache-license-gen</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope><!-- hack to have ignite-apache-license-gen at first place at mvn reactor -->
+        </dependency>
     </dependencies>
 
     <build>
@@ -567,60 +574,52 @@
                     </execution>
                 </executions>
             </plugin>
+
+            <plugin><!-- generates dependencies licenses -->
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-remote-resources-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>ignite-dependencies</id>
+                        <goals>
+                            <goal>process</goal>
+                        </goals>
+                        <configuration>
+                            <resourceBundles>
+                                <resourceBundle>org.apache.ignite:ignite-apache-license-gen:${project.version}</resourceBundle>
+                            </resourceBundles>
+                            <excludeTransitive>true</excludeTransitive>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-antrun-plugin</artifactId>
+                <version>1.7</version>
+                <executions>
+                    <execution>
+                        <id>licenses-file-rename</id>
+                        <goals>
+                            <goal>run</goal>
+                        </goals>
+                        <phase>compile</phase>
+                        <configuration>
+                            <target>
+                                <!-- moving licenses generated by "ignite-dependencies" -->
+                                <move file="${basedir}/target/classes/META-INF/licenses.txt" tofile="${basedir}/target/licenses/${project.artifactId}-licenses.txt"/>
+                            </target>
+                            <failOnError>false</failOnError>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
         </plugins>
     </build>
 
     <profiles>
         <profile>
-            <id>apache-release</id>
-            <build>
-                <plugins>
-                    <plugin>
-                        <groupId>org.apache.maven.plugins</groupId>
-                        <artifactId>maven-remote-resources-plugin</artifactId>
-                        <executions>
-                            <execution>
-                                <id>ignite-dependencies</id>
-                                <goals>
-                                    <goal>process</goal>
-                                </goals>
-                                <configuration>
-                                    <resourceBundles>
-                                        <resourceBundle>org.apache.ignite:ignite-apache-license-gen:${project.version}</resourceBundle>
-                                    </resourceBundles>
-                                    <excludeTransitive>true</excludeTransitive>
-                                </configuration>
-                            </execution>
-                        </executions>
-                    </plugin>
-
-                    <plugin>
-                        <groupId>org.apache.maven.plugins</groupId>
-                        <artifactId>maven-antrun-plugin</artifactId>
-                        <version>1.7</version>
-                        <executions>
-                            <execution>
-                                <id>licenses-file-rename</id>
-                                <goals>
-                                    <goal>run</goal>
-                                </goals>
-                                <phase>compile</phase>
-                                <configuration>
-                                    <target>
-                                        <!-- moving licenses generated by "ignite-dependencies" -->
-                                        <move file="${basedir}/target/classes/META-INF/licenses.txt" tofile="${basedir}/target/licenses/${project.artifactId}-licenses.txt"/>
-                                    </target>
-                                    <failOnError>false</failOnError>
-                              </configuration>
-                            </execution>
-                        </executions>
-                    </plugin>
-
-                </plugins>
-            </build>
-        </profile>
-
-        <profile>
             <id>check-licenses</id>
             <build>
                 <plugins>


[23/34] incubator-ignite git commit: Merge branch 'ignite-1189'

Posted by av...@apache.org.
Merge branch 'ignite-1189'


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

Branch: refs/heads/ignite-1093
Commit: cd844a7f959c79e3b5e9364ab9993f1c3d4fc91e
Parents: d9acbd1 e42f954
Author: nikolay_tikhonov <nt...@gridgain.com>
Authored: Mon Aug 10 13:34:03 2015 +0300
Committer: nikolay_tikhonov <nt...@gridgain.com>
Committed: Mon Aug 10 13:34:03 2015 +0300

----------------------------------------------------------------------
 .../configuration/IgniteConfiguration.java      |  1 -
 .../dht/atomic/GridDhtAtomicCache.java          | 36 ++++++++++++++------
 2 files changed, 26 insertions(+), 11 deletions(-)
----------------------------------------------------------------------



[19/34] incubator-ignite git commit: # ignite-1142

Posted by av...@apache.org.
# ignite-1142

Signed-off-by: Yakov Zhdanov <yz...@gridgain.com>


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

Branch: refs/heads/ignite-1093
Commit: d7dd4a0272aff8e00324254ac97f47393d05f70c
Parents: 63944d4
Author: S.Vladykin <sv...@gridgain.com>
Authored: Thu Aug 6 16:24:56 2015 +0300
Committer: Yakov Zhdanov <yz...@gridgain.com>
Committed: Thu Aug 6 16:27:59 2015 +0300

----------------------------------------------------------------------
 .../cache/query/GridCacheSqlQuery.java          |  33 ++-
 .../cache/query/GridCacheTwoStepQuery.java      |  34 +--
 .../processors/query/h2/IgniteH2Indexing.java   |  27 +-
 .../processors/query/h2/sql/GridSqlElement.java |  18 +-
 .../query/h2/sql/GridSqlFunction.java           |  17 +-
 .../processors/query/h2/sql/GridSqlQuery.java   |   4 +-
 .../query/h2/sql/GridSqlQueryParser.java        |  94 ++++---
 .../query/h2/sql/GridSqlQuerySplitter.java      | 117 +++++----
 .../processors/query/h2/sql/GridSqlSelect.java  |  76 +++---
 .../processors/query/h2/sql/GridSqlType.java    |  24 +-
 .../processors/query/h2/sql/GridSqlUnion.java   |   2 +-
 .../h2/twostep/GridReduceQueryExecutor.java     | 211 ++++++---------
 .../query/h2/twostep/GridThreadLocalTable.java  | 262 +++++++++++++++++++
 .../IgniteCacheAbstractFieldsQuerySelfTest.java |   2 +-
 14 files changed, 614 insertions(+), 307 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d7dd4a02/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlQuery.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlQuery.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlQuery.java
index 7a0e140..d5eb379 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlQuery.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlQuery.java
@@ -26,6 +26,7 @@ import org.apache.ignite.marshaller.*;
 import org.apache.ignite.plugin.extensions.communication.*;
 
 import java.nio.*;
+import java.util.*;
 
 /**
  * Query.
@@ -38,9 +39,6 @@ public class GridCacheSqlQuery implements Message {
     public static final Object[] EMPTY_PARAMS = {};
 
     /** */
-    private String alias;
-
-    /** */
     @GridToStringInclude
     private String qry;
 
@@ -52,6 +50,11 @@ public class GridCacheSqlQuery implements Message {
     /** */
     private byte[] paramsBytes;
 
+    /** */
+    @GridToStringInclude
+    @GridDirectTransient
+    private LinkedHashMap<String, ?> columns;
+
     /**
      * For {@link Message}.
      */
@@ -60,24 +63,32 @@ public class GridCacheSqlQuery implements Message {
     }
 
     /**
-     * @param alias Alias.
      * @param qry Query.
      * @param params Query parameters.
      */
-    public GridCacheSqlQuery(String alias, String qry, Object[] params) {
+    public GridCacheSqlQuery(String qry, Object[] params) {
         A.ensure(!F.isEmpty(qry), "qry must not be empty");
 
-        this.alias = alias;
         this.qry = qry;
 
         this.params = F.isEmpty(params) ? EMPTY_PARAMS : params;
     }
 
     /**
-     * @return Alias.
+     * @return Columns.
      */
-    public String alias() {
-        return alias;
+    public LinkedHashMap<String, ?> columns() {
+        return columns;
+    }
+
+    /**
+     * @param columns Columns.
+     * @return {@code this}.
+     */
+    public GridCacheSqlQuery columns(LinkedHashMap<String, ?> columns) {
+        this.columns = columns;
+
+        return this;
     }
 
     /**
@@ -138,7 +149,7 @@ public class GridCacheSqlQuery implements Message {
 
         switch (writer.state()) {
             case 0:
-                if (!writer.writeString("alias", alias))
+                if (!writer.writeString("alias", null))
                     return false;
 
                 writer.incrementState();
@@ -169,7 +180,7 @@ public class GridCacheSqlQuery implements Message {
 
         switch (reader.state()) {
             case 0:
-                alias = reader.readString("alias");
+                reader.readString("alias");
 
                 if (!reader.isLastRead())
                     return false;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d7dd4a02/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheTwoStepQuery.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheTwoStepQuery.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheTwoStepQuery.java
index 1dacd10..83a79e3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheTwoStepQuery.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheTwoStepQuery.java
@@ -17,10 +17,7 @@
 
 package org.apache.ignite.internal.processors.cache.query;
 
-import org.apache.ignite.*;
-import org.apache.ignite.internal.util.*;
 import org.apache.ignite.internal.util.tostring.*;
-import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
 
 import java.util.*;
@@ -34,11 +31,11 @@ public class GridCacheTwoStepQuery {
 
     /** */
     @GridToStringInclude
-    private Map<String, GridCacheSqlQuery> mapQrys;
+    private List<GridCacheSqlQuery> mapQrys = new ArrayList<>();
 
     /** */
     @GridToStringInclude
-    private GridCacheSqlQuery reduce;
+    private GridCacheSqlQuery rdc;
 
     /** */
     private int pageSize = DFLT_PAGE_SIZE;
@@ -51,13 +48,14 @@ public class GridCacheTwoStepQuery {
 
     /**
      * @param spaces All spaces accessed in query.
-     * @param qry Reduce query.
-     * @param params Reduce query parameters.
+     * @param rdc Reduce query.
      */
-    public GridCacheTwoStepQuery(Set<String> spaces, String qry, Object ... params) {
+    public GridCacheTwoStepQuery(Set<String> spaces, GridCacheSqlQuery rdc) {
+        assert rdc != null;
+
         this.spaces = spaces;
 
-        reduce = new GridCacheSqlQuery(null, qry, params);
+        this.rdc = rdc;
     }
 
     /**
@@ -89,32 +87,24 @@ public class GridCacheTwoStepQuery {
     }
 
     /**
-     * @param alias Alias.
      * @param qry SQL Query.
-     * @param params Query parameters.
      */
-    public void addMapQuery(String alias, String qry, Object ... params) {
-        A.ensure(!F.isEmpty(alias), "alias must not be empty");
-
-        if (mapQrys == null)
-            mapQrys = new GridLeanMap<>();
-
-        if (mapQrys.put(alias, new GridCacheSqlQuery(alias, qry, params)) != null)
-            throw new IgniteException("Failed to add query, alias already exists: " + alias + ".");
+    public void addMapQuery(GridCacheSqlQuery qry) {
+        mapQrys.add(qry);
     }
 
     /**
      * @return Reduce query.
      */
     public GridCacheSqlQuery reduceQuery() {
-        return reduce;
+        return rdc;
     }
 
     /**
      * @return Map queries.
      */
-    public Collection<GridCacheSqlQuery> mapQueries() {
-        return mapQrys.values();
+    public List<GridCacheSqlQuery> mapQueries() {
+        return mapQrys;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d7dd4a02/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 c76dbe7..dc61d76 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
@@ -599,6 +599,9 @@ public class IgniteH2Indexing implements GridQueryIndexing {
             String name = rsMeta.getColumnLabel(i);
             String type = rsMeta.getColumnClassName(i);
 
+            if (type == null) // Expression always returns NULL.
+                type = Void.class.getName();
+
             meta.add(new SqlFieldMetadata(schemaName, typeName, name, type));
         }
 
@@ -852,6 +855,14 @@ public class IgniteH2Indexing implements GridQueryIndexing {
             throw new CacheException("Failed to parse query: " + sqlQry, e);
         }
 
+        try {
+            bindParameters(stmt, F.asList(qry.getArgs()));
+        }
+        catch (IgniteCheckedException e) {
+            throw new CacheException("Failed to bind parameters: [qry=" + sqlQry + ", params=" +
+                Arrays.deepToString(qry.getArgs()) + "]", e);
+        }
+
         GridCacheTwoStepQuery twoStepQry;
         List<GridQueryFieldMetadata> meta;
 
@@ -1318,14 +1329,20 @@ public class IgniteH2Indexing implements GridQueryIndexing {
             }
         }
 
-        executeStatement("INFORMATION_SCHEMA", "SHUTDOWN");
-
         for (Connection c : conns)
             U.close(c, log);
 
         conns.clear();
         schemas.clear();
 
+        try (Connection c = DriverManager.getConnection(dbUrl);
+             Statement s = c.createStatement()) {
+            s.execute("SHUTDOWN");
+        }
+        catch (SQLException e) {
+            U.error(log, "Failed to shutdown database.", e);
+        }
+
         if (log.isDebugEnabled())
             log.debug("Cache query index stopped.");
     }
@@ -1341,9 +1358,6 @@ public class IgniteH2Indexing implements GridQueryIndexing {
 
         createSchema(schema);
 
-        executeStatement(schema, "CREATE ALIAS " + GridSqlQuerySplitter.TABLE_FUNC_NAME +
-            " NOBUFFER FOR \"" + GridReduceQueryExecutor.class.getName() + ".mergeTableFunction\"");
-
         createSqlFunctions(schema, ccfg.getSqlFunctionClasses());
     }
 
@@ -1881,8 +1895,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
          * @param type Type.
          */
         SqlFieldMetadata(@Nullable String schemaName, @Nullable String typeName, String name, String type) {
-            assert name != null;
-            assert type != null;
+            assert name != null && type != null : schemaName + " | " + typeName + " | " + name + " | " + type;
 
             this.schemaName = schemaName;
             this.typeName = typeName;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d7dd4a02/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlElement.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlElement.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlElement.java
index 44705de..0f98a33 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlElement.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlElement.java
@@ -27,7 +27,7 @@ public abstract class GridSqlElement implements Iterable<GridSqlElement> {
     protected List<GridSqlElement> children;
 
     /** */
-    private GridSqlType expressionResultType;
+    private GridSqlType resultType;
 
     /**
      * @param children Initial child list.
@@ -41,15 +41,18 @@ public abstract class GridSqlElement implements Iterable<GridSqlElement> {
     /**
      * @return Optional expression result type (if this is an expression and result type is known).
      */
-    public GridSqlType expressionResultType() {
-        return expressionResultType;
+    public GridSqlType resultType() {
+        return resultType;
     }
 
     /**
      * @param type Optional expression result type (if this is an expression and result type is known).
+     * @return {@code this}.
      */
-    public void expressionResultType(GridSqlType type) {
-        expressionResultType = type;
+    public GridSqlElement resultType(GridSqlType type) {
+        resultType = type;
+
+        return this;
     }
 
     /**
@@ -110,4 +113,9 @@ public abstract class GridSqlElement implements Iterable<GridSqlElement> {
     @Override public Iterator<GridSqlElement> iterator() {
         return children.iterator();
     }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return getSQL();
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d7dd4a02/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlFunction.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlFunction.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlFunction.java
index c41bbb7..77039b0 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlFunction.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlFunction.java
@@ -50,9 +50,6 @@ public class GridSqlFunction extends GridSqlElement {
     /** */
     protected final GridSqlFunctionType type;
 
-    /**  */
-    private String castType;
-
     /**
      * @param type Function type.
      */
@@ -87,16 +84,6 @@ public class GridSqlFunction extends GridSqlElement {
         this(schema, TYPE_MAP.get(name), name);
     }
 
-    /**
-     * @param castType Type for {@link GridSqlFunctionType#CAST} function.
-     * @return {@code this}.
-     */
-    public GridSqlFunction setCastType(String castType) {
-        this.castType = castType;
-
-        return this;
-    }
-
     /** {@inheritDoc} */
     @Override public String getSQL() {
         StatementBuilder buff = new StatementBuilder();
@@ -123,12 +110,16 @@ public class GridSqlFunction extends GridSqlElement {
         buff.append('(');
 
         if (type == CAST) {
+            String castType = resultType().sql();
+
             assert !F.isEmpty(castType) : castType;
             assert size() == 1;
 
             buff.append(child().getSQL()).append(" AS ").append(castType);
         }
         else if (type == CONVERT) {
+            String castType = resultType().sql();
+
             assert !F.isEmpty(castType) : castType;
             assert size() == 1;
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d7dd4a02/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQuery.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQuery.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQuery.java
index ad13dfe..329304a 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQuery.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQuery.java
@@ -134,7 +134,7 @@ public abstract class GridSqlQuery {
      * @param col Column index.
      * @return Expression for column index.
      */
-    protected abstract GridSqlElement expression(int col);
+    protected abstract GridSqlElement column(int col);
 
     /**
      * @param buff Statement builder.
@@ -157,7 +157,7 @@ public abstract class GridSqlQuery {
                 if (idx < visibleCols)
                     buff.append(idx + 1);
                 else {
-                    GridSqlElement expr = expression(idx);
+                    GridSqlElement expr = column(idx);
 
                     if (expr == null) // For plain select should never be null, for union H2 itself can't parse query.
                         throw new IllegalStateException("Failed to build query: " + buff.toString());

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d7dd4a02/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java
index 4267b4a..a52f3b0 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java
@@ -22,7 +22,6 @@ import org.h2.command.*;
 import org.h2.command.dml.*;
 import org.h2.engine.*;
 import org.h2.expression.*;
-import org.h2.expression.Parameter;
 import org.h2.jdbc.*;
 import org.h2.result.*;
 import org.h2.table.*;
@@ -205,12 +204,12 @@ public class GridSqlQueryParser {
                 res = new GridSqlSubquery(parse(qry));
             }
             else if (tbl instanceof FunctionTable)
-                res = parseExpression(FUNC_EXPR.get((FunctionTable)tbl));
+                res = parseExpression(FUNC_EXPR.get((FunctionTable)tbl), false);
             else if (tbl instanceof RangeTable) {
                 res = new GridSqlFunction(GridSqlFunctionType.SYSTEM_RANGE);
 
-                res.addChild(parseExpression(RANGE_MIN.get((RangeTable)tbl)));
-                res.addChild(parseExpression(RANGE_MAX.get((RangeTable)tbl)));
+                res.addChild(parseExpression(RANGE_MIN.get((RangeTable)tbl), false));
+                res.addChild(parseExpression(RANGE_MAX.get((RangeTable)tbl), false));
             }
             else
                 assert0(false, filter.getSelect().getSQL());
@@ -242,7 +241,7 @@ public class GridSqlQueryParser {
         res.distinct(select.isDistinct());
 
         Expression where = CONDITION.get(select);
-        res.where(parseExpression(where));
+        res.where(parseExpression(where, false));
 
         Set<TableFilter> allFilters = new HashSet<>(select.getTopFilters());
 
@@ -257,7 +256,7 @@ public class GridSqlQueryParser {
             GridSqlElement gridFilter = parseTable(filter);
 
             from = from == null ? gridFilter : new GridSqlJoin(from, gridFilter, filter.isJoinOuter(),
-                parseExpression(filter.getJoinCondition()));
+                parseExpression(filter.getJoinCondition(), false));
 
             allFilters.remove(filter);
 
@@ -272,7 +271,7 @@ public class GridSqlQueryParser {
         ArrayList<Expression> expressions = select.getExpressions();
 
         for (int i = 0; i < expressions.size(); i++)
-            res.addSelectExpression(parseExpression(expressions.get(i)), i < select.getColumnCount());
+            res.addColumn(parseExpression(expressions.get(i), true), i < select.getColumnCount());
 
         int[] grpIdx = GROUP_INDEXES.get(select);
 
@@ -286,8 +285,8 @@ public class GridSqlQueryParser {
 
         processSortOrder(select.getSortOrder(), res);
 
-        res.limit(parseExpression(select.getLimit()));
-        res.offset(parseExpression(select.getOffset()));
+        res.limit(parseExpression(select.getLimit(), false));
+        res.offset(parseExpression(select.getOffset(), false));
 
         return res;
     }
@@ -346,8 +345,8 @@ public class GridSqlQueryParser {
 
         res.unionType(union.getUnionType());
 
-        res.limit(parseExpression(union.getLimit()));
-        res.offset(parseExpression(union.getOffset()));
+        res.limit(parseExpression(union.getLimit(), false));
+        res.offset(parseExpression(union.getOffset(), false));
 
         processSortOrder(UNION_SORT.get(union), res);
 
@@ -358,22 +357,29 @@ public class GridSqlQueryParser {
 
     /**
      * @param expression Expression.
+     * @param calcTypes Calculate types for all the expressions.
+     * @return Parsed expression.
      */
-    private GridSqlElement parseExpression(@Nullable Expression expression) {
+    private GridSqlElement parseExpression(@Nullable Expression expression, boolean calcTypes) {
         if (expression == null)
             return null;
 
         GridSqlElement res = (GridSqlElement)h2ObjToGridObj.get(expression);
 
         if (res == null) {
-            res = parseExpression0(expression);
+            res = parseExpression0(expression, calcTypes);
 
-            if (expression.getType() != Value.UNKNOWN) {
-                Column c = new Column(null, expression.getType(), expression.getPrecision(), expression.getScale(),
-                    expression.getDisplaySize());
+            if (calcTypes) {
+                GridSqlType type = GridSqlType.UNKNOWN;
 
-                res.expressionResultType(new GridSqlType(c.getType(), c.getScale(), c.getPrecision(), c.getDisplaySize(),
-                    c.getCreateSQL()));
+                if (expression.getType() != Value.UNKNOWN) {
+                    Column c = new Column(null, expression.getType(), expression.getPrecision(), expression.getScale(),
+                        expression.getDisplaySize());
+
+                    type = new GridSqlType(c.getType(), c.getScale(), c.getPrecision(), c.getDisplaySize(), c.getCreateSQL());
+                }
+
+                res.resultType(type);
             }
 
             h2ObjToGridObj.put(expression, res);
@@ -384,8 +390,10 @@ public class GridSqlQueryParser {
 
     /**
      * @param expression Expression.
+     * @param calcTypes Calculate types for all the expressions.
+     * @return Parsed expression.
      */
-    private GridSqlElement parseExpression0(Expression expression) {
+    private GridSqlElement parseExpression0(Expression expression, boolean calcTypes) {
         if (expression instanceof ExpressionColumn) {
             TableFilter tblFilter = ((ExpressionColumn)expression).getTableFilter();
 
@@ -395,7 +403,8 @@ public class GridSqlQueryParser {
         }
 
         if (expression instanceof Alias)
-            return new GridSqlAlias(expression.getAlias(), parseExpression(expression.getNonAliasExpression()), true);
+            return new GridSqlAlias(expression.getAlias(),
+                parseExpression(expression.getNonAliasExpression(), calcTypes), true);
 
         if (expression instanceof ValueExpression)
             return new GridSqlConst(expression.getValue(null));
@@ -408,12 +417,13 @@ public class GridSqlQueryParser {
             if (type == Operation.NEGATE) {
                 assert OPERATION_RIGHT.get(operation) == null;
 
-                return new GridSqlOperation(GridSqlOperationType.NEGATE, parseExpression(OPERATION_LEFT.get(operation)));
+                return new GridSqlOperation(GridSqlOperationType.NEGATE,
+                    parseExpression(OPERATION_LEFT.get(operation), calcTypes));
             }
 
             return new GridSqlOperation(OPERATION_OP_TYPES[type],
-                parseExpression(OPERATION_LEFT.get(operation)),
-                parseExpression(OPERATION_RIGHT.get(operation)));
+                parseExpression(OPERATION_LEFT.get(operation), calcTypes),
+                parseExpression(OPERATION_RIGHT.get(operation), calcTypes));
         }
 
         if (expression instanceof Comparison) {
@@ -423,18 +433,18 @@ public class GridSqlQueryParser {
 
             assert opType != null : COMPARISON_TYPE.get(cmp);
 
-            GridSqlElement left = parseExpression(COMPARISON_LEFT.get(cmp));
+            GridSqlElement left = parseExpression(COMPARISON_LEFT.get(cmp), calcTypes);
 
             if (opType.childrenCount() == 1)
                 return new GridSqlOperation(opType, left);
 
-            GridSqlElement right = parseExpression(COMPARISON_RIGHT.get(cmp));
+            GridSqlElement right = parseExpression(COMPARISON_RIGHT.get(cmp), calcTypes);
 
             return new GridSqlOperation(opType, left, right);
         }
 
         if (expression instanceof ConditionNot)
-            return new GridSqlOperation(NOT, parseExpression(expression.getNotIfPossible(null)));
+            return new GridSqlOperation(NOT, parseExpression(expression.getNotIfPossible(null), calcTypes));
 
         if (expression instanceof ConditionAndOr) {
             ConditionAndOr andOr = (ConditionAndOr)expression;
@@ -444,7 +454,7 @@ public class GridSqlQueryParser {
             assert type == ConditionAndOr.AND || type == ConditionAndOr.OR;
 
             return new GridSqlOperation(type == ConditionAndOr.AND ? AND : OR,
-                parseExpression(ANDOR_LEFT.get(andOr)), parseExpression(ANDOR_RIGHT.get(andOr)));
+                parseExpression(ANDOR_LEFT.get(andOr), calcTypes), parseExpression(ANDOR_RIGHT.get(andOr), calcTypes));
         }
 
         if (expression instanceof Subquery) {
@@ -458,12 +468,12 @@ public class GridSqlQueryParser {
         if (expression instanceof ConditionIn) {
             GridSqlOperation res = new GridSqlOperation(IN);
 
-            res.addChild(parseExpression(LEFT_CI.get((ConditionIn)expression)));
+            res.addChild(parseExpression(LEFT_CI.get((ConditionIn)expression), calcTypes));
 
             List<Expression> vals = VALUE_LIST_CI.get((ConditionIn)expression);
 
             for (Expression val : vals)
-                res.addChild(parseExpression(val));
+                res.addChild(parseExpression(val, calcTypes));
 
             return res;
         }
@@ -471,12 +481,12 @@ public class GridSqlQueryParser {
         if (expression instanceof ConditionInConstantSet) {
             GridSqlOperation res = new GridSqlOperation(IN);
 
-            res.addChild(parseExpression(LEFT_CICS.get((ConditionInConstantSet) expression)));
+            res.addChild(parseExpression(LEFT_CICS.get((ConditionInConstantSet)expression), calcTypes));
 
             List<Expression> vals = VALUE_LIST_CICS.get((ConditionInConstantSet)expression);
 
             for (Expression val : vals)
-                res.addChild(parseExpression(val));
+                res.addChild(parseExpression(val, calcTypes));
 
             return res;
         }
@@ -490,7 +500,7 @@ public class GridSqlQueryParser {
             assert0(!all, expression);
             assert0(compareType == Comparison.EQUAL, expression);
 
-            res.addChild(parseExpression(LEFT_CIS.get((ConditionInSelect) expression)));
+            res.addChild(parseExpression(LEFT_CIS.get((ConditionInSelect) expression), calcTypes));
 
             Query qry = QUERY.get((ConditionInSelect)expression);
 
@@ -506,8 +516,9 @@ public class GridSqlQueryParser {
 
             boolean regexp = REGEXP_CL.get((CompareLike)expression);
 
-            return new GridSqlOperation(regexp ? REGEXP : LIKE, parseExpression(LEFT.get((CompareLike) expression)),
-                parseExpression(RIGHT.get((CompareLike) expression)));
+            return new GridSqlOperation(regexp ? REGEXP : LIKE,
+                parseExpression(LEFT.get((CompareLike)expression), calcTypes),
+                parseExpression(RIGHT.get((CompareLike)expression), calcTypes));
         }
 
         if (expression instanceof Function) {
@@ -524,13 +535,16 @@ public class GridSqlQueryParser {
                         res.addChild(GridSqlPlaceholder.EMPTY);
                     }
                     else
-                        res.addChild(parseExpression(arg));
+                        res.addChild(parseExpression(arg, calcTypes));
                 }
             }
 
-            if (f.getFunctionType() == Function.CAST || f.getFunctionType() == Function.CONVERT)
-                res.setCastType(new Column(null, f.getType(), f.getPrecision(), f.getScale(), f.getDisplaySize())
-                    .getCreateSQL());
+            if (f.getFunctionType() == Function.CAST || f.getFunctionType() == Function.CONVERT) {
+                Column c = new Column(null, f.getType(), f.getPrecision(), f.getScale(), f.getDisplaySize());
+
+                res.resultType(new GridSqlType(c.getType(), c.getScale(), c.getPrecision(),
+                    c.getDisplaySize(), c.getCreateSQL()));
+            }
 
             return res;
         }
@@ -544,7 +558,7 @@ public class GridSqlQueryParser {
 
             if (f.getArgs() != null) {
                 for (Expression arg : f.getArgs())
-                    res.addChild(parseExpression(arg));
+                    res.addChild(parseExpression(arg, calcTypes));
             }
 
             return res;
@@ -560,7 +574,7 @@ public class GridSqlQueryParser {
             Expression on = ON.get((Aggregate)expression);
 
             if (on != null)
-                res.addChild(parseExpression(on));
+                res.addChild(parseExpression(on, calcTypes));
 
             return res;
         }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d7dd4a02/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQuerySplitter.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQuerySplitter.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQuerySplitter.java
index 502366d..2f8bcdd 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQuerySplitter.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQuerySplitter.java
@@ -22,7 +22,6 @@ import org.apache.ignite.internal.processors.cache.query.*;
 import org.apache.ignite.internal.processors.query.h2.*;
 import org.apache.ignite.internal.util.typedef.*;
 import org.h2.jdbc.*;
-import org.h2.value.*;
 import org.jetbrains.annotations.*;
 
 import java.util.*;
@@ -35,20 +34,20 @@ import static org.apache.ignite.internal.processors.query.h2.sql.GridSqlPlacehol
  */
 public class GridSqlQuerySplitter {
     /** */
-    private static final String TABLE_PREFIX = "__T";
+    private static final String TABLE_SCHEMA = "PUBLIC";
 
     /** */
-    private static final String COLUMN_PREFIX = "__C";
+    private static final String TABLE_PREFIX = "__T";
 
     /** */
-    public static final String TABLE_FUNC_NAME = "__Z0";
+    private static final String COLUMN_PREFIX = "__C";
 
     /**
      * @param idx Index of table.
-     * @return Table name.
+     * @return Table.
      */
-    private static String table(int idx) {
-        return TABLE_PREFIX + idx;
+    public static GridSqlTable table(int idx) {
+        return new GridSqlTable(TABLE_SCHEMA, TABLE_PREFIX + idx);
     }
 
     /**
@@ -88,7 +87,9 @@ public class GridSqlQuerySplitter {
 
         int c = 0;
 
-        for (GridSqlElement expr : left.select(true)) {
+        for (GridSqlElement expr : left.columns(true)) {
+            GridSqlType type = expr.resultType();
+
             String colName;
 
             if (expr instanceof GridSqlAlias)
@@ -101,12 +102,14 @@ public class GridSqlQuerySplitter {
                 expr = alias(colName, expr);
 
                 // Set generated alias to the expression.
-                left.setSelectExpression(c, expr);
+                left.setColumn(c, expr);
             }
 
             GridSqlColumn col = column(colName);
 
-            wrapQry.addSelectExpression(col, true);
+            col.resultType(type);
+
+            wrapQry.addColumn(col, true);
 
             c++;
         }
@@ -137,17 +140,15 @@ public class GridSqlQuerySplitter {
         // nullifying or updating things, have to make sure that we will not need them in the original form later.
         final GridSqlSelect mapQry = wrapUnion(collectAllSpaces(GridSqlQueryParser.parse(stmt), spaces));
 
-        final String mergeTable = TABLE_FUNC_NAME + "()"; // table(0); TODO IGNITE-1142
-
         final boolean explain = mapQry.explain();
 
         mapQry.explain(false);
 
-        GridSqlSelect rdcQry = new GridSqlSelect().from(new GridSqlFunction(null, TABLE_FUNC_NAME)); // table(mergeTable)); TODO IGNITE-1142
+        GridSqlSelect rdcQry = new GridSqlSelect().from(table(0));
 
         // Split all select expressions into map-reduce parts.
         List<GridSqlElement> mapExps = F.addAll(new ArrayList<GridSqlElement>(mapQry.allColumns()),
-            mapQry.select(false));
+            mapQry.columns(false));
 
         GridSqlElement[] rdcExps = new GridSqlElement[mapQry.visibleColumns()];
 
@@ -159,16 +160,16 @@ public class GridSqlQuerySplitter {
             aggregateFound |= splitSelectExpression(mapExps, rdcExps, colNames, i, collocated);
 
         // Fill select expressions.
-        mapQry.clearSelect();
+        mapQry.clearColumns();
 
         for (GridSqlElement exp : mapExps) // Add all map expressions as visible.
-            mapQry.addSelectExpression(exp, true);
+            mapQry.addColumn(exp, true);
 
         for (GridSqlElement rdcExp : rdcExps) // Add corresponding visible reduce columns.
-            rdcQry.addSelectExpression(rdcExp, true);
+            rdcQry.addColumn(rdcExp, true);
 
         for (int i = rdcExps.length; i < mapExps.size(); i++)  // Add all extra map columns as invisible reduce columns.
-            rdcQry.addSelectExpression(column(((GridSqlAlias)mapExps.get(i)).alias()), false);
+            rdcQry.addColumn(column(((GridSqlAlias)mapExps.get(i)).alias()), false);
 
         // -- GROUP BY
         if (mapQry.groupColumns() != null && !collocated)
@@ -214,11 +215,12 @@ public class GridSqlQuerySplitter {
         }
 
         // Build resulting two step query.
-        GridCacheTwoStepQuery res = new GridCacheTwoStepQuery(spaces, rdcQry.getSQL(),
-            findParams(rdcQry, params, new ArrayList<>()).toArray());
+        GridCacheTwoStepQuery res = new GridCacheTwoStepQuery(spaces, new GridCacheSqlQuery(rdcQry.getSQL(),
+            findParams(rdcQry, params, new ArrayList<>()).toArray()));
 
-        res.addMapQuery(mergeTable, mapQry.getSQL(),
-            findParams(mapQry, params, new ArrayList<>(params.length)).toArray());
+        res.addMapQuery(new GridCacheSqlQuery(mapQry.getSQL(),
+            findParams(mapQry, params, new ArrayList<>(params.length)).toArray())
+            .columns(collectColumns(mapExps)));
 
         res.explain(explain);
 
@@ -226,6 +228,37 @@ public class GridSqlQuerySplitter {
     }
 
     /**
+     * @param cols Columns from SELECT clause.
+     * @return Map of columns with types.
+     */
+    private static LinkedHashMap<String,?> collectColumns(List<GridSqlElement> cols) {
+        LinkedHashMap<String, GridSqlType> res = new LinkedHashMap<>(cols.size(), 1f, false);
+
+        for (int i = 0; i < cols.size(); i++) {
+            GridSqlElement col = cols.get(i);
+            GridSqlType t = col.resultType();
+
+            if (t == null)
+                throw new NullPointerException("Column type.");
+
+            if (t == GridSqlType.UNKNOWN)
+                throw new IllegalStateException("Unknown type: " + col);
+
+            String alias;
+
+            if (col instanceof GridSqlAlias)
+                alias = ((GridSqlAlias)col).alias();
+            else
+                alias = columnName(i);
+
+            if (res.put(alias, t) != null)
+                throw new IllegalStateException("Alias already exists: " + alias);
+        }
+
+        return res;
+    }
+
+    /**
      * @param qry Query.
      * @param spaces Space names.
      * @return Query.
@@ -242,7 +275,7 @@ public class GridSqlQuerySplitter {
 
             collectAllSpacesInFrom(select.from(), spaces);
 
-            for (GridSqlElement el : select.select(false))
+            for (GridSqlElement el : select.columns(false))
                 collectAllSpacesInSubqueries(el, spaces);
 
             collectAllSpacesInSubqueries(select.where(), spaces);
@@ -325,7 +358,7 @@ public class GridSqlQuerySplitter {
         if (params.length == 0)
             return target;
 
-        for (GridSqlElement el : qry.select(false))
+        for (GridSqlElement el : qry.columns(false))
             findParams(el, params, target);
 
         findParams(qry.from(), params, target);
@@ -422,11 +455,6 @@ public class GridSqlQuerySplitter {
             if (idx < rdcSelect.length) { // SELECT __C0 AS original_alias
                 GridSqlElement rdcEl = column(mapColAlias);
 
-                GridSqlType type = el.expressionResultType();
-
-                if (type != null && type.type() == Value.UUID) // There is no JDBC type UUID, so conversion to bytes occurs.
-                    rdcEl = function(CAST).setCastType("UUID").addChild(rdcEl); // TODO IGNITE-1142 - remove this cast when table function removed
-
                 if (colNames.add(rdcColAlias)) // To handle column name duplication (usually wildcard for few tables).
                     rdcEl = alias(rdcColAlias, rdcEl);
 
@@ -499,6 +527,8 @@ public class GridSqlQuerySplitter {
     ) {
         GridSqlAggregateFunction agg = parentExpr.child(aggIdx);
 
+        assert agg.resultType() != null;
+
         GridSqlElement mapAgg, rdcAgg;
 
         // Create stubbed map alias to fill it with correct expression later.
@@ -513,7 +543,8 @@ public class GridSqlQuerySplitter {
         switch (agg.type()) {
             case AVG: // SUM( AVG(CAST(x AS DOUBLE))*COUNT(x) )/SUM( COUNT(x) ).
                 //-- COUNT(x) map
-                GridSqlElement cntMapAgg = aggregate(agg.distinct(), COUNT).addChild(agg.child());
+                GridSqlElement cntMapAgg = aggregate(agg.distinct(), COUNT)
+                    .resultType(GridSqlType.BIGINT).addChild(agg.child());
 
                 // Add generated alias to COUNT(x).
                 // Using size as index since COUNT will be added as the last select element to the map query.
@@ -524,8 +555,8 @@ public class GridSqlQuerySplitter {
                 mapSelect.add(cntMapAgg);
 
                 //-- AVG(CAST(x AS DOUBLE)) map
-                mapAgg = aggregate(agg.distinct(), AVG).addChild( // Add function argument.
-                    function(CAST).setCastType("DOUBLE").addChild(agg.child()));
+                mapAgg = aggregate(agg.distinct(), AVG).resultType(GridSqlType.DOUBLE).addChild(
+                    function(CAST).resultType(GridSqlType.DOUBLE).addChild(agg.child()));
 
                 //-- SUM( AVG(x)*COUNT(x) )/SUM( COUNT(x) ) reduce
                 GridSqlElement sumUpRdc = aggregate(false, SUM).addChild(
@@ -542,20 +573,20 @@ public class GridSqlQuerySplitter {
             case SUM: // SUM( SUM(x) )
             case MAX: // MAX( MAX(x) )
             case MIN: // MIN( MIN(x) )
-                mapAgg = aggregate(agg.distinct(), agg.type()).addChild(agg.child());
+                mapAgg = aggregate(agg.distinct(), agg.type()).resultType(agg.resultType()).addChild(agg.child());
                 rdcAgg = aggregate(agg.distinct(), agg.type()).addChild(column(mapAggAlias.alias()));
 
                 break;
 
             case COUNT_ALL: // CAST(SUM( COUNT(*) ) AS BIGINT)
             case COUNT: // CAST(SUM( COUNT(x) ) AS BIGINT)
-                mapAgg = aggregate(agg.distinct(), agg.type());
+                mapAgg = aggregate(agg.distinct(), agg.type()).resultType(GridSqlType.BIGINT);
 
                 if (agg.type() == COUNT)
                     mapAgg.addChild(agg.child());
 
                 rdcAgg = aggregate(false, SUM).addChild(column(mapAggAlias.alias()));
-                rdcAgg = function(CAST).setCastType("BIGINT").addChild(rdcAgg);
+                rdcAgg = function(CAST).resultType(GridSqlType.BIGINT).addChild(rdcAgg);
 
                 break;
 
@@ -564,9 +595,11 @@ public class GridSqlQuerySplitter {
         }
 
         assert !(mapAgg instanceof GridSqlAlias);
+        assert mapAgg.resultType() != null;
 
         // Fill the map alias with aggregate.
         mapAggAlias.child(0, mapAgg);
+        mapAggAlias.resultType(mapAgg.resultType());
 
         // Replace in original expression aggregate with reduce aggregate.
         parentExpr.child(aggIdx, rdcAgg);
@@ -595,7 +628,11 @@ public class GridSqlQuerySplitter {
      * @return Alias.
      */
     private static GridSqlAlias alias(String alias, GridSqlElement child) {
-        return new GridSqlAlias(alias, child);
+        GridSqlAlias res = new GridSqlAlias(alias, child);
+
+        res.resultType(child.resultType());
+
+        return res;
     }
 
     /**
@@ -615,12 +652,4 @@ public class GridSqlQuerySplitter {
     private static GridSqlFunction function(GridSqlFunctionType type) {
         return new GridSqlFunction(type);
     }
-
-    /**
-     * @param name Table name.
-     * @return Table.
-     */
-    private static GridSqlTable table(String name) {
-        return new GridSqlTable(null, name);
-    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d7dd4a02/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlSelect.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlSelect.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlSelect.java
index fb2643e..6705c48 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlSelect.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlSelect.java
@@ -26,10 +26,10 @@ import java.util.*;
  */
 public class GridSqlSelect extends GridSqlQuery {
     /** */
-    private List<GridSqlElement> allExprs = new ArrayList<>();
+    private List<GridSqlElement> cols = new ArrayList<>();
 
     /** */
-    private List<GridSqlElement> select = new ArrayList<>();
+    private int visibleCols;
 
     /** */
     private int[] grpCols;
@@ -45,19 +45,19 @@ public class GridSqlSelect extends GridSqlQuery {
 
     /** {@inheritDoc} */
     @Override public int visibleColumns() {
-        return select.size();
+        return visibleCols;
     }
 
     /**
      * @return Number of columns is select including invisible ones.
      */
     public int allColumns() {
-        return allExprs.size();
+        return cols.size();
     }
 
     /** {@inheritDoc} */
-    @Override protected GridSqlElement expression(int col) {
-        return allExprs.get(col);
+    @Override protected GridSqlElement column(int col) {
+        return cols.get(col);
     }
 
     /** {@inheritDoc} */
@@ -67,7 +67,7 @@ public class GridSqlSelect extends GridSqlQuery {
         if (distinct)
             buff.append(" DISTINCT");
 
-        for (GridSqlElement expression : select) {
+        for (GridSqlElement expression : columns(true)) {
             buff.appendExceptFirst(",");
             buff.append('\n');
             buff.append(expression.getSQL());
@@ -86,14 +86,14 @@ public class GridSqlSelect extends GridSqlQuery {
             for (int grpCol : grpCols) {
                 buff.appendExceptFirst(", ");
 
-                addAlias(buff, allExprs.get(grpCol));
+                addAlias(buff, cols.get(grpCol));
             }
         }
 
         if (havingCol >= 0) {
             buff.append("\nHAVING ");
 
-            addAlias(buff, allExprs.get(havingCol));
+            addAlias(buff, cols.get(havingCol));
         }
 
         getSortLimitSQL(buff);
@@ -114,52 +114,59 @@ public class GridSqlSelect extends GridSqlQuery {
 
     /**
      * @param visibleOnly If only visible expressions needed.
-     * @return Select phrase expressions.
+     * @return Select clause expressions.
      */
-    public Iterable<GridSqlElement> select(boolean visibleOnly) {
-        return visibleOnly ? select : allExprs;
+    public Iterable<GridSqlElement> columns(boolean visibleOnly) {
+        assert visibleCols <= cols.size();
+
+        return visibleOnly && visibleCols != cols.size() ?
+            cols.subList(0, visibleCols) : cols;
     }
 
     /**
-     * Clears select list.
+     * Clears select expressions list.
+     * @return {@code this}.
      */
-    public void clearSelect() {
-        select = new ArrayList<>();
-        allExprs = new ArrayList<>();
+    public GridSqlSelect clearColumns() {
+        visibleCols = 0;
+        cols = new ArrayList<>();
+
+        return this;
     }
 
     /**
      * @param expression Expression.
      * @param visible Expression is visible in select phrase.
+     * @return {@code this}.
      */
-    public void addSelectExpression(GridSqlElement expression, boolean visible) {
+    public GridSqlSelect addColumn(GridSqlElement expression, boolean visible) {
         if (expression == null)
             throw new NullPointerException();
 
         if (visible) {
-            if (select.size() != allExprs.size())
+            if (visibleCols != cols.size())
                 throw new IllegalStateException("Already started adding invisible columns.");
 
-            select.add(expression);
+            visibleCols++;
         }
-        else if (select.isEmpty())
-            throw new IllegalStateException("No visible columns.");
 
-        allExprs.add(expression);
+        cols.add(expression);
+
+        return this;
     }
 
     /**
      * @param colIdx Column index.
      * @param expression Expression.
+     * @return {@code this}.
      */
-    public void setSelectExpression(int colIdx, GridSqlElement expression) {
+    public GridSqlSelect setColumn(int colIdx, GridSqlElement expression) {
         if (expression == null)
             throw new NullPointerException();
 
-        if (colIdx < select.size()) // Assuming that all the needed expressions were already added.
-            select.set(colIdx, expression);
+        cols.set(colIdx, expression);
 
-        allExprs.set(colIdx, expression);
+        return this;
     }
 
     /**
@@ -171,9 +178,12 @@ public class GridSqlSelect extends GridSqlQuery {
 
     /**
      * @param grpCols Group columns.
+     * @return {@code this}.
      */
-    public void groupColumns(int[] grpCols) {
+    public GridSqlSelect groupColumns(int[] grpCols) {
         this.grpCols = grpCols;
+
+        return this;
     }
 
     /**
@@ -202,9 +212,12 @@ public class GridSqlSelect extends GridSqlQuery {
 
     /**
      * @param where New where.
+     * @return {@code this}.
      */
-    public void where(GridSqlElement where) {
+    public GridSqlSelect where(GridSqlElement where) {
         this.where = where;
+
+        return this;
     }
 
     /**
@@ -226,16 +239,19 @@ public class GridSqlSelect extends GridSqlQuery {
      * @return Having.
      */
     public GridSqlElement having() {
-        return havingCol >= 0 ? allExprs.get(havingCol) : null;
+        return havingCol >= 0 ? column(havingCol) : null;
     }
 
     /**
      * @param col Index of HAVING column.
+     * @return {@code this}.
      */
-    public void havingColumn(int col) {
+    public GridSqlSelect havingColumn(int col) {
         assert col >= -1 : col;
 
         havingCol = col;
+
+        return this;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d7dd4a02/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlType.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlType.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlType.java
index 1dbcd46..aeee562 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlType.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlType.java
@@ -17,10 +17,27 @@
 
 package org.apache.ignite.internal.processors.query.h2.sql;
 
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.h2.value.*;
+
 /**
  * SQL Data type based on H2.
  */
-public class GridSqlType {
+public final class GridSqlType {
+    /** */
+    public static final GridSqlType UNKNOWN = new GridSqlType(Value.UNKNOWN, 0, 0, 0, null);
+
+    /** */
+    public static final GridSqlType BIGINT = new GridSqlType(Value.LONG, 0, ValueLong.PRECISION,
+        ValueLong.DISPLAY_SIZE, "BIGINT");
+
+    /** */
+    public static final GridSqlType DOUBLE = new GridSqlType(Value.DOUBLE, 0, ValueDouble.PRECISION,
+        ValueDouble.DISPLAY_SIZE, "DOUBLE");
+
+    /** */
+    public static final GridSqlType UUID = new GridSqlType(Value.UUID, 0, Integer.MAX_VALUE, 36, "UUID");
+
     /** H2 type. */
     private final int type;
 
@@ -91,4 +108,9 @@ public class GridSqlType {
     public String sql() {
         return sql;
     }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return S.toString(GridSqlType.class, this);
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d7dd4a02/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlUnion.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlUnion.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlUnion.java
index 721c288..2900470 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlUnion.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlUnion.java
@@ -41,7 +41,7 @@ public class GridSqlUnion extends GridSqlQuery {
     }
 
     /** {@inheritDoc} */
-    @Override protected GridSqlElement expression(int col) {
+    @Override protected GridSqlElement column(int col) {
         throw new IllegalStateException();
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d7dd4a02/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
index 5510e9e..03500e6 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
@@ -29,6 +29,7 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.*;
 import org.apache.ignite.internal.processors.cache.query.*;
 import org.apache.ignite.internal.processors.query.*;
 import org.apache.ignite.internal.processors.query.h2.*;
+import org.apache.ignite.internal.processors.query.h2.sql.*;
 import org.apache.ignite.internal.processors.query.h2.twostep.messages.*;
 import org.apache.ignite.internal.util.*;
 import org.apache.ignite.internal.util.typedef.*;
@@ -36,16 +37,11 @@ import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.lang.*;
 import org.apache.ignite.marshaller.*;
 import org.apache.ignite.plugin.extensions.communication.*;
-import org.h2.command.*;
 import org.h2.command.ddl.*;
-import org.h2.command.dml.*;
 import org.h2.engine.*;
-import org.h2.expression.*;
-import org.h2.index.*;
 import org.h2.jdbc.*;
 import org.h2.result.*;
 import org.h2.table.*;
-import org.h2.tools.*;
 import org.h2.util.*;
 import org.h2.value.*;
 import org.jetbrains.annotations.*;
@@ -55,9 +51,9 @@ import javax.cache.*;
 import java.lang.reflect.*;
 import java.sql.*;
 import java.util.*;
-import java.util.Set;
 import java.util.concurrent.*;
 import java.util.concurrent.atomic.*;
+import java.util.concurrent.locks.*;
 
 import static org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion.*;
 
@@ -84,7 +80,10 @@ public class GridReduceQueryExecutor {
     private final ConcurrentMap<Long, QueryRun> runs = new ConcurrentHashMap8<>();
 
     /** */
-    private static ThreadLocal<GridMergeTable> curFunTbl = new ThreadLocal<>();
+    private volatile List<GridThreadLocalTable> fakeTbls = Collections.emptyList();
+
+    /** */
+    private final Lock fakeTblsLock = new ReentrantLock();
 
     /** */
     private static final Constructor<JdbcResultSet> CONSTRUCTOR;
@@ -475,11 +474,13 @@ public class GridReduceQueryExecutor {
                 nodes = Collections.singleton(F.rand(nodes));
             }
 
+            int tblIdx = 0;
+
             for (GridCacheSqlQuery mapQry : qry.mapQueries()) {
                 GridMergeTable tbl;
 
                 try {
-                    tbl = createFunctionTable(r.conn, mapQry, qry.explain()); // createTable(r.conn, mapQry); TODO
+                    tbl = createMergeTable(r.conn, mapQry, qry.explain());
                 }
                 catch (IgniteCheckedException e) {
                     throw new IgniteException(e);
@@ -492,7 +493,7 @@ public class GridReduceQueryExecutor {
 
                 r.tbls.add(tbl);
 
-                curFunTbl.set(tbl);
+                fakeTable(r.conn, tblIdx++).setInnerTable(tbl);
             }
 
             r.latch = new CountDownLatch(r.tbls.size() * nodes.size());
@@ -512,7 +513,7 @@ public class GridReduceQueryExecutor {
                     mapQrys = new ArrayList<>(qry.mapQueries().size());
 
                     for (GridCacheSqlQuery mapQry : qry.mapQueries())
-                        mapQrys.add(new GridCacheSqlQuery(mapQry.alias(), "EXPLAIN " + mapQry.query(), mapQry.parameters()));
+                        mapQrys.add(new GridCacheSqlQuery("EXPLAIN " + mapQry.query(), mapQry.parameters()));
                 }
 
                 if (nodes.size() != 1 || !F.first(nodes).isLocal()) { // Marshall params for remotes.
@@ -565,8 +566,6 @@ public class GridReduceQueryExecutor {
                 for (GridMergeTable tbl : r.tbls) {
                     if (!tbl.getScanIndex(null).fetchedAll()) // We have to explicitly cancel queries on remote nodes.
                         send(nodes, new GridQueryCancelRequest(qryReqId), null);
-
-//                dropTable(r.conn, tbl.getName()); TODO
                 }
 
                 if (retry) {
@@ -600,7 +599,8 @@ public class GridReduceQueryExecutor {
                 if (!runs.remove(qryReqId, r))
                     U.warn(log, "Query run was already removed: " + qryReqId);
 
-                curFunTbl.remove();
+                for (int i = 0, mapQrys = qry.mapQueries().size(); i < mapQrys; i++)
+                    fakeTable(null, i).setInnerTable(null); // Drop all merge tables.
             }
         }
     }
@@ -626,6 +626,54 @@ public class GridReduceQueryExecutor {
     }
 
     /**
+     * @param idx Table index.
+     * @return Table name.
+     */
+    private static String table(int idx) {
+        return GridSqlQuerySplitter.table(idx).getSQL();
+    }
+
+    /**
+     * Gets or creates new fake table for index.
+     *
+     * @param idx Index of table.
+     * @return Table.
+     */
+    private GridThreadLocalTable fakeTable(Connection c, int idx) {
+        List<GridThreadLocalTable> tbls = fakeTbls;
+
+        assert tbls.size() >= idx;
+
+        if (tbls.size() == idx) { // If table for such index does not exist, create one.
+            fakeTblsLock.lock();
+
+            try {
+                if ((tbls = fakeTbls).size() == idx) { // Double check inside of lock.
+                    try (Statement stmt = c.createStatement()) {
+                        stmt.executeUpdate("CREATE TABLE " + table(idx) +
+                            "(fake BOOL) ENGINE \"" + GridThreadLocalTable.Engine.class.getName() + '"');
+                    }
+                    catch (SQLException e) {
+                        throw new IllegalStateException(e);
+                    }
+
+                    List<GridThreadLocalTable> newTbls = new ArrayList<>(tbls.size() + 1);
+
+                    newTbls.addAll(tbls);
+                    newTbls.add(GridThreadLocalTable.Engine.getCreated());
+
+                    fakeTbls = tbls = newTbls;
+                }
+            }
+            finally {
+                fakeTblsLock.unlock();
+            }
+        }
+
+        return tbls.get(idx);
+    }
+
+    /**
      * Calculates data nodes for replicated caches on unstable topology.
      *
      * @param cctx Cache context for main space.
@@ -858,16 +906,18 @@ public class GridReduceQueryExecutor {
         throws IgniteCheckedException {
         List<List<?>> lists = new ArrayList<>();
 
-        for (GridCacheSqlQuery mapQry : qry.mapQueries()) {
-            ResultSet rs = h2.executeSqlQueryWithTimer(space, c, "SELECT PLAN FROM " + mapQry.alias(), null);
+        for (int i = 0, mapQrys = qry.mapQueries().size(); i < mapQrys; i++) {
+            ResultSet rs = h2.executeSqlQueryWithTimer(space, c, "SELECT PLAN FROM " + table(i), null);
 
             lists.add(F.asList(getPlan(rs)));
         }
 
+        int tblIdx = 0;
+
         for (GridCacheSqlQuery mapQry : qry.mapQueries()) {
-            GridMergeTable tbl = createFunctionTable(c, mapQry, false);
+            GridMergeTable tbl = createMergeTable(c, mapQry, false);
 
-            curFunTbl.set(tbl); // Now it will be only a single table.
+            fakeTable(c, tblIdx++).setInnerTable(tbl);
         }
 
         GridCacheSqlQuery rdc = qry.reduceQuery();
@@ -961,118 +1011,12 @@ public class GridReduceQueryExecutor {
 
     /**
      * @param conn Connection.
-     * @param tblName Table name.
-     * @throws SQLException If failed.
-     */
-    private void dropTable(Connection conn, String tblName) throws SQLException {
-        try (Statement s = conn.createStatement()) {
-            s.execute("DROP TABLE " + tblName);
-        }
-    }
-
-    /**
-     * @return Merged result set.
-     */
-    public static ResultSet mergeTableFunction(JdbcConnection c) throws Exception {
-        GridMergeTable tbl = curFunTbl.get();
-
-        Session ses = (Session)c.getSession();
-
-        String url = c.getMetaData().getURL();
-
-        // URL is either "jdbc:default:connection" or "jdbc:columnlist:connection"
-        final Cursor cursor = url.charAt(5) == 'c' ? null : tbl.getScanIndex(ses).find(ses, null, null);
-
-        final Column[] cols = tbl.getColumns();
-
-        SimpleResultSet rs = new SimpleResultSet(cursor == null ? null : new SimpleRowSource() {
-            @Override public Object[] readRow() throws SQLException {
-                if (!cursor.next())
-                    return null;
-
-                Row r = cursor.get();
-
-                Object[] row = new Object[cols.length];
-
-                for (int i = 0; i < row.length; i++)
-                    row[i] = r.getValue(i).getObject();
-
-                return row;
-            }
-
-            @Override public void close() {
-                // No-op.
-            }
-
-            @Override public void reset() throws SQLException {
-                throw new SQLException("Unsupported.");
-            }
-        }) {
-            @Override public byte[] getBytes(int colIdx) throws SQLException {
-                assert cursor != null;
-
-                return cursor.get().getValue(colIdx - 1).getBytes();
-            }
-
-            @Override public <T> T getObject(int columnIndex, Class<T> type) throws SQLException {
-                throw new UnsupportedOperationException();
-            }
-
-            @Override public <T> T getObject(String columnLabel, Class<T> type) throws SQLException {
-                throw new UnsupportedOperationException();
-            }
-        };
-
-        for (Column col : cols)
-            rs.addColumn(col.getName(), DataType.convertTypeToSQLType(col.getType()),
-                MathUtils.convertLongToInt(col.getPrecision()), col.getScale());
-
-        return rs;
-    }
-
-    /**
-     * @param asQuery Query.
-     * @return List of columns.
-     */
-    private static ArrayList<Column> generateColumnsFromQuery(org.h2.command.dml.Query asQuery) {
-        int columnCount = asQuery.getColumnCount();
-        ArrayList<Expression> expressions = asQuery.getExpressions();
-        ArrayList<Column> cols = new ArrayList<>();
-        for (int i = 0; i < columnCount; i++) {
-            Expression expr = expressions.get(i);
-            int type = expr.getType();
-            String name = expr.getAlias();
-            long precision = expr.getPrecision();
-            int displaySize = expr.getDisplaySize();
-            DataType dt = DataType.getDataType(type);
-            if (precision > 0 && (dt.defaultPrecision == 0 ||
-                (dt.defaultPrecision > precision && dt.defaultPrecision < Byte.MAX_VALUE))) {
-                // dont' set precision to MAX_VALUE if this is the default
-                precision = dt.defaultPrecision;
-            }
-            int scale = expr.getScale();
-            if (scale > 0 && (dt.defaultScale == 0 ||
-                (dt.defaultScale > scale && dt.defaultScale < precision))) {
-                scale = dt.defaultScale;
-            }
-            if (scale > precision) {
-                precision = scale;
-            }
-            Column col = new Column(name, type, precision, scale, displaySize);
-            cols.add(col);
-        }
-
-        return cols;
-    }
-
-    /**
-     * @param conn Connection.
      * @param qry Query.
      * @param explain Explain.
      * @return Table.
      * @throws IgniteCheckedException
      */
-    private GridMergeTable createFunctionTable(JdbcConnection conn, GridCacheSqlQuery qry, boolean explain)
+    private GridMergeTable createMergeTable(JdbcConnection conn, GridCacheSqlQuery qry, boolean explain)
         throws IgniteCheckedException {
         try {
             Session ses = (Session)conn.getSession();
@@ -1084,17 +1028,24 @@ public class GridReduceQueryExecutor {
             data.create = true;
 
             if (!explain) {
-                Prepared prepare = ses.prepare(qry.query(), false);
+                LinkedHashMap<String,?> colsMap = qry.columns();
+
+                assert colsMap != null;
+
+                ArrayList<Column> cols = new ArrayList<>(colsMap.size());
+
+                for (Map.Entry<String,?> e : colsMap.entrySet()) {
+                    String alias = e.getKey();
+                    GridSqlType t = (GridSqlType)e.getValue();
 
-                List<org.h2.expression.Parameter> parsedParams = prepare.getParameters();
+                    assert !F.isEmpty(alias);
 
-                for (int i = Math.min(parsedParams.size(), qry.parameters().length); --i >= 0; ) {
-                    Object val = qry.parameters()[i];
+                    Column c = new Column(alias, t.type(), t.precision(), t.scale(), t.displaySize());
 
-                    parsedParams.get(i).setValue(DataType.convertToValue(ses, val, Value.UNKNOWN));
+                    cols.add(c);
                 }
 
-                data.columns = generateColumnsFromQuery((Query)prepare);
+                data.columns = cols;
             }
             else
                 data.columns = planColumns();

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d7dd4a02/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridThreadLocalTable.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridThreadLocalTable.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridThreadLocalTable.java
new file mode 100644
index 0000000..c468371
--- /dev/null
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridThreadLocalTable.java
@@ -0,0 +1,262 @@
+/*
+ * 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.query.h2.twostep;
+
+import org.h2.api.*;
+import org.h2.command.ddl.*;
+import org.h2.engine.*;
+import org.h2.index.*;
+import org.h2.result.*;
+import org.h2.schema.*;
+import org.h2.table.*;
+import org.h2.value.*;
+
+import java.util.*;
+
+/**
+ * Thread local table wrapper for another table instance.
+ */
+public class GridThreadLocalTable extends Table {
+    /** Delegate table */
+    private final ThreadLocal<Table> tbl = new ThreadLocal<>();
+
+    /**
+     * @param schema Schema.
+     * @param id ID.
+     * @param name Table name.
+     * @param persistIndexes Persist indexes.
+     * @param persistData Persist data.
+     */
+    public GridThreadLocalTable(Schema schema, int id, String name, boolean persistIndexes, boolean persistData) {
+        super(schema, id, name, persistIndexes, persistData);
+    }
+
+    /**
+     * @param t Table or {@code null} to reset existing.
+     */
+    public void setInnerTable(Table t) {
+        if (t == null)
+            tbl.remove();
+        else
+            tbl.set(t);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Index getPrimaryKey() {
+        return tbl.get().getPrimaryKey();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Column getRowIdColumn() {
+        return tbl.get().getRowIdColumn();
+    }
+
+    /** {@inheritDoc} */
+    @Override public PlanItem getBestPlanItem(Session session, int[] masks, TableFilter filter, SortOrder sortOrder) {
+        return tbl.get().getBestPlanItem(session, masks, filter, sortOrder);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Value getDefaultValue(Session session, Column column) {
+        return tbl.get().getDefaultValue(session, column);
+    }
+
+    /** {@inheritDoc} */
+    @Override public SearchRow getTemplateSimpleRow(boolean singleColumn) {
+        return tbl.get().getTemplateSimpleRow(singleColumn);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Row getTemplateRow() {
+        return tbl.get().getTemplateRow();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Column getColumn(String columnName) {
+        return tbl.get().getColumn(columnName);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Column getColumn(int index) {
+        return tbl.get().getColumn(index);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Index getIndexForColumn(Column column) {
+        return tbl.get().getIndexForColumn(column);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Column[] getColumns() {
+        return tbl.get().getColumns();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void setColumns(Column[] columns) {
+        throw new IllegalStateException("Cols: " + Arrays.asList(columns));
+    }
+
+    /** {@inheritDoc} */
+    @Override public void lock(Session session, boolean exclusive, boolean force) {
+        tbl.get().lock(session, exclusive, force);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void close(Session session) {
+        // No-op.
+    }
+
+    /** {@inheritDoc} */
+    @Override public void unlock(Session s) {
+        tbl.get().unlock(s);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Index addIndex(Session session, String indexName, int indexId, IndexColumn[] cols,
+        IndexType indexType, boolean create, String indexComment) {
+        return tbl.get().addIndex(session, indexName, indexId, cols, indexType, create, indexComment);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void removeRow(Session session, Row row) {
+        tbl.get().removeRow(session, row);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void truncate(Session session) {
+        tbl.get().truncate(session);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void addRow(Session session, Row row) {
+        tbl.get().addRow(session, row);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void checkSupportAlter() {
+        tbl.get().checkSupportAlter();
+    }
+
+    /** {@inheritDoc} */
+    @Override public String getTableType() {
+        return tbl.get().getTableType();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Index getUniqueIndex() {
+        return tbl.get().getUniqueIndex();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Index getScanIndex(Session session) {
+        return tbl.get().getScanIndex(session);
+    }
+
+    /** {@inheritDoc} */
+    @Override public ArrayList<Index> getIndexes() {
+        return tbl.get().getIndexes();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isLockedExclusively() {
+        return tbl.get().isLockedExclusively();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getMaxDataModificationId() {
+        return tbl.get().getMaxDataModificationId();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDeterministic() {
+        return tbl.get().isDeterministic();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean canGetRowCount() {
+        return tbl.get().canGetRowCount();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean canDrop() {
+        return tbl.get().canDrop();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getRowCount(Session session) {
+        return tbl.get().getRowCount(session);
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getRowCountApproximation() {
+        return tbl.get().getRowCountApproximation();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getDiskSpaceUsed() {
+        return tbl.get().getDiskSpaceUsed();
+    }
+
+    /** {@inheritDoc} */
+    @Override public String getCreateSQL() {
+        return "";
+    }
+
+    /** {@inheritDoc} */
+    @Override public String getDropSQL() {
+        return tbl.get().getDropSQL();
+    }
+
+    /** {@inheritDoc} */
+    @Override public void checkRename() {
+        tbl.get().checkRename();
+    }
+
+    /**
+     * Engine.
+     */
+    public static class Engine implements TableEngine {
+        /** */
+        private static ThreadLocal<GridThreadLocalTable> createdTbl = new ThreadLocal<>();
+
+        /**
+         * @return Created table.
+         */
+        public static GridThreadLocalTable getCreated() {
+            GridThreadLocalTable tbl = createdTbl.get();
+
+            assert tbl != null;
+
+            createdTbl.remove();
+
+            return tbl;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Table createTable(CreateTableData d) {
+            assert createdTbl.get() == null;
+
+            GridThreadLocalTable tbl = new GridThreadLocalTable(d.schema, d.id, d.tableName, d.persistIndexes,
+                d.persistData);
+
+            createdTbl.set(tbl);
+
+            return tbl;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d7dd4a02/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractFieldsQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractFieldsQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractFieldsQuerySelfTest.java
index ccb3115..18bfd57 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractFieldsQuerySelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractFieldsQuerySelfTest.java
@@ -316,7 +316,7 @@ public abstract class IgniteCacheAbstractFieldsQuerySelfTest extends GridCommonA
         if (cacheMode() == PARTITIONED) {
             assertEquals(2, res.size());
 
-            assertTrue(((String)res.get(1).get(0)).contains(GridSqlQuerySplitter.TABLE_FUNC_NAME));
+            assertTrue(((String)res.get(1).get(0)).contains(GridSqlQuerySplitter.table(0).getSQL()));
         }
         else
             assertEquals(1, res.size());


[34/34] incubator-ignite git commit: ignite-1093

Posted by av...@apache.org.
ignite-1093


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

Branch: refs/heads/ignite-1093
Commit: 64319443ab55aa4a0fc4c56182c774dec8446d48
Parents: 50d32b3
Author: Anton Vinogradov <vi...@gmail.com>
Authored: Fri Aug 14 16:29:31 2015 +0300
Committer: Anton Vinogradov <vi...@gmail.com>
Committed: Fri Aug 14 16:29:31 2015 +0300

----------------------------------------------------------------------
 .../configuration/CacheConfiguration.java       |  27 ++
 .../communication/GridIoMessageFactory.java     |   7 +-
 .../processors/cache/GridCacheIoManager.java    |   8 +
 .../dht/preloader/GridDhtPartitionDemander.java | 156 ++++---
 .../dht/preloader/GridDhtPartitionSupplier.java |  25 +-
 .../GridDhtPartitionSupplyMessageV2.java        | 423 +++++++++++++++++++
 .../GridCacheMassiveRebalancingSelfTest.java    | 210 ---------
 ...ridCacheMassiveRebalancingAsyncSelfTest.java |  37 ++
 ...GridCacheMassiveRebalancingSyncSelfTest.java | 252 +++++++++++
 9 files changed, 864 insertions(+), 281 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/64319443/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
index 3ad0f01..a19e136 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
@@ -57,6 +57,9 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
     /** Default rebalance timeout (ms).*/
     public static final long DFLT_REBALANCE_TIMEOUT = 10000;
 
+    /** Default rebalance batches count. */
+    public static final long DFLT_REBALANCE_BATCHES_COUNT = 3;
+
     /** Time in milliseconds to wait between rebalance messages to avoid overloading CPU. */
     public static final long DFLT_REBALANCE_THROTTLE = 0;
 
@@ -240,6 +243,9 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
     /** Off-heap memory size. */
     private long offHeapMaxMem = DFLT_OFFHEAP_MEMORY;
 
+    /** Rebalance batches count. */
+    private long rebalanceBatchesCount = DFLT_REBALANCE_BATCHES_COUNT;
+
     /** */
     private boolean swapEnabled = DFLT_SWAP_ENABLED;
 
@@ -1751,6 +1757,27 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
     }
 
     /**
+     * To gain better rebalancing performance supplier node can provide mode than one batch at start and provide
+     * one new to each next demand request.
+     *
+     * Gets number of batches generated by supply node at rebalancing start.
+     *
+     * @return
+     */
+    public long getRebalanceBatchesCount() {
+        return rebalanceBatchesCount;
+    }
+
+    /**
+     * Sets number of batches generated by supply node at rebalancing start.
+     *
+     * @param rebalanceBatchesCnt batches count.
+     */
+    public void setRebalanceBatchesCount(long rebalanceBatchesCnt) {
+        this.rebalanceBatchesCount = rebalanceBatchesCnt;
+    }
+
+    /**
      * Gets cache store session listener factories.
      *
      * @return Cache store session listener factories.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/64319443/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java
index 7fe8da8..7ddbfb7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java
@@ -600,7 +600,12 @@ public class GridIoMessageFactory implements MessageFactory {
 
                 break;
 
-            // [-3..112] - this
+            case 113:
+                msg = new GridDhtPartitionSupplyMessageV2();
+
+                break;
+
+            // [-3..113] - this
             // [120..123] - DR
             // [-4..-22] - SQL
             default:

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/64319443/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
index 84e4dc2..da55f7e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
@@ -503,6 +503,14 @@ public class GridCacheIoManager extends GridCacheSharedManagerAdapter {
 
             break;
 
+            case 113: {
+                GridDhtPartitionSupplyMessageV2 req = (GridDhtPartitionSupplyMessageV2)msg;
+
+                U.error(log, "Supply message v2 cannot be unmarshalled.", req.classError());
+            }
+
+            break;
+
             default:
                 throw new IgniteCheckedException("Failed to send response to node. Unsupported direct type [message="
                     + msg + "]");

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/64319443/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
index 16f7a61..262ccb7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
@@ -72,9 +72,6 @@ public class GridDhtPartitionDemander {
     /** Last exchange future. */
     private volatile GridDhtPartitionsExchangeFuture lastExchangeFut;
 
-    /** Assignments. */
-    private volatile GridDhtPreloaderAssignments assigns;
-
     /**
      * @param cctx Cache context.
      * @param busyLock Shutdown lock.
@@ -95,8 +92,8 @@ public class GridDhtPartitionDemander {
             for (int cnt = 0; cnt < cctx.config().getRebalanceThreadPoolSize(); cnt++) {
                 final int idx = cnt;
 
-                cctx.io().addOrderedHandler(topic(cnt, cctx.cacheId()), new CI2<UUID, GridDhtPartitionSupplyMessage>() {
-                    @Override public void apply(final UUID id, final GridDhtPartitionSupplyMessage m) {
+                cctx.io().addOrderedHandler(topic(cnt, cctx.cacheId()), new CI2<UUID, GridDhtPartitionSupplyMessageV2>() {
+                    @Override public void apply(final UUID id, final GridDhtPartitionSupplyMessageV2 m) {
                         enterBusy();
 
                         try {
@@ -110,7 +107,7 @@ public class GridDhtPartitionDemander {
             }
         }
 
-        syncFut = new SyncFuture();
+        syncFut = new SyncFuture(null);
 
         if (!enabled)
             // Calling onDone() immediately since preloading is disabled.
@@ -282,13 +279,15 @@ public class GridDhtPartitionDemander {
         if (delay == 0 || force) {
             assert assigns != null;
 
-            AffinityTopologyVersion topVer = cctx.affinity().affinityTopologyVersion();
+            AffinityTopologyVersion topVer = assigns.topologyVersion();
 
-            if (this.assigns != null) {
+            if (syncFut.isInited()) {
                 syncFut.get();
 
-                syncFut = new SyncFuture();
+                syncFut = new SyncFuture(assigns);
             }
+            else
+                syncFut.init(assigns);
 
             if (assigns.isEmpty() || topologyChanged(topVer)) {
                 syncFut.onDone();
@@ -296,28 +295,30 @@ public class GridDhtPartitionDemander {
                 return;
             }
 
-            this.assigns = assigns;
-
             for (Map.Entry<ClusterNode, GridDhtPartitionDemandMessage> e : assigns.entrySet()) {
                 GridDhtPartitionDemandMessage d = e.getValue();
 
                 d.timeout(cctx.config().getRebalanceTimeout());
                 d.workerId(0);//old api support.
 
-                ClusterNode node = e.getKey();
+                final ClusterNode node = e.getKey();
 
                 final long start = U.currentTimeMillis();
 
                 final CacheConfiguration cfg = cctx.config();
 
+                final AffinityTopologyVersion top = d.topologyVersion();
+
                 if (cfg.getRebalanceDelay() >= 0 && !cctx.kernalContext().clientNode()) {
                     U.log(log, "Starting rebalancing [cache=" + cctx.name() + ", mode=" + cfg.getRebalanceMode() +
-                        ", from node=" + node.id() + ", partitions count=" + d.partitions().size() + "]");
-
-                    syncFut.listen(new CI1<Object>() {
-                        @Override public void apply(Object t) {
-                            U.log(log, "Completed rebalancing [cache=" + cctx.name() + ", mode="
-                                + cfg.getRebalanceMode() + ", time=" + (U.currentTimeMillis() - start) + " ms]");
+                        ", from node=" + node.id() + ", partitions count=" + d.partitions().size() + ", topology=" + d.topologyVersion() + "]");
+
+                    syncFut.listen(new CI1<IgniteInternalFuture<Boolean>>() {
+                        @Override public void apply(IgniteInternalFuture<Boolean> t) {
+                            Boolean cancelled = ((SyncFuture)t).cancelled();
+                            U.log(log, (cancelled ? "Cancelled" : "Completed") + " rebalancing [cache=" + cctx.name() + ", mode="
+                                + cfg.getRebalanceMode() + ", from node=" + node.id() + ", topology=" + top +
+                                ", time=" + (U.currentTimeMillis() - start) + " ms]");
                         }
                     });
                 }
@@ -394,7 +395,7 @@ public class GridDhtPartitionDemander {
      * @param c Partitions.
      * @return String representation of partitions list.
      */
-    private String partitionsList(Collection<Integer> c){
+    private String partitionsList(Collection<Integer> c) {
         LinkedList<Integer> s = new LinkedList<>(c);
 
         Collections.sort(s);
@@ -446,21 +447,19 @@ public class GridDhtPartitionDemander {
     private void handleSupplyMessage(
         int idx,
         final UUID id,
-        final GridDhtPartitionSupplyMessage supply) {
-        ClusterNode node = cctx.node(id);
-
-        assert node != null;
-
-        GridDhtPartitionDemandMessage d = assigns.get(node);
-
-        AffinityTopologyVersion topVer = d.topologyVersion();
+        final GridDhtPartitionSupplyMessageV2 supply) {
+        AffinityTopologyVersion topVer = supply.topologyVersion();
 
         if (topologyChanged(topVer)) {
-            syncFut.cancel(id);
+            syncFut.onCancel(id, topVer);
 
             return;
         }
 
+        ClusterNode node = cctx.node(id);
+
+        assert node != null;
+
         if (log.isDebugEnabled())
             log.debug("Received supply message: " + supply);
 
@@ -469,15 +468,13 @@ public class GridDhtPartitionDemander {
             if (log.isDebugEnabled())
                 log.debug("Class got undeployed during preloading: " + supply.classError());
 
-            syncFut.cancel(id);
+            syncFut.onCancel(id, topVer);
 
             return;
         }
 
         final GridDhtPartitionTopology top = cctx.dht().topology();
 
-        GridDhtPartitionsExchangeFuture exchFut = assigns.exchangeFuture();
-
         try {
 
             // Preload.
@@ -524,14 +521,10 @@ public class GridDhtPartitionDemander {
                             if (last) {
                                 top.own(part);
 
-                                syncFut.onPartitionDone(id, p);
+                                syncFut.onPartitionDone(id, p, topVer);
 
                                 if (log.isDebugEnabled())
                                     log.debug("Finished rebalancing partition: " + part);
-
-                                if (cctx.events().isRecordable(EVT_CACHE_REBALANCE_PART_LOADED))
-                                    preloadEvent(p, EVT_CACHE_REBALANCE_PART_LOADED,
-                                        exchFut.discoveryEvent());
                             }
                         }
                         finally {
@@ -540,14 +533,14 @@ public class GridDhtPartitionDemander {
                         }
                     }
                     else {
-                        syncFut.onPartitionDone(id, p);
+                        syncFut.onPartitionDone(id, p, topVer);
 
                         if (log.isDebugEnabled())
                             log.debug("Skipping rebalancing partition (state is not MOVING): " + part);
                     }
                 }
                 else {
-                    syncFut.onPartitionDone(id, p);
+                    syncFut.onPartitionDone(id, p, topVer);
 
                     if (log.isDebugEnabled())
                         log.debug("Skipping rebalancing partition (it does not belong on current node): " + p);
@@ -557,35 +550,40 @@ public class GridDhtPartitionDemander {
             // Only request partitions based on latest topology version.
             for (Integer miss : supply.missed())
                 if (cctx.affinity().localNode(miss, topVer))
-                    syncFut.onMissedPartition(id, miss);
+                    syncFut.onMissedPartition(id, miss, topVer);
 
             for (Integer miss : supply.missed())
-                syncFut.onPartitionDone(id, miss);
+                syncFut.onPartitionDone(id, miss, topVer);
 
             if (!syncFut.isDone()) {
 
-                // Create copy.
-                GridDhtPartitionDemandMessage nextD =
-                    new GridDhtPartitionDemandMessage(d, Collections.<Integer>emptySet());
+                GridDhtPartitionDemandMessage d = syncFut.getDemandMessage(topVer, node);
+
+                if (d != null) {
+
+                    // Create copy.
+                    GridDhtPartitionDemandMessage nextD =
+                        new GridDhtPartitionDemandMessage(d, Collections.<Integer>emptySet());
 
-                nextD.topic(topic(idx, cctx.cacheId()));
+                    nextD.topic(topic(idx, cctx.cacheId()));
 
-                // Send demand message.
-                cctx.io().sendOrderedMessage(node, GridDhtPartitionSupplier.topic(idx, cctx.cacheId()),
-                    nextD, cctx.ioPolicy(), d.timeout());
+                    // Send demand message.
+                    cctx.io().sendOrderedMessage(node, GridDhtPartitionSupplier.topic(idx, cctx.cacheId()),
+                        nextD, cctx.ioPolicy(), cctx.config().getRebalanceTimeout());
+                }
             }
         }
         catch (ClusterTopologyCheckedException e) {
             if (log.isDebugEnabled())
                 log.debug("Node left during rebalancing (will retry) [node=" + node.id() +
                     ", msg=" + e.getMessage() + ']');
-            syncFut.cancel(id);
+            syncFut.onCancel(id, topVer);
         }
         catch (IgniteCheckedException ex) {
             U.error(log, "Failed to receive partitions from node (rebalancing will not " +
-                "fully finish) [node=" + node.id() + ", msg=" + d + ']', ex);
+                "fully finish) [node=" + node.id() + ", msg=" + supply + ']', ex);
 
-            syncFut.cancel(id);
+            syncFut.onCancel(id, topVer);
         }
     }
 
@@ -687,7 +685,7 @@ public class GridDhtPartitionDemander {
     /**
      *
      */
-    private class SyncFuture extends GridFutureAdapter<Object> {
+    public class SyncFuture extends GridFutureAdapter<Boolean> {
         /** */
         private static final long serialVersionUID = 1L;
 
@@ -695,32 +693,74 @@ public class GridDhtPartitionDemander {
 
         private ConcurrentHashMap8<UUID, Collection<Integer>> missed = new ConcurrentHashMap8<>();
 
-        public void append(UUID nodeId, Collection<Integer> parts) {
+        /** Assignments. */
+        private volatile GridDhtPreloaderAssignments assigns;
+
+        private volatile boolean cancelled = false;
+
+        SyncFuture(GridDhtPreloaderAssignments assigns) {
+            this.assigns = assigns;
+        }
+
+        public AffinityTopologyVersion topologyVersion() {
+            return assigns != null ? assigns.topologyVersion() : null;
+        }
+
+        void init(
+            GridDhtPreloaderAssignments assigns) {
+            this.assigns = assigns;
+        }
+
+        boolean isInited() {
+            return assigns != null;
+        }
+
+        void append(UUID nodeId, Collection<Integer> parts) {
             remaining.put(nodeId, parts);
 
             missed.put(nodeId, new GridConcurrentHashSet<Integer>());
         }
 
-        void cancel(UUID nodeId) {
-            if (isDone())
+        GridDhtPartitionDemandMessage getDemandMessage(AffinityTopologyVersion topVer, ClusterNode node) {
+            if (!topVer.equals(assigns.topologyVersion()))
+                return null;
+
+            return assigns.get(node);
+        }
+
+        void onCancel(UUID nodeId, AffinityTopologyVersion topVer) {
+            if (isDone() || !topVer.equals(assigns.topologyVersion()))
                 return;
 
             remaining.remove(nodeId);
 
+            cancelled = true;
+
             checkIsDone();
         }
 
-        void onMissedPartition(UUID nodeId, int p) {
+        boolean cancelled() {
+            return cancelled;
+        }
+
+        void onMissedPartition(UUID nodeId, int p, AffinityTopologyVersion topVer) {
+            if (isDone() || !topVer.equals(assigns.topologyVersion()))
+                return;
+
             if (missed.get(nodeId) == null)
                 missed.put(nodeId, new GridConcurrentHashSet<Integer>());
 
             missed.get(nodeId).add(p);
         }
 
-        void onPartitionDone(UUID nodeId, int p) {
-            if (isDone())
+        void onPartitionDone(UUID nodeId, int p, AffinityTopologyVersion topVer) {
+            if (isDone() || !topVer.equals(assigns.topologyVersion()))
                 return;
 
+            if (cctx.events().isRecordable(EVT_CACHE_REBALANCE_PART_LOADED))
+                preloadEvent(p, EVT_CACHE_REBALANCE_PART_LOADED,
+                    assigns.exchangeFuture().discoveryEvent());
+
             Collection<Integer> parts = remaining.get(nodeId);
 
             parts.remove(p);
@@ -758,7 +798,7 @@ public class GridDhtPartitionDemander {
 
                 cctx.shared().exchange().scheduleResendPartitions();//TODO: Is in necessary?
 
-                onDone();
+                onDone(cancelled);
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/64319443/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplier.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplier.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplier.java
index b948fbd..c496f8d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplier.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplier.java
@@ -170,8 +170,8 @@ class GridDhtPartitionSupplier {
         if (!cctx.affinity().affinityTopologyVersion().equals(d.topologyVersion()))
             return;
 
-        GridDhtPartitionSupplyMessage s = new GridDhtPartitionSupplyMessage(d.workerId(),
-            d.updateSequence(), cctx.cacheId());
+        GridDhtPartitionSupplyMessageV2 s = new GridDhtPartitionSupplyMessageV2(d.workerId(),
+            d.updateSequence(), cctx.cacheId(), d.topologyVersion());
 
         long preloadThrottle = cctx.config().getRebalanceThrottle();
 
@@ -180,12 +180,13 @@ class GridDhtPartitionSupplier {
         T2<UUID, Object> scId = new T2<>(id, d.topic());
 
         try {
-            SupplyContext sctx = scMap.remove(scId);
-
             if (!d.partitions().isEmpty()) {//Only initial request contains partitions.
                 doneMap.remove(scId);
+                scMap.remove(scId);
             }
 
+            SupplyContext sctx = scMap.remove(scId);
+
             if (doneMap.get(scId) != null)
                 return;
 
@@ -195,7 +196,7 @@ class GridDhtPartitionSupplier {
 
             boolean newReq = true;
 
-            long maxBatchesCnt = 3;//Todo: param
+            long maxBatchesCnt = cctx.config().getRebalanceBatchesCount();
 
             if (sctx != null) {
                 phase = sctx.phase;
@@ -273,8 +274,8 @@ class GridDhtPartitionSupplier {
                                     return;
                                 }
                                 else {
-                                    s = new GridDhtPartitionSupplyMessage(d.workerId(), d.updateSequence(),
-                                        cctx.cacheId());
+                                    s = new GridDhtPartitionSupplyMessageV2(d.workerId(), d.updateSequence(),
+                                        cctx.cacheId(), d.topologyVersion());
                                 }
                             }
 
@@ -340,8 +341,8 @@ class GridDhtPartitionSupplier {
                                             return;
                                         }
                                         else {
-                                            s = new GridDhtPartitionSupplyMessage(d.workerId(), d.updateSequence(),
-                                                cctx.cacheId());
+                                            s = new GridDhtPartitionSupplyMessageV2(d.workerId(), d.updateSequence(),
+                                                cctx.cacheId(), d.topologyVersion());
                                         }
                                     }
 
@@ -443,8 +444,8 @@ class GridDhtPartitionSupplier {
                                     return;
                                 }
                                 else {
-                                    s = new GridDhtPartitionSupplyMessage(d.workerId(), d.updateSequence(),
-                                        cctx.cacheId());
+                                    s = new GridDhtPartitionSupplyMessageV2(d.workerId(), d.updateSequence(),
+                                        cctx.cacheId(), d.topologyVersion());
                                 }
                             }
 
@@ -491,7 +492,7 @@ class GridDhtPartitionSupplier {
      * @return {@code True} if message was sent, {@code false} if recipient left grid.
      * @throws IgniteCheckedException If failed.
      */
-    private boolean reply(ClusterNode n, GridDhtPartitionDemandMessage d, GridDhtPartitionSupplyMessage s)
+    private boolean reply(ClusterNode n, GridDhtPartitionDemandMessage d, GridDhtPartitionSupplyMessageV2 s)
         throws IgniteCheckedException {
 
         try {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/64319443/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessageV2.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessageV2.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessageV2.java
new file mode 100644
index 0000000..93d0db6
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessageV2.java
@@ -0,0 +1,423 @@
+/*
+ *  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.distributed.dht.preloader;
+
+import org.apache.ignite.*;
+import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.processors.affinity.*;
+import org.apache.ignite.internal.processors.cache.*;
+import org.apache.ignite.internal.util.tostring.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.apache.ignite.plugin.extensions.communication.*;
+
+import java.io.*;
+import java.nio.*;
+import java.util.*;
+
+/**
+ * Partition supply message.
+ */
+public class GridDhtPartitionSupplyMessageV2 extends GridCacheMessage implements GridCacheDeployable {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** Worker ID. */
+    private int workerId = -1;
+
+    /** Update sequence. */
+    private long updateSeq;
+
+    /** Acknowledgement flag. */
+    private boolean ack;
+
+    /** Topology version. */
+    private AffinityTopologyVersion topVer;
+
+    /** Partitions that have been fully sent. */
+    @GridDirectCollection(int.class)
+    private Collection<Integer> last;
+
+    /** Partitions which were not found. */
+    @GridToStringInclude
+    @GridDirectCollection(int.class)
+    private Collection<Integer> missed;
+
+    /** Entries. */
+    @GridDirectMap(keyType = int.class, valueType = CacheEntryInfoCollection.class)
+    private Map<Integer, CacheEntryInfoCollection> infos = new HashMap<>();
+
+    /** Message size. */
+    @GridDirectTransient
+    private int msgSize;
+
+    /**
+     * @param workerId Worker ID.
+     * @param updateSeq Update sequence for this node.
+     * @param cacheId Cache ID.
+     */
+    GridDhtPartitionSupplyMessageV2(int workerId, long updateSeq, int cacheId, AffinityTopologyVersion topVer) {
+        assert workerId >= 0;
+        assert updateSeq > 0;
+
+        this.cacheId = cacheId;
+        this.updateSeq = updateSeq;
+        this.workerId = workerId;
+        this.topVer = topVer;
+    }
+
+    /**
+     * Empty constructor required for {@link Externalizable}.
+     */
+    public GridDhtPartitionSupplyMessageV2() {
+        // No-op.
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean allowForStartup() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean ignoreClassErrors() {
+        return true;
+    }
+
+    /**
+     * @return Worker ID.
+     */
+    int workerId() {
+        return workerId;
+    }
+
+    /**
+     * @return Update sequence.
+     */
+    long updateSequence() {
+        return updateSeq;
+    }
+
+    /**
+     * Marks this message for acknowledgment.
+     */
+    void markAck() {
+        ack = true;
+    }
+
+    /**
+     * @return Acknowledgement flag.
+     */
+    boolean ack() {
+        return ack;
+    }
+
+    /**
+     * @return Topology version for which demand message is sent.
+     */
+    @Override public AffinityTopologyVersion topologyVersion() {
+        return topVer;
+    }
+
+    /**
+     * @return Flag to indicate last message for partition.
+     */
+    Collection<Integer> last() {
+        return last == null ? Collections.<Integer>emptySet() : last;
+    }
+
+    /**
+     * @param p Partition which was fully sent.
+     */
+    void last(int p) {
+        if (last == null)
+            last = new HashSet<>();
+
+        if (last.add(p)) {
+            msgSize += 4;
+
+            // If partition is empty, we need to add it.
+            if (!infos.containsKey(p)) {
+                CacheEntryInfoCollection infoCol = new CacheEntryInfoCollection();
+
+                infoCol.init();
+
+                infos.put(p, infoCol);
+            }
+        }
+    }
+
+    /**
+     * @param p Missed partition.
+     */
+    void missed(int p) {
+        if (missed == null)
+            missed = new HashSet<>();
+
+        if (missed.add(p))
+            msgSize += 4;
+    }
+
+    /**
+     * @return Missed partitions.
+     */
+    Collection<Integer> missed() {
+        return missed == null ? Collections.<Integer>emptySet() : missed;
+    }
+
+    /**
+     * @return Entries.
+     */
+    Map<Integer, CacheEntryInfoCollection> infos() {
+        return infos;
+    }
+
+    /**
+     * @return Message size.
+     */
+    int messageSize() {
+        return msgSize;
+    }
+
+    /**
+     * @param p Partition.
+     * @param info Entry to add.
+     * @param ctx Cache context.
+     * @throws IgniteCheckedException If failed.
+     */
+    void addEntry(int p, GridCacheEntryInfo info, GridCacheContext ctx) throws IgniteCheckedException {
+        assert info != null;
+
+        marshalInfo(info, ctx);
+
+        msgSize += info.marshalledSize(ctx);
+
+        CacheEntryInfoCollection infoCol = infos.get(p);
+
+        if (infoCol == null) {
+            msgSize += 4;
+
+            infos.put(p, infoCol = new CacheEntryInfoCollection());
+
+            infoCol.init();
+        }
+
+        infoCol.add(info);
+    }
+
+    /**
+     * @param p Partition.
+     * @param info Entry to add.
+     * @param ctx Cache context.
+     * @throws IgniteCheckedException If failed.
+     */
+    void addEntry0(int p, GridCacheEntryInfo info, GridCacheContext ctx) throws IgniteCheckedException {
+        assert info != null;
+        assert (info.key() != null || info.keyBytes() != null);
+        assert info.value() != null;
+
+        // Need to call this method to initialize info properly.
+        marshalInfo(info, ctx);
+
+        msgSize += info.marshalledSize(ctx);
+
+        CacheEntryInfoCollection infoCol = infos.get(p);
+
+        if (infoCol == null) {
+            msgSize += 4;
+
+            infos.put(p, infoCol = new CacheEntryInfoCollection());
+
+            infoCol.init();
+        }
+
+        infoCol.add(info);
+    }
+
+    /** {@inheritDoc} */
+    @SuppressWarnings("ForLoopReplaceableByForEach")
+    @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException {
+        super.finishUnmarshal(ctx, ldr);
+
+        GridCacheContext cacheCtx = ctx.cacheContext(cacheId);
+
+        for (CacheEntryInfoCollection col : infos().values()) {
+            List<GridCacheEntryInfo>  entries = col.infos();
+
+            for (int i = 0; i < entries.size(); i++)
+                entries.get(i).unmarshal(cacheCtx, ldr);
+        }
+    }
+
+    /**
+     * @return Number of entries in message.
+     */
+    public int size() {
+        return infos.size();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean writeTo(ByteBuffer buf, MessageWriter writer) {
+        writer.setBuffer(buf);
+
+        if (!super.writeTo(buf, writer))
+            return false;
+
+        if (!writer.isHeaderWritten()) {
+            if (!writer.writeHeader(directType(), fieldsCount()))
+                return false;
+
+            writer.onHeaderWritten();
+        }
+
+        switch (writer.state()) {
+            case 3:
+                if (!writer.writeBoolean("ack", ack))
+                    return false;
+
+                writer.incrementState();
+
+            case 4:
+                if (!writer.writeMap("infos", infos, MessageCollectionItemType.INT, MessageCollectionItemType.MSG))
+                    return false;
+
+                writer.incrementState();
+
+            case 5:
+                if (!writer.writeCollection("last", last, MessageCollectionItemType.INT))
+                    return false;
+
+                writer.incrementState();
+
+            case 6:
+                if (!writer.writeCollection("missed", missed, MessageCollectionItemType.INT))
+                    return false;
+
+                writer.incrementState();
+
+            case 7:
+                if (!writer.writeMessage("topVer", topVer))
+                    return false;
+
+                writer.incrementState();
+
+            case 8:
+                if (!writer.writeLong("updateSeq", updateSeq))
+                    return false;
+
+                writer.incrementState();
+
+            case 9:
+                if (!writer.writeInt("workerId", workerId))
+                    return false;
+
+                writer.incrementState();
+
+        }
+
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean readFrom(ByteBuffer buf, MessageReader reader) {
+        reader.setBuffer(buf);
+
+        if (!reader.beforeMessageRead())
+            return false;
+
+        if (!super.readFrom(buf, reader))
+            return false;
+
+        switch (reader.state()) {
+            case 3:
+                ack = reader.readBoolean("ack");
+
+                if (!reader.isLastRead())
+                    return false;
+
+                reader.incrementState();
+
+            case 4:
+                infos = reader.readMap("infos", MessageCollectionItemType.INT, MessageCollectionItemType.MSG, false);
+
+                if (!reader.isLastRead())
+                    return false;
+
+                reader.incrementState();
+
+            case 5:
+                last = reader.readCollection("last", MessageCollectionItemType.INT);
+
+                if (!reader.isLastRead())
+                    return false;
+
+                reader.incrementState();
+
+            case 6:
+                missed = reader.readCollection("missed", MessageCollectionItemType.INT);
+
+                if (!reader.isLastRead())
+                    return false;
+
+                reader.incrementState();
+
+            case 7:
+                topVer = reader.readMessage("topVer");
+
+                if (!reader.isLastRead())
+                    return false;
+
+                reader.incrementState();
+
+            case 8:
+                updateSeq = reader.readLong("updateSeq");
+
+                if (!reader.isLastRead())
+                    return false;
+
+                reader.incrementState();
+
+            case 9:
+                workerId = reader.readInt("workerId");
+
+                if (!reader.isLastRead())
+                    return false;
+
+                reader.incrementState();
+
+        }
+
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override public byte directType() {
+        return 113;
+    }
+
+    /** {@inheritDoc} */
+    @Override public byte fieldsCount() {
+        return 10;
+    }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return S.toString(GridDhtPartitionSupplyMessageV2.class, this,
+            "size", size(),
+            "parts", infos.keySet(),
+            "super", super.toString());
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/64319443/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMassiveRebalancingSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMassiveRebalancingSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMassiveRebalancingSelfTest.java
deleted file mode 100644
index 0771509..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMassiveRebalancingSelfTest.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.cache;
-
-import org.apache.ignite.*;
-import org.apache.ignite.cache.*;
-import org.apache.ignite.configuration.*;
-import org.apache.ignite.internal.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
-import org.apache.ignite.spi.discovery.tcp.*;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
-import org.apache.ignite.testframework.junits.common.*;
-
-import java.util.concurrent.atomic.*;
-
-/**
- *
- */
-public class GridCacheMassiveRebalancingSelfTest extends GridCommonAbstractTest {
-    /** */
-    private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
-
-    private static int TEST_SIZE = 1_024_000;
-
-    /** cache name. */
-    protected static String CACHE_NAME_DHT = "cache";
-
-    /** {@inheritDoc} */
-    @Override protected long getTestTimeout() {
-        return Long.MAX_VALUE;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
-        IgniteConfiguration iCfg = super.getConfiguration(gridName);
-
-        CacheConfiguration<Integer, Integer> cacheCfg = new CacheConfiguration<>();
-
-        ((TcpDiscoverySpi)iCfg.getDiscoverySpi()).setIpFinder(ipFinder);
-        ((TcpDiscoverySpi)iCfg.getDiscoverySpi()).setForceServerMode(true);
-
-        if (getTestGridName(3).equals(gridName))
-            iCfg.setClientMode(true);
-
-        cacheCfg.setName(CACHE_NAME_DHT);
-        cacheCfg.setCacheMode(CacheMode.PARTITIONED);
-        //cacheCfg.setRebalanceBatchSize(1024);
-        cacheCfg.setRebalanceMode(CacheRebalanceMode.SYNC);
-        cacheCfg.setRebalanceThreadPoolSize(4);
-        //cacheCfg.setRebalanceTimeout(1000000);
-        cacheCfg.setBackups(1);
-
-        iCfg.setCacheConfiguration(cacheCfg);
-        return iCfg;
-    }
-
-    /**
-     * @param ignite Ignite.
-     */
-    private void generateData(Ignite ignite) {
-        try (IgniteDataStreamer<Integer, Integer> stmr = ignite.dataStreamer(CACHE_NAME_DHT)) {
-            for (int i = 0; i < TEST_SIZE; i++) {
-                if (i % 1_000_000 == 0)
-                    log.info("Prepared " + i / 1_000_000 + "m entries.");
-
-                stmr.addData(i, i);
-            }
-        }
-    }
-
-    /**
-     * @param ignite Ignite.
-     * @throws IgniteCheckedException
-     */
-    private void checkData(Ignite ignite) throws IgniteCheckedException {
-        for (int i = 0; i < TEST_SIZE; i++) {
-            if (i % 1_000_000 == 0)
-                log.info("Checked " + i / 1_000_000 + "m entries.");
-
-            assert ignite.cache(CACHE_NAME_DHT).get(i).equals(i) : "keys " + i + " does not match";
-        }
-    }
-
-    /**
-     * @throws Exception
-     */
-    public void testMassiveRebalancing() throws Exception {
-        Ignite ignite = startGrid(0);
-
-        generateData(ignite);
-
-        log.info("Preloading started.");
-
-        long start = System.currentTimeMillis();
-
-        startGrid(1);
-
-        startGrid(2);
-
-        long spend = (System.currentTimeMillis() - start) / 1000;
-
-        IgniteInternalFuture f1 = ((GridCacheAdapter)grid(1).context().cache().internalCache(CACHE_NAME_DHT)).preloader().syncFuture();
-        IgniteInternalFuture f2 = ((GridCacheAdapter)grid(2).context().cache().internalCache(CACHE_NAME_DHT)).preloader().syncFuture();
-
-        stopGrid(0);
-
-        //TODO: refactor to get futures by topology
-        while (f1 == ((GridCacheAdapter)grid(1).context().cache().internalCache(CACHE_NAME_DHT)).preloader().syncFuture() ||
-            f2 == ((GridCacheAdapter)grid(2).context().cache().internalCache(CACHE_NAME_DHT)).preloader().syncFuture())
-            U.sleep(100);
-
-        ((GridCacheAdapter)grid(1).context().cache().internalCache(CACHE_NAME_DHT)).preloader().syncFuture().get();
-        ((GridCacheAdapter)grid(2).context().cache().internalCache(CACHE_NAME_DHT)).preloader().syncFuture().get();
-
-        f2 = ((GridCacheAdapter)grid(2).context().cache().internalCache(CACHE_NAME_DHT)).preloader().syncFuture();
-
-        stopGrid(1);
-
-        while (f2 == ((GridCacheAdapter)grid(2).context().cache().internalCache(CACHE_NAME_DHT)).preloader().syncFuture())
-            U.sleep(100);
-
-        ((GridCacheAdapter)grid(2).context().cache().internalCache(CACHE_NAME_DHT)).preloader().syncFuture().get();
-
-        checkData(grid(2));
-
-        log.info("Spend " + spend + " seconds to preload entries.");
-
-        stopAllGrids();
-    }
-
-    /**
-     * @throws Exception
-     */
-    public void testOpPerSecRebalancingTest() throws Exception {
-        startGrid(0);
-
-        final AtomicBoolean cancelled = new AtomicBoolean(false);
-
-        generateData(grid(0));
-
-        startGrid(1);
-        startGrid(2);
-        startGrid(3);
-
-        Thread t = new Thread(new Runnable() {
-            @Override public void run() {
-
-                long spend = 0;
-
-                long ops = 0;
-
-                while (!cancelled.get()) {
-                    try {
-                        long start = System.currentTimeMillis();
-
-                        int size = 1000;
-
-                        for (int i = 0; i < size; i++)
-                            grid(3).cachex(CACHE_NAME_DHT).remove(i);
-
-                        for (int i = 0; i < size; i++)
-                            grid(3).cachex(CACHE_NAME_DHT).put(i, i);
-
-                        spend += System.currentTimeMillis() - start;
-
-                        ops += size * 2;
-                    }
-                    catch (IgniteCheckedException e) {
-                        e.printStackTrace();
-                    }
-
-                    log.info("Ops. per ms: " + ops / spend);
-                }
-            }
-        });
-        t.start();
-
-        stopGrid(0);
-        startGrid(0);
-
-        stopGrid(0);
-        startGrid(0);
-
-        stopGrid(0);
-        startGrid(0);
-
-        cancelled.set(true);
-        t.join();
-
-        checkData(grid(3));
-
-        //stopAllGrids();
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/64319443/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheMassiveRebalancingAsyncSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheMassiveRebalancingAsyncSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheMassiveRebalancingAsyncSelfTest.java
new file mode 100644
index 0000000..8bcd6d1
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheMassiveRebalancingAsyncSelfTest.java
@@ -0,0 +1,37 @@
+/*
+ *  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.distributed.rebalancing;
+
+import org.apache.ignite.cache.*;
+import org.apache.ignite.configuration.*;
+
+/**
+ *
+ */
+public class GridCacheMassiveRebalancingAsyncSelfTest extends GridCacheMassiveRebalancingSyncSelfTest {
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration iCfg = super.getConfiguration(gridName);
+
+        CacheConfiguration cacheCfg = iCfg.getCacheConfiguration()[0];
+
+        cacheCfg.setRebalanceMode(CacheRebalanceMode.ASYNC);
+
+        return iCfg;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/64319443/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheMassiveRebalancingSyncSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheMassiveRebalancingSyncSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheMassiveRebalancingSyncSelfTest.java
new file mode 100644
index 0000000..cd12954
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheMassiveRebalancingSyncSelfTest.java
@@ -0,0 +1,252 @@
+/*
+ *  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.distributed.rebalancing;
+
+import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.processors.cache.*;
+import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.apache.ignite.spi.discovery.tcp.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
+import org.apache.ignite.testframework.junits.common.*;
+
+import java.util.concurrent.atomic.*;
+
+/**
+ *
+ */
+public class GridCacheMassiveRebalancingSyncSelfTest extends GridCommonAbstractTest {
+    /** */
+    private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+
+    private static int TEST_SIZE = 1_024_000;
+
+    /** cache name. */
+    protected static String CACHE_NAME_DHT = "cache";
+
+    /** {@inheritDoc} */
+    @Override protected long getTestTimeout() {
+        return Long.MAX_VALUE;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration iCfg = super.getConfiguration(gridName);
+
+        CacheConfiguration<Integer, Integer> cacheCfg = new CacheConfiguration<>();
+
+        ((TcpDiscoverySpi)iCfg.getDiscoverySpi()).setIpFinder(ipFinder);
+        ((TcpDiscoverySpi)iCfg.getDiscoverySpi()).setForceServerMode(true);
+
+        if (getTestGridName(3).equals(gridName))
+            iCfg.setClientMode(true);
+
+        cacheCfg.setName(CACHE_NAME_DHT);
+        cacheCfg.setCacheMode(CacheMode.PARTITIONED);
+        //cacheCfg.setRebalanceBatchSize(1024);
+        //cacheCfg.setRebalanceBatchesCount(1);
+        cacheCfg.setRebalanceMode(CacheRebalanceMode.SYNC);
+        cacheCfg.setRebalanceThreadPoolSize(4);
+        //cacheCfg.setRebalanceTimeout(1000000);
+        cacheCfg.setBackups(1);
+
+        iCfg.setCacheConfiguration(cacheCfg);
+        return iCfg;
+    }
+
+    /**
+     * @param ignite Ignite.
+     */
+    protected void generateData(Ignite ignite) {
+        try (IgniteDataStreamer<Integer, Integer> stmr = ignite.dataStreamer(CACHE_NAME_DHT)) {
+            for (int i = 0; i < TEST_SIZE; i++) {
+                if (i % 1_000_000 == 0)
+                    log.info("Prepared " + i / 1_000_000 + "m entries.");
+
+                stmr.addData(i, i);
+            }
+        }
+    }
+
+    /**
+     * @param ignite Ignite.
+     * @throws IgniteCheckedException
+     */
+    protected void checkData(Ignite ignite) throws IgniteCheckedException {
+        for (int i = 0; i < TEST_SIZE; i++) {
+            if (i % 1_000_000 == 0)
+                log.info("Checked " + i / 1_000_000 + "m entries.");
+
+            assert ignite.cache(CACHE_NAME_DHT).get(i).equals(i) : "keys " + i + " does not match";
+        }
+    }
+
+    /**
+     * @throws Exception
+     */
+    public void testSimpleRebalancing() throws Exception {
+        Ignite ignite = startGrid(0);
+
+        generateData(ignite);
+
+        log.info("Preloading started.");
+
+        long start = System.currentTimeMillis();
+
+        startGrid(1);
+
+        IgniteInternalFuture f1 = ((GridCacheAdapter)grid(1).context().cache().internalCache(CACHE_NAME_DHT)).preloader().syncFuture();
+
+        f1.get();
+
+        long spend = (System.currentTimeMillis() - start) / 1000;
+
+        stopGrid(0);
+
+        checkData(grid(1));
+
+        log.info("Spend " + spend + " seconds to preload entries.");
+
+        stopAllGrids();
+    }
+
+    /**
+     * @throws Exception
+     */
+    public void testComplexRebalancing() throws Exception {
+        Ignite ignite = startGrid(0);
+
+        generateData(ignite);
+
+        log.info("Preloading started.");
+
+        long start = System.currentTimeMillis();
+
+        startGrid(1);
+        startGrid(2);
+
+        IgniteInternalFuture f2 = ((GridCacheAdapter)grid(2).context().cache().internalCache(CACHE_NAME_DHT)).preloader().syncFuture();
+        f2.get();
+
+        IgniteInternalFuture f1 = ((GridCacheAdapter)grid(1).context().cache().internalCache(CACHE_NAME_DHT)).preloader().syncFuture();
+        while (!((GridDhtPartitionDemander.SyncFuture)f1).topologyVersion().equals(((GridDhtPartitionDemander.SyncFuture)f2).topologyVersion())) {
+            U.sleep(100);
+
+            f1 = ((GridCacheAdapter)grid(1).context().cache().internalCache(CACHE_NAME_DHT)).preloader().syncFuture();
+        }
+        f1.get();
+
+        long spend = (System.currentTimeMillis() - start) / 1000;
+
+        f1 = ((GridCacheAdapter)grid(1).context().cache().internalCache(CACHE_NAME_DHT)).preloader().syncFuture();
+        f2 = ((GridCacheAdapter)grid(2).context().cache().internalCache(CACHE_NAME_DHT)).preloader().syncFuture();
+
+        stopGrid(0);
+
+        //TODO: refactor to get futures by topology
+        while (f1 == ((GridCacheAdapter)grid(1).context().cache().internalCache(CACHE_NAME_DHT)).preloader().syncFuture() ||
+            f2 == ((GridCacheAdapter)grid(2).context().cache().internalCache(CACHE_NAME_DHT)).preloader().syncFuture())
+            U.sleep(100);
+
+        ((GridCacheAdapter)grid(1).context().cache().internalCache(CACHE_NAME_DHT)).preloader().syncFuture().get();
+        ((GridCacheAdapter)grid(2).context().cache().internalCache(CACHE_NAME_DHT)).preloader().syncFuture().get();
+
+        f2 = ((GridCacheAdapter)grid(2).context().cache().internalCache(CACHE_NAME_DHT)).preloader().syncFuture();
+
+        stopGrid(1);
+
+        while (f2 == ((GridCacheAdapter)grid(2).context().cache().internalCache(CACHE_NAME_DHT)).preloader().syncFuture())
+            U.sleep(100);
+
+        ((GridCacheAdapter)grid(2).context().cache().internalCache(CACHE_NAME_DHT)).preloader().syncFuture().get();
+
+        checkData(grid(2));
+
+        log.info("Spend " + spend + " seconds to preload entries.");
+
+        stopAllGrids();
+    }
+
+    /**
+     * @throws Exception
+     */
+    public void _testOpPerSecRebalancingTest() throws Exception {
+        startGrid(0);
+
+        final AtomicBoolean cancelled = new AtomicBoolean(false);
+
+        generateData(grid(0));
+
+        startGrid(1);
+        startGrid(2);
+        startGrid(3);
+
+        Thread t = new Thread(new Runnable() {
+            @Override public void run() {
+
+                long spend = 0;
+
+                long ops = 0;
+
+                while (!cancelled.get()) {
+                    try {
+                        long start = System.currentTimeMillis();
+
+                        int size = 1000;
+
+                        for (int i = 0; i < size; i++)
+                            grid(3).cachex(CACHE_NAME_DHT).remove(i);
+
+                        for (int i = 0; i < size; i++)
+                            grid(3).cachex(CACHE_NAME_DHT).put(i, i);
+
+                        spend += System.currentTimeMillis() - start;
+
+                        ops += size * 2;
+                    }
+                    catch (IgniteCheckedException e) {
+                        e.printStackTrace();
+                    }
+
+                    log.info("Ops. per ms: " + ops / spend);
+                }
+            }
+        });
+        t.start();
+
+        stopGrid(0);
+        startGrid(0);
+
+        stopGrid(0);
+        startGrid(0);
+
+        stopGrid(0);
+        startGrid(0);
+
+        cancelled.set(true);
+        t.join();
+
+        checkData(grid(3));
+
+        //stopAllGrids();
+    }
+}
\ No newline at end of file


[04/34] incubator-ignite git commit: ignite-1189: 2 reproducing deadlock

Posted by av...@apache.org.
ignite-1189: 2 reproducing deadlock


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

Branch: refs/heads/ignite-1093
Commit: 3ce3c8b71064ff4d8abd78cd95f4678cb7a74811
Parents: efa7e99
Author: Denis Magda <dm...@gridgain.com>
Authored: Tue Aug 4 10:33:57 2015 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Tue Aug 4 10:33:57 2015 +0300

----------------------------------------------------------------------
 .../dht/atomic/GridDhtAtomicCache.java          | 40 +++-----------------
 1 file changed, 5 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3ce3c8b7/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 18911fd..d6163c2 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
@@ -85,8 +85,6 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
     /** */
     private GridNearAtomicCache<K, V> near;
 
-    private ThreadLocal<List<GridDhtCacheEntry>> lockedEntries = new ThreadLocal<>();
-
     /**
      * Empty constructor required by {@link Externalizable}.
      */
@@ -992,20 +990,6 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
         final GridNearAtomicUpdateRequest req,
         final CI2<GridNearAtomicUpdateRequest, GridNearAtomicUpdateResponse> completionCb
     ) {
-        boolean printKeys = false;
-
-        if (lockedEntries.get() != null) {
-            for (GridDhtCacheEntry entry : lockedEntries.get())
-                U.error(log, "Locked entry [entry=" + entry + ']');
-
-            printKeys = true;
-        }
-
-        if (printKeys) {
-            for (KeyCacheObject obj : req.keys())
-                U.error(log, "Key requested: " + obj);
-        }
-
         IgniteInternalFuture<Object> forceFut = preldr.request(req.keys(), req.topologyVersion());
 
         if (forceFut.isDone())
@@ -1048,26 +1032,10 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
         IgniteCacheExpiryPolicy expiry = null;
 
         try {
-            boolean printKeys = false;
-
-            if (lockedEntries.get() != null) {
-                for (GridDhtCacheEntry entry : lockedEntries.get())
-                    U.error(log, "Locked entry (2) [entry=" + entry + ']');
-
-                printKeys = true;
-            }
-
-            if (printKeys) {
-                for (KeyCacheObject obj : keys)
-                    U.error(log, "Key requested: " + obj);
-            }
-
             // If batch store update is enabled, we need to lock all entries.
             // First, need to acquire locks on cache entries, then check filter.
             List<GridDhtCacheEntry> locked = lockEntries(keys, req.topologyVersion());
 
-            lockedEntries.set(locked);
-
             Collection<IgniteBiTuple<GridDhtCacheEntry, GridCacheVersion>> deleted = null;
 
             try {
@@ -1184,11 +1152,13 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
 
                 e.printStackTrace();
             }
+            catch (Exception e) {
+                if (X.hasCause(e, InterruptedException.class))
+                    U.error(log, "FUCK Interrupted", e);
+            }
             finally {
-                if (locked != null) {
-                    lockedEntries.set(null);
+                if (locked != null)
                     unlockEntries(locked, req.topologyVersion());
-                }
 
                 // Enqueue if necessary after locks release.
                 if (deleted != null) {


[29/34] incubator-ignite git commit: # ignite-1229: stop ping process when node left topology

Posted by av...@apache.org.
# ignite-1229: stop ping process when node left topology


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

Branch: refs/heads/ignite-1093
Commit: d5986c265c9f68c2a98c48d4ba75444fad9e6725
Parents: ae11e9b
Author: sboikov <sb...@gridgain.com>
Authored: Wed Aug 12 11:42:22 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed Aug 12 11:42:22 2015 +0300

----------------------------------------------------------------------
 .../ignite/spi/discovery/tcp/ServerImpl.java    | 91 +++++++++++++-------
 1 file changed, 60 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d5986c26/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
index 92c21ed..76144e3 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
@@ -388,12 +388,15 @@ class ServerImpl extends TcpDiscoveryImpl {
 
         TcpDiscoveryNode node = ring.node(nodeId);
 
-        if (node == null || !node.visible())
+        if (node == null)
+            return false;
+
+        if (!nodeAlive(nodeId))
             return false;
 
         boolean res = pingNode(node);
 
-        if (!res && !node.isClient()) {
+        if (!res && !node.isClient() && nodeAlive(nodeId)) {
             LT.warn(log, null, "Failed to ping node (status check will be initiated): " + nodeId);
 
             msgWorker.addMessage(new TcpDiscoveryStatusCheckMessage(locNode, node.id()));
@@ -421,14 +424,18 @@ class ServerImpl extends TcpDiscoveryImpl {
 
             node = ring.node(node.clientRouterNodeId());
 
-            if (node == null || !node.visible())
+            if (node == null || !nodeAlive(node.id()))
                 return false;
         }
 
         for (InetSocketAddress addr : spi.getNodeAddresses(node, U.sameMacs(locNode, node))) {
             try {
                 // ID returned by the node should be the same as ID of the parameter for ping to succeed.
-                IgniteBiTuple<UUID, Boolean> t = pingNode(addr, clientNodeId);
+                IgniteBiTuple<UUID, Boolean> t = pingNode(addr, node.id(), clientNodeId);
+
+                if (t == null)
+                    // Remote node left topology.
+                    return false;
 
                 boolean res = node.id().equals(t.get1()) && (clientNodeId == null || t.get2());
 
@@ -453,12 +460,14 @@ class ServerImpl extends TcpDiscoveryImpl {
      * Pings the node by its address to see if it's alive.
      *
      * @param addr Address of the node.
+     * @param nodeId Node ID to ping. In case when client node ID is not null this node ID is an ID of the router node.
      * @param clientNodeId Client node ID.
-     * @return ID of the remote node and "client exists" flag if node alive.
+     * @return ID of the remote node and "client exists" flag if node alive or {@code null} if the remote node has
+     *         left a topology during the ping process.
      * @throws IgniteCheckedException If an error occurs.
      */
-    private IgniteBiTuple<UUID, Boolean> pingNode(InetSocketAddress addr, @Nullable UUID clientNodeId)
-        throws IgniteCheckedException {
+    private @Nullable IgniteBiTuple<UUID, Boolean> pingNode(InetSocketAddress addr, @Nullable UUID nodeId,
+        @Nullable UUID clientNodeId) throws IgniteCheckedException {
         assert addr != null;
 
         UUID locNodeId = getLocalNodeId();
@@ -537,6 +546,16 @@ class ServerImpl extends TcpDiscoveryImpl {
                         return t;
                     }
                     catch (IOException | IgniteCheckedException e) {
+                        if (nodeId != null && !nodeAlive(nodeId)) {
+                            if (log.isDebugEnabled())
+                                log.debug("Failed to ping the node (has left or leaving topology): [nodeId=" + nodeId +
+                                    ']');
+
+                            fut.onDone((IgniteBiTuple<UUID, Boolean>)null);
+
+                            return null;
+                        }
+
                         if (errs == null)
                             errs = new ArrayList<>();
 
@@ -615,6 +634,28 @@ class ServerImpl extends TcpDiscoveryImpl {
     }
 
     /**
+     * Checks whether a node is alive or not.
+     *
+     * @param nodeId Node ID.
+     * @return {@code True} if node is in the ring and is not being removed from.
+     */
+    private boolean nodeAlive(UUID nodeId) {
+        // Is node alive or about to be removed from the ring?
+        TcpDiscoveryNode node = ring.node(nodeId);
+
+        boolean nodeAlive = node != null && node.visible();
+
+        if (nodeAlive) {
+            synchronized (mux) {
+                nodeAlive = !F.transform(failedNodes, F.node2id()).contains(nodeId) &&
+                    !F.transform(leavingNodes, F.node2id()).contains(nodeId);
+            }
+        }
+
+        return nodeAlive;
+    }
+
+    /**
      * Tries to join this node to topology.
      *
      * @throws IgniteSpiException If any error occurs.
@@ -1520,7 +1561,7 @@ class ServerImpl extends TcpDiscoveryImpl {
 
                         if (res == null) {
                             try {
-                                res = pingNode(addr, null).get1() != null;
+                                res = pingNode(addr, null, null).get1() != null;
                             }
                             catch (IgniteCheckedException e) {
                                 if (log.isDebugEnabled())
@@ -3775,9 +3816,17 @@ class ServerImpl extends TcpDiscoveryImpl {
                             else {
                                 int aliveCheck = clientNode.decrementAliveCheck();
 
-                                if (aliveCheck <= 0 && isLocalNodeCoordinator() && !failedNodes.contains(clientNode))
-                                    processNodeFailedMessage(new TcpDiscoveryNodeFailedMessage(locNodeId,
-                                        clientNode.id(), clientNode.internalOrder()));
+                                if (aliveCheck <= 0 && isLocalNodeCoordinator()) {
+                                    boolean failedNode;
+
+                                    synchronized (mux) {
+                                        failedNode = failedNodes.contains(clientNode);
+                                    }
+
+                                    if (!failedNode)
+                                        processNodeFailedMessage(new TcpDiscoveryNodeFailedMessage(locNodeId,
+                                            clientNode.id(), clientNode.internalOrder()));
+                                }
                             }
                         }
                     }
@@ -4689,26 +4738,6 @@ class ServerImpl extends TcpDiscoveryImpl {
         }
 
         /**
-         * @param nodeId Node ID.
-         * @return {@code True} if node is in the ring and is not being removed from.
-         */
-        private boolean nodeAlive(UUID nodeId) {
-            // Is node alive or about to be removed from the ring?
-            TcpDiscoveryNode node = ring.node(nodeId);
-
-            boolean nodeAlive = node != null && node.visible();
-
-            if (nodeAlive) {
-                synchronized (mux) {
-                    nodeAlive = !F.transform(failedNodes, F.node2id()).contains(nodeId) &&
-                        !F.transform(leavingNodes, F.node2id()).contains(nodeId);
-                }
-            }
-
-            return nodeAlive;
-        }
-
-        /**
          * @param msg Join request message.
          * @param clientMsgWrk Client message worker to start.
          * @return Whether connection was successful.


[30/34] incubator-ignite git commit: ignite-1093

Posted by av...@apache.org.
ignite-1093


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

Branch: refs/heads/ignite-1093
Commit: 8f36482b33d05d20a065d2b3684d82ab7559b902
Parents: 50e188d
Author: Anton Vinogradov <vi...@gmail.com>
Authored: Wed Aug 12 12:42:48 2015 +0300
Committer: Anton Vinogradov <vi...@gmail.com>
Committed: Wed Aug 12 12:42:48 2015 +0300

----------------------------------------------------------------------
 .../dht/preloader/GridDhtPartitionDemander.java | 168 ++++++++-----------
 .../dht/preloader/GridDhtPreloader.java         |  19 +--
 .../GridCacheMassiveRebalancingSelfTest.java    |  19 ++-
 3 files changed, 90 insertions(+), 116 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8f36482b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
index f6a33c3..6c95707 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.processors.cache.distributed.dht.preloader;
 import org.apache.ignite.*;
 import org.apache.ignite.cache.*;
 import org.apache.ignite.cluster.*;
+import org.apache.ignite.configuration.*;
 import org.apache.ignite.events.*;
 import org.apache.ignite.internal.*;
 import org.apache.ignite.internal.cluster.*;
@@ -305,6 +306,22 @@ public class GridDhtPartitionDemander {
 
                 ClusterNode node = e.getKey();
 
+                final long start = U.currentTimeMillis();
+
+                final CacheConfiguration cfg = cctx.config();
+
+                if (cfg.getRebalanceDelay() >= 0 && !cctx.kernalContext().clientNode()) {
+                    U.log(log, "Starting rebalancing [cache=" + cctx.name() + ", mode=" + cfg.getRebalanceMode() +
+                        ", from node=" + node.id() + ", partitions count=" + d.partitions().size() + "]");
+
+                    syncFut.listen(new CI1<Object>() {
+                        @Override public void apply(Object t) {
+                            U.log(log, "Completed rebalancing [cache=" + cctx.name() + ", mode="
+                                + cfg.getRebalanceMode() + ", time=" + (U.currentTimeMillis() - start) + " ms]");
+                        }
+                    });
+                }
+
                 GridConcurrentHashSet<Integer> remainings = new GridConcurrentHashSet<>();
 
                 remainings.addAll(d.partitions());
@@ -342,50 +359,6 @@ public class GridDhtPartitionDemander {
                         }
                     }
                 }
-
-                if (log.isInfoEnabled() && !d.partitions().isEmpty()) {
-                    LinkedList<Integer> s = new LinkedList<>(d.partitions());
-
-                    Collections.sort(s);
-
-                    StringBuilder sb = new StringBuilder();
-
-                    int start = -1;
-
-                    int prev = -1;
-
-                    Iterator<Integer> sit = s.iterator();
-
-                    while (sit.hasNext()) {
-                        int p = sit.next();
-                        if (start == -1) {
-                            start = p;
-                            prev = p;
-                        }
-
-                        if (prev < p - 1) {
-                            sb.append(start);
-
-                            if (start != prev)
-                                sb.append("-").append(prev);
-
-                            sb.append(", ");
-
-                            start = p;
-                        }
-
-                        if (!sit.hasNext()) {
-                            sb.append(start);
-
-                            if (start != p)
-                                sb.append("-").append(p);
-                        }
-
-                        prev = p;
-                    }
-
-                    log.info("Requested rebalancing [from node=" + node.id() + ", partitions=" + s.size() + " (" + sb.toString() + ")]");
-                }
             }
         }
         else if (delay > 0) {
@@ -659,82 +632,83 @@ public class GridDhtPartitionDemander {
     void updateLastExchangeFuture(GridDhtPartitionsExchangeFuture lastFut) {
         lastExchangeFut = lastFut;
     }
-/**
- *
- */
-private class SyncFuture extends GridFutureAdapter<Object> {
-    /** */
-    private static final long serialVersionUID = 1L;
-
-    private ConcurrentHashMap8<UUID, Collection<Integer>> remaining = new ConcurrentHashMap8<>();
 
-    private ConcurrentHashMap8<UUID, Collection<Integer>> missed = new ConcurrentHashMap8<>();
-
-    public void append(UUID nodeId, Collection<Integer> parts) {
-        remaining.put(nodeId, parts);
-
-        missed.put(nodeId, new GridConcurrentHashSet<Integer>());
-    }
+    /**
+     *
+     */
+    private class SyncFuture extends GridFutureAdapter<Object> {
+        /** */
+        private static final long serialVersionUID = 1L;
 
-    void cancel(UUID nodeId) {
-        if (isDone())
-            return;
+        private ConcurrentHashMap8<UUID, Collection<Integer>> remaining = new ConcurrentHashMap8<>();
 
-        remaining.remove(nodeId);
+        private ConcurrentHashMap8<UUID, Collection<Integer>> missed = new ConcurrentHashMap8<>();
 
-        checkIsDone();
-    }
+        public void append(UUID nodeId, Collection<Integer> parts) {
+            remaining.put(nodeId, parts);
 
-    void onMissedPartition(UUID nodeId, int p) {
-        if (missed.get(nodeId) == null)
             missed.put(nodeId, new GridConcurrentHashSet<Integer>());
+        }
 
-        missed.get(nodeId).add(p);
-   }
-
-    void onPartitionDone(UUID nodeId, int p) {
-        if (isDone())
-            return;
+        void cancel(UUID nodeId) {
+            if (isDone())
+                return;
 
-        Collection<Integer> parts = remaining.get(nodeId);
+            remaining.remove(nodeId);
 
-        parts.remove(p);
+            checkIsDone();
+        }
 
-        if (parts.isEmpty()) {
-            remaining.remove(nodeId);
+        void onMissedPartition(UUID nodeId, int p) {
+            if (missed.get(nodeId) == null)
+                missed.put(nodeId, new GridConcurrentHashSet<Integer>());
 
-            if (log.isDebugEnabled())
-                log.debug("Completed full partition iteration for node [nodeId=" + nodeId + ']');
+            missed.get(nodeId).add(p);
         }
 
-        checkIsDone();
-    }
+        void onPartitionDone(UUID nodeId, int p) {
+            if (isDone())
+                return;
 
-    private void checkIsDone() {
-        if (remaining.isEmpty()) {
-            if (log.isDebugEnabled())
-                log.debug("Completed sync future.");
+            Collection<Integer> parts = remaining.get(nodeId);
+
+            parts.remove(p);
 
-            Collection<Integer> m = new HashSet<>();
+            if (parts.isEmpty()) {
+                remaining.remove(nodeId);
 
-            for (Map.Entry<UUID, Collection<Integer>> e : missed.entrySet()) {
-                if (e.getValue() != null && !e.getValue().isEmpty())
-                    m.addAll(e.getValue());
+                if (log.isDebugEnabled())
+                    log.debug("Completed full partition iteration for node [nodeId=" + nodeId + ']');
             }
 
-            if (!m.isEmpty()) {
+            checkIsDone();
+        }
+
+        private void checkIsDone() {
+            if (remaining.isEmpty()) {
                 if (log.isDebugEnabled())
-                    log.debug("Reassigning partitions that were missed: " + m);
+                    log.debug("Completed sync future.");
 
-                cctx.shared().exchange().forceDummyExchange(true, assigns.exchangeFuture());
-            }
+                Collection<Integer> m = new HashSet<>();
 
-            missed.clear();
+                for (Map.Entry<UUID, Collection<Integer>> e : missed.entrySet()) {
+                    if (e.getValue() != null && !e.getValue().isEmpty())
+                        m.addAll(e.getValue());
+                }
+
+                if (!m.isEmpty()) {
+                    if (log.isDebugEnabled())
+                        log.debug("Reassigning partitions that were missed: " + m);
+
+                    cctx.shared().exchange().forceDummyExchange(true, assigns.exchangeFuture());
+                }
+
+                missed.clear();
 
-            cctx.shared().exchange().scheduleResendPartitions();//TODO: Is in necessary?
+                cctx.shared().exchange().scheduleResendPartitions();//TODO: Is in necessary?
 
-            onDone();
+                onDone();
+            }
         }
     }
 }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8f36482b/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 d994a19..7f99ebf 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
@@ -19,7 +19,6 @@ package org.apache.ignite.internal.processors.cache.distributed.dht.preloader;
 
 import org.apache.ignite.*;
 import org.apache.ignite.cluster.*;
-import org.apache.ignite.configuration.*;
 import org.apache.ignite.events.*;
 import org.apache.ignite.internal.*;
 import org.apache.ignite.internal.cluster.*;
@@ -220,24 +219,8 @@ public class GridDhtPreloader extends GridCachePreloaderAdapter {
 
     /** {@inheritDoc} */
     @Override public void onInitialExchangeComplete(@Nullable Throwable err) {
-        if (err == null) {
+        if (err == null)
             startFut.onDone();
-
-            final long start = U.currentTimeMillis();
-
-            final CacheConfiguration cfg = cctx.config();
-
-            if (cfg.getRebalanceDelay() >= 0 && !cctx.kernalContext().clientNode()) {
-                U.log(log, "Starting rebalancing in " + cfg.getRebalanceMode() + " mode: " + cctx.name());
-
-                demander.syncFuture().listen(new CI1<Object>() {
-                    @Override public void apply(Object t) {
-                        U.log(log, "Completed rebalancing in " + cfg.getRebalanceMode() + " mode " +
-                            "[cache=" + cctx.name() + ", time=" + (U.currentTimeMillis() - start) + " ms]");
-                    }
-                });
-            }
-        }
         else
             startFut.onDone(err);
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8f36482b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMassiveRebalancingSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMassiveRebalancingSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMassiveRebalancingSelfTest.java
index 5148753..ca95905 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMassiveRebalancingSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMassiveRebalancingSelfTest.java
@@ -20,6 +20,8 @@ package org.apache.ignite.internal.processors.cache;
 import org.apache.ignite.*;
 import org.apache.ignite.cache.*;
 import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.spi.discovery.tcp.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
@@ -113,12 +115,27 @@ public class GridCacheMassiveRebalancingSelfTest extends GridCommonAbstractTest
 
         long spend = (System.currentTimeMillis() - start) / 1000;
 
+        IgniteInternalFuture f1 = ((GridCacheAdapter)grid(1).context().cache().internalCache(CACHE_NAME_DHT)).preloader().syncFuture();
+        IgniteInternalFuture f2 = ((GridCacheAdapter)grid(2).context().cache().internalCache(CACHE_NAME_DHT)).preloader().syncFuture();
+
         stopGrid(0);
 
-        Thread.sleep(20000);
+        while (f1 == ((GridCacheAdapter)grid(1).context().cache().internalCache(CACHE_NAME_DHT)).preloader().syncFuture() ||
+            f2 == ((GridCacheAdapter)grid(2).context().cache().internalCache(CACHE_NAME_DHT)).preloader().syncFuture())
+            U.sleep(100);
+
+        ((GridCacheAdapter)grid(1).context().cache().internalCache(CACHE_NAME_DHT)).preloader().syncFuture().get();
+        ((GridCacheAdapter)grid(2).context().cache().internalCache(CACHE_NAME_DHT)).preloader().syncFuture().get();
+
+        f2 = ((GridCacheAdapter)grid(2).context().cache().internalCache(CACHE_NAME_DHT)).preloader().syncFuture();
 
         stopGrid(1);
 
+        while (f2 == ((GridCacheAdapter)grid(2).context().cache().internalCache(CACHE_NAME_DHT)).preloader().syncFuture())
+            U.sleep(100);
+
+        ((GridCacheAdapter)grid(2).context().cache().internalCache(CACHE_NAME_DHT)).preloader().syncFuture().get();
+
         checkData(grid(2));
 
         log.info("Spend " + spend + " seconds to preload entries.");


[17/34] incubator-ignite git commit: minor

Posted by av...@apache.org.
minor


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

Branch: refs/heads/ignite-1093
Commit: 56efb6b112abd03f673ee65ca8061b4728e1205d
Parents: 5ce8bc6
Author: Yakov Zhdanov <yz...@gridgain.com>
Authored: Thu Aug 6 15:53:48 2015 +0300
Committer: Yakov Zhdanov <yz...@gridgain.com>
Committed: Thu Aug 6 15:53:48 2015 +0300

----------------------------------------------------------------------
 .../tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/56efb6b1/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java
index bdc7865..b93c547 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java
@@ -330,9 +330,10 @@ public class TcpDiscoveryMulticastIpFinder extends TcpDiscoveryVmIpFinder {
                         reqItfs.add(mcastAddr);
                     }
                     catch (IOException e) {
-                        log.debug("Failed to create multicast socket [mcastAddr=" + mcastAddr +
-                            ", mcastGrp=" + mcastGrp + ", mcastPort=" + mcastPort + ", locAddr=" + mcastAddr +
-                            ", err=" + e + ']');
+                        if (log.isDebugEnabled())
+                            log.debug("Failed to create multicast socket [mcastAddr=" + mcastAddr +
+                                ", mcastGrp=" + mcastGrp + ", mcastPort=" + mcastPort + ", locAddr=" + mcastAddr +
+                                ", err=" + e + ']');
                     }
                 }
             }


[03/34] incubator-ignite git commit: ignite-1189: reproducing deadlock

Posted by av...@apache.org.
ignite-1189: reproducing deadlock


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

Branch: refs/heads/ignite-1093
Commit: efa7e99bbad76ce35a55e6ad9faa9aac8e57b5f4
Parents: 6b237e1
Author: Denis Magda <dm...@gridgain.com>
Authored: Tue Aug 4 09:12:12 2015 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Tue Aug 4 09:12:12 2015 +0300

----------------------------------------------------------------------
 .../dht/atomic/GridDhtAtomicCache.java          | 36 +++++++++++++++-
 .../IgniteCacheAtomicNodeRestartTest.java       | 43 ++++++++++++++++++++
 2 files changed, 78 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/efa7e99b/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 0a21979..18911fd 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
@@ -85,6 +85,8 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
     /** */
     private GridNearAtomicCache<K, V> near;
 
+    private ThreadLocal<List<GridDhtCacheEntry>> lockedEntries = new ThreadLocal<>();
+
     /**
      * Empty constructor required by {@link Externalizable}.
      */
@@ -990,6 +992,20 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
         final GridNearAtomicUpdateRequest req,
         final CI2<GridNearAtomicUpdateRequest, GridNearAtomicUpdateResponse> completionCb
     ) {
+        boolean printKeys = false;
+
+        if (lockedEntries.get() != null) {
+            for (GridDhtCacheEntry entry : lockedEntries.get())
+                U.error(log, "Locked entry [entry=" + entry + ']');
+
+            printKeys = true;
+        }
+
+        if (printKeys) {
+            for (KeyCacheObject obj : req.keys())
+                U.error(log, "Key requested: " + obj);
+        }
+
         IgniteInternalFuture<Object> forceFut = preldr.request(req.keys(), req.topologyVersion());
 
         if (forceFut.isDone())
@@ -1032,10 +1048,26 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
         IgniteCacheExpiryPolicy expiry = null;
 
         try {
+            boolean printKeys = false;
+
+            if (lockedEntries.get() != null) {
+                for (GridDhtCacheEntry entry : lockedEntries.get())
+                    U.error(log, "Locked entry (2) [entry=" + entry + ']');
+
+                printKeys = true;
+            }
+
+            if (printKeys) {
+                for (KeyCacheObject obj : keys)
+                    U.error(log, "Key requested: " + obj);
+            }
+
             // If batch store update is enabled, we need to lock all entries.
             // First, need to acquire locks on cache entries, then check filter.
             List<GridDhtCacheEntry> locked = lockEntries(keys, req.topologyVersion());
 
+            lockedEntries.set(locked);
+
             Collection<IgniteBiTuple<GridDhtCacheEntry, GridCacheVersion>> deleted = null;
 
             try {
@@ -1153,8 +1185,10 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
                 e.printStackTrace();
             }
             finally {
-                if (locked != null)
+                if (locked != null) {
+                    lockedEntries.set(null);
                     unlockEntries(locked, req.topologyVersion());
+                }
 
                 // Enqueue if necessary after locks release.
                 if (deleted != null) {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/efa7e99b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheAtomicNodeRestartTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheAtomicNodeRestartTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheAtomicNodeRestartTest.java
index fa8898f..70e6c4c 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheAtomicNodeRestartTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheAtomicNodeRestartTest.java
@@ -31,7 +31,50 @@ public class IgniteCacheAtomicNodeRestartTest extends GridCachePartitionedNodeRe
         return ATOMIC;
     }
 
+    /** {@inheritDoc} */
     @Override public void testRestartWithPutTenNodesTwoBackups() throws Throwable {
+        super.testRestartWithPutTenNodesTwoBackups();
+    }
+
+    @Override public void testRestart() throws Exception {
+    }
+
+    @Override public void testRestartWithPutTwoNodesNoBackups() throws Throwable {
+    }
+
+    @Override public void testRestartWithPutTwoNodesOneBackup() throws Throwable {
+    }
+
+    @Override public void testRestartWithPutFourNodesNoBackups() throws Throwable {
+    }
+
+    @Override public void testRestartWithPutFourNodesOneBackups() throws Throwable {
+    }
+
+    @Override public void testRestartWithPutSixNodesTwoBackups() throws Throwable {
+    }
+
+    @Override public void testRestartWithPutEightNodesTwoBackups() throws Throwable {
+    }
+
+    @Override public void testRestartWithTxEightNodesTwoBackups() throws Throwable {
+    }
+
+    @Override public void testRestartWithTxFourNodesNoBackups() throws Throwable {
+    }
+
+    @Override public void testRestartWithTxFourNodesOneBackups() throws Throwable {
+    }
+
+    @Override public void testRestartWithTxSixNodesTwoBackups() throws Throwable {
+    }
+
+    @Override public void testRestartWithTxTenNodesTwoBackups() throws Throwable {
+    }
+
+    @Override public void testRestartWithTxTwoNodesNoBackups() throws Throwable {
+    }
 
+    @Override public void testRestartWithTxTwoNodesOneBackup() throws Throwable {
     }
 }


[05/34] incubator-ignite git commit: ignite-1189: 3 reproducing deadlock

Posted by av...@apache.org.
ignite-1189: 3 reproducing deadlock


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

Branch: refs/heads/ignite-1093
Commit: 28c9977bb8344f2d73c65d45656b673a9a4c634b
Parents: 3ce3c8b
Author: Denis Magda <dm...@gridgain.com>
Authored: Tue Aug 4 11:41:48 2015 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Tue Aug 4 11:41:48 2015 +0300

----------------------------------------------------------------------
 .../cache/distributed/dht/atomic/GridDhtAtomicCache.java        | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/28c9977b/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 d6163c2..4d73fb2 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
@@ -1153,8 +1153,9 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
                 e.printStackTrace();
             }
             catch (Exception e) {
-                if (X.hasCause(e, InterruptedException.class))
-                    U.error(log, "FUCK Interrupted", e);
+                U.error(log, "FUCK ERROR", e);
+
+                throw e;
             }
             finally {
                 if (locked != null)


[06/34] incubator-ignite git commit: ignite-1189: 4 reproducing deadlock

Posted by av...@apache.org.
ignite-1189: 4 reproducing deadlock


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

Branch: refs/heads/ignite-1093
Commit: 132562b431bc3250abe56ec48725c5ebe6083964
Parents: 28c9977
Author: Denis Magda <dm...@gridgain.com>
Authored: Tue Aug 4 12:26:00 2015 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Tue Aug 4 12:26:00 2015 +0300

----------------------------------------------------------------------
 .../dht/atomic/GridDhtAtomicCache.java          |  8 ++--
 .../IgniteCacheAtomicNodeRestartTest.java       | 45 ++++++++++++++++++++
 2 files changed, 48 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/132562b4/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 4d73fb2..cd6e28d 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
@@ -1152,11 +1152,6 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
 
                 e.printStackTrace();
             }
-            catch (Exception e) {
-                U.error(log, "FUCK ERROR", e);
-
-                throw e;
-            }
             finally {
                 if (locked != null)
                     unlockEntries(locked, req.topologyVersion());
@@ -1179,6 +1174,9 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
 
             remap = true;
         }
+        catch (Exception e) {
+            U.error(log, "Unexpected exception during cache update", e);
+        }
 
         if (remap) {
             assert dhtFut == null;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/132562b4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheAtomicNodeRestartTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheAtomicNodeRestartTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheAtomicNodeRestartTest.java
index 70e6c4c..caee4d0 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheAtomicNodeRestartTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheAtomicNodeRestartTest.java
@@ -36,7 +36,52 @@ public class IgniteCacheAtomicNodeRestartTest extends GridCachePartitionedNodeRe
         super.testRestartWithPutTenNodesTwoBackups();
     }
 
+    public void testRestartWithPutTenNodesTwoBackups2() throws Throwable {
+        super.testRestartWithPutTenNodesTwoBackups();
+    }
+    public void testRestartWithPutTenNodesTwoBackups3() throws Throwable {
+        super.testRestartWithPutTenNodesTwoBackups();
+    }
+    public void testRestartWithPutTenNodesTwoBackups4() throws Throwable {
+        super.testRestartWithPutTenNodesTwoBackups();
+    }
+    public void testRestartWithPutTenNodesTwoBackups5() throws Throwable {
+        super.testRestartWithPutTenNodesTwoBackups();
+    }
+    public void testRestartWithPutTenNodesTwoBackups6() throws Throwable {
+        super.testRestartWithPutTenNodesTwoBackups();
+    }
+    public void testRestartWithPutTenNodesTwoBackups7() throws Throwable {
+        super.testRestartWithPutTenNodesTwoBackups();
+    }
+    public void testRestartWithPutTenNodesTwoBackups8() throws Throwable {
+        super.testRestartWithPutTenNodesTwoBackups();
+    }
+    public void testRestartWithPutTenNodesTwoBackups9() throws Throwable {
+        super.testRestartWithPutTenNodesTwoBackups();
+    }
+    public void testRestartWithPutTenNodesTwoBackups10() throws Throwable {
+        super.testRestartWithPutTenNodesTwoBackups();
+    }
+    public void testRestartWithPutTenNodesTwoBackups11() throws Throwable {
+        super.testRestartWithPutTenNodesTwoBackups();
+    }
+    public void testRestartWithPutTenNodesTwoBackups12() throws Throwable {
+        super.testRestartWithPutTenNodesTwoBackups();
+    }
+    public void testRestartWithPutTenNodesTwoBackups13() throws Throwable {
+        super.testRestartWithPutTenNodesTwoBackups();
+    }
+    public void testRestartWithPutTenNodesTwoBackups14() throws Throwable {
+        super.testRestartWithPutTenNodesTwoBackups();
+    }
+
+    @Override protected long getTestTimeout() {
+        return Long.MAX_VALUE;
+    }
+
     @Override public void testRestart() throws Exception {
+
     }
 
     @Override public void testRestartWithPutTwoNodesNoBackups() throws Throwable {


[25/34] incubator-ignite git commit: Merge remote-tracking branch 'origin/master'

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


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

Branch: refs/heads/ignite-1093
Commit: 0798e6f1764aaf3e8101383b7a8ac3d7ed9b9d2c
Parents: bd770a5 cd844a7
Author: sboikov <sb...@gridgain.com>
Authored: Mon Aug 10 16:08:49 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Mon Aug 10 16:08:49 2015 +0300

----------------------------------------------------------------------
 .../configuration/IgniteConfiguration.java      |  1 -
 .../dht/atomic/GridDhtAtomicCache.java          | 36 ++++++++++++++------
 2 files changed, 26 insertions(+), 11 deletions(-)
----------------------------------------------------------------------



[10/34] incubator-ignite git commit: # ignite-1198

Posted by av...@apache.org.
# ignite-1198


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

Branch: refs/heads/ignite-1093
Commit: 2173b0e1500d3dbc198a610042fca9b92d4f7de7
Parents: 023ffe0
Author: Alexey Goncharuk <ag...@gridgain.com>
Authored: Wed Aug 5 14:05:07 2015 -0700
Committer: Alexey Goncharuk <ag...@gridgain.com>
Committed: Wed Aug 5 14:25:13 2015 -0700

----------------------------------------------------------------------
 .../org/apache/ignite/spark/IgniteContext.scala  | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2173b0e1/modules/spark/src/main/scala/org/apache/ignite/spark/IgniteContext.scala
----------------------------------------------------------------------
diff --git a/modules/spark/src/main/scala/org/apache/ignite/spark/IgniteContext.scala b/modules/spark/src/main/scala/org/apache/ignite/spark/IgniteContext.scala
index 5267244a..6e48017 100644
--- a/modules/spark/src/main/scala/org/apache/ignite/spark/IgniteContext.scala
+++ b/modules/spark/src/main/scala/org/apache/ignite/spark/IgniteContext.scala
@@ -19,7 +19,8 @@ package org.apache.ignite.spark
 
 
 import org.apache.ignite.internal.IgnitionEx
-import org.apache.ignite.{Ignition, Ignite}
+import org.apache.ignite.internal.util.IgniteUtils
+import org.apache.ignite.{IgniteSystemProperties, Ignition, Ignite}
 import org.apache.ignite.configuration.{CacheConfiguration, IgniteConfiguration}
 import org.apache.spark.{Logging, SparkContext}
 import org.apache.spark.sql.SQLContext
@@ -41,8 +42,12 @@ class IgniteContext[K, V](
 
     private val cfgClo = new Once(cfgF)
 
+    private val igniteHome = IgniteUtils.getIgniteHome
+
     if (!client) {
-        val workers = sparkContext.getExecutorStorageStatus.length - 1
+        // Get required number of executors with default equals to number of available executors.
+        val workers = sparkContext.getConf.getInt("spark.executor.instances",
+            sparkContext.getExecutorStorageStatus.length)
 
         if (workers <= 0)
             throw new IllegalStateException("No Spark executors found to start Ignite nodes.")
@@ -125,6 +130,16 @@ class IgniteContext[K, V](
      * @return Ignite instance.
      */
     def ignite(): Ignite = {
+        val home = IgniteUtils.getIgniteHome
+
+        if (home == null && igniteHome != null) {
+            logInfo("Setting IGNITE_HOME from driver not as it is not available on this worker: " + igniteHome)
+
+            IgniteUtils.nullifyHomeDirectory()
+
+            System.setProperty(IgniteSystemProperties.IGNITE_HOME, igniteHome)
+        }
+
         val igniteCfg = cfgClo()
 
         try {


[09/34] incubator-ignite git commit: ignite-1189: eventually fixed the deadlock

Posted by av...@apache.org.
ignite-1189: eventually fixed the deadlock


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

Branch: refs/heads/ignite-1093
Commit: 67706063d2e8d8cc3ed8d55cdfffccc0a21005c6
Parents: d78e4c8
Author: Denis Magda <dm...@gridgain.com>
Authored: Tue Aug 4 13:34:19 2015 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Tue Aug 4 13:34:19 2015 +0300

----------------------------------------------------------------------
 .../dht/atomic/GridDhtAtomicCache.java          |  6 +-
 .../IgniteCacheAtomicNodeRestartTest.java       | 92 --------------------
 2 files changed, 5 insertions(+), 93 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/67706063/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 470efdd..14b4680 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
@@ -1175,6 +1175,8 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
             remap = true;
         }
         catch (Exception e) {
+            // At least RuntimeException can be thrown by the code above when GridCacheContext is cleaned and there is
+            // an attempt to use cleaned resources.
             U.error(log, "Unexpected exception during cache update", e);
 
             res.addFailedKeys(keys, e);
@@ -2184,7 +2186,9 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
             }
         }
         finally {
-            // Release locks.
+            // At least RuntimeException can be thrown by the code above when GridCacheContext is cleaned and there is
+            // an attempt to use cleaned resources.
+            // That's why releasing locks in the finally block..
             for (GridCacheMapEntry entry : locked) {
                 if (entry != null)
                     UNSAFE.monitorExit(entry);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/67706063/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheAtomicNodeRestartTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheAtomicNodeRestartTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheAtomicNodeRestartTest.java
index caee4d0..1c4e616 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheAtomicNodeRestartTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheAtomicNodeRestartTest.java
@@ -30,96 +30,4 @@ public class IgniteCacheAtomicNodeRestartTest extends GridCachePartitionedNodeRe
     @Override protected CacheAtomicityMode atomicityMode() {
         return ATOMIC;
     }
-
-    /** {@inheritDoc} */
-    @Override public void testRestartWithPutTenNodesTwoBackups() throws Throwable {
-        super.testRestartWithPutTenNodesTwoBackups();
-    }
-
-    public void testRestartWithPutTenNodesTwoBackups2() throws Throwable {
-        super.testRestartWithPutTenNodesTwoBackups();
-    }
-    public void testRestartWithPutTenNodesTwoBackups3() throws Throwable {
-        super.testRestartWithPutTenNodesTwoBackups();
-    }
-    public void testRestartWithPutTenNodesTwoBackups4() throws Throwable {
-        super.testRestartWithPutTenNodesTwoBackups();
-    }
-    public void testRestartWithPutTenNodesTwoBackups5() throws Throwable {
-        super.testRestartWithPutTenNodesTwoBackups();
-    }
-    public void testRestartWithPutTenNodesTwoBackups6() throws Throwable {
-        super.testRestartWithPutTenNodesTwoBackups();
-    }
-    public void testRestartWithPutTenNodesTwoBackups7() throws Throwable {
-        super.testRestartWithPutTenNodesTwoBackups();
-    }
-    public void testRestartWithPutTenNodesTwoBackups8() throws Throwable {
-        super.testRestartWithPutTenNodesTwoBackups();
-    }
-    public void testRestartWithPutTenNodesTwoBackups9() throws Throwable {
-        super.testRestartWithPutTenNodesTwoBackups();
-    }
-    public void testRestartWithPutTenNodesTwoBackups10() throws Throwable {
-        super.testRestartWithPutTenNodesTwoBackups();
-    }
-    public void testRestartWithPutTenNodesTwoBackups11() throws Throwable {
-        super.testRestartWithPutTenNodesTwoBackups();
-    }
-    public void testRestartWithPutTenNodesTwoBackups12() throws Throwable {
-        super.testRestartWithPutTenNodesTwoBackups();
-    }
-    public void testRestartWithPutTenNodesTwoBackups13() throws Throwable {
-        super.testRestartWithPutTenNodesTwoBackups();
-    }
-    public void testRestartWithPutTenNodesTwoBackups14() throws Throwable {
-        super.testRestartWithPutTenNodesTwoBackups();
-    }
-
-    @Override protected long getTestTimeout() {
-        return Long.MAX_VALUE;
-    }
-
-    @Override public void testRestart() throws Exception {
-
-    }
-
-    @Override public void testRestartWithPutTwoNodesNoBackups() throws Throwable {
-    }
-
-    @Override public void testRestartWithPutTwoNodesOneBackup() throws Throwable {
-    }
-
-    @Override public void testRestartWithPutFourNodesNoBackups() throws Throwable {
-    }
-
-    @Override public void testRestartWithPutFourNodesOneBackups() throws Throwable {
-    }
-
-    @Override public void testRestartWithPutSixNodesTwoBackups() throws Throwable {
-    }
-
-    @Override public void testRestartWithPutEightNodesTwoBackups() throws Throwable {
-    }
-
-    @Override public void testRestartWithTxEightNodesTwoBackups() throws Throwable {
-    }
-
-    @Override public void testRestartWithTxFourNodesNoBackups() throws Throwable {
-    }
-
-    @Override public void testRestartWithTxFourNodesOneBackups() throws Throwable {
-    }
-
-    @Override public void testRestartWithTxSixNodesTwoBackups() throws Throwable {
-    }
-
-    @Override public void testRestartWithTxTenNodesTwoBackups() throws Throwable {
-    }
-
-    @Override public void testRestartWithTxTwoNodesNoBackups() throws Throwable {
-    }
-
-    @Override public void testRestartWithTxTwoNodesOneBackup() throws Throwable {
-    }
 }


[02/34] incubator-ignite git commit: ignite-1189: trying to reproduce failures

Posted by av...@apache.org.
ignite-1189: trying to reproduce failures


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

Branch: refs/heads/ignite-1093
Commit: 6b237e119caad68474cc785c0373da8ce31011d8
Parents: ac6d75d
Author: Denis Magda <dm...@gridgain.com>
Authored: Mon Aug 3 14:45:40 2015 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Mon Aug 3 14:45:40 2015 +0300

----------------------------------------------------------------------
 .../org/apache/ignite/internal/IgnitionEx.java  | 21 +++++---------------
 .../IgniteCacheAtomicNodeRestartTest.java       |  4 ++++
 2 files changed, 9 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6b237e11/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
index d355085..5cbe377 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
@@ -261,11 +261,8 @@ public class IgnitionEx {
     public static boolean stop(@Nullable String name, boolean cancel) {
         IgniteNamedInstance grid = name != null ? grids.get(name) : dfltGrid;
 
-        if (grid != null) {
-            IgniteState state = grid.state();
-
-            if (state == STARTED)
-                grid.stop(cancel);
+        if (grid != null && grid.state() == STARTED) {
+            grid.stop(cancel);
 
             boolean fireEvt;
 
@@ -280,18 +277,10 @@ public class IgnitionEx {
                 }
             }
 
-            if (state == STARTED) {
-                if (fireEvt)
-                    notifyStateChange(grid.getName(), grid.state());
-
-                return true;
-            }
-            else {
-                U.warn(null, "Ignoring stopping grid instance (has not been in STARTED state): [grid=" + name +
-                    ", state=" + state + ']');
+            if (fireEvt)
+                notifyStateChange(grid.getName(), grid.state());
 
-                return false;
-            }
+            return true;
         }
 
         // We don't have log at this point...

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6b237e11/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheAtomicNodeRestartTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheAtomicNodeRestartTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheAtomicNodeRestartTest.java
index 1c4e616..fa8898f 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheAtomicNodeRestartTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheAtomicNodeRestartTest.java
@@ -30,4 +30,8 @@ public class IgniteCacheAtomicNodeRestartTest extends GridCachePartitionedNodeRe
     @Override protected CacheAtomicityMode atomicityMode() {
         return ATOMIC;
     }
+
+    @Override public void testRestartWithPutTenNodesTwoBackups() throws Throwable {
+
+    }
 }


[32/34] incubator-ignite git commit: Merge remote-tracking branch 'remotes/origin/master' into ignite-1093

Posted by av...@apache.org.
Merge remote-tracking branch 'remotes/origin/master' into ignite-1093


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

Branch: refs/heads/ignite-1093
Commit: 199692269b9c3385e79327dc05f16c7610cf9e78
Parents: 6640c9a d5986c2
Author: Anton Vinogradov <vi...@gmail.com>
Authored: Wed Aug 12 14:33:19 2015 +0300
Committer: Anton Vinogradov <vi...@gmail.com>
Committed: Wed Aug 12 14:33:19 2015 +0300

----------------------------------------------------------------------
 assembly/release-hadoop.xml                     |   5 +
 .../configuration/IgniteConfiguration.java      |   1 -
 .../GridCachePartitionExchangeManager.java      |  48 ++--
 .../dht/atomic/GridDhtAtomicCache.java          |  36 ++-
 .../cache/query/GridCacheSqlQuery.java          |  33 ++-
 .../cache/query/GridCacheTwoStepQuery.java      |  34 +--
 .../ignite/spi/discovery/tcp/ClientImpl.java    |  28 +-
 .../ignite/spi/discovery/tcp/ServerImpl.java    |  91 ++++---
 .../TcpDiscoveryMulticastIpFinder.java          |   7 +-
 .../cache/CacheStopAndDestroySelfTest.java      |  87 ------
 .../processors/query/h2/IgniteH2Indexing.java   |  27 +-
 .../processors/query/h2/sql/GridSqlElement.java |  18 +-
 .../query/h2/sql/GridSqlFunction.java           |  17 +-
 .../processors/query/h2/sql/GridSqlQuery.java   |   4 +-
 .../query/h2/sql/GridSqlQueryParser.java        |  94 ++++---
 .../query/h2/sql/GridSqlQuerySplitter.java      | 117 +++++----
 .../processors/query/h2/sql/GridSqlSelect.java  |  76 +++---
 .../processors/query/h2/sql/GridSqlType.java    |  24 +-
 .../processors/query/h2/sql/GridSqlUnion.java   |   2 +-
 .../h2/twostep/GridReduceQueryExecutor.java     | 211 ++++++---------
 .../query/h2/twostep/GridThreadLocalTable.java  | 262 +++++++++++++++++++
 .../IgniteCacheAbstractFieldsQuerySelfTest.java |   2 +-
 .../org/apache/ignite/spark/IgniteContext.scala |  19 +-
 .../config/benchmark-multicast.properties       |   1 +
 parent/pom.xml                                  |  97 ++++---
 scripts/git-apply-patch.sh                      |  94 -------
 scripts/git-patch-functions.sh                  |  56 +---
 27 files changed, 830 insertions(+), 661 deletions(-)
----------------------------------------------------------------------



[26/34] incubator-ignite git commit: ignite-1222

Posted by av...@apache.org.
ignite-1222


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

Branch: refs/heads/ignite-1093
Commit: fbda19d4b530051f0ab6784379afe66be7d44c76
Parents: cd844a7
Author: Anton Vinogradov <vi...@gmail.com>
Authored: Mon Aug 10 16:11:46 2015 +0300
Committer: Anton Vinogradov <vi...@gmail.com>
Committed: Mon Aug 10 16:11:46 2015 +0300

----------------------------------------------------------------------
 .../cache/CacheStopAndDestroySelfTest.java      | 87 --------------------
 1 file changed, 87 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/fbda19d4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStopAndDestroySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStopAndDestroySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStopAndDestroySelfTest.java
index 803789e..17f0db7 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStopAndDestroySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStopAndDestroySelfTest.java
@@ -712,93 +712,6 @@ public class CacheStopAndDestroySelfTest extends GridCommonAbstractTest {
     }
 
     /**
-     * Tests concurrent close.
-     *
-     * @throws Exception If failed.
-     */
-    public void testConcurrentCloseSetWithTry() throws Exception {
-        final AtomicInteger a1 = new AtomicInteger();
-        final AtomicInteger a2 = new AtomicInteger();
-        final AtomicInteger a3 = new AtomicInteger();
-        final AtomicInteger a4 = new AtomicInteger();
-
-        Thread t1 = new Thread(new Runnable() {
-            @Override public void run() {
-                Thread.currentThread().setName("test-thread-1");
-
-                closeWithTry(a1, 0);
-            }
-        });
-        Thread t2 = new Thread(new Runnable() {
-            @Override public void run() {
-                Thread.currentThread().setName("test-thread-2");
-
-                closeWithTry(a2, 0);
-            }
-        });
-        Thread t3 = new Thread(new Runnable() {
-            @Override public void run() {
-                Thread.currentThread().setName("test-thread-3");
-
-                closeWithTry(a3, 2);
-            }
-        });
-        Thread t4 = new Thread(new Runnable() {
-            @Override public void run() {
-                Thread.currentThread().setName("test-thread-4");
-
-                closeWithTry(a4, 2);
-            }
-        });
-
-        IgniteCache<Object, Object> cache = grid(0).getOrCreateCache(getDhtConfig());
-
-        cache.close();
-
-        t1.start();
-        t2.start();
-        t3.start();
-        t4.start();
-
-        try {
-            U.sleep(1000);
-        }
-        finally {
-            stop = true;
-        }
-
-        t1.join();
-        t2.join();
-        t3.join();
-        t4.join();
-
-        assert a1.get() > 1;
-        assert a2.get() > 1;
-        assert a3.get() > 1;
-        assert a4.get() > 1;
-
-        checkUsageFails(cache);
-    }
-
-    /**
-     * @param a AtomicInteger.
-     * @param node Node.
-     */
-    public void closeWithTry(AtomicInteger a, int node) {
-        while (!stop) {
-            try (IgniteCache<String, String> cache = grid(node).getOrCreateCache(getDhtConfig())) {
-                a.incrementAndGet();
-
-                assert cache.get(KEY_VAL) == null || cache.get(KEY_VAL).equals(KEY_VAL);
-
-                cache.put(KEY_VAL, KEY_VAL);
-
-                assert cache.get(KEY_VAL).equals(KEY_VAL);
-            }
-        }
-    }
-
-    /**
      * Tests start -> destroy -> start -> close using CacheManager.
      */
     public void testTckStyleCreateDestroyClose() {


[21/34] incubator-ignite git commit: # ignite-1209

Posted by av...@apache.org.
# ignite-1209

Signed-off-by: Yakov Zhdanov <yz...@gridgain.com>


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

Branch: refs/heads/ignite-1093
Commit: d9acbd1da16efac59d3cc44c18c16af2db5f50f2
Parents: ebcdb4b
Author: ashutak <as...@gridgain.com>
Authored: Thu Aug 6 18:21:08 2015 +0300
Committer: Yakov Zhdanov <yz...@gridgain.com>
Committed: Thu Aug 6 18:29:44 2015 +0300

----------------------------------------------------------------------
 scripts/git-apply-patch.sh     | 94 -------------------------------------
 scripts/git-patch-functions.sh | 56 ++--------------------
 2 files changed, 4 insertions(+), 146 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d9acbd1d/scripts/git-apply-patch.sh
----------------------------------------------------------------------
diff --git a/scripts/git-apply-patch.sh b/scripts/git-apply-patch.sh
deleted file mode 100755
index 757cd26..0000000
--- a/scripts/git-apply-patch.sh
+++ /dev/null
@@ -1,94 +0,0 @@
-#!/bin/bash
-#
-# 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.
-#
-
-#
-# Git patch-file applier.
-#
-echo 'Usage: scripts/git-apply-patch.sh <ignite-task> [-ih|--ignitehome <path>] [-idb|--ignitedefbranch <branch-name>] [-ph|--patchhome <path>]'
-echo "It should be called from IGNITE_HOME directory."
-echo "Patch will be applied to DEFAULT_BRANCH from PATCHES_HOME."
-echo "Note: you can use ${IGNITE_HOME}/scripts/git-patch-prop-local.sh to set your own local properties (to rewrite settings at git-patch-prop-local.sh). "
-echo
-
-#
-# Init home and import properties and functions.
-#
-if [ -z ${IGNITE_HOME} ] # Script can be called from not IGNITE_HOME if IGNITE_HOME was set.
-    then IGNITE_HOME=$PWD
-fi
-
-. ${IGNITE_HOME}/scripts/git-patch-prop.sh # Import properties.
-. ${IGNITE_HOME}/scripts/git-patch-functions.sh # Import patch functions.
-
-if [ -f ${IGNITE_HOME}/scripts/git-patch-prop-local.sh ] # Whether a local user properties file exists.
-    then . ${IGNITE_HOME}/scripts/git-patch-prop-local.sh # Import user properties (it will rewrite global properties).
-fi
-
-#
-# Ignite task.
-#
-IGNITE_TASK=$1
-
-#
-# Read command line params.
-#
-while [[ $# > 1 ]]
-do
-    key="$1"
-
-    case $key in
-        -ih|--ignitehome)
-        IGNITE_HOME="$2"
-        shift
-        ;;
-
-        -idb|--ignitedefbranch)
-        IGNITE_DEFAULT_BRANCH="$2"
-        shift
-        ;;
-
-        -ph|--patchhome)
-        PATCHES_HOME="$2"
-        shift
-        ;;
-        *)
-
-        echo "Unknown parameter: ${key}"
-        ;;
-    esac
-    shift
-done
-
-echo "IGNITE_HOME    : ${IGNITE_HOME}"
-echo "Default branch : ${IGNITE_DEFAULT_BRANCH}"
-echo "Ignite task    : ${IGNITE_TASK}"
-echo
-echo "PATCHES_HOME   : ${PATCHES_HOME}"
-echo
-
-#
-# Main script logic.
-#
-
-currentAndDefaultBranchesShouldBeEqual ${IGNITE_HOME} ${IGNITE_DEFAULT_BRANCH}
-
-requireCleanWorkTree ${IGNITE_HOME}
-
-IGNITE_PATCH_FILE=${PATCHES_HOME}/${IGNITE_DEFAULT_BRANCH}_${IGNITE_TASK}.patch
-
-applyPatch ${IGNITE_HOME} ${IGNITE_DEFAULT_BRANCH} ${IGNITE_PATCH_FILE}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d9acbd1d/scripts/git-patch-functions.sh
----------------------------------------------------------------------
diff --git a/scripts/git-patch-functions.sh b/scripts/git-patch-functions.sh
index 3cc1bb0..cade691 100644
--- a/scripts/git-patch-functions.sh
+++ b/scripts/git-patch-functions.sh
@@ -50,13 +50,16 @@ formatPatch () {
     cd ${GIT_HOME}
 
     git checkout ${DEFAULT_BRANCH}
+
+    DEF_BRANCH_REV="$(git rev-parse --short HEAD)"
+
     git checkout -b tmppatch
 
     # Merge to make only one commit.
     git merge --squash ${PATCHED_BRANCH}
     git commit -a -m "# ${PATCHED_BRANCH}"
 
-    PATCH_FILE=${PATCHES_HOME}'/'${DEFAULT_BRANCH}_${PATCHED_BRANCH}${PATCH_SUFFIX}
+    PATCH_FILE=${PATCHES_HOME}'/'${DEFAULT_BRANCH}_${DEF_BRANCH_REV}_${PATCHED_BRANCH}${PATCH_SUFFIX}
 
     git format-patch ${DEFAULT_BRANCH}  --stdout > ${PATCH_FILE}
     echo "Patch file created."
@@ -125,55 +128,4 @@ requireCleanWorkTree () {
     fi
 }
 
-#
-# Applies patch. Applies patch file created by formatPatch method.
-#
-# Params:
-# - Git home.
-# - Default branch.
-# - File with patch.
-#
-applyPatch () {
-    GIT_HOME=$1
-    DEFAULT_BRANCH=$2
-    PATCH_FILE=$3
-
-    cd ${GIT_HOME}
-
-    if [ ! -f ${PATCH_FILE} ]
-    then
-        echo $0", ERROR:"
-        echo "Expected patch file not found: $PATCH_FILE."
-
-        exit 1
-    fi
-
-    echo "Patch $PATCH_FILE will be applied to $DEFAULT_BRANCH branch."
-
-    git am ${PATCH_FILE}
-}
-
-#
-# Checks that given Default branch and Current branch are equal.
-# Exit with code 1 in error case.
-#
-# Params:
-# - Git home.
-# - Default branch.
-#
-currentAndDefaultBranchesShouldBeEqual () {
-    GIT_HOME=$1
-    DEFAULT_BRANCH=$2
-
-    cd ${GIT_HOME}
-
-    CURRENT_BRANCH=$( determineCurrentBranch ${GIT_HOME} )
-
-    if [ "$CURRENT_BRANCH" != "$DEFAULT_BRANCH" ]
-    then
-        echo $0", ERROR:"
-        echo "You are not on an expected branch. Your current branch at $GIT_HOME is $CURRENT_BRANCH, should be $DEFAULT_BRANCH."
 
-        exit 1
-    fi
-}


[07/34] incubator-ignite git commit: ignite-1189: fixing deadlock

Posted by av...@apache.org.
ignite-1189: fixing deadlock


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

Branch: refs/heads/ignite-1093
Commit: 4d528becc1cd3db9d4d2d6db2053895043aa3918
Parents: 132562b
Author: Denis Magda <dm...@gridgain.com>
Authored: Tue Aug 4 13:04:35 2015 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Tue Aug 4 13:04:35 2015 +0300

----------------------------------------------------------------------
 .../dht/atomic/GridDhtAtomicCache.java          | 29 +++++++++++++-------
 1 file changed, 19 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4d528bec/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 cd6e28d..470efdd 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
@@ -1176,6 +1176,12 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
         }
         catch (Exception e) {
             U.error(log, "Unexpected exception during cache update", e);
+
+            res.addFailedKeys(keys, e);
+
+            completionCb.apply(req, res);
+
+            return;
         }
 
         if (remap) {
@@ -2167,19 +2173,22 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
         // Enqueue entries while holding locks.
         Collection<KeyCacheObject> skip = null;
 
-        for (GridCacheMapEntry entry : locked) {
-            if (entry != null && entry.deleted()) {
-                if (skip == null)
-                    skip = new HashSet<>(locked.size(), 1.0f);
+        try {
+            for (GridCacheMapEntry entry : locked) {
+                if (entry != null && entry.deleted()) {
+                    if (skip == null)
+                        skip = new HashSet<>(locked.size(), 1.0f);
 
-                skip.add(entry.key());
+                    skip.add(entry.key());
+                }
             }
         }
-
-        // Release locks.
-        for (GridCacheMapEntry entry : locked) {
-            if (entry != null)
-                UNSAFE.monitorExit(entry);
+        finally {
+            // Release locks.
+            for (GridCacheMapEntry entry : locked) {
+                if (entry != null)
+                    UNSAFE.monitorExit(entry);
+            }
         }
 
         // Try evict partitions.


[27/34] incubator-ignite git commit: Merge remote-tracking branch 'origin/master'

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


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

Branch: refs/heads/ignite-1093
Commit: 19fb305d5ceff430911d8dc25685686f6446ea21
Parents: fbda19d 0798e6f
Author: Anton Vinogradov <vi...@gmail.com>
Authored: Mon Aug 10 16:12:53 2015 +0300
Committer: Anton Vinogradov <vi...@gmail.com>
Committed: Mon Aug 10 16:12:53 2015 +0300

----------------------------------------------------------------------
 .../cache/GridCachePartitionExchangeManager.java    | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
----------------------------------------------------------------------



[08/34] incubator-ignite git commit: Merge remote-tracking branch 'remotes/origin/master' into ignite-1189

Posted by av...@apache.org.
Merge remote-tracking branch 'remotes/origin/master' into ignite-1189


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

Branch: refs/heads/ignite-1093
Commit: d78e4c8eef921775d2d5d1fcd5adf151c3d46923
Parents: 4d528be b056a73
Author: Denis Magda <dm...@gridgain.com>
Authored: Tue Aug 4 13:32:45 2015 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Tue Aug 4 13:32:45 2015 +0300

----------------------------------------------------------------------
 .../ClientAbstractMultiNodeSelfTest.java        |   4 +-
 .../apache/ignite/IgniteSystemProperties.java   |   2 +-
 .../store/jdbc/CacheAbstractJdbcStore.java      |  21 +-
 .../apache/ignite/internal/IgniteKernal.java    |   2 +-
 .../org/apache/ignite/internal/IgnitionEx.java  |  43 +-
 .../managers/communication/GridIoManager.java   | 188 +++++++-
 .../processors/cache/GridCacheMvccManager.java  |  73 +--
 .../processors/cache/GridCacheProcessor.java    |   2 +-
 .../processors/cache/GridCacheProxyImpl.java    |  42 +-
 .../processors/cache/GridCacheSwapManager.java  |   2 +-
 .../distributed/near/GridNearGetFuture.java     |  20 +-
 .../ignite/internal/util/IgniteUtils.java       |  16 +
 .../util/nio/GridCommunicationClient.java       |   5 +-
 .../util/nio/GridNioFinishedFuture.java         |  12 +
 .../ignite/internal/util/nio/GridNioFuture.java |  14 +
 .../internal/util/nio/GridNioFutureImpl.java    |  15 +
 .../util/nio/GridNioRecoveryDescriptor.java     |  13 +-
 .../ignite/internal/util/nio/GridNioServer.java |   5 +
 .../util/nio/GridNioSessionMetaKey.java         |   5 +-
 .../util/nio/GridShmemCommunicationClient.java  |   7 +-
 .../util/nio/GridTcpNioCommunicationClient.java |  14 +-
 .../communication/tcp/TcpCommunicationSpi.java  |  43 +-
 .../ignite/spi/discovery/tcp/ClientImpl.java    |   2 +-
 .../src/test/config/io-manager-benchmark.xml    |   3 +-
 .../GridJobMasterLeaveAwareSelfTest.java        |  10 +-
 .../IgniteClientReconnectAbstractTest.java      |   5 +-
 .../IgniteClientReconnectCacheTest.java         |   5 +-
 .../GridDeploymentMessageCountSelfTest.java     |   5 +-
 .../cache/CacheStopAndDestroySelfTest.java      |   8 +-
 .../GridCacheAtomicMessageCountSelfTest.java    |   6 +-
 .../processors/cache/GridCacheMvccSelfTest.java |   1 -
 ...ridCacheReplicatedSynchronousCommitTest.java |   5 +-
 .../IgniteCacheAbstractStopBusySelfTest.java    |   6 +-
 .../cache/IgniteCacheNearLockValueSelfTest.java |   6 +-
 ...eDynamicCacheStartNoExchangeTimeoutTest.java |   4 +-
 .../cache/IgniteTxReentryAbstractSelfTest.java  |   5 +-
 ...niteCacheClientNodeChangingTopologyTest.java |   6 +-
 ...teCacheClientNodePartitionsExchangeTest.java |   4 +-
 .../IgniteCacheNearOffheapGetSelfTest.java      | 131 ++++++
 ...xOriginatingNodeFailureAbstractSelfTest.java |   6 +-
 ...cOriginatingNodeFailureAbstractSelfTest.java |   6 +-
 .../GridCacheDhtPreloadMessageCountTest.java    |   5 +-
 ...ePrimaryNodeFailureRecoveryAbstractTest.java |   6 +-
 ...eAtomicInvalidPartitionHandlingSelfTest.java |   5 +-
 .../near/IgniteCacheNearTxRollbackTest.java     |   6 +-
 .../GridCacheReplicatedInvalidateSelfTest.java  |   6 +-
 ...CommunicationRecoveryAckClosureSelfTest.java | 464 +++++++++++++++++++
 .../testsuites/IgniteCacheTestSuite2.java       |   1 +
 .../IgniteSpiCommunicationSelfTestSuite.java    |   1 +
 .../ignite/util/TestTcpCommunicationSpi.java    |   6 +-
 ...CacheScanPartitionQueryFallbackSelfTest.java |  15 +-
 .../parser/dialect/OracleMetadataDialect.java   |   4 +-
 .../src/test/java/config/ignite-test-config.xml |  43 ++
 .../ignite/internal/GridFactorySelfTest.java    |   9 +
 .../visor/commands/kill/VisorKillCommand.scala  |   2 +-
 55 files changed, 1148 insertions(+), 197 deletions(-)
----------------------------------------------------------------------



[33/34] incubator-ignite git commit: ignite-1093

Posted by av...@apache.org.
ignite-1093


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

Branch: refs/heads/ignite-1093
Commit: 50d32b38426dd19adcef81e7c645f95a6ff6927e
Parents: 1996922
Author: Anton Vinogradov <vi...@gmail.com>
Authored: Thu Aug 13 10:51:15 2015 +0300
Committer: Anton Vinogradov <vi...@gmail.com>
Committed: Thu Aug 13 10:51:15 2015 +0300

----------------------------------------------------------------------
 .../dht/preloader/GridDhtPartitionDemander.java | 51 ++++++++++++++++++++
 1 file changed, 51 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/50d32b38/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
index 6c95707..16f7a61 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
@@ -357,6 +357,9 @@ public class GridDhtPartitionDemander {
                         catch (IgniteCheckedException ex) {
                             U.error(log, "Failed to send partition demand message to local node", ex);
                         }
+
+                        if (log.isDebugEnabled())
+                            log.debug("Requested rebalancing [from node=" + node.id() + ", listener index=" + cnt + ", partitions count=" + sParts.get(cnt).size() + " (" + partitionsList(sParts.get(cnt)) + ")]");
                     }
                 }
             }
@@ -388,6 +391,54 @@ public class GridDhtPartitionDemander {
     }
 
     /**
+     * @param c Partitions.
+     * @return String representation of partitions list.
+     */
+    private String partitionsList(Collection<Integer> c){
+        LinkedList<Integer> s = new LinkedList<>(c);
+
+        Collections.sort(s);
+
+        StringBuilder sb = new StringBuilder();
+
+        int start = -1;
+
+        int prev = -1;
+
+        Iterator<Integer> sit = s.iterator();
+
+        while (sit.hasNext()) {
+            int p = sit.next();
+            if (start == -1) {
+                start = p;
+                prev = p;
+            }
+
+            if (prev < p - 1) {
+                sb.append(start);
+
+                if (start != prev)
+                    sb.append("-").append(prev);
+
+                sb.append(", ");
+
+                start = p;
+            }
+
+            if (!sit.hasNext()) {
+                sb.append(start);
+
+                if (start != p)
+                    sb.append("-").append(p);
+            }
+
+            prev = p;
+        }
+
+        return sb.toString();
+    }
+
+    /**
      * @param idx Index.
      * @param id Node id.
      * @param supply Supply.


[18/34] incubator-ignite git commit: Merge remote-tracking branch 'origin/master'

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


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

Branch: refs/heads/ignite-1093
Commit: 63944d41d9bb7e9e74366f935b9f620e01bc36ce
Parents: 56efb6b b94c130
Author: Yakov Zhdanov <yz...@gridgain.com>
Authored: Thu Aug 6 15:54:01 2015 +0300
Committer: Yakov Zhdanov <yz...@gridgain.com>
Committed: Thu Aug 6 15:54:01 2015 +0300

----------------------------------------------------------------------
 assembly/release-hadoop.xml                     |  5 +
 .../config/benchmark-multicast.properties       |  1 +
 parent/pom.xml                                  | 97 ++++++++++----------
 3 files changed, 54 insertions(+), 49 deletions(-)
----------------------------------------------------------------------



[20/34] incubator-ignite git commit: Renaming

Posted by av...@apache.org.
Renaming


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

Branch: refs/heads/ignite-1093
Commit: ebcdb4bf5cfe508670129389637984b8dba43146
Parents: d7dd4a0
Author: Yakov Zhdanov <yz...@gridgain.com>
Authored: Thu Aug 6 16:44:21 2015 +0300
Committer: Yakov Zhdanov <yz...@gridgain.com>
Committed: Thu Aug 6 16:44:21 2015 +0300

----------------------------------------------------------------------
 .../internal/processors/cache/query/GridCacheSqlQuery.java     | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ebcdb4bf/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlQuery.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlQuery.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlQuery.java
index d5eb379..77bbe39 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlQuery.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlQuery.java
@@ -53,7 +53,7 @@ public class GridCacheSqlQuery implements Message {
     /** */
     @GridToStringInclude
     @GridDirectTransient
-    private LinkedHashMap<String, ?> columns;
+    private LinkedHashMap<String, ?> cols;
 
     /**
      * For {@link Message}.
@@ -78,7 +78,7 @@ public class GridCacheSqlQuery implements Message {
      * @return Columns.
      */
     public LinkedHashMap<String, ?> columns() {
-        return columns;
+        return cols;
     }
 
     /**
@@ -86,7 +86,7 @@ public class GridCacheSqlQuery implements Message {
      * @return {@code this}.
      */
     public GridCacheSqlQuery columns(LinkedHashMap<String, ?> columns) {
-        this.columns = columns;
+        this.cols = columns;
 
         return this;
     }