You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ag...@apache.org on 2017/04/26 09:31:22 UTC

[01/29] ignite git commit: IGNITE-2578 .NET: Un-ignore AtomicReference tests

Repository: ignite
Updated Branches:
  refs/heads/ignite-5024 0c0514564 -> eac6762b2


IGNITE-2578 .NET: Un-ignore AtomicReference tests


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

Branch: refs/heads/ignite-5024
Commit: 09b65075b12ff6ea0a54a404e0f339a6538143f1
Parents: 8a1ded1
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Mon Apr 24 12:07:42 2017 +0300
Committer: Pavel Tupitsyn <pt...@apache.org>
Committed: Mon Apr 24 12:07:42 2017 +0300

----------------------------------------------------------------------
 .../Apache.Ignite.Core.Tests/DataStructures/AtomicReferenceTest.cs | 2 --
 1 file changed, 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/09b65075/modules/platforms/dotnet/Apache.Ignite.Core.Tests/DataStructures/AtomicReferenceTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/DataStructures/AtomicReferenceTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/DataStructures/AtomicReferenceTest.cs
index 93375da..751b291 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/DataStructures/AtomicReferenceTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/DataStructures/AtomicReferenceTest.cs
@@ -128,7 +128,6 @@ namespace Apache.Ignite.Core.Tests.DataStructures
         /// Tests DateTime in the atomic.
         /// </summary>
         [Test]
-        [Ignore("IGNITE-2578")]
         public void TestDateTime()
         {
             TestOperations(DateTime.Now, DateTime.Now.AddDays(-1));
@@ -138,7 +137,6 @@ namespace Apache.Ignite.Core.Tests.DataStructures
         /// Tests serializable objects in the atomic.
         /// </summary>
         [Test]
-        [Ignore("IGNITE-2578")]
         public void TestSerializable()
         {
             TestOperations(new SerializableObj {Foo = 16}, new SerializableObj {Foo = -5});


[21/29] ignite git commit: IGNITE-5064 Removed obsolete EventTypes + minor cleanup.

Posted by ag...@apache.org.
IGNITE-5064 Removed obsolete EventTypes + minor cleanup.


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

Branch: refs/heads/ignite-5024
Commit: 4e4a22d9aad4fdbfbcefc4eeacb65f8cffa181f2
Parents: 8a5266e
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Tue Apr 25 16:12:01 2017 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Tue Apr 25 16:12:01 2017 +0700

----------------------------------------------------------------------
 .../web-console/frontend/app/data/event-groups.json   | 14 --------------
 .../web-console/frontend/app/modules/cluster/Cache.js |  4 ----
 .../frontend/app/modules/cluster/CacheMetrics.js      |  4 ----
 modules/web-console/web-agent/pom.xml                 |  2 +-
 .../apache/ignite/console/agent/AgentLauncher.java    | 10 +++++-----
 5 files changed, 6 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/4e4a22d9/modules/web-console/frontend/app/data/event-groups.json
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/data/event-groups.json b/modules/web-console/frontend/app/data/event-groups.json
index 8d0c878..094fd28 100644
--- a/modules/web-console/frontend/app/data/event-groups.json
+++ b/modules/web-console/frontend/app/data/event-groups.json
@@ -97,8 +97,6 @@
       "EVT_CACHE_OBJECT_REMOVED",
       "EVT_CACHE_OBJECT_LOCKED",
       "EVT_CACHE_OBJECT_UNLOCKED",
-      "EVT_CACHE_OBJECT_SWAPPED",
-      "EVT_CACHE_OBJECT_UNSWAPPED",
       "EVT_CACHE_OBJECT_EXPIRED"
     ]
   },
@@ -136,18 +134,6 @@
     ]
   },
   {
-    "label": "EVTS_SWAPSPACE",
-    "value": "EVTS_SWAPSPACE",
-    "class": "org.apache.ignite.events.EventType",
-    "events": [
-      "EVT_SWAP_SPACE_CLEARED",
-      "EVT_SWAP_SPACE_DATA_REMOVED",
-      "EVT_SWAP_SPACE_DATA_READ",
-      "EVT_SWAP_SPACE_DATA_STORED",
-      "EVT_SWAP_SPACE_DATA_EVICTED"
-    ]
-  },
-  {
     "label": "EVTS_IGFS",
     "value": "EVTS_IGFS",
     "class": "org.apache.ignite.events.EventType",

http://git-wip-us.apache.org/repos/asf/ignite/blob/4e4a22d9/modules/web-console/frontend/app/modules/cluster/Cache.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/cluster/Cache.js b/modules/web-console/frontend/app/modules/cluster/Cache.js
index 4918a7c..f954ad2 100644
--- a/modules/web-console/frontend/app/modules/cluster/Cache.js
+++ b/modules/web-console/frontend/app/modules/cluster/Cache.js
@@ -40,10 +40,6 @@ export default class Cache {
         this.offHeapPrimarySize = cache.offHeapPrimaryEntriesCount || 0;
         this.offHeapBackupSize = cache.offHeapBackupEntriesCount || 0;
 
-        // Swap.
-        this.swapSize = cache.swapSize;
-        this.swapKeys = cache.swapKeys;
-
         const m = cache.metrics;
 
         // Read/write metrics.

http://git-wip-us.apache.org/repos/asf/ignite/blob/4e4a22d9/modules/web-console/frontend/app/modules/cluster/CacheMetrics.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/cluster/CacheMetrics.js b/modules/web-console/frontend/app/modules/cluster/CacheMetrics.js
index 90d3a9b..160b7d1 100644
--- a/modules/web-console/frontend/app/modules/cluster/CacheMetrics.js
+++ b/modules/web-console/frontend/app/modules/cluster/CacheMetrics.js
@@ -40,10 +40,6 @@ export default class CacheMetrics {
         this.offHeapPrimarySize = cache.offHeapPrimaryEntriesCount || 0;
         this.offHeapBackupSize = cache.offHeapBackupEntriesCount || 0;
 
-        // Swap.
-        this.swapSize = cache.swapSize;
-        this.swapKeys = cache.swapKeys;
-
         const m = cache.metrics;
 
         // Read/write metrics.

http://git-wip-us.apache.org/repos/asf/ignite/blob/4e4a22d9/modules/web-console/web-agent/pom.xml
----------------------------------------------------------------------
diff --git a/modules/web-console/web-agent/pom.xml b/modules/web-console/web-agent/pom.xml
index 697e58f..49e0ef0 100644
--- a/modules/web-console/web-agent/pom.xml
+++ b/modules/web-console/web-agent/pom.xml
@@ -61,7 +61,7 @@
         <dependency>
             <groupId>com.squareup.okhttp3</groupId>
             <artifactId>okhttp</artifactId>
-            <version>3.6.0</version>
+            <version>3.7.0</version>
         </dependency>
 
         <dependency>

http://git-wip-us.apache.org/repos/asf/ignite/blob/4e4a22d9/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/AgentLauncher.java
----------------------------------------------------------------------
diff --git a/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/AgentLauncher.java b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/AgentLauncher.java
index 65b8192..4db26ba 100644
--- a/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/AgentLauncher.java
+++ b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/AgentLauncher.java
@@ -33,9 +33,9 @@ import java.net.URISyntaxException;
 import java.net.URL;
 import java.net.UnknownHostException;
 import java.util.Arrays;
-import java.util.Scanner;
 import java.util.Collection;
 import java.util.List;
+import java.util.Scanner;
 import java.util.concurrent.CountDownLatch;
 import java.util.jar.Attributes;
 import java.util.jar.Manifest;
@@ -65,7 +65,7 @@ import static org.apache.ignite.console.agent.AgentUtils.fromJSON;
 import static org.apache.ignite.console.agent.AgentUtils.toJSON;
 
 /**
- * Control Center Agent launcher.
+ * Ignite Web Agent launcher.
  */
 public class AgentLauncher {
     /** */
@@ -235,7 +235,7 @@ public class AgentLauncher {
      * @param fmt Format string.
      * @param args Arguments.
      */
-    private static String readLine(String fmt, Object ... args) {
+    private static String readLine(String fmt, Object... args) {
         if (System.console() != null)
             return System.console().readLine(fmt, args);
 
@@ -248,7 +248,7 @@ public class AgentLauncher {
      * @param fmt Format string.
      * @param args Arguments.
      */
-    private static char[] readPassword(String fmt, Object ... args) {
+    private static char[] readPassword(String fmt, Object... args) {
         if (System.console() != null)
             return System.console().readPassword(fmt, args);
 
@@ -339,7 +339,7 @@ public class AgentLauncher {
             case "http":
             case "https":
                 final String username = System.getProperty(uri.getScheme() + ".proxyUsername");
-                final char[] pwd = System.getProperty(uri.getScheme() +  ".proxyPassword", "").toCharArray();
+                final char[] pwd = System.getProperty(uri.getScheme() + ".proxyPassword", "").toCharArray();
 
                 Authenticator.setDefault(new Authenticator() {
                     @Override protected PasswordAuthentication getPasswordAuthentication() {


[22/29] ignite git commit: IGNITE-3521: IGFS: removed "maxSpaceSize" remnants from XML files.

Posted by ag...@apache.org.
IGNITE-3521: IGFS: removed "maxSpaceSize" remnants from XML files.


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

Branch: refs/heads/ignite-5024
Commit: 860049dc76f86e3d9339eb8b4a4d5a0a6439f1d1
Parents: 4739458
Author: devozerov <vo...@gridgain.com>
Authored: Tue Apr 25 12:14:22 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Tue Apr 25 12:14:22 2017 +0300

----------------------------------------------------------------------
 .../src/test/java/org/apache/ignite/spring/sprint-exclude.xml      | 2 --
 1 file changed, 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/860049dc/modules/spring/src/test/java/org/apache/ignite/spring/sprint-exclude.xml
----------------------------------------------------------------------
diff --git a/modules/spring/src/test/java/org/apache/ignite/spring/sprint-exclude.xml b/modules/spring/src/test/java/org/apache/ignite/spring/sprint-exclude.xml
index adc87a9..37b460f 100644
--- a/modules/spring/src/test/java/org/apache/ignite/spring/sprint-exclude.xml
+++ b/modules/spring/src/test/java/org/apache/ignite/spring/sprint-exclude.xml
@@ -34,8 +34,6 @@
                 <bean class="org.apache.ignite.configuration.FileSystemConfiguration">
                     <property name="name" value="test"/>
 
-                    <property name="maxSpaceSize" value="#{100L * 1024 * 1024}"/>
-
                     <!-- Loopback endpoint. -->
                     <property name="ipcEndpointConfiguration">
                         <bean class="org.apache.ignite.igfs.IgfsIpcEndpointConfiguration">


[23/29] ignite git commit: Merge remote-tracking branch 'origin/ignite-2.0' into ignite-2.0

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


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

Branch: refs/heads/ignite-5024
Commit: 712398e1254867f38556c941094edb23c9b346ae
Parents: 860049d 4e4a22d
Author: devozerov <vo...@gridgain.com>
Authored: Tue Apr 25 12:14:48 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Tue Apr 25 12:14:48 2017 +0300

----------------------------------------------------------------------
 .../configuration/CacheConfiguration.java       |  57 ++--
 .../configuration/MemoryConfiguration.java      |  12 +-
 .../MemoryPolicyConfiguration.java              |   6 +-
 .../IgniteCacheDatabaseSharedManager.java       | 130 ++++----
 .../cache/MemoryPolicyConfigValidationTest.java |   6 +-
 .../MemoryPolicyInitializationTest.java         | 307 +++++++++++++++++++
 .../testsuites/IgniteCacheTestSuite2.java       |   2 +
 .../Cache/Configuration/MemoryConfiguration.cs  |   7 +
 .../Configuration/MemoryPolicyConfiguration.cs  |   3 +
 .../frontend/app/data/event-groups.json         |  14 -
 .../frontend/app/modules/cluster/Cache.js       |   4 -
 .../app/modules/cluster/CacheMetrics.js         |   4 -
 modules/web-console/web-agent/pom.xml           |   2 +-
 .../ignite/console/agent/AgentLauncher.java     |  10 +-
 14 files changed, 446 insertions(+), 118 deletions(-)
----------------------------------------------------------------------



[04/29] ignite git commit: IGNITE-5018 review and improve javadocs in ML module (minor fixes)

Posted by ag...@apache.org.
IGNITE-5018 review and improve javadocs in ML module (minor fixes)


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

Branch: refs/heads/ignite-5024
Commit: 7378bc38abf8ec6ed8aca9c3608eec00f1a86fb2
Parents: 33079fc
Author: Anton Vinogradov <av...@apache.org>
Authored: Mon Apr 24 13:20:37 2017 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Mon Apr 24 13:20:37 2017 +0300

----------------------------------------------------------------------
 modules/ml/src/main/java/org/apache/ignite/ml/math/Matrix.java    | 1 -
 .../org/apache/ignite/ml/math/impls/matrix/PivotedMatrixView.java | 1 -
 .../ignite/ml/math/impls/storage/matrix/CacheMatrixStorage.java   | 1 -
 .../ml/math/impls/storage/matrix/DenseOffHeapMatrixStorage.java   | 1 -
 .../ml/math/impls/storage/matrix/FunctionMatrixStorage.java       | 1 -
 .../math/impls/storage/matrix/SparseLocalOnHeapMatrixStorage.java | 2 --
 .../ignite/ml/math/impls/storage/vector/CacheVectorStorage.java   | 1 -
 .../ml/math/impls/storage/vector/ConstantVectorStorage.java       | 1 -
 .../ml/math/impls/storage/vector/DelegateVectorStorage.java       | 1 -
 .../ml/math/impls/storage/vector/FunctionVectorStorage.java       | 1 -
 .../ignite/ml/math/impls/storage/vector/MatrixVectorStorage.java  | 1 -
 .../ignite/ml/math/impls/storage/vector/PivotedVectorStorage.java | 1 -
 .../impls/storage/vector/SingleElementVectorDelegateStorage.java  | 1 -
 .../ml/math/impls/storage/vector/SingleElementVectorStorage.java  | 1 -
 .../impls/storage/vector/SparseLocalOffHeapVectorStorage.java     | 1 -
 .../math/impls/storage/vector/SparseLocalOnHeapVectorStorage.java | 2 --
 .../org/apache/ignite/ml/math/impls/vector/AbstractVector.java    | 1 -
 .../org/apache/ignite/ml/math/impls/vector/DelegatingVector.java  | 1 -
 .../org/apache/ignite/ml/math/impls/vector/MatrixVectorView.java  | 1 -
 .../org/apache/ignite/ml/math/impls/vector/PivotedVectorView.java | 1 -
 .../java/org/apache/ignite/ml/math/impls/vector/RandomVector.java | 3 +--
 .../apache/ignite/ml/math/impls/vector/SingleElementVector.java   | 2 +-
 .../ml/src/test/java/org/apache/ignite/ml/math/TracerTest.java    | 1 -
 .../ml/math/impls/storage/matrix/MatrixStorageFixtures.java       | 1 -
 .../apache/ignite/ml/math/impls/vector/AbstractVectorTest.java    | 1 -
 .../org/apache/ignite/ml/math/impls/vector/CacheVectorTest.java   | 1 -
 26 files changed, 2 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/7378bc38/modules/ml/src/main/java/org/apache/ignite/ml/math/Matrix.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/Matrix.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/Matrix.java
index 798d831..2cf4e63 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/Matrix.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/Matrix.java
@@ -18,7 +18,6 @@
 package org.apache.ignite.ml.math;
 
 import java.io.Externalizable;
-
 import org.apache.ignite.lang.IgniteUuid;
 import org.apache.ignite.ml.math.exceptions.CardinalityException;
 import org.apache.ignite.ml.math.exceptions.IndexException;

http://git-wip-us.apache.org/repos/asf/ignite/blob/7378bc38/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/PivotedMatrixView.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/PivotedMatrixView.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/PivotedMatrixView.java
index 16bdc3e..361bee5 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/PivotedMatrixView.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/PivotedMatrixView.java
@@ -20,7 +20,6 @@ package org.apache.ignite.ml.math.impls.matrix;
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
-
 import org.apache.ignite.ml.math.Matrix;
 import org.apache.ignite.ml.math.MatrixStorage;
 import org.apache.ignite.ml.math.Vector;

http://git-wip-us.apache.org/repos/asf/ignite/blob/7378bc38/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/CacheMatrixStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/CacheMatrixStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/CacheMatrixStorage.java
index 687216b..dcef3ff 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/CacheMatrixStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/CacheMatrixStorage.java
@@ -20,7 +20,6 @@ package org.apache.ignite.ml.math.impls.storage.matrix;
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
-
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.Ignition;
 import org.apache.ignite.ml.math.MatrixKeyMapper;

http://git-wip-us.apache.org/repos/asf/ignite/blob/7378bc38/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/DenseOffHeapMatrixStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/DenseOffHeapMatrixStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/DenseOffHeapMatrixStorage.java
index 410da47..62060d1 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/DenseOffHeapMatrixStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/DenseOffHeapMatrixStorage.java
@@ -20,7 +20,6 @@ package org.apache.ignite.ml.math.impls.storage.matrix;
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
-
 import org.apache.ignite.internal.util.GridUnsafe;
 import org.apache.ignite.ml.math.MatrixStorage;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/7378bc38/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/FunctionMatrixStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/FunctionMatrixStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/FunctionMatrixStorage.java
index 5bb2569..de30015 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/FunctionMatrixStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/FunctionMatrixStorage.java
@@ -20,7 +20,6 @@ package org.apache.ignite.ml.math.impls.storage.matrix;
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
-
 import org.apache.ignite.ml.math.MatrixStorage;
 import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
 import org.apache.ignite.ml.math.functions.IntIntDoubleToVoidFunction;

http://git-wip-us.apache.org/repos/asf/ignite/blob/7378bc38/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/SparseLocalOnHeapMatrixStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/SparseLocalOnHeapMatrixStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/SparseLocalOnHeapMatrixStorage.java
index db85b0f..b33cb26 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/SparseLocalOnHeapMatrixStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/SparseLocalOnHeapMatrixStorage.java
@@ -19,13 +19,11 @@ package org.apache.ignite.ml.math.impls.storage.matrix;
 
 import it.unimi.dsi.fastutil.ints.Int2DoubleOpenHashMap;
 import it.unimi.dsi.fastutil.ints.Int2DoubleRBTreeMap;
-
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import java.util.HashMap;
 import java.util.Map;
-
 import org.apache.ignite.ml.math.MatrixStorage;
 import org.apache.ignite.ml.math.StorageConstants;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/7378bc38/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/CacheVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/CacheVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/CacheVectorStorage.java
index bec232d..c0c7152 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/CacheVectorStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/CacheVectorStorage.java
@@ -20,7 +20,6 @@ package org.apache.ignite.ml.math.impls.storage.vector;
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
-
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.Ignition;
 import org.apache.ignite.ml.math.ValueMapper;

http://git-wip-us.apache.org/repos/asf/ignite/blob/7378bc38/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/ConstantVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/ConstantVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/ConstantVectorStorage.java
index 1b899a1..0423bc5 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/ConstantVectorStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/ConstantVectorStorage.java
@@ -20,7 +20,6 @@ package org.apache.ignite.ml.math.impls.storage.vector;
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
-
 import org.apache.ignite.ml.math.VectorStorage;
 import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/7378bc38/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/DelegateVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/DelegateVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/DelegateVectorStorage.java
index 2a48653..6775d44 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/DelegateVectorStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/DelegateVectorStorage.java
@@ -20,7 +20,6 @@ package org.apache.ignite.ml.math.impls.storage.vector;
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
-
 import org.apache.ignite.ml.math.VectorStorage;
 
 /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/7378bc38/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/FunctionVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/FunctionVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/FunctionVectorStorage.java
index a17eb0b..aabe3b1 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/FunctionVectorStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/FunctionVectorStorage.java
@@ -20,7 +20,6 @@ package org.apache.ignite.ml.math.impls.storage.vector;
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
-
 import org.apache.ignite.ml.math.VectorStorage;
 import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
 import org.apache.ignite.ml.math.functions.IgniteFunction;

http://git-wip-us.apache.org/repos/asf/ignite/blob/7378bc38/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/MatrixVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/MatrixVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/MatrixVectorStorage.java
index 59545a4..7700a7c 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/MatrixVectorStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/MatrixVectorStorage.java
@@ -20,7 +20,6 @@ package org.apache.ignite.ml.math.impls.storage.vector;
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
-
 import org.apache.ignite.ml.math.Matrix;
 import org.apache.ignite.ml.math.VectorStorage;
 import org.apache.ignite.ml.math.exceptions.IndexException;

http://git-wip-us.apache.org/repos/asf/ignite/blob/7378bc38/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/PivotedVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/PivotedVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/PivotedVectorStorage.java
index 537d651..1c798e4 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/PivotedVectorStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/PivotedVectorStorage.java
@@ -21,7 +21,6 @@ import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import java.util.Arrays;
-
 import org.apache.ignite.ml.math.VectorStorage;
 
 /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/7378bc38/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorDelegateStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorDelegateStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorDelegateStorage.java
index 453c0f7..ac86e16 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorDelegateStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorDelegateStorage.java
@@ -20,7 +20,6 @@ package org.apache.ignite.ml.math.impls.storage.vector;
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
-
 import org.apache.ignite.ml.math.Vector;
 import org.apache.ignite.ml.math.VectorStorage;
 import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;

http://git-wip-us.apache.org/repos/asf/ignite/blob/7378bc38/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorStorage.java
index 6378399..488e158 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorStorage.java
@@ -20,7 +20,6 @@ package org.apache.ignite.ml.math.impls.storage.vector;
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
-
 import org.apache.ignite.ml.math.VectorStorage;
 import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/7378bc38/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOffHeapVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOffHeapVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOffHeapVectorStorage.java
index fe70fbd..f6148c8 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOffHeapVectorStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOffHeapVectorStorage.java
@@ -21,7 +21,6 @@ import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import java.nio.ByteBuffer;
-
 import org.apache.ignite.internal.util.offheap.GridOffHeapMap;
 import org.apache.ignite.internal.util.offheap.GridOffHeapMapFactory;
 import org.apache.ignite.ml.math.VectorStorage;

http://git-wip-us.apache.org/repos/asf/ignite/blob/7378bc38/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOnHeapVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOnHeapVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOnHeapVectorStorage.java
index d3dba8e..8400758 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOnHeapVectorStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOnHeapVectorStorage.java
@@ -19,12 +19,10 @@ package org.apache.ignite.ml.math.impls.storage.vector;
 
 import it.unimi.dsi.fastutil.ints.Int2DoubleOpenHashMap;
 import it.unimi.dsi.fastutil.ints.Int2DoubleRBTreeMap;
-
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import java.util.Map;
-
 import org.apache.ignite.ml.math.StorageConstants;
 import org.apache.ignite.ml.math.VectorStorage;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/7378bc38/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/AbstractVector.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/AbstractVector.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/AbstractVector.java
index d59964b..83ac837 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/AbstractVector.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/AbstractVector.java
@@ -28,7 +28,6 @@ import java.util.NoSuchElementException;
 import java.util.Spliterator;
 import java.util.function.Consumer;
 import java.util.function.IntToDoubleFunction;
-
 import org.apache.ignite.lang.IgniteUuid;
 import org.apache.ignite.ml.math.Matrix;
 import org.apache.ignite.ml.math.Vector;

http://git-wip-us.apache.org/repos/asf/ignite/blob/7378bc38/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/DelegatingVector.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/DelegatingVector.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/DelegatingVector.java
index 545d728..c868160 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/DelegatingVector.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/DelegatingVector.java
@@ -24,7 +24,6 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.Spliterator;
 import java.util.function.IntToDoubleFunction;
-
 import org.apache.ignite.lang.IgniteUuid;
 import org.apache.ignite.ml.math.Matrix;
 import org.apache.ignite.ml.math.Vector;

http://git-wip-us.apache.org/repos/asf/ignite/blob/7378bc38/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/MatrixVectorView.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/MatrixVectorView.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/MatrixVectorView.java
index e479945..3becbcf 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/MatrixVectorView.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/MatrixVectorView.java
@@ -20,7 +20,6 @@ package org.apache.ignite.ml.math.impls.vector;
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
-
 import org.apache.ignite.ml.math.Matrix;
 import org.apache.ignite.ml.math.Vector;
 import org.apache.ignite.ml.math.exceptions.IndexException;

http://git-wip-us.apache.org/repos/asf/ignite/blob/7378bc38/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/PivotedVectorView.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/PivotedVectorView.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/PivotedVectorView.java
index 0d53e71..365b5eb 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/PivotedVectorView.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/PivotedVectorView.java
@@ -20,7 +20,6 @@ package org.apache.ignite.ml.math.impls.vector;
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
-
 import org.apache.ignite.ml.math.Matrix;
 import org.apache.ignite.ml.math.Vector;
 import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;

http://git-wip-us.apache.org/repos/asf/ignite/blob/7378bc38/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/RandomVector.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/RandomVector.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/RandomVector.java
index df6f791..633773e 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/RandomVector.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/RandomVector.java
@@ -21,13 +21,12 @@ import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import java.util.Map;
-
 import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.Vector;
 import org.apache.ignite.ml.math.VectorStorage;
 import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
 import org.apache.ignite.ml.math.impls.matrix.RandomMatrix;
 import org.apache.ignite.ml.math.impls.storage.vector.RandomVectorStorage;
-import org.apache.ignite.ml.math.Vector;
 
 /**
  * Random vector. Each value is taken from {-1,0,1} with roughly equal probability. Note

http://git-wip-us.apache.org/repos/asf/ignite/blob/7378bc38/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/SingleElementVector.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/SingleElementVector.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/SingleElementVector.java
index 21e8141..3ec14a2 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/SingleElementVector.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/SingleElementVector.java
@@ -1 +1 @@
-/*
 * 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.ml.math.impls.vector;

import java.util.Map;

import org.apache.ignite.ml.math.Matrix;
import org.apache.ignite.ml.math.Vector;
import org.apache.ignite.ml.math.except
 ions.UnsupportedOperationException;
import org.apache.ignite.ml.math.impls.storage.vector.SingleElementVectorStorage;

/**
 * Read-write vector holding a single non-zero value at some index.
 */
public class SingleElementVector extends AbstractVector {
    /**
     *
     */
    public SingleElementVector() {
        // No-op
    }

    /**
     * @param size Parent vector size.
     * @param idx Index of the parent vector element.
     * @param val Value of the vector element.
     */
    public SingleElementVector(int size, int idx, double val) {
        super(new SingleElementVectorStorage(size, idx, val));
    }

    /**
     * @param args Parameters to create new vector instance.
     */
    public SingleElementVector(Map<String, Object> args) {
        assert args != null;

        if (args.containsKey("size") && args.containsKey("index") && args.containsKey("value")) {
            int size = (int)args.get("size");
            int idx = (int)args.get("index");
            doub
 le val = (double)args.get("value");

            setStorage(new SingleElementVectorStorage(size, idx, val));
        }
        else
            throw new UnsupportedOperationException("Invalid constructor argument(s).");
    }

    /**
     *
     *
     */
    private SingleElementVectorStorage storage() {
        return (SingleElementVectorStorage)getStorage();
    }

    /** {@inheritDoc} */
    @Override public Element minElement() {
        return makeElement(storage().index());
    }

    /** {@inheritDoc} */
    @Override public Element maxElement() {
        return makeElement(storage().index());
    }

    /** {@inheritDoc} */
    @Override public double sum() {
        return getX(storage().index());
    }

    /** {@inheritDoc} */
    @Override public int nonZeroElements() {
        return isZero(get(storage().index())) ? 0 : 1;
    }

    /** {@inheritDoc} */
    @Override public Vector like(int crd) {
        int idx = storage().index();

        return new SingleElemen
 tVector(crd, idx, getX(idx));
    }

    /** {@inheritDoc} */
    @Override public Matrix likeMatrix(int rows, int cols) {
        throw new UnsupportedOperationException();
    }
}
\ No newline at end of file
+/*
 * 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.ml.math.impls.vector;

import java.util.Map;
import org.apache.ignite.ml.math.Matrix;
import org.apache.ignite.ml.math.Vector;
import org.apache.ignite.ml.math.excepti
 ons.UnsupportedOperationException;
import org.apache.ignite.ml.math.impls.storage.vector.SingleElementVectorStorage;

/**
 * Read-write vector holding a single non-zero value at some index.
 */
public class SingleElementVector extends AbstractVector {
    /**
     *
     */
    public SingleElementVector() {
        // No-op
    }

    /**
     * @param size Parent vector size.
     * @param idx Index of the parent vector element.
     * @param val Value of the vector element.
     */
    public SingleElementVector(int size, int idx, double val) {
        super(new SingleElementVectorStorage(size, idx, val));
    }

    /**
     * @param args Parameters to create new vector instance.
     */
    public SingleElementVector(Map<String, Object> args) {
        assert args != null;

        if (args.containsKey("size") && args.containsKey("index") && args.containsKey("value")) {
            int size = (int)args.get("size");
            int idx = (int)args.get("index");
            doubl
 e val = (double)args.get("value");

            setStorage(new SingleElementVectorStorage(size, idx, val));
        }
        else
            throw new UnsupportedOperationException("Invalid constructor argument(s).");
    }

    /**
     *
     *
     */
    private SingleElementVectorStorage storage() {
        return (SingleElementVectorStorage)getStorage();
    }

    /** {@inheritDoc} */
    @Override public Element minElement() {
        return makeElement(storage().index());
    }

    /** {@inheritDoc} */
    @Override public Element maxElement() {
        return makeElement(storage().index());
    }

    /** {@inheritDoc} */
    @Override public double sum() {
        return getX(storage().index());
    }

    /** {@inheritDoc} */
    @Override public int nonZeroElements() {
        return isZero(get(storage().index())) ? 0 : 1;
    }

    /** {@inheritDoc} */
    @Override public Vector like(int crd) {
        int idx = storage().index();

        return new SingleElement
 Vector(crd, idx, getX(idx));
    }

    /** {@inheritDoc} */
    @Override public Matrix likeMatrix(int rows, int cols) {
        throw new UnsupportedOperationException();
    }
}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/7378bc38/modules/ml/src/test/java/org/apache/ignite/ml/math/TracerTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/TracerTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/TracerTest.java
index b4f7330..0bc393f 100644
--- a/modules/ml/src/test/java/org/apache/ignite/ml/math/TracerTest.java
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/TracerTest.java
@@ -23,7 +23,6 @@ import java.nio.file.Files;
 import java.nio.file.Path;
 import java.util.List;
 import java.util.Optional;
-
 import org.apache.ignite.ml.math.impls.MathTestConstants;
 import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
 import org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector;

http://git-wip-us.apache.org/repos/asf/ignite/blob/7378bc38/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/matrix/MatrixStorageFixtures.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/matrix/MatrixStorageFixtures.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/matrix/MatrixStorageFixtures.java
index 78f3dde..afd6a5d 100644
--- a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/matrix/MatrixStorageFixtures.java
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/matrix/MatrixStorageFixtures.java
@@ -23,7 +23,6 @@ import java.util.List;
 import java.util.NoSuchElementException;
 import java.util.function.BiConsumer;
 import java.util.function.Supplier;
-
 import org.apache.ignite.ml.math.MatrixStorage;
 import org.apache.ignite.ml.math.StorageConstants;
 import org.jetbrains.annotations.NotNull;

http://git-wip-us.apache.org/repos/asf/ignite/blob/7378bc38/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/AbstractVectorTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/AbstractVectorTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/AbstractVectorTest.java
index 0707e0a..a7954cd 100644
--- a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/AbstractVectorTest.java
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/AbstractVectorTest.java
@@ -19,7 +19,6 @@ package org.apache.ignite.ml.math.impls.vector;
 
 import java.util.Arrays;
 import java.util.stream.StreamSupport;
-
 import org.apache.ignite.ml.math.Matrix;
 import org.apache.ignite.ml.math.Vector;
 import org.apache.ignite.ml.math.VectorStorage;

http://git-wip-us.apache.org/repos/asf/ignite/blob/7378bc38/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/CacheVectorTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/CacheVectorTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/CacheVectorTest.java
index ce9f98a..b5813d7 100644
--- a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/CacheVectorTest.java
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/CacheVectorTest.java
@@ -23,7 +23,6 @@ import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.util.stream.IntStream;
-
 import junit.framework.TestCase;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;


[11/29] ignite git commit: Removed unused swap-related code.

Posted by ag...@apache.org.
Removed unused swap-related code.


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

Branch: refs/heads/ignite-5024
Commit: 340204333624ecbc4166e52a83056885c673373c
Parents: b58d584
Author: sboikov <sb...@gridgain.com>
Authored: Mon Apr 24 16:49:02 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Mon Apr 24 16:49:02 2017 +0300

----------------------------------------------------------------------
 .../cache/GridCacheBatchSwapEntry.java          |  76 -----
 .../processors/cache/GridCacheEntryEx.java      |  23 --
 .../cache/GridCacheEvictionManager.java         |  95 +-----
 .../processors/cache/GridCacheMapEntry.java     |  73 ----
 .../processors/cache/GridCacheSwapEntry.java    |  82 -----
 .../cache/GridCacheSwapEntryImpl.java           | 339 -------------------
 .../cache/IgniteCacheOffheapManager.java        |   3 -
 .../cache/IgniteCacheOffheapManagerImpl.java    |   5 -
 .../processors/cache/GridCacheTestEntryEx.java  |  15 -
 9 files changed, 9 insertions(+), 702 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/34020433/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheBatchSwapEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheBatchSwapEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheBatchSwapEntry.java
deleted file mode 100644
index 01c9bab..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheBatchSwapEntry.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.cache;
-
-import java.nio.ByteBuffer;
-import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
-import org.apache.ignite.lang.IgniteUuid;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Entry for batch swap operations.
- */
-public class GridCacheBatchSwapEntry extends GridCacheSwapEntryImpl {
-    /** Key. */
-    private KeyCacheObject key;
-
-    /** Partition. */
-    private int part;
-
-    /**
-     * Creates batch swap entry.
-     *
-     * @param key Key.
-     * @param part Partition id.
-     * @param valBytes Value bytes.
-     * @param type Value type.
-     * @param ver Version.
-     * @param ttl Time to live.
-     * @param expireTime Expire time.
-     * @param keyClsLdrId Key class loader ID.
-     * @param valClsLdrId Optional value class loader ID.
-     */
-    public GridCacheBatchSwapEntry(KeyCacheObject key,
-        int part,
-        ByteBuffer valBytes,
-        byte type,
-        GridCacheVersion ver,
-        long ttl,
-        long expireTime,
-        IgniteUuid keyClsLdrId,
-        @Nullable IgniteUuid valClsLdrId) {
-        super(valBytes, type, ver, ttl, expireTime, keyClsLdrId, valClsLdrId);
-
-        this.key = key;
-        this.part = part;
-    }
-
-    /**
-     * @return Key.
-     */
-    public KeyCacheObject key() {
-        return key;
-    }
-
-    /**
-     * @return Partition id.
-     */
-    public int partition() {
-        return part;
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/34020433/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
index 1eab04e..6a5b4b9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
@@ -221,16 +221,6 @@ public interface GridCacheEntryEx {
         boolean evictOffheap) throws IgniteCheckedException;
 
     /**
-     * Evicts entry when batch evict is performed. When called, does not write entry data to swap, but instead
-     * returns batch swap entry if entry was marked obsolete.
-     *
-     * @param obsoleteVer Version to mark obsolete with.
-     * @return Swap entry if this entry was marked obsolete, {@code null} if entry was not evicted.
-     * @throws IgniteCheckedException If failed.
-     */
-    public GridCacheBatchSwapEntry evictInBatchInternal(GridCacheVersion obsoleteVer) throws IgniteCheckedException;
-
-    /**
      * This method should be called each time entry is marked obsolete
      * other than by calling {@link #markObsolete(GridCacheVersion)}.
      */
@@ -695,19 +685,6 @@ public interface GridCacheEntryEx {
         boolean fromStore) throws IgniteCheckedException, GridCacheEntryRemovedException;
 
     /**
-     * Sets new value if current version is <tt>0</tt> using swap entry data.
-     * Note that this method does not update cache index.
-     *
-     * @param key Key.
-     * @param unswapped Swap entry to set entry state from.
-     * @return {@code True} if  initial value was set.
-     * @throws IgniteCheckedException In case of error.
-     * @throws GridCacheEntryRemovedException If entry was removed.
-     */
-    public boolean initialValue(KeyCacheObject key, GridCacheSwapEntry unswapped)
-        throws IgniteCheckedException, GridCacheEntryRemovedException;
-
-    /**
      * Create versioned entry for this cache entry.
      *
      * @param keepBinary Keep binary flag.

http://git-wip-us.apache.org/repos/asf/ignite/blob/34020433/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
index 0deae07..8ba10a2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
@@ -17,12 +17,7 @@
 
 package org.apache.ignite.internal.processors.cache;
 
-import java.util.ArrayList;
 import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
 import java.util.Set;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.cache.eviction.EvictionFilter;
@@ -31,8 +26,8 @@ import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
 import org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry;
 import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
+import org.apache.ignite.internal.processors.cache.version.GridCacheVersionManager;
 import org.apache.ignite.internal.util.GridBusyLock;
-import org.apache.ignite.internal.util.GridUnsafe;
 import org.apache.ignite.internal.util.typedef.X;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteUuid;
@@ -260,96 +255,24 @@ public class GridCacheEvictionManager extends GridCacheManagerAdapter implements
     /** {@inheritDoc} */
     @Override public void batchEvict(Collection<?> keys, @Nullable GridCacheVersion obsoleteVer)
         throws IgniteCheckedException {
-        List<GridCacheEntryEx> locked = new ArrayList<>(keys.size());
-
-        Set<GridCacheEntryEx> notRmv = null;
-
-        Collection<GridCacheBatchSwapEntry> swapped = new ArrayList<>(keys.size());
-
         boolean recordable = cctx.events().isRecordable(EVT_CACHE_ENTRY_EVICTED);
 
         GridCacheAdapter cache = cctx.cache();
 
-        Map<Object, GridCacheEntryEx> cached = U.newLinkedHashMap(keys.size());
-
         // Get all participating entries to avoid deadlock.
         for (Object k : keys) {
             KeyCacheObject cacheKey = cctx.toCacheKeyObject(k);
 
-            GridCacheEntryEx e = cache.peekEx(cacheKey);
-
-            if (e != null)
-                cached.put(k, e);
-        }
-
-        try {
-            for (GridCacheEntryEx entry : cached.values()) {
-                // Do not evict internal entries.
-                if (entry.key().internal())
-                    continue;
-
-                // Lock entry.
-                GridUnsafe.monitorEnter(entry);
-
-                locked.add(entry);
-
-                if (entry.obsolete()) {
-                    if (notRmv == null)
-                        notRmv = new HashSet<>();
-
-                    notRmv.add(entry);
-
-                    continue;
-                }
-
-                if (obsoleteVer == null)
-                    obsoleteVer = cctx.versions().next();
-
-                GridCacheBatchSwapEntry swapEntry = entry.evictInBatchInternal(obsoleteVer);
-
-                if (swapEntry != null) {
-                    assert entry.obsolete() : entry;
-
-                    swapped.add(swapEntry);
-
-                    if (log.isDebugEnabled())
-                        log.debug("Entry was evicted [entry=" + entry + ", localNode=" + cctx.nodeId() + ']');
-                }
-                else if (!entry.obsolete()) {
-                    if (notRmv == null)
-                        notRmv = new HashSet<>();
-
-                    notRmv.add(entry);
-                }
-            }
-
-            // Batch write to swap.
-            if (!swapped.isEmpty())
-                cctx.offheap().writeAll(swapped);
-        }
-        finally {
-            // Unlock entries in reverse order.
-            for (ListIterator<GridCacheEntryEx> it = locked.listIterator(locked.size()); it.hasPrevious(); ) {
-                GridCacheEntryEx e = it.previous();
-
-                GridUnsafe.monitorExit(e);
-            }
-
-            // Remove entries and fire events outside the locks.
-            for (GridCacheEntryEx entry : locked) {
-                if (entry.obsolete() && (notRmv == null || !notRmv.contains(entry))) {
-                    entry.onMarkedObsolete();
-
-                    cache.removeEntry(entry);
+            GridCacheEntryEx entry = cache.peekEx(cacheKey);
 
-                    if (plcEnabled)
-                        notifyPolicy(entry);
+            if (entry != null && entry.evictInternal(GridCacheVersionManager.EVICT_VER, null, false)) {
+                if (plcEnabled)
+                    notifyPolicy(entry);
 
-                    if (recordable)
-                        cctx.events().addEvent(entry.partition(), entry.key(), cctx.nodeId(), (IgniteUuid)null, null,
-                            EVT_CACHE_ENTRY_EVICTED, null, false, entry.rawGet(), entry.hasValue(), null, null, null,
-                            false);
-                }
+                if (recordable)
+                    cctx.events().addEvent(entry.partition(), entry.key(), cctx.nodeId(), (IgniteUuid)null, null,
+                        EVT_CACHE_ENTRY_EVICTED, null, false, entry.rawGet(), entry.hasValue(), null, null, null,
+                        false);
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/34020433/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
index 856ac993..21c58fa 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
@@ -2709,31 +2709,6 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
     }
 
     /** {@inheritDoc} */
-    @Override public synchronized boolean initialValue(KeyCacheObject key, GridCacheSwapEntry unswapped) throws
-        IgniteCheckedException,
-        GridCacheEntryRemovedException {
-        checkObsolete();
-
-        if (isNew()) {
-            CacheObject val = unswapped.value();
-
-            val = cctx.kernalContext().cacheObjects().prepareForCache(val, cctx);
-
-            // Version does not change for load ops.
-            update(val,
-                unswapped.expireTime(),
-                unswapped.ttl(),
-                unswapped.version(),
-                true
-            );
-
-            return true;
-        }
-
-        return false;
-    }
-
-    /** {@inheritDoc} */
     @Override public synchronized GridCacheVersionedEntryEx versionedEntry(final boolean keepBinary)
         throws IgniteCheckedException, GridCacheEntryRemovedException {
         boolean isNew = isStartVersion();
@@ -3518,54 +3493,6 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
         return false;
     }
 
-    /** {@inheritDoc} */
-    @Override public final GridCacheBatchSwapEntry evictInBatchInternal(GridCacheVersion obsoleteVer)
-        throws IgniteCheckedException {
-        assert Thread.holdsLock(this);
-        assert !obsolete();
-
-        GridCacheBatchSwapEntry ret = null;
-
-        try {
-            if (!hasReaders() && markObsolete0(obsoleteVer, false, null)) {
-                if (!isStartVersion() && hasValueUnlocked()) {
-                    IgniteUuid valClsLdrId = null;
-                    IgniteUuid keyClsLdrId = null;
-
-                    if (cctx.deploymentEnabled()) {
-                        if (val != null) {
-                            valClsLdrId = cctx.deploy().getClassLoaderId(
-                                U.detectObjectClassLoader(val.value(cctx.cacheObjectContext(), false)));
-                        }
-
-                        keyClsLdrId = cctx.deploy().getClassLoaderId(
-                            U.detectObjectClassLoader(keyValue(false)));
-                    }
-
-                    IgniteBiTuple<byte[], Byte> valBytes = valueBytes0();
-
-                    ret = new GridCacheBatchSwapEntry(key(),
-                        partition(),
-                        ByteBuffer.wrap(valBytes.get1()),
-                        valBytes.get2(),
-                        ver,
-                        ttlExtras(),
-                        expireTimeExtras(),
-                        keyClsLdrId,
-                        valClsLdrId);
-                }
-
-                value(null);
-            }
-        }
-        catch (GridCacheEntryRemovedException ignored) {
-            if (log.isDebugEnabled())
-                log.debug("Got removed entry when evicting (will simply return): " + this);
-        }
-
-        return ret;
-    }
-
     /**
      * @param filter Entry filter.
      * @return {@code True} if entry is visitable.

http://git-wip-us.apache.org/repos/asf/ignite/blob/34020433/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapEntry.java
deleted file mode 100644
index 73519eb..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapEntry.java
+++ /dev/null
@@ -1,82 +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.internal.processors.cache.version.GridCacheVersion;
-import org.apache.ignite.lang.IgniteUuid;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Swap entry.
- */
-public interface GridCacheSwapEntry {
-    /**
-     * @return Value bytes.
-     */
-    public byte[] valueBytes();
-
-    /**
-     * @return Object type.
-     */
-    public byte type();
-
-    /**
-     * @param valBytes Value bytes.
-     */
-    public void valueBytes(@Nullable byte[] valBytes);
-
-    /**
-     * @return Value.
-     */
-    public CacheObject value();
-
-    /**
-     * @param val Value.
-     */
-    public void value(CacheObject val);
-
-    /**
-     * @return Version.
-     */
-    public GridCacheVersion version();
-
-    /**
-     * @return Time to live.
-     */
-    public long ttl();
-
-    /**
-     * @return Expire time.
-     */
-    public long expireTime();
-
-    /**
-     * @return Class loader ID for entry key ({@code null} for local class loader).
-     */
-    @Nullable public IgniteUuid keyClassLoaderId();
-
-    /**
-     * @return Class loader ID for entry value ({@code null} for local class loader).
-     */
-    @Nullable public IgniteUuid valueClassLoaderId();
-
-    /**
-     * @return If entry is offheap based returns offheap address, otherwise 0.
-     */
-    public long offheapPointer();
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/34020433/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapEntryImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapEntryImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapEntryImpl.java
deleted file mode 100644
index 410a6ee..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapEntryImpl.java
+++ /dev/null
@@ -1,339 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.cache;
-
-import java.nio.ByteBuffer;
-import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
-import org.apache.ignite.internal.processors.cache.version.GridCacheVersionEx;
-import org.apache.ignite.internal.util.GridUnsafe;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.lang.IgniteBiTuple;
-import org.apache.ignite.lang.IgniteUuid;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Swap entry.
- */
-public class GridCacheSwapEntryImpl implements GridCacheSwapEntry {
-    /** */
-    static final int EXPIRE_TIME_OFFSET = 8;
-
-    /** */
-    static final int VERSION_OFFSET = 16;
-
-    /** */
-    static final int VERSION_SIZE = 16;
-
-    /** */
-    static final int VERSION_EX_SIZE = 32;
-
-    /** */
-    static final int GUID_SIZE = 24;
-
-    /** Value bytes. */
-    private ByteBuffer valBytes;
-
-    /** Value. */
-    private CacheObject val;
-
-    /** Type. */
-    private byte type;
-
-    /** Class loader ID. */
-    private IgniteUuid keyClsLdrId;
-
-    /** Class loader ID. */
-    private IgniteUuid valClsLdrId;
-
-    /** Version. */
-    private GridCacheVersion ver;
-
-    /** Time to live. */
-    private long ttl;
-
-    /** Expire time. */
-    private long expireTime;
-
-    /**
-     * @param valBytes Value.
-     * @param type Type.
-     * @param ver Version.
-     * @param ttl Entry time to live.
-     * @param expireTime Expire time.
-     * @param keyClsLdrId Class loader ID for entry key (can be {@code null} for local class loader).
-     * @param valClsLdrId Class loader ID for entry value (can be {@code null} for local class loader).
-     */
-    public GridCacheSwapEntryImpl(
-        ByteBuffer valBytes,
-        byte type,
-        GridCacheVersion ver,
-        long ttl,
-        long expireTime,
-        @Nullable IgniteUuid keyClsLdrId,
-        @Nullable IgniteUuid valClsLdrId) {
-        this.valBytes = valBytes;
-        this.type = type;
-        this.ver = ver;
-        this.ttl = ttl;
-        this.expireTime = expireTime;
-        this.valClsLdrId = valClsLdrId;
-        this.keyClsLdrId = keyClsLdrId;
-    }
-
-    /**
-     * @param bytes Entry bytes.
-     * @return TTL.
-     */
-    public static long timeToLive(byte[] bytes) {
-        return GridUnsafe.getLong(bytes, GridUnsafe.BYTE_ARR_OFF);
-    }
-
-    /**
-     * @param bytes Entry bytes.
-     * @return Expire time.
-     */
-    public static long expireTime(byte[] bytes) {
-        return GridUnsafe.getLong(bytes, GridUnsafe.BYTE_ARR_OFF + EXPIRE_TIME_OFFSET);
-    }
-
-    /**
-     * @param bytes Entry bytes.
-     * @return Version.
-     */
-    public static GridCacheVersion version(byte[] bytes) {
-        long off = GridUnsafe.BYTE_ARR_OFF + VERSION_OFFSET; // Skip ttl, expire time.
-
-        boolean verEx = GridUnsafe.getByte(bytes, off++) != 0;
-
-        return U.readVersion(bytes, off, verEx);
-    }
-
-    /**
-     * @param bytes Entry bytes.
-     * @return Value if value is byte array, otherwise {@code null}.
-     */
-    @Nullable public static IgniteBiTuple<byte[], Byte> getValue(byte[] bytes) {
-        long off = GridUnsafe.BYTE_ARR_OFF + VERSION_OFFSET; // Skip ttl, expire time.
-
-        boolean verEx = GridUnsafe.getByte(bytes, off++) != 0;
-
-        off += verEx ? VERSION_EX_SIZE : VERSION_SIZE;
-
-        int arrLen = GridUnsafe.getInt(bytes, off);
-
-        off += 4;
-
-        byte type = GridUnsafe.getByte(bytes, off++);
-
-        byte[] valBytes = new byte[arrLen];
-
-        GridUnsafe.copyMemory(bytes, off, valBytes, GridUnsafe.BYTE_ARR_OFF, arrLen);
-
-        return new IgniteBiTuple<>(valBytes, type);
-    }
-
-    /** {@inheritDoc} */
-    @Override public byte[] valueBytes() {
-        if (valBytes != null) {
-            assert valBytes.capacity() == valBytes.limit();
-
-            return valBytes.array();
-        }
-
-        return null;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void valueBytes(@Nullable byte[] valBytes) {
-        this.valBytes = valBytes != null ? ByteBuffer.wrap(valBytes) : null;
-    }
-
-    /** {@inheritDoc} */
-    @Override public CacheObject value() {
-        return val;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void value(CacheObject val) {
-        this.val = val;
-    }
-
-    /** {@inheritDoc} */
-    @Override public byte type() {
-        return type;
-    }
-
-    /** {@inheritDoc} */
-    @Override public GridCacheVersion version() {
-        return ver;
-    }
-
-    /** {@inheritDoc} */
-    @Override public long ttl() {
-        return ttl;
-    }
-
-    /** {@inheritDoc} */
-    @Override public long expireTime() {
-        return expireTime;
-    }
-
-    /** {@inheritDoc} */
-    @Nullable @Override public IgniteUuid keyClassLoaderId() {
-        return keyClsLdrId;
-    }
-
-    /** {@inheritDoc} */
-    @Nullable @Override public IgniteUuid valueClassLoaderId() {
-        return valClsLdrId;
-    }
-
-    /** {@inheritDoc} */
-    @Override public long offheapPointer() {
-        return 0;
-    }
-
-    /**
-     * @return Entry bytes.
-     */
-    public byte[] marshal() {
-        // Ttl + expire time + Ex Version flag + Version.
-        int size = 16 + 1 + ((ver instanceof GridCacheVersionEx) ? VERSION_EX_SIZE : VERSION_SIZE);
-
-        size += 1; // Plain byte array flag.
-
-        int len = valBytes.limit();
-
-        size += len + 4; // Value bytes.
-
-        size += (valClsLdrId == null ? 1 : (1 + GUID_SIZE));
-
-        size += (keyClsLdrId == null ? 1 : (1 + GUID_SIZE));
-
-        byte[] arr = new byte[size];
-
-        long off = GridUnsafe.BYTE_ARR_OFF;
-
-        GridUnsafe.putLong(arr, off, ttl);
-
-        off += 8;
-
-        GridUnsafe.putLong(arr, off, expireTime);
-
-        off += 8;
-
-        off = U.writeVersion(arr, off, ver);
-
-        GridUnsafe.putInt(arr, off, len);
-
-        off += 4;
-
-        GridUnsafe.putByte(arr, off++, type);
-
-        GridUnsafe.copyMemory(valBytes.array(), GridUnsafe.BYTE_ARR_OFF, arr, off, len);
-
-        off += len;
-
-        off = U.writeGridUuid(arr, off, valClsLdrId);
-
-        U.writeGridUuid(arr, off, keyClsLdrId);
-
-        return arr;
-    }
-
-    /**
-     * @param arr Entry bytes.
-     * @param valOnly If {@code true} unmarshalls only entry value.
-     * @return Entry.
-     */
-    public static GridCacheSwapEntryImpl unmarshal(byte[] arr, boolean valOnly) {
-        if (valOnly) {
-            long off = GridUnsafe.BYTE_ARR_OFF + VERSION_OFFSET; // Skip ttl, expire time.
-
-            boolean verEx = GridUnsafe.getByte(arr, off++) != 0;
-
-            off += verEx ? VERSION_EX_SIZE : VERSION_SIZE;
-
-            int arrLen = GridUnsafe.getInt(arr, off);
-
-            off += 4;
-
-            byte type = GridUnsafe.getByte(arr, off++);
-
-            byte[] valBytes = new byte[arrLen];
-
-            GridUnsafe.copyMemory(arr, off, valBytes, GridUnsafe.BYTE_ARR_OFF, arrLen);
-
-            return new GridCacheSwapEntryImpl(ByteBuffer.wrap(valBytes),
-                type,
-                null,
-                0L,
-                0L,
-                null,
-                null);
-        }
-
-        long off = GridUnsafe.BYTE_ARR_OFF;
-
-        long ttl = GridUnsafe.getLong(arr, off);
-
-        off += 8;
-
-        long expireTime = GridUnsafe.getLong(arr, off);
-
-        off += 8;
-
-        boolean verEx = GridUnsafe.getBoolean(arr, off++);
-
-        GridCacheVersion ver = U.readVersion(arr, off, verEx);
-
-        off += verEx ? VERSION_EX_SIZE : VERSION_SIZE;
-
-        int arrLen = GridUnsafe.getInt(arr, off);
-
-        off += 4;
-
-        byte type = GridUnsafe.getByte(arr, off++);
-
-        byte[] valBytes = new byte[arrLen];
-
-        GridUnsafe.copyMemory(arr, off, valBytes, GridUnsafe.BYTE_ARR_OFF, arrLen);
-
-        off += arrLen;
-
-        IgniteUuid valClsLdrId = U.readGridUuid(arr, off);
-
-        off += valClsLdrId == null ? 1 : (1 + GUID_SIZE);
-
-        IgniteUuid keyClsLdrId = U.readGridUuid(arr, off);
-
-        return new GridCacheSwapEntryImpl(ByteBuffer.wrap(valBytes),
-            type,
-            ver,
-            ttl,
-            expireTime,
-            keyClsLdrId,
-            valClsLdrId);
-    }
-
-    /** {@inheritDoc} */
-    @Override public String toString() {
-        return S.toString(GridCacheSwapEntryImpl.class, this);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/34020433/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManager.java
index 4a98f6a..9eb5368 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManager.java
@@ -239,9 +239,6 @@ public interface IgniteCacheOffheapManager extends GridCacheManager {
      */
     public GridAtomicLong globalRemoveId();
 
-    // TODO GG-10884: moved from GridCacheSwapManager.
-    void writeAll(Iterable<GridCacheBatchSwapEntry> swapped) throws IgniteCheckedException;
-
     /**
      * @param idxName Index name.
      * @return Root page for index tree.

http://git-wip-us.apache.org/repos/asf/ignite/blob/34020433/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java
index 73edbe1..650f65e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java
@@ -431,11 +431,6 @@ public class IgniteCacheOffheapManagerImpl extends GridCacheManagerAdapter imple
         return 0;
     }
 
-    /** {@inheritDoc} */
-    @Override public void writeAll(Iterable<GridCacheBatchSwapEntry> swapped) throws IgniteCheckedException {
-        // No-op.
-    }
-
     /**
      * @param primary {@code True} if need return primary entries.
      * @param backup {@code True} if need return backup entries.

http://git-wip-us.apache.org/repos/asf/ignite/blob/34020433/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
index a060f7e..53764ca 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
@@ -376,14 +376,6 @@ public class GridCacheTestEntryEx extends GridMetadataAwareAdapter implements Gr
         return false;
     }
 
-    /** {@inheritDoc} */
-    @Override public GridCacheBatchSwapEntry evictInBatchInternal(GridCacheVersion obsoleteVer)
-        throws IgniteCheckedException {
-        assert false;
-
-        return null;
-    }
-
     /** @inheritDoc */
     @Override public boolean isNew() {
         assert false; return false;
@@ -663,13 +655,6 @@ public class GridCacheTestEntryEx extends GridMetadataAwareAdapter implements Gr
     }
 
     /** @inheritDoc */
-    @Override public boolean initialValue(KeyCacheObject key, GridCacheSwapEntry unswapped) {
-        assert false;
-
-        return false;
-    }
-
-    /** @inheritDoc */
     @Override public GridCacheVersionedEntryEx versionedEntry(final boolean keepBinary) throws IgniteCheckedException {
         return null;
     }


[06/29] ignite git commit: Merge remote-tracking branch 'origin/ignite-2.0' into ignite-2.0

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


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

Branch: refs/heads/ignite-5024
Commit: 1214d7e7e0d0853559e0017366efaf10927aa898
Parents: 3192806 7378bc3
Author: sboikov <sb...@gridgain.com>
Authored: Mon Apr 24 13:21:36 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Mon Apr 24 13:21:36 2017 +0300

----------------------------------------------------------------------
 .../java/org/apache/ignite/ml/math/Algebra.java |  89 +++++++++-------
 .../ignite/ml/math/IdentityValueMapper.java     |   3 +-
 .../java/org/apache/ignite/ml/math/Matrix.java  |  32 +++---
 .../org/apache/ignite/ml/math/MurmurHash.java   |  16 +--
 .../java/org/apache/ignite/ml/math/Tracer.java  |   4 +-
 .../java/org/apache/ignite/ml/math/Vector.java  |   3 +-
 .../decompositions/CholeskyDecomposition.java   |   8 +-
 .../math/decompositions/EigenDecomposition.java |   4 +-
 .../ml/math/decompositions/LUDecomposition.java |   8 +-
 .../ignite/ml/math/functions/Functions.java     |  21 +++-
 .../ml/math/impls/matrix/PivotedMatrixView.java |   2 +-
 .../impls/matrix/SparseDistributedMatrix.java   |  12 +--
 .../storage/matrix/CacheMatrixStorage.java      |  15 ++-
 .../matrix/DenseOffHeapMatrixStorage.java       |  14 ++-
 .../storage/matrix/FunctionMatrixStorage.java   |  16 +--
 .../matrix/SparseLocalOnHeapMatrixStorage.java  |  18 ++--
 .../storage/vector/CacheVectorStorage.java      |  12 +--
 .../storage/vector/ConstantVectorStorage.java   |   9 +-
 .../storage/vector/FunctionVectorStorage.java   |  16 +--
 .../storage/vector/MatrixVectorStorage.java     |  18 ++--
 .../storage/vector/PivotedVectorStorage.java    |  15 +--
 .../SingleElementVectorDelegateStorage.java     |  12 +--
 .../vector/SingleElementVectorStorage.java      |  10 +-
 .../vector/SparseLocalOffHeapVectorStorage.java |   2 +
 .../vector/SparseLocalOnHeapVectorStorage.java  |   9 +-
 .../ml/math/impls/vector/MatrixVectorView.java  |  19 ++--
 .../ml/math/impls/vector/PivotedVectorView.java |  13 +--
 .../ml/math/impls/vector/RandomVector.java      |   5 +-
 .../math/impls/vector/SingleElementVector.java  | 103 +------------------
 .../org/apache/ignite/ml/math/TracerTest.java   |  11 +-
 .../ml/math/impls/matrix/CacheMatrixTest.java   |  10 +-
 .../impls/matrix/MatrixKeyMapperForTests.java   |  19 ++--
 .../storage/matrix/MatrixStorageFixtures.java   |  18 ++--
 .../SparseLocalOffHeapVectorStorageTest.java    |   3 +-
 .../math/impls/vector/AbstractVectorTest.java   |  41 ++++----
 .../ml/math/impls/vector/CacheVectorTest.java   |   4 +-
 36 files changed, 305 insertions(+), 309 deletions(-)
----------------------------------------------------------------------



[29/29] ignite git commit: Merge branch ignite-2.0 into ignite-5024

Posted by ag...@apache.org.
Merge branch ignite-2.0 into ignite-5024


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

Branch: refs/heads/ignite-5024
Commit: eac6762b2da884b3aca8094b8a13c670aaeac55a
Parents: 0c05145 4be320a
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Wed Apr 26 12:32:02 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Wed Apr 26 12:32:02 2017 +0300

----------------------------------------------------------------------
 .../examples/datagrid/CacheQueryExample.java    |  54 +-
 .../streaming/wordcount/QueryWords.java         |   3 +-
 .../examples/IndexingBridgeMethodTest.java      |  93 ---
 .../IgniteExamplesJ8SelfTestSuite.java          |   2 -
 .../cassandra/common/PropertyMappingHelper.java |  21 +-
 .../persistence/KeyPersistenceSettings.java     |  18 +-
 .../store/cassandra/persistence/PojoField.java  |  21 +-
 .../cassandra/persistence/PojoKeyField.java     |   7 -
 .../cassandra/persistence/PojoValueField.java   |   6 -
 .../persistence/ValuePersistenceSettings.java   |  12 +-
 .../org/apache/ignite/tests/pojos/Person.java   |  10 +-
 .../org/apache/ignite/tests/pojos/Product.java  |   7 -
 .../apache/ignite/tests/pojos/ProductOrder.java |   8 -
 .../internal/jdbc2/JdbcResultSetSelfTest.java   |   2 +-
 .../org/apache/ignite/cache/CacheMetrics.java   |   1 -
 .../org/apache/ignite/cache/QueryEntity.java    |  43 +-
 .../org/apache/ignite/cache/query/Query.java    |  48 ++
 .../ignite/cache/query/SqlFieldsQuery.java      |  26 +
 .../org/apache/ignite/cache/query/SqlQuery.java |  26 +
 .../cache/query/annotations/QuerySqlField.java  |   2 +-
 .../cache/query/annotations/QueryTextField.java |   4 +-
 .../configuration/CacheConfiguration.java       |  83 +--
 .../configuration/FileSystemConfiguration.java  |  25 -
 .../configuration/MemoryConfiguration.java      |  13 +-
 .../MemoryPolicyConfiguration.java              |   6 +-
 .../org/apache/ignite/igfs/IgfsMetrics.java     |   5 +-
 .../optimized/OptimizedMarshaller.java          |   3 +-
 .../processors/cache/GridCacheAdapter.java      |  14 -
 .../cache/GridCacheBatchSwapEntry.java          |  76 ---
 .../processors/cache/GridCacheEntryEx.java      |  23 -
 .../cache/GridCacheEvictionManager.java         |  95 +--
 .../processors/cache/GridCacheMapEntry.java     |  73 ---
 .../processors/cache/GridCacheProcessor.java    |   9 +-
 .../processors/cache/GridCacheProxyImpl.java    |  12 -
 .../processors/cache/GridCacheSwapEntry.java    |  82 ---
 .../cache/GridCacheSwapEntryImpl.java           | 339 ----------
 .../cache/IgniteCacheOffheapManager.java        |   3 -
 .../cache/IgniteCacheOffheapManagerImpl.java    |   5 -
 .../processors/cache/IgniteCacheProxy.java      |  22 +-
 .../processors/cache/IgniteInternalCache.java   |   7 -
 .../IgniteCacheDatabaseSharedManager.java       | 115 ++--
 .../dht/GridDhtTransactionalCacheAdapter.java   |   1 -
 .../dht/preloader/GridDhtPartitionDemander.java |  12 -
 .../distributed/near/GridNearCacheAdapter.java  |   5 -
 .../GridCacheAtomicReferenceImpl.java           |   2 +
 .../processors/igfs/IgfsDataManager.java        |  36 +-
 .../processors/query/GridQueryProcessor.java    |   4 +-
 .../internal/processors/query/QuerySchema.java  |   4 +-
 .../internal/processors/query/QueryUtils.java   |  79 ++-
 .../ignite/internal/util/GridIntIterator.java   |  33 +
 .../ignite/internal/util/GridIntList.java       |  21 +-
 .../ignite/internal/util/IgniteUtils.java       |  19 +
 .../internal/visor/VisorDataTransferObject.java |  15 +-
 .../visor/binary/VisorBinaryMetadata.java       |   3 +-
 .../visor/cache/VisorCacheConfiguration.java    |   3 +-
 .../internal/visor/igfs/VisorIgfsMetrics.java   |   3 +-
 .../visor/node/VisorIgfsConfiguration.java      |  13 -
 .../resources/META-INF/classnames.properties    |  47 +-
 .../IgniteClientReconnectAtomicsTest.java       |  15 +-
 .../processors/cache/GridCacheTestEntryEx.java  |  15 -
 .../cache/MemoryPolicyConfigValidationTest.java |   6 +-
 .../MemoryPolicyInitializationTest.java         | 307 +++++++++
 ...heClientMultiNodeUpdateTopologyLockTest.java |  28 +-
 .../distributed/IgniteCacheGetRestartTest.java  |   2 +-
 .../processors/igfs/IgfsMaxSizeSelfTest.java    | 121 ----
 .../processors/igfs/IgfsSizeSelfTest.java       |  50 +-
 .../testsuites/IgniteCacheTestSuite2.java       |   2 +
 .../ignite/testsuites/IgniteIgfsTestSuite.java  |   3 -
 .../query/h2/H2IndexingAbstractGeoSelfTest.java |   4 +-
 .../resources/META-INF/classnames.properties    |   1 +
 .../HadoopIgfs20FileSystemAbstractSelfTest.java |   1 -
 .../cache/hibernate/HibernateCacheProxy.java    |   5 -
 .../cache/hibernate/HibernateCacheProxy.java    |   5 -
 .../processors/query/h2/IgniteH2Indexing.java   |  16 +-
 .../query/h2/twostep/GridMapQueryExecutor.java  |   5 +-
 .../h2/twostep/GridReduceQueryExecutor.java     | 222 ++++++-
 .../h2/twostep/msg/GridH2QueryRequest.java      |  64 +-
 .../cache/GridCacheQueryTestValue.java          |   2 +-
 .../IgniteCacheAbstractFieldsQuerySelfTest.java |  29 +-
 .../cache/IgniteCacheDistributedJoinTest.java   |   6 +-
 ...IgniteCacheJoinQueryWithAffinityKeyTest.java |  20 +-
 .../cache/IgniteCrossCachesJoinsQueryTest.java  |  77 +--
 ...stributedPartitionQueryAbstractSelfTest.java | 652 +++++++++++++++++++
 ...utedPartitionQueryConfigurationSelfTest.java |  92 +++
 ...butedPartitionQueryNodeRestartsSelfTest.java | 114 ++++
 ...eCacheDistributedPartitionQuerySelfTest.java |  90 +++
 .../IgniteCacheQueryNodeRestartSelfTest2.java   |   7 +-
 .../DynamicIndexAbstractBasicSelfTest.java      |  16 +-
 .../index/QueryEntityValidationSelfTest.java    | 162 +++++
 .../query/IgniteSqlSplitterSelfTest.java        |  46 +-
 .../IgniteCacheQuerySelfTestSuite.java          |   9 +
 .../java/org/apache/ignite/ml/math/Algebra.java |  89 ++-
 .../ignite/ml/math/IdentityValueMapper.java     |   3 +-
 .../java/org/apache/ignite/ml/math/Matrix.java  |  32 +-
 .../org/apache/ignite/ml/math/MurmurHash.java   |  16 +-
 .../java/org/apache/ignite/ml/math/Tracer.java  |   4 +-
 .../java/org/apache/ignite/ml/math/Vector.java  |   3 +-
 .../decompositions/CholeskyDecomposition.java   |   8 +-
 .../math/decompositions/EigenDecomposition.java |   4 +-
 .../ml/math/decompositions/LUDecomposition.java |   8 +-
 .../ignite/ml/math/functions/Functions.java     |  21 +-
 .../ml/math/impls/matrix/PivotedMatrixView.java |   2 +-
 .../impls/matrix/SparseDistributedMatrix.java   |  12 +-
 .../storage/matrix/CacheMatrixStorage.java      |  15 +-
 .../matrix/DenseOffHeapMatrixStorage.java       |  14 +-
 .../storage/matrix/FunctionMatrixStorage.java   |  16 +-
 .../matrix/SparseLocalOnHeapMatrixStorage.java  |  18 +-
 .../storage/vector/CacheVectorStorage.java      |  12 +-
 .../storage/vector/ConstantVectorStorage.java   |   9 +-
 .../storage/vector/FunctionVectorStorage.java   |  16 +-
 .../storage/vector/MatrixVectorStorage.java     |  18 +-
 .../storage/vector/PivotedVectorStorage.java    |  15 +-
 .../SingleElementVectorDelegateStorage.java     |  12 +-
 .../vector/SingleElementVectorStorage.java      |  10 +-
 .../vector/SparseLocalOffHeapVectorStorage.java |   2 +
 .../vector/SparseLocalOnHeapVectorStorage.java  |   9 +-
 .../ml/math/impls/vector/MatrixVectorView.java  |  19 +-
 .../ml/math/impls/vector/PivotedVectorView.java |  13 +-
 .../ml/math/impls/vector/RandomVector.java      |   5 +-
 .../math/impls/vector/SingleElementVector.java  | 103 +--
 .../org/apache/ignite/ml/math/TracerTest.java   |  11 +-
 .../ml/math/impls/matrix/CacheMatrixTest.java   |  10 +-
 .../impls/matrix/MatrixKeyMapperForTests.java   |  19 +-
 .../storage/matrix/MatrixStorageFixtures.java   |  18 +-
 .../SparseLocalOffHeapVectorStorageTest.java    |   3 +-
 .../math/impls/vector/AbstractVectorTest.java   |  41 +-
 .../ml/math/impls/vector/CacheVectorTest.java   |   4 +-
 .../Apache.Ignite.Core.Tests.csproj             |   1 +
 .../Query/Continuous/ContinuousQueryTest.cs     | 115 ++++
 .../DataStructures/AtomicReferenceTest.cs       |   2 -
 .../Cache/Configuration/MemoryConfiguration.cs  |   7 +
 .../Configuration/MemoryPolicyConfiguration.cs  |   3 +
 modules/platforms/dotnet/build.ps1              |  12 +-
 .../org/apache/ignite/spring/sprint-exclude.xml |   2 -
 .../frontend/app/data/event-groups.json         |  14 -
 .../frontend/app/modules/cluster/Cache.js       |   4 -
 .../app/modules/cluster/CacheMetrics.js         |   4 -
 modules/web-console/web-agent/pom.xml           |   2 +-
 .../ignite/console/agent/AgentLauncher.java     |  10 +-
 139 files changed, 2812 insertions(+), 1896 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/eac6762b/modules/core/src/main/java/org/apache/ignite/cache/CacheMetrics.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/cache/CacheMetrics.java
index c0eb98e,c0eb98e..e780f3e
--- a/modules/core/src/main/java/org/apache/ignite/cache/CacheMetrics.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/CacheMetrics.java
@@@ -109,7 -109,7 +109,6 @@@ public interface CacheMetrics 
       */
      public float getAverageRemoveTime();
  
--
      /**
       * The mean time to execute tx commit.
       *

http://git-wip-us.apache.org/repos/asf/ignite/blob/eac6762b/modules/core/src/main/java/org/apache/ignite/configuration/MemoryConfiguration.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/configuration/MemoryConfiguration.java
index d0c8688,f88a95a..cdbed94
--- a/modules/core/src/main/java/org/apache/ignite/configuration/MemoryConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/MemoryConfiguration.java
@@@ -89,11 -84,8 +92,11 @@@ public class MemoryConfiguration implem
      private int concLvl;
  
      /** A name of the memory policy that defines the default memory region. */
-     private String dfltMemPlcName;
+     private String dfltMemPlcName = DFLT_MEM_PLC_DEFAULT_NAME;
  
 +    /** Size of memory (in bytes) to use for default MemoryPolicy. */
 +    private Long dfltMemPlcSize;
 +
      /** Memory policies. */
      private MemoryPolicyConfiguration[] memPlcs;
  
@@@ -175,14 -171,7 +182,12 @@@
      public MemoryPolicyConfiguration createDefaultPolicyConfig() {
          MemoryPolicyConfiguration memPlc = new MemoryPolicyConfiguration();
  
 -        memPlc.setSize(DFLT_MEMORY_POLICY_SIZE);
 +        long maxSize = (dfltMemPlcSize != null) ? dfltMemPlcSize : DFLT_MEMORY_POLICY_MAX_SIZE;
 +
-         memPlc.setName(null);
- 
 +        if (maxSize < DFLT_MEMORY_POLICY_INITIAL_SIZE)
 +            memPlc.setInitialSize(maxSize);
 +
 +        memPlc.setMaxSize(maxSize);
  
          return memPlc;
      }

http://git-wip-us.apache.org/repos/asf/ignite/blob/eac6762b/modules/core/src/main/java/org/apache/ignite/configuration/MemoryPolicyConfiguration.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/configuration/MemoryPolicyConfiguration.java
index 2f52fe1,d0adcf9..dcfca37
--- a/modules/core/src/main/java/org/apache/ignite/configuration/MemoryPolicyConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/MemoryPolicyConfiguration.java
@@@ -61,13 -63,10 +63,13 @@@ public final class MemoryPolicyConfigur
      private static final long serialVersionUID = 0L;
  
      /** Memory policy name. */
-     private String name;
+     private String name = DFLT_MEM_PLC_DEFAULT_NAME;
  
 +    /** Memory policy start size. */
 +    private long initialSize = MemoryConfiguration.DFLT_MEMORY_POLICY_INITIAL_SIZE;
 +
      /** Memory policy maximum size. */
 -    private long size;
 +    private long maxSize = MemoryConfiguration.DFLT_MEMORY_POLICY_MAX_SIZE;
  
      /** An optional path to a memory mapped file for this memory policy. */
      private String swapFilePath;

http://git-wip-us.apache.org/repos/asf/ignite/blob/eac6762b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheDatabaseSharedManager.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheDatabaseSharedManager.java
index fa5f751,ae594fa..58a641f
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheDatabaseSharedManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheDatabaseSharedManager.java
@@@ -65,10 -64,10 +67,10 @@@ import static org.apache.ignite.configu
   */
  public class IgniteCacheDatabaseSharedManager extends GridCacheSharedManagerAdapter implements IgniteChangeGlobalStateSupport {
      /** MemoryPolicyConfiguration name reserved for internal caches. */
-     private static final String SYSTEM_MEMORY_POLICY_NAME = "sysMemPlc";
+     static final String SYSTEM_MEMORY_POLICY_NAME = "sysMemPlc";
  
      /** Minimum size of memory chunk */
 -    private static final long MIN_PAGE_MEMORY_SIZE = 1024 * 1024;
 +    private static final long MIN_PAGE_MEMORY_SIZE = 10 * 1024 * 1024;
  
      /** */
      protected Map<String, MemoryPolicy> memPlcMap;
@@@ -123,6 -120,34 +127,34 @@@
      }
  
      /**
+      * Registers MBeans for all MemoryMetrics configured in this instance.
+      */
+     private void registerMetricsMBeans() {
+         IgniteConfiguration cfg = cctx.gridConfig();
+ 
 -        for (MemoryMetrics memMetrics : memMetricsMap.values())
 -            registerMetricsMBean((MemoryMetricsImpl) memMetrics, cfg);
++        for (MemoryPolicy memPlc : memPlcMap.values())
++            registerMetricsMBean((MemoryMetricsMXBean)memPlc.memoryMetrics(), cfg);
+     }
+ 
+     /**
+      * @param memMetrics Memory metrics.
+      */
 -    private void registerMetricsMBean(MemoryMetricsImpl memMetrics, IgniteConfiguration cfg) {
++    private void registerMetricsMBean(MemoryMetricsMXBean memMetrics, IgniteConfiguration cfg) {
+         try {
+             U.registerMBean(
+                     cfg.getMBeanServer(),
+                     cfg.getIgniteInstanceName(),
+                     "MemoryMetrics",
+                     memMetrics.getName(),
+                     memMetrics,
+                     MemoryMetricsMXBean.class);
+         }
+         catch (JMException e) {
 -            log.warning("Failed to register MBean for MemoryMetrics with name: '" + memMetrics.getName() + "'");
++            U.error(log, "Failed to register MBean for MemoryMetrics with name: '" + memMetrics.getName() + "'", e);
+         }
+     }
+ 
+     /**
       * @param dbCfg Database config.
       */
      protected void initPageMemoryDataStructures(MemoryConfiguration dbCfg) throws IgniteCheckedException {
@@@ -179,58 -204,69 +211,63 @@@
          if (memPlcsCfgs == null) {
              //reserve place for default and system memory policies
              memPlcMap = U.newHashMap(2);
 -            memMetricsMap = U.newHashMap(2);
  
-             MemoryPolicyConfiguration dfltPlcCfg = memCfg.createDefaultPolicyConfig();
- 
-             dfltMemPlc = initMemoryPolicy(dfltPlcCfg, memCfg);
 -            addMemoryPolicy(dbCfg,
 -                    dbCfg.createDefaultPolicyConfig(),
 -                    DFLT_MEM_PLC_DEFAULT_NAME);
++            addMemoryPolicy(memCfg,
++                memCfg.createDefaultPolicyConfig(),
++                DFLT_MEM_PLC_DEFAULT_NAME);
  
 -            log.warning("No user-defined default MemoryPolicy found; system default of 1GB size will be used.");
 +            U.warn(log, "No user-defined default MemoryPolicy found; system default of 1GB size will be used.");
          }
          else {
 -            String dfltMemPlcName = dbCfg.getDefaultMemoryPolicyName();
 +            String dfltMemPlcName = memCfg.getDefaultMemoryPolicyName();
  
-             if (dfltMemPlcName == null) {
+             if (DFLT_MEM_PLC_DEFAULT_NAME.equals(dfltMemPlcName) && !hasCustomDefaultMemoryPolicy(memPlcsCfgs)) {
                  //reserve additional place for default and system memory policies
                  memPlcMap = U.newHashMap(memPlcsCfgs.length + 2);
 -                memMetricsMap = U.newHashMap(memPlcsCfgs.length + 2);
  
-                 MemoryPolicyConfiguration dfltPlcCfg = memCfg.createDefaultPolicyConfig();
- 
-                 dfltMemPlc = initMemoryPolicy(dfltPlcCfg, memCfg);
 -                addMemoryPolicy(dbCfg,
 -                        dbCfg.createDefaultPolicyConfig(),
 -                        DFLT_MEM_PLC_DEFAULT_NAME);
++                addMemoryPolicy(memCfg,
++                    memCfg.createDefaultPolicyConfig(),
++                    DFLT_MEM_PLC_DEFAULT_NAME);
  
 -                log.warning("No user-defined default MemoryPolicy found; system default will be allocated.");
 +                U.warn(log, "No user-defined default MemoryPolicy found; system default of 1GB size will be used.");
              }
 -            else {
 +            else
-                 //reserve additional place for system memory policy only
+                 //reserve additional space for system memory policy only
                  memPlcMap = U.newHashMap(memPlcsCfgs.length + 1);
 -                memMetricsMap = U.newHashMap(memPlcsCfgs.length + 1);
 -            }
  
-             for (MemoryPolicyConfiguration memPlcCfg : memPlcsCfgs) {
-                 MemoryPolicy memPlc = initMemoryPolicy(memPlcCfg, memCfg);
- 
-                 if (memPlcCfg.getName().equals(dfltMemPlcName))
-                     dfltMemPlc = memPlc;
-             }
+             for (MemoryPolicyConfiguration memPlcCfg : memPlcsCfgs)
 -                addMemoryPolicy(dbCfg, memPlcCfg, memPlcCfg.getName());
++                addMemoryPolicy(memCfg, memPlcCfg, memPlcCfg.getName());
          }
  
-         MemoryPolicyConfiguration sysPlcCfg = createSystemMemoryPolicy(memCfg.getSystemCacheMemorySize());
- 
-         initMemoryPolicy(sysPlcCfg, memCfg);
 -        addMemoryPolicy(dbCfg,
 -                createSystemMemoryPolicy(dbCfg.getSystemCacheMemorySize()),
 -                SYSTEM_MEMORY_POLICY_NAME);
++        addMemoryPolicy(memCfg,
++            createSystemMemoryPolicy(memCfg.getSystemCacheMemorySize()),
++            SYSTEM_MEMORY_POLICY_NAME);
      }
  
      /**
-      * @param plcCfg Policy configuration.
-      * @param memCfg Memory configuration.
-      * @return Initialized memory policy.
+      * @param dbCfg Database config.
+      * @param memPlcCfg Memory policy config.
+      * @param memPlcName Memory policy name.
       */
-     private MemoryPolicy initMemoryPolicy(MemoryPolicyConfiguration plcCfg, MemoryConfiguration memCfg) {
-         MemoryMetricsImpl sysMemMetrics = new MemoryMetricsImpl(plcCfg);
+     private void addMemoryPolicy(MemoryConfiguration dbCfg,
+                                  MemoryPolicyConfiguration memPlcCfg,
+                                  String memPlcName) {
+         String dfltMemPlcName = dbCfg.getDefaultMemoryPolicyName();
+ 
+         if (dfltMemPlcName == null)
+             dfltMemPlcName = DFLT_MEM_PLC_DEFAULT_NAME;
  
-         MemoryPolicy plc = initMemory(memCfg, plcCfg, sysMemMetrics);
+         MemoryMetricsImpl memMetrics = new MemoryMetricsImpl(memPlcCfg);
  
-         memPlcMap.put(plcCfg.getName(), plc);
+         MemoryPolicy memPlc = initMemory(dbCfg, memPlcCfg, memMetrics);
  
-         registerMetricsMBean(sysMemMetrics);
+         memPlcMap.put(memPlcName, memPlc);
  
-         return plc;
 -        memMetricsMap.put(memPlcName, memMetrics);
 -
+         if (memPlcName.equals(dfltMemPlcName))
+             dfltMemPlc = memPlc;
+         else if (memPlcName.equals(DFLT_MEM_PLC_DEFAULT_NAME))
 -            log.warning("Memory Policy with name 'default' isn't used as a default. " +
++            U.warn(log, "Memory Policy with name 'default' isn't used as a default. " +
+                     "Please check Memory Policies configuration.");
      }
  
      /**
@@@ -298,30 -330,12 +327,30 @@@
       * @param plcNames All MemoryPolicy names.
       * @throws IgniteCheckedException In case of validation violation.
       */
 -    private static void checkDefaultPolicyConfiguration(String dfltPlcName, Set<String> plcNames) throws IgniteCheckedException {
 +    private static void checkDefaultPolicyConfiguration(
 +        String dfltPlcName,
 +        long dfltPlcSize,
 +        Collection<String> plcNames
 +    ) throws IgniteCheckedException {
 +        if (dfltPlcSize != -1) {
 +            if (dfltPlcName != null)
 +                throw new IgniteCheckedException("User-defined MemoryPolicy configuration " +
 +                    "and defaultMemoryPolicySize properties are set at the same time. " +
 +                    "Delete either MemoryConfiguration.defaultMemoryPolicySize property " +
 +                    "or user-defined default MemoryPolicy configuration");
 +
 +            if (dfltPlcSize < MIN_PAGE_MEMORY_SIZE)
 +                throw new IgniteCheckedException("User-defined default MemoryPolicy size is less than 1MB. " +
 +                        "Use MemoryConfiguration.defaultMemoryPolicySize property to set correct size.");
 +        }
 +
-         if (dfltPlcName != null) {
+         if (!DFLT_MEM_PLC_DEFAULT_NAME.equals(dfltPlcName)) {
              if (dfltPlcName.isEmpty())
                  throw new IgniteCheckedException("User-defined default MemoryPolicy name must be non-empty");
 +
              if (!plcNames.contains(dfltPlcName))
 -                throw new IgniteCheckedException("User-defined default MemoryPolicy name must be presented among configured MemoryPolices: " + dfltPlcName);
 +                throw new IgniteCheckedException("User-defined default MemoryPolicy name " +
 +                    "must be presented among configured MemoryPolices: " + dfltPlcName);
          }
      }
  

http://git-wip-us.apache.org/repos/asf/ignite/blob/eac6762b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
index acd0a1f,7fa2355..621b833
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
@@@ -242,7 -243,11 +243,11 @@@ public class IgfsDataManager extends Ig
       * @return Maximum number of bytes for IGFS data cache.
       */
      public long maxSpaceSize() {
-         return (igfsCtx.configuration().getMaxSpaceSize() <= 0) ? 0 : dataCachePrj.igfsDataSpaceMax();
+         MemoryPolicy plc = dataCachePrj.context().memoryPolicy();
+ 
 -        long size = plc != null ? plc.config().getSize() : 0;
++        long size = plc != null ? plc.config().getMaxSize() : 0;
+ 
+         return (size <= 0) ? 0 : size ;
      }
  
      /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/eac6762b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
index fde8cbf,59d334a..6f8728c
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
@@@ -10114,4 -10094,23 +10114,23 @@@ public abstract class IgniteUtils 
              throw new IgniteCheckedException(e);
          }
      }
+ 
+     /**
+      * Returns {@link GridIntIterator} for range of primitive integers.
+      * @param start Start.
+      * @param cnt Count.
+      */
+     public static GridIntIterator forRange(final int start, final int cnt) {
+         return new GridIntIterator() {
+             int c = 0;
+ 
+             @Override public boolean hasNext() {
+                 return c < cnt;
+             }
+ 
+             @Override public int next() {
+                 return start + c++;
+             }
+         };
+     }
 -}
 +}

http://git-wip-us.apache.org/repos/asf/ignite/blob/eac6762b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MemoryPolicyConfigValidationTest.java
----------------------------------------------------------------------
diff --cc modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MemoryPolicyConfigValidationTest.java
index 62278da,154e562..a1a05eb
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MemoryPolicyConfigValidationTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MemoryPolicyConfigValidationTest.java
@@@ -305,10 -217,10 +305,10 @@@ public class MemoryPolicyConfigValidati
          NAMES_CONFLICT("Two MemoryPolicies have the same name: "),
  
          /** */
-         RESERVED_MEMORY_POLICY_MISUSE("'sysMemPlc' policy name is reserved for internal use."),
+         SYSTEM_MEMORY_POLICY_NAME_MISUSE("'sysMemPlc' policy name is reserved for internal use."),
  
          /** */
 -        TOO_SMALL_MEMORY_SIZE("MemoryPolicy must have size more than 1MB: "),
 +        TOO_SMALL_MEMORY_SIZE("MemoryPolicy must have size more than 10MB "),
  
          /** */
          NULL_NAME_ON_USER_DEFINED_POLICY("User-defined MemoryPolicyConfiguration must have non-null and non-empty name."),

http://git-wip-us.apache.org/repos/asf/ignite/blob/eac6762b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/database/MemoryPolicyInitializationTest.java
----------------------------------------------------------------------
diff --cc modules/core/src/test/java/org/apache/ignite/internal/processors/cache/database/MemoryPolicyInitializationTest.java
index 0000000,1e3f328..a1c9728
mode 000000,100644..100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/database/MemoryPolicyInitializationTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/database/MemoryPolicyInitializationTest.java
@@@ -1,0 -1,307 +1,307 @@@
+ /*
+  * Licensed to the Apache Software Foundation (ASF) under one or more
+  * contributor license agreements.  See the NOTICE file distributed with
+  * this work for additional information regarding copyright ownership.
+  * The ASF licenses this file to You under the Apache License, Version 2.0
+  * (the "License"); you may not use this file except in compliance with
+  * the License.  You may obtain a copy of the License at
+  *
+  *      http://www.apache.org/licenses/LICENSE-2.0
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+ package org.apache.ignite.internal.processors.cache.database;
+ 
+ import java.util.Collection;
+ import org.apache.ignite.IgniteCache;
+ import org.apache.ignite.configuration.CacheConfiguration;
+ import org.apache.ignite.configuration.IgniteConfiguration;
+ import org.apache.ignite.configuration.MemoryConfiguration;
+ import org.apache.ignite.configuration.MemoryPolicyConfiguration;
+ import org.apache.ignite.internal.IgniteEx;
+ import org.apache.ignite.internal.processors.cache.GridCacheContext;
+ import org.apache.ignite.internal.util.typedef.internal.U;
+ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+ 
+ import static org.apache.ignite.configuration.MemoryConfiguration.DFLT_MEM_PLC_DEFAULT_NAME;
+ 
+ /**
+  *
+  */
+ public class MemoryPolicyInitializationTest extends GridCommonAbstractTest {
+     /** */
+     private static final String CUSTOM_NON_DEFAULT_MEM_PLC_NAME = "custom_mem_plc";
+ 
+     /** */
+     private static final long USER_CUSTOM_MEM_PLC_SIZE = 10 * 1024 * 1024;
+ 
+     /** */
+     private static final long USER_DEFAULT_MEM_PLC_SIZE = 99 * 1024 * 1024;
+ 
+     /** */
+     private MemoryConfiguration memCfg;
+ 
+     /** {@inheritDoc} */
+     @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
+         IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
+ 
+         cfg.setMemoryConfiguration(memCfg);
+ 
+         return cfg;
+     }
+ 
+     /** {@inheritDoc} */
+     @Override protected void beforeTest() throws Exception {
+         memCfg = null;
+     }
+ 
+     /** {@inheritDoc} */
+     @Override protected void afterTest() throws Exception {
+         stopAllGrids();
+     }
+ 
+     /**
+      * Verifies that expected memory policies are allocated when used doesn't provide any MemoryPolicyConfiguration.
+      */
+     public void testNoConfigProvided() throws Exception {
+         memCfg = null;
+ 
+         IgniteEx ignite = startGrid(0);
+ 
+         Collection<MemoryPolicy> allMemPlcs = ignite.context().cache().context().database().memoryPolicies();
+ 
+         assertTrue(allMemPlcs.size() == 2);
+ 
+         verifyDefaultAndSystemMemoryPolicies(allMemPlcs);
+     }
+ 
+     /**
+      * Verifies that expected memory policies are allocated when used provides MemoryPolicyConfiguration
+      * with non-default custom MemoryPolicy.
+      */
+     public void testCustomConfigNoDefault() throws Exception {
+         prepareCustomNoDefaultConfig();
+ 
+         IgniteEx ignite = startGrid(0);
+ 
+         Collection<MemoryPolicy> allMemPlcs = ignite.context().cache().context().database().memoryPolicies();
+ 
+         assertTrue(allMemPlcs.size() == 3);
+ 
+         verifyDefaultAndSystemMemoryPolicies(allMemPlcs);
+ 
+         assertTrue("Custom non-default memory policy is not presented",
+                 isMemoryPolicyPresented(allMemPlcs, CUSTOM_NON_DEFAULT_MEM_PLC_NAME));
+     }
+ 
+     /**
+      * User is allowed to configure memory policy with 'default' name,
+      * in that case Ignite instance will use this user-defined memory policy as a default one.
+      */
+     public void testCustomConfigOverridesDefault() throws Exception {
+         prepareCustomConfigWithOverridingDefault();
+ 
+         IgniteEx ignite = startGrid(0);
+ 
+         IgniteCacheDatabaseSharedManager dbMgr = ignite.context().cache().context().database();
+ 
+         Collection<MemoryPolicy> allMemPlcs = dbMgr.memoryPolicies();
+ 
+         assertTrue(allMemPlcs.size() == 2);
+ 
+         verifyDefaultAndSystemMemoryPolicies(allMemPlcs);
+ 
+         MemoryPolicy dfltMemPlc = U.field(dbMgr, "dfltMemPlc");
+ 
 -        assertTrue(dfltMemPlc.config().getSize() == USER_DEFAULT_MEM_PLC_SIZE);
++        assertTrue(dfltMemPlc.config().getMaxSize() == USER_DEFAULT_MEM_PLC_SIZE);
+     }
+ 
+     /**
+      * User is allowed to define fully custom memory policy and make it default by setting its name to memory config.
+      *
+      * At the same time user still can create a memory policy with name 'default'
+      * which although won't be used as default.
+      */
+     public void testCustomConfigOverridesDefaultNameAndDeclaresDefault() throws Exception {
+         prepareCustomConfigWithOverriddenDefaultName();
+ 
+         IgniteEx ignite = startGrid(0);
+ 
+         IgniteCacheDatabaseSharedManager dbMgr = ignite.context().cache().context().database();
+ 
+         Collection<MemoryPolicy> allMemPlcs = dbMgr.memoryPolicies();
+ 
+         assertTrue(allMemPlcs.size() == 3);
+ 
+         verifyDefaultAndSystemMemoryPolicies(allMemPlcs);
+ 
+         MemoryPolicy dfltMemPlc = U.field(dbMgr, "dfltMemPlc");
+ 
 -        assertTrue(dfltMemPlc.config().getSize() == USER_CUSTOM_MEM_PLC_SIZE);
++        assertTrue(dfltMemPlc.config().getMaxSize() == USER_CUSTOM_MEM_PLC_SIZE);
+     }
+ 
+     /**
+      * Test for verification that caches with not specified memory policy name,
+      * with specified default memory policy name and specified custom memory policy name
+      * all started with correct memory policy.
+      */
+     public void testCachesOnOverriddenMemoryPolicy() throws Exception {
+         prepareCustomConfigWithOverridingDefaultAndCustom();
+ 
+         IgniteEx ignite = startGrid(0);
+ 
+         CacheConfiguration cache1Cfg = new CacheConfiguration()
+                 .setName("cache1");
+ 
+         IgniteCache cache1 = ignite.createCache(cache1Cfg);
+ 
+         verifyCacheMemoryPolicy(cache1, DFLT_MEM_PLC_DEFAULT_NAME);
+ 
+         CacheConfiguration cache2Cfg = new CacheConfiguration()
+                 .setName("cache2")
+                 .setMemoryPolicyName(CUSTOM_NON_DEFAULT_MEM_PLC_NAME);
+ 
+         IgniteCache cache2 = ignite.createCache(cache2Cfg);
+ 
+         verifyCacheMemoryPolicy(cache2, CUSTOM_NON_DEFAULT_MEM_PLC_NAME);
+ 
+         CacheConfiguration cache3Cfg = new CacheConfiguration()
+                 .setName("cache3")
+                 .setMemoryPolicyName(DFLT_MEM_PLC_DEFAULT_NAME);
+ 
+         IgniteCache cache3 = ignite.createCache(cache3Cfg);
+ 
+         verifyCacheMemoryPolicy(cache3, DFLT_MEM_PLC_DEFAULT_NAME);
+     }
+ 
+     /**
+      * Test for verification that caches with not specified memory policy name,
+      * with specified default memory policy name and specified custom memory policy name
+      * all started with correct memory policy.
+      */
+     public void testCachesOnUserDefinedDefaultMemoryPolicy() throws Exception {
+         prepareCustomConfigWithOverriddenDefaultName();
+ 
+         IgniteEx ignite = startGrid(0);
+ 
+         CacheConfiguration cache1Cfg = new CacheConfiguration()
+                 .setName("cache1");
+ 
+         IgniteCache cache1 = ignite.createCache(cache1Cfg);
+ 
+         verifyCacheMemoryPolicy(cache1, CUSTOM_NON_DEFAULT_MEM_PLC_NAME);
+ 
+         CacheConfiguration cache2Cfg = new CacheConfiguration()
+                 .setName("cache2")
+                 .setMemoryPolicyName(CUSTOM_NON_DEFAULT_MEM_PLC_NAME);
+ 
+         IgniteCache cache2 = ignite.createCache(cache2Cfg);
+ 
+         verifyCacheMemoryPolicy(cache2, CUSTOM_NON_DEFAULT_MEM_PLC_NAME);
+ 
+         CacheConfiguration cache3Cfg = new CacheConfiguration()
+                 .setName("cache3")
+                 .setMemoryPolicyName(DFLT_MEM_PLC_DEFAULT_NAME);
+ 
+         IgniteCache cache3 = ignite.createCache(cache3Cfg);
+ 
+         verifyCacheMemoryPolicy(cache3, DFLT_MEM_PLC_DEFAULT_NAME);
+     }
+ 
+     /**
+      * @param cache Cache.
+      * @param plcName Policy name.
+      */
+     private void verifyCacheMemoryPolicy(IgniteCache cache, String plcName) {
+         GridCacheContext ctx = U.field(cache, "ctx");
+ 
+         assertEquals(plcName, ctx.memoryPolicy().config().getName());
+     }
+ 
+     /**
+      *
+      */
+     private void prepareCustomConfigWithOverriddenDefaultName() {
+         memCfg = new MemoryConfiguration();
+ 
+         memCfg.setDefaultMemoryPolicyName(CUSTOM_NON_DEFAULT_MEM_PLC_NAME);
+ 
+         memCfg.setMemoryPolicies(new MemoryPolicyConfiguration()
+                 .setName(CUSTOM_NON_DEFAULT_MEM_PLC_NAME)
 -                .setSize(USER_CUSTOM_MEM_PLC_SIZE),
++                .setMaxSize(USER_CUSTOM_MEM_PLC_SIZE),
+ 
+                 new MemoryPolicyConfiguration()
+                 .setName(DFLT_MEM_PLC_DEFAULT_NAME)
 -                .setSize(USER_DEFAULT_MEM_PLC_SIZE)
++                .setMaxSize(USER_DEFAULT_MEM_PLC_SIZE)
+         );
+     }
+ 
+ 
+     /**
+      *
+      */
+     private void prepareCustomConfigWithOverridingDefault() {
+         memCfg = new MemoryConfiguration();
+ 
+         memCfg.setMemoryPolicies(new MemoryPolicyConfiguration()
+                 .setName(DFLT_MEM_PLC_DEFAULT_NAME)
 -                .setSize(USER_DEFAULT_MEM_PLC_SIZE)
++                .setMaxSize(USER_DEFAULT_MEM_PLC_SIZE)
+         );
+     }
+ 
+     /**
+      *
+      */
+     private void prepareCustomConfigWithOverridingDefaultAndCustom() {
+         memCfg = new MemoryConfiguration();
+ 
+         memCfg.setMemoryPolicies(new MemoryPolicyConfiguration()
+                 .setName(DFLT_MEM_PLC_DEFAULT_NAME)
 -                .setSize(USER_DEFAULT_MEM_PLC_SIZE),
++                .setMaxSize(USER_DEFAULT_MEM_PLC_SIZE),
+ 
+                 new MemoryPolicyConfiguration()
+                 .setName(CUSTOM_NON_DEFAULT_MEM_PLC_NAME)
 -                .setSize(USER_CUSTOM_MEM_PLC_SIZE)
++                .setMaxSize(USER_CUSTOM_MEM_PLC_SIZE)
+         );
+     }
+ 
+     /**
+      * @param allMemPlcs Collection of all memory policies.
+      */
+     private void verifyDefaultAndSystemMemoryPolicies(Collection<MemoryPolicy> allMemPlcs) {
+         assertTrue("Default memory policy is not presented",
+                 isMemoryPolicyPresented(allMemPlcs, DFLT_MEM_PLC_DEFAULT_NAME));
+ 
+         assertTrue("System memory policy is not presented",
+                 isMemoryPolicyPresented(allMemPlcs, IgniteCacheDatabaseSharedManager.SYSTEM_MEMORY_POLICY_NAME));
+     }
+ 
+     /**
+      *
+      */
+     private void prepareCustomNoDefaultConfig() {
+         memCfg = new MemoryConfiguration();
+ 
+         memCfg.setMemoryPolicies(new MemoryPolicyConfiguration()
+                 .setName(CUSTOM_NON_DEFAULT_MEM_PLC_NAME)
 -                .setSize(USER_CUSTOM_MEM_PLC_SIZE)
++                .setMaxSize(USER_CUSTOM_MEM_PLC_SIZE)
+         );
+     }
+ 
+     /**
+      * @param memPlcs Collection of memory policies.
+      * @param nameToVerify Excepted name of memory policy.
+      */
+     private boolean isMemoryPolicyPresented(Collection<MemoryPolicy> memPlcs, String nameToVerify) {
+         for (MemoryPolicy memPlc : memPlcs) {
+             if (nameToVerify.equals(memPlc.config().getName()))
+                 return true;
+         }
+ 
+         return false;
+     }
+ }

http://git-wip-us.apache.org/repos/asf/ignite/blob/eac6762b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsSizeSelfTest.java
----------------------------------------------------------------------
diff --cc modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsSizeSelfTest.java
index 645f341,fbe0872..456971a
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsSizeSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsSizeSelfTest.java
@@@ -386,7 -390,22 +390,22 @@@ public class IgfsSizeSelfTest extends I
       * @throws Exception If failed.
       */
      private void checkOversize() throws Exception {
-         igfsMaxData = BLOCK_SIZE;
+         final long maxSize = 32 * 1024 * 1024;
+ 
+         memIgfsdDataPlcSetter = new IgniteInClosure<IgniteConfiguration>() {
+             @Override public void apply(IgniteConfiguration cfg) {
+                 String memPlcName = "igfsDataMemPlc";
+ 
+                 cfg.setMemoryConfiguration(new MemoryConfiguration().setMemoryPolicies(
 -                    new MemoryPolicyConfiguration().setSize(maxSize).setName(memPlcName)));
++                    new MemoryPolicyConfiguration().setMaxSize(maxSize).setName(memPlcName)));
+ 
+                 FileSystemConfiguration igfsCfg = cfg.getFileSystemConfiguration()[0];
+ 
+                 igfsCfg.getDataCacheConfiguration().setMemoryPolicyName(memPlcName);
+ 
+                 cfg.setCacheConfiguration(new CacheConfiguration().setName("QQQ").setMemoryPolicyName(memPlcName));
+             }
+         };
  
          startUp();
  

http://git-wip-us.apache.org/repos/asf/ignite/blob/eac6762b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQueryAbstractSelfTest.java
----------------------------------------------------------------------
diff --cc modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQueryAbstractSelfTest.java
index 0000000,708fb1d..0a0afb4
mode 000000,100644..100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQueryAbstractSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQueryAbstractSelfTest.java
@@@ -1,0 -1,655 +1,652 @@@
+ /*
+  * 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.near;
+ 
+ import java.io.Serializable;
+ import java.util.ArrayList;
+ import java.util.Arrays;
+ import java.util.Collections;
+ import java.util.Comparator;
+ import java.util.List;
+ import java.util.Map;
+ import java.util.NavigableMap;
+ import java.util.TreeMap;
+ import java.util.UUID;
+ import javax.cache.Cache;
+ import javax.cache.CacheException;
+ import org.apache.ignite.Ignite;
+ import org.apache.ignite.IgniteCache;
+ import org.apache.ignite.IgniteDataStreamer;
+ import org.apache.ignite.IgniteException;
+ import org.apache.ignite.binary.BinaryObject;
+ import org.apache.ignite.cache.CacheMode;
+ import org.apache.ignite.cache.affinity.AffinityFunction;
+ import org.apache.ignite.cache.affinity.AffinityFunctionContext;
+ import org.apache.ignite.cache.affinity.AffinityKeyMapped;
+ import org.apache.ignite.cache.query.SqlFieldsQuery;
+ import org.apache.ignite.cache.query.SqlQuery;
+ import org.apache.ignite.cache.query.annotations.QuerySqlField;
+ import org.apache.ignite.cluster.ClusterNode;
+ import org.apache.ignite.configuration.CacheConfiguration;
+ import org.apache.ignite.configuration.IgniteConfiguration;
+ import org.apache.ignite.configuration.MemoryConfiguration;
 -import org.apache.ignite.configuration.MemoryPolicyConfiguration;
+ import org.apache.ignite.internal.IgniteInterruptedCheckedException;
+ import org.apache.ignite.internal.util.GridRandom;
+ import org.apache.ignite.internal.util.typedef.F;
+ import org.apache.ignite.internal.util.typedef.X;
+ import org.apache.ignite.internal.util.typedef.internal.U;
+ import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+ import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+ import org.apache.ignite.util.AttributeNodeFilter;
+ import org.jsr166.ThreadLocalRandom8;
+ 
+ import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+ import static org.apache.ignite.cache.CacheRebalanceMode.SYNC;
+ import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
+ 
+ /**
+  * Abstract test for queries over explicit partitions.
+  */
+ public abstract class IgniteCacheDistributedPartitionQueryAbstractSelfTest extends GridCommonAbstractTest {
+     /** Join query for test. */
+     private static final String JOIN_QRY = "select cl._KEY, de.depositId, de.regionId from " +
+         "\"cl\".Client cl, \"de\".Deposit de, \"re\".Region re where cl.clientId=de.clientId and de.regionId=re._KEY";
+ 
+     /** Region node attribute name. */
+     private static final String REGION_ATTR_NAME = "reg";
+ 
+     /** Grids count. */
+     protected static final int GRIDS_COUNT = 10;
+ 
+     /** IP finder. */
+     private static final TcpDiscoveryVmIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+ 
+     /** Partitions per region distribution. */
+     protected static final int[] PARTS_PER_REGION = new int[] {10, 20, 30, 40, 24};
+ 
+     /** Unmapped region id. */
+     protected static final int UNMAPPED_REGION = PARTS_PER_REGION.length;
+ 
+     /** Clients per partition. */
+     protected static final int CLIENTS_PER_PARTITION = 1;
+ 
+     /** Total clients. */
+     private static final int TOTAL_CLIENTS;
+ 
+     /** Affinity function to use on partitioned caches. */
+     private static final AffinityFunction AFFINITY = new RegionAwareAffinityFunction();
+ 
+     /** Partitions count. */
+     private static final int PARTS_COUNT;
+ 
+     /** Regions to partitions mapping. */
+     protected static final NavigableMap<Integer, List<Integer>> REGION_TO_PART_MAP = new TreeMap<>();
+ 
+     /** Query threads count. */
+     protected static final int QUERY_THREADS_CNT = 4;
+ 
+     /** Restarting threads count. */
+     protected static final int RESTART_THREADS_CNT = 2;
+ 
+     /** Node stop time. */
+     protected static final int NODE_RESTART_TIME = 1_000;
+ 
+     static {
+         int total = 0, parts = 0, p = 0, regionId = 1;
+ 
+         for (int regCnt : PARTS_PER_REGION) {
+             total += regCnt * CLIENTS_PER_PARTITION;
+ 
+             parts += regCnt;
+ 
+             REGION_TO_PART_MAP.put(regionId++, Arrays.asList(p, regCnt));
+ 
+             p += regCnt;
+         }
+ 
+         /** Last region was left empty intentionally, see {@link #UNMAPPED_REGION} */
+         TOTAL_CLIENTS = total - PARTS_PER_REGION[PARTS_PER_REGION.length - 1] * CLIENTS_PER_PARTITION;
+ 
+         PARTS_COUNT = parts;
+     }
+ 
+     /** Deposits per client. */
+     public static final int DEPOSITS_PER_CLIENT = 10;
+ 
+     /** Rnd. */
+     protected GridRandom rnd = new GridRandom();
+ 
+     /** {@inheritDoc} */
+     @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+         IgniteConfiguration cfg = super.getConfiguration(gridName);
+ 
 -        MemoryConfiguration memCfg = new MemoryConfiguration();
 -        memCfg.setDefaultMemoryPolicyName("default");
 -        memCfg.setMemoryPolicies(new MemoryPolicyConfiguration().setName("default").setSize(20 * 1024 * 1024));
++        MemoryConfiguration memCfg = new MemoryConfiguration().setDefaultMemoryPolicySize(20 * 1024 * 1024);
+ 
+         cfg.setMemoryConfiguration(memCfg);
+ 
+         TcpDiscoverySpi spi = (TcpDiscoverySpi)cfg.getDiscoverySpi();
+         spi.setIpFinder(IP_FINDER);
+ 
+         cfg.setDiscoverySpi(spi);
+ 
+         /** Clients cache */
+         CacheConfiguration<ClientKey, Client> clientCfg = new CacheConfiguration<>();
+         clientCfg.setName("cl");
+         clientCfg.setWriteSynchronizationMode(FULL_SYNC);
+         clientCfg.setAtomicityMode(TRANSACTIONAL);
+         clientCfg.setRebalanceMode(SYNC);
+         clientCfg.setBackups(2);
+         clientCfg.setAffinity(AFFINITY);
+         clientCfg.setIndexedTypes(ClientKey.class, Client.class);
+ 
+         /** Deposits cache */
+         CacheConfiguration<DepositKey, Deposit> depoCfg = new CacheConfiguration<>();
+         depoCfg.setName("de");
+         depoCfg.setWriteSynchronizationMode(FULL_SYNC);
+         depoCfg.setAtomicityMode(TRANSACTIONAL);
+         depoCfg.setRebalanceMode(SYNC);
+         depoCfg.setBackups(2);
+         depoCfg.setAffinity(AFFINITY);
+         depoCfg.setIndexedTypes(DepositKey.class, Deposit.class);
+ 
+         /** Regions cache. Uses default affinity. */
+         CacheConfiguration<Integer, Region> regionCfg = new CacheConfiguration<>();
+         regionCfg.setName("re");
+         regionCfg.setWriteSynchronizationMode(FULL_SYNC);
+         regionCfg.setAtomicityMode(TRANSACTIONAL);
+         regionCfg.setRebalanceMode(SYNC);
+         regionCfg.setCacheMode(CacheMode.REPLICATED);
+         regionCfg.setIndexedTypes(Integer.class, Region.class);
+ 
+         cfg.setCacheConfiguration(clientCfg, depoCfg, regionCfg);
+ 
+         if ("client".equals(gridName))
+             cfg.setClientMode(true);
+         else {
+             Integer reg = regionForGrid(gridName);
+ 
+             cfg.setUserAttributes(F.asMap(REGION_ATTR_NAME, reg));
+ 
+             log().info("Assigned region " + reg + " to grid " + gridName);
+         }
+ 
+         return cfg;
+     }
+ 
+     /** */
+     private static final class RegionAwareAffinityFunction implements AffinityFunction {
+         /** {@inheritDoc} */
+         @Override public void reset() {
+             // No-op.
+         }
+ 
+         /** {@inheritDoc} */
+         @Override public int partitions() {
+             return PARTS_COUNT;
+         }
+ 
+         /** {@inheritDoc} */
+         @Override public int partition(Object key) {
+             Integer regionId;
+ 
+             if (key instanceof RegionKey)
+                 regionId = ((RegionKey)key).regionId;
+             else if (key instanceof BinaryObject) {
+                 BinaryObject bo = (BinaryObject)key;
+ 
+                 regionId = bo.field("regionId");
+             }
+             else
+                 throw new IgniteException("Unsupported key for region aware affinity");
+ 
+             List<Integer> range = REGION_TO_PART_MAP.get(regionId);
+ 
+             Integer cnt = range.get(1);
+ 
+             return U.safeAbs(key.hashCode() % cnt) + range.get(0); // Assign partition in region's range.
+         }
+ 
+         /** {@inheritDoc} */
+         @Override public List<List<ClusterNode>> assignPartitions(AffinityFunctionContext affCtx) {
+             List<ClusterNode> nodes = affCtx.currentTopologySnapshot();
+ 
+             List<List<ClusterNode>> assignment = new ArrayList<>(PARTS_COUNT);
+ 
+             for (int p = 0; p < PARTS_COUNT; p++) {
+                 // Get region for partition.
+                 int regionId = regionForPart(p);
+ 
+                 // Filter all nodes for region.
+                 AttributeNodeFilter f = new AttributeNodeFilter(REGION_ATTR_NAME, regionId);
+ 
+                 List<ClusterNode> regionNodes = new ArrayList<>();
+ 
+                 for (ClusterNode node : nodes)
+                     if (f.apply(node))
+                         regionNodes.add(node);
+ 
+                 final int cp = p;
+ 
+                 Collections.sort(regionNodes, new Comparator<ClusterNode>() {
+                     @Override public int compare(ClusterNode o1, ClusterNode o2) {
+                         return Long.compare(hash(cp, o1), hash(cp, o2));
+                     }
+                 });
+ 
+                 assignment.add(regionNodes);
+             }
+ 
+             return assignment;
+         }
+ 
+         /** {@inheritDoc} */
+         @Override public void removeNode(UUID nodeId) {
+             // No-op.
+         }
+ 
+         /**
+          * @param part Partition.
+          */
+         protected int regionForPart(int part) {
+             for (Map.Entry<Integer, List<Integer>> entry : REGION_TO_PART_MAP.entrySet()) {
+                 List<Integer> range = entry.getValue();
+ 
+                 if (range.get(0) <= part && part < range.get(0) + range.get(1))
+                     return entry.getKey();
+             }
+ 
+             throw new IgniteException("Failed to find zone for partition");
+         }
+ 
+         /**
+          * @param part Partition.
+          * @param obj Object.
+          */
+         private long hash(int part, Object obj) {
+             long x = ((long)part << 32) | obj.hashCode();
+             x ^= x >>> 12;
+             x ^= x << 25;
+             x ^= x >>> 27;
+             return x * 2685821657736338717L;
+         }
+     }
+ 
+     /**
+      * Assigns a region to grid part.
+      *
+      * @param gridName Grid name.
+      */
+     protected Integer regionForGrid(String gridName) {
+         char c = gridName.charAt(gridName.length() - 1);
+         switch (c) {
+             case '0':
+                 return 1;
+             case '1':
+             case '2':
+                 return 2;
+             case '3':
+             case '4':
+             case '5':
+                 return 3;
+             default:
+                 return 4;
+         }
+     }
+ 
+     /** {@inheritDoc} */
+     @Override protected void beforeTestsStarted() throws Exception {
+         super.beforeTestsStarted();
+ 
+         int sum1 = 0;
+         for (List<Integer> range : REGION_TO_PART_MAP.values())
+             sum1 += range.get(1);
+ 
+         assertEquals("Illegal partition per region distribution", PARTS_COUNT, sum1);
+ 
+         startGridsMultiThreaded(GRIDS_COUNT);
+ 
+         startGrid("client");
+ 
+         // Fill caches.
+         int clientId = 1;
+         int depositId = 1;
+         int regionId = 1;
+         int p = 1; // Percents counter. Log message will be printed 10 times.
+ 
+         try (IgniteDataStreamer<ClientKey, Client> clStr = grid(0).dataStreamer("cl");
+              IgniteDataStreamer<DepositKey, Deposit> depStr = grid(0).dataStreamer("de")) {
+             for (int cnt : PARTS_PER_REGION) {
+                 // Last region was left empty intentionally.
+                 if (regionId < PARTS_PER_REGION.length) {
+                     for (int i = 0; i < cnt * CLIENTS_PER_PARTITION; i++) {
+                         ClientKey ck = new ClientKey(clientId, regionId);
+ 
+                         Client cl = new Client();
+                         cl.firstName = "First_Name_" + clientId;
+                         cl.lastName = "Last_Name_" + clientId;
+                         cl.passport = clientId * 1_000;
+ 
+                         clStr.addData(ck, cl);
+ 
+                         for (int j = 0; j < DEPOSITS_PER_CLIENT; j++) {
+                             DepositKey dk = new DepositKey(depositId++, new ClientKey(clientId, regionId));
+ 
+                             Deposit depo = new Deposit();
+                             depo.amount = ThreadLocalRandom8.current().nextLong(1_000_001);
+                             depStr.addData(dk, depo);
+                         }
+ 
+                         if (clientId / (float)TOTAL_CLIENTS >= p / 10f) {
+                             log().info("Loaded " + clientId + " of " + TOTAL_CLIENTS);
+ 
+                             p++;
+                         }
+ 
+                         clientId++;
+                     }
+                 }
+ 
+                 Region region = new Region();
+                 region.name = "Region_" + regionId;
+                 region.code = regionId * 10;
+ 
+                 grid(0).cache("re").put(regionId, region);
+ 
+                 regionId++;
+             }
+         }
+     }
+ 
+     /** {@inheritDoc} */
+     @Override protected void afterTestsStopped() throws Exception {
+         super.afterTestsStopped();
+ 
+         stopAllGrids();
+     }
+ 
+     /**
+      * @param orig Originator.
+      */
+     protected void doTestRegionQuery(Ignite orig) {
+         IgniteCache<ClientKey, Client> cl = orig.cache("cl");
+ 
+         for (int regionId = 1; regionId <= PARTS_PER_REGION.length; regionId++) {
+             SqlQuery<ClientKey, Client> qry1 = new SqlQuery<>(Client.class, "regionId=?");
+             qry1.setArgs(regionId);
+ 
+             List<Cache.Entry<ClientKey, Client>> clients1 = cl.query(qry1).getAll();
+ 
+             int expRegionCnt = regionId == 5 ? 0 : PARTS_PER_REGION[regionId - 1] * CLIENTS_PER_PARTITION;
+ 
+             assertEquals("Region " + regionId + " count", expRegionCnt, clients1.size());
+ 
+             validateClients(regionId, clients1);
+ 
+             // Repeat the same query with partition set condition.
+             List<Integer> range = REGION_TO_PART_MAP.get(regionId);
+ 
+             SqlQuery<ClientKey, Client> qry2 = new SqlQuery<>(Client.class, "1=1");
+             qry2.setPartitions(createRange(range.get(0), range.get(1)));
+ 
+             try {
+                 List<Cache.Entry<ClientKey, Client>> clients2 = cl.query(qry2).getAll();
+ 
+                 assertEquals("Region " + regionId + " count with partition set", expRegionCnt, clients2.size());
+ 
+                 // Query must produce only results from single region.
+                 validateClients(regionId, clients2);
+ 
+                 if (regionId == UNMAPPED_REGION)
+                     fail();
+             } catch (CacheException ignored) {
+                 if (regionId != UNMAPPED_REGION)
+                     fail();
+             }
+         }
+     }
+ 
+     /** */
+     protected int[] createRange(int start, int cnt) {
+         int[] vals = new int[cnt];
+ 
+         for (int i = 0; i < cnt; i++)
+             vals[i] = start + i;
+ 
+         return vals;
+     }
+ 
+     /**
+      * @param orig Originator.
+      */
+     protected void doTestPartitionsQuery(Ignite orig) {
+         IgniteCache<ClientKey, Client> cl = orig.cache("cl");
+ 
+         for (int regionId = 1; regionId <= PARTS_PER_REGION.length; regionId++) {
+             log().info("Running test queries for region " + regionId);
+ 
+             List<Integer> range = REGION_TO_PART_MAP.get(regionId);
+ 
+             int[] parts = createRange(range.get(0), range.get(1));
+ 
+             int off = rnd.nextInt(parts.length);
+ 
+             int p1 = parts[off], p2 = parts[(off + (1 + rnd.nextInt(parts.length-1))) % parts.length];
+ 
+             log().info("Parts: " + p1 + " " + p2);
+ 
+             SqlQuery<ClientKey, Client> qry = new SqlQuery<>(Client.class, "1=1");
+ 
+             qry.setPartitions(p1, p2);
+ 
+             try {
+                 List<Cache.Entry<ClientKey, Client>> clients = cl.query(qry).getAll();
+ 
+                 // Query must produce only results from two partitions.
+                 for (Cache.Entry<ClientKey, Client> client : clients) {
+                     int p = orig.affinity("cl").partition(client.getKey());
+ 
+                     assertTrue("Incorrect partition for key", p == p1 || p == p2);
+                 }
+ 
+                 if (regionId == UNMAPPED_REGION)
+                     fail();
+             } catch (CacheException ignored) {
+                 if (regionId != UNMAPPED_REGION)
+                     fail();
+             }
+         }
+     }
+ 
+     /**
+      * @param orig Query originator.
+      * @param regionIds Region ids.
+      */
+     protected void doTestJoinQuery(Ignite orig, int... regionIds) {
+         IgniteCache<ClientKey, Client> cl = orig.cache("cl");
+ 
+         if (regionIds == null) {
+             regionIds = new int[PARTS_PER_REGION.length];
+ 
+             for (int i = 0; i < regionIds.length; i++)
+                 regionIds[i] = i + 1;
+         }
+ 
+         for (int regionId : regionIds) {
+             List<Integer> range = REGION_TO_PART_MAP.get(regionId);
+ 
+             SqlFieldsQuery qry = new SqlFieldsQuery(JOIN_QRY);
+ 
+             int[] pSet = createRange(range.get(0), 1 + rnd.nextInt(range.get(1) - 1));
+ 
+             qry.setPartitions(pSet);
+ 
+             try {
+                 List<List<?>> rows = cl.query(qry).getAll();
+ 
+                 for (List<?> row : rows) {
+                     ClientKey key = (ClientKey)row.get(0);
+ 
+                     int p = orig.affinity("cl").partition(key);
+ 
+                     assertTrue(Arrays.binarySearch(pSet, p) >= 0);
+                 }
+ 
+                 // Query must produce only results from single region.
+                 for (List<?> row : rows)
+                     assertEquals("Region id", regionId, ((Integer)row.get(2)).intValue());
+ 
+                 if (regionId == UNMAPPED_REGION)
+                     fail();
+             }
+             catch (CacheException ignored) {
+                 if (X.hasCause(ignored, InterruptedException.class, IgniteInterruptedCheckedException.class))
+                     return; // Allow interruptions.
+ 
+                 if (regionId != UNMAPPED_REGION)
+                     fail();
+             }
+         }
+     }
+ 
+     /**
+      * @param regionId Region id.
+      * @param clients Clients.
+      */
+     protected void validateClients(int regionId, List<Cache.Entry<ClientKey, Client>> clients) {
+         for (Cache.Entry<ClientKey, Client> entry : clients) {
+             List<Integer> range = REGION_TO_PART_MAP.get(regionId);
+ 
+             int start = range.get(0) * CLIENTS_PER_PARTITION;
+             int end = start + range.get(1) * CLIENTS_PER_PARTITION;
+ 
+             int clientId = entry.getKey().clientId;
+ 
+             assertTrue("Client id in range", start < clientId && start <= end);
+         }
+     }
+ 
+     /** */
+     protected static class ClientKey extends RegionKey {
+         /** Client id. */
+         @QuerySqlField(index = true)
+         protected int clientId;
+ 
+         /**
+          * @param clientId Client id.
+          * @param regionId Region id.
+          */
+         public ClientKey(int clientId, int regionId) {
+             this.clientId = clientId;
+             this.regionId = regionId;
+         }
+ 
+         /** {@inheritDoc} */
+         @Override public boolean equals(Object o) {
+             if (this == o)
+                 return true;
+             if (o == null || getClass() != o.getClass())
+                 return false;
+ 
+             ClientKey clientKey = (ClientKey)o;
+ 
+             return clientId == clientKey.clientId;
+ 
+         }
+ 
+         /** {@inheritDoc} */
+         @Override public int hashCode() {
+             return clientId;
+         }
+     }
+ 
+     /** */
+     protected static class DepositKey extends RegionKey {
+         @QuerySqlField(index = true)
+         protected int depositId;
+ 
+         @QuerySqlField(index = true)
+         protected int clientId;
+ 
+         /** Client id. */
+         @AffinityKeyMapped
+         protected ClientKey clientKey;
+ 
+         /**
+          * @param depositId Client id.
+          * @param clientKey Client key.
+          */
+         public DepositKey(int depositId, ClientKey clientKey) {
+             this.depositId = depositId;
+             this.clientId = clientKey.clientId;
+             this.regionId = clientKey.regionId;
+             this.clientKey = clientKey;
+         }
+ 
+         /** {@inheritDoc} */
+         @Override public boolean equals(Object o) {
+             if (this == o)
+                 return true;
+             if (o == null || getClass() != o.getClass())
+                 return false;
+ 
+             DepositKey that = (DepositKey)o;
+ 
+             return depositId == that.depositId;
+         }
+ 
+         /** {@inheritDoc} */
+         @Override public int hashCode() {
+             return depositId;
+         }
+     }
+ 
+     /** */
+     protected static class RegionKey implements Serializable {
+         /** Region id. */
+         @QuerySqlField(index = true)
+         protected int regionId;
+     }
+ 
+     /** */
+     protected static class Client {
+         @QuerySqlField
+         protected String firstName;
+ 
+         @QuerySqlField
+         protected String lastName;
+ 
+         @QuerySqlField(index = true)
+         protected int passport;
+     }
+ 
+     /** */
+     protected static class Deposit {
+         @QuerySqlField
+         protected long amount;
+     }
+ 
+     /** */
+     protected static class Region {
+         @QuerySqlField
+         protected String name;
+ 
+         @QuerySqlField
+         protected int code;
+     }
+ }

http://git-wip-us.apache.org/repos/asf/ignite/blob/eac6762b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartSelfTest2.java
----------------------------------------------------------------------
diff --cc modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartSelfTest2.java
index 6fc9c39,001f40b..943a5c8
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartSelfTest2.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartSelfTest2.java
@@@ -29,14 -29,16 +29,15 @@@ import org.apache.ignite.IgniteCache
  import org.apache.ignite.IgniteCheckedException;
  import org.apache.ignite.cache.affinity.AffinityKey;
  import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
++import org.apache.ignite.cache.query.QueryCancelledException;
  import org.apache.ignite.cache.query.SqlFieldsQuery;
  import org.apache.ignite.cache.query.annotations.QuerySqlField;
  import org.apache.ignite.configuration.CacheConfiguration;
  import org.apache.ignite.configuration.IgniteConfiguration;
+ import org.apache.ignite.configuration.MemoryConfiguration;
 -import org.apache.ignite.configuration.MemoryPolicyConfiguration;
  import org.apache.ignite.internal.IgniteFutureTimeoutCheckedException;
  import org.apache.ignite.internal.IgniteInternalFuture;
  import org.apache.ignite.internal.IgniteInterruptedCheckedException;
--import org.apache.ignite.cache.query.QueryCancelledException;
  import org.apache.ignite.internal.util.GridRandom;
  import org.apache.ignite.internal.util.typedef.CAX;
  import org.apache.ignite.internal.util.typedef.F;
@@@ -89,6 -91,12 +90,10 @@@ public class IgniteCacheQueryNodeRestar
      @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
          IgniteConfiguration c = super.getConfiguration(igniteInstanceName);
  
 -        MemoryConfiguration memCfg = new MemoryConfiguration();
 -        memCfg.setDefaultMemoryPolicyName("default");
 -        memCfg.setMemoryPolicies(new MemoryPolicyConfiguration().setName("default").setSize(50 * 1024 * 1024));
++        MemoryConfiguration memCfg = new MemoryConfiguration().setDefaultMemoryPolicySize(50 * 1024 * 1024);
+ 
+         c.setMemoryConfiguration(memCfg);
+ 
          TcpDiscoverySpi disco = new TcpDiscoverySpi();
  
          disco.setIpFinder(ipFinder);

http://git-wip-us.apache.org/repos/asf/ignite/blob/eac6762b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryPolicyConfiguration.cs
----------------------------------------------------------------------
diff --cc modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryPolicyConfiguration.cs
index e4b89e1,fe4e91f..e6e9153
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryPolicyConfiguration.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryPolicyConfiguration.cs
@@@ -53,8 -42,7 +53,9 @@@ namespace Apache.Ignite.Core.Cache.Conf
          {
              EvictionThreshold = DefaultEvictionThreshold;
              EmptyPagesPoolSize = DefaultEmptyPagesPoolSize;
+             Name = MemoryConfiguration.DefaultDefaultMemoryPolicyName;
 +            InitialSize = DefaultInitialSize;
 +            MaxSize = DefaultMaxSize;
          }
  
          /// <summary>

http://git-wip-us.apache.org/repos/asf/ignite/blob/eac6762b/modules/web-console/web-agent/pom.xml
----------------------------------------------------------------------


[02/29] ignite git commit: IGNITE-5058: Fixed QueryIndex validation when QueryEntity.valueType is not set yet. This closes #1861.

Posted by ag...@apache.org.
IGNITE-5058: Fixed QueryIndex validation when QueryEntity.valueType is not set yet. This closes #1861.


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

Branch: refs/heads/ignite-5024
Commit: 1968e4f59eea6265aaf82a3fa515eecc99a91310
Parents: 09b6507
Author: devozerov <vo...@gridgain.com>
Authored: Mon Apr 24 12:31:51 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Mon Apr 24 12:31:51 2017 +0300

----------------------------------------------------------------------
 .../org/apache/ignite/cache/QueryEntity.java    |  43 ++---
 .../processors/cache/GridCacheProcessor.java    |   4 +
 .../internal/processors/query/QuerySchema.java  |   4 +-
 .../internal/processors/query/QueryUtils.java   |  79 ++++++++-
 .../query/h2/H2IndexingAbstractGeoSelfTest.java |   2 +-
 .../DynamicIndexAbstractBasicSelfTest.java      |  16 +-
 .../index/QueryEntityValidationSelfTest.java    | 162 +++++++++++++++++++
 .../IgniteCacheQuerySelfTestSuite.java          |   3 +
 8 files changed, 278 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/1968e4f5/modules/core/src/main/java/org/apache/ignite/cache/QueryEntity.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/QueryEntity.java b/modules/core/src/main/java/org/apache/ignite/cache/QueryEntity.java
index 31fe264..806cd7d 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/QueryEntity.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/QueryEntity.java
@@ -18,16 +18,18 @@
 package org.apache.ignite.cache;
 
 import java.io.Serializable;
+import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.Set;
 
-import org.apache.ignite.internal.processors.query.QueryUtils;
-import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.tostring.GridToStringInclude;
 import org.apache.ignite.internal.util.typedef.internal.A;
+import org.apache.ignite.internal.util.typedef.internal.S;
 
 /**
  * Query entity is a description of {@link org.apache.ignite.IgniteCache cache} entry (composed of key and value)
@@ -44,16 +46,20 @@ public class QueryEntity implements Serializable {
     private String valType;
 
     /** Fields available for query. A map from field name to type name. */
+    @GridToStringInclude
     private LinkedHashMap<String, String> fields = new LinkedHashMap<>();
 
     /** Set of field names that belong to the key. */
+    @GridToStringInclude
     private Set<String> keyFields;
 
     /** Aliases. */
+    @GridToStringInclude
     private Map<String, String> aliases = new HashMap<>();
 
     /** Collection of query indexes. */
-    private Map<String, QueryIndex> idxs = new HashMap<>();
+    @GridToStringInclude
+    private Collection<QueryIndex> idxs;
 
     /** Table name. */
     private String tableName;
@@ -78,7 +84,7 @@ public class QueryEntity implements Serializable {
         keyFields = other.keyFields != null ? new HashSet<>(other.keyFields) : null;
 
         aliases = new HashMap<>(other.aliases);
-        idxs = new HashMap<>(other.idxs);
+        idxs = other.idxs != null ? new ArrayList<>(other.idxs) : null;
 
         tableName = other.tableName;
     }
@@ -190,7 +196,7 @@ public class QueryEntity implements Serializable {
      * @return Collection of index entities.
      */
     public Collection<QueryIndex> getIndexes() {
-        return idxs.values();
+        return idxs == null ? Collections.<QueryIndex>emptyList() : idxs;
     }
 
     /**
@@ -222,32 +228,12 @@ public class QueryEntity implements Serializable {
      * @return {@code this} for chaining.
      */
     public QueryEntity setIndexes(Collection<QueryIndex> idxs) {
-        for (QueryIndex idx : idxs) {
-            if (!F.isEmpty(idx.getFields())) {
-                if (idx.getName() == null)
-                    idx.setName(QueryUtils.indexName(this, idx));
-
-                if (idx.getIndexType() == null)
-                    throw new IllegalArgumentException("Index type is not set " + idx.getName());
-
-                if (!this.idxs.containsKey(idx.getName()))
-                    this.idxs.put(idx.getName(), idx);
-                else
-                    throw new IllegalArgumentException("Duplicate index name: " + idx.getName());
-            }
-        }
+        this.idxs = idxs;
 
         return this;
     }
 
     /**
-     * Clear indexes.
-     */
-    public void clearIndexes() {
-        this.idxs.clear();
-    }
-
-    /**
      * Gets table name for this query entity.
      *
      * @return table name
@@ -282,4 +268,9 @@ public class QueryEntity implements Serializable {
 
         return this;
     }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return S.toString(QueryEntity.class, this);
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/1968e4f5/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
index 28ef22f..a555b55 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
@@ -512,6 +512,8 @@ public class GridCacheProcessor extends GridProcessorAdapter {
         if (cc.getEvictionPolicy() != null && !cc.isOnheapCacheEnabled())
             throw new IgniteCheckedException("Onheap cache must be enabled if eviction policy is configured [cacheName="
                 + U.maskName(cc.getName()) + "]");
+
+        QueryUtils.validateCacheConfiguration(cc);
     }
 
     /**
@@ -1461,6 +1463,8 @@ public class GridCacheProcessor extends GridProcessorAdapter {
 
         CacheStore cfgStore = cfg.getCacheStoreFactory() != null ? cfg.getCacheStoreFactory().create() : null;
 
+        QueryUtils.prepareCacheConfiguration(cfg);
+
         validate(ctx.config(), cfg, cacheType, cfgStore);
 
         if (pluginMgr == null)

http://git-wip-us.apache.org/repos/asf/ignite/blob/1968e4f5/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QuerySchema.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QuerySchema.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QuerySchema.java
index 395f077..b380131 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QuerySchema.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QuerySchema.java
@@ -111,7 +111,6 @@ public class QuerySchema implements Serializable {
 
                             idxs.add(op0.index());
 
-                            entity.clearIndexes();
                             entity.setIndexes(idxs);
                         }
 
@@ -142,8 +141,7 @@ public class QuerySchema implements Serializable {
 
                         newIdxs.remove(victim);
 
-                        entity.clearIndexes();
-                        entity.setIndexes(idxs);
+                        entity.setIndexes(newIdxs);
 
                         break;
                     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/1968e4f5/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryUtils.java
index 3a7437b..e56f39f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryUtils.java
@@ -45,6 +45,7 @@ import java.lang.reflect.Method;
 import java.math.BigDecimal;
 import java.sql.Time;
 import java.sql.Timestamp;
+import java.util.Collection;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
@@ -162,9 +163,6 @@ public class QueryUtils {
      */
     public static QueryTypeCandidate typeForQueryEntity(String space, GridCacheContext cctx, QueryEntity qryEntity,
         List<Class<?>> mustDeserializeClss) throws IgniteCheckedException {
-        if (F.isEmpty(qryEntity.getValueType()))
-            throw new IgniteCheckedException("Value type is not set: " + qryEntity);
-
         GridKernalContext ctx = cctx.kernalContext();
         CacheConfiguration<?,?> ccfg = cctx.config();
 
@@ -797,6 +795,81 @@ public class QueryUtils {
     }
 
     /**
+     * Prepare cache configuration.
+     *
+     * @param ccfg Cache configuration.
+     */
+    @SuppressWarnings("unchecked")
+    public static void prepareCacheConfiguration(CacheConfiguration ccfg) {
+        assert ccfg != null;
+
+        Collection<QueryEntity> entities = ccfg.getQueryEntities();
+
+        if (!F.isEmpty(entities)) {
+            for (QueryEntity entity : entities) {
+                if (F.isEmpty(entity.getValueType()))
+                    continue;
+
+                Collection<QueryIndex> idxs = entity.getIndexes();
+
+                if (!F.isEmpty(idxs)) {
+                    for (QueryIndex idx : idxs) {
+                        if (idx.getName() == null) {
+                            String idxName = indexName(entity, idx);
+
+                            idx.setName(idxName);
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * Prepare cache configuration.
+     *
+     * @param ccfg Cache configuration.
+     * @throws IgniteCheckedException If failed.
+     */
+    @SuppressWarnings("unchecked")
+    public static void validateCacheConfiguration(CacheConfiguration ccfg) throws IgniteCheckedException {
+        assert ccfg != null;
+
+        Collection<QueryEntity> entities = ccfg.getQueryEntities();
+
+        if (!F.isEmpty(entities)) {
+            for (QueryEntity entity : entities) {
+                if (F.isEmpty(entity.getValueType()))
+                    throw new IgniteCheckedException("Value type cannot be null or empty [cacheName=" +
+                        ccfg.getName() + ", queryEntity=" + entity + ']');
+
+                Collection<QueryIndex> idxs = entity.getIndexes();
+
+                if (!F.isEmpty(idxs)) {
+                    Set<String> idxNames = new HashSet<>();
+
+                    for (QueryIndex idx : idxs) {
+                        String idxName = idx.getName();
+
+                        if (idxName == null)
+                            idxName = indexName(entity, idx);
+
+                        assert !F.isEmpty(idxName);
+
+                        if (!idxNames.add(idxName))
+                            throw new IgniteCheckedException("Duplicate index name [cacheName=" + ccfg.getName() +
+                                ", queryEntity=" + entity + ", queryIdx=" + idx + ']');
+
+                        if (idx.getIndexType() == null)
+                            throw new IgniteCheckedException("Index type is not set [cacheName=" + ccfg.getName() +
+                                ", queryEntity=" + entity + ", queryIdx=" + idx + ']');
+                    }
+                }
+            }
+        }
+    }
+
+    /**
      * Private constructor.
      */
     private QueryUtils() {

http://git-wip-us.apache.org/repos/asf/ignite/blob/1968e4f5/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingAbstractGeoSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingAbstractGeoSelfTest.java b/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingAbstractGeoSelfTest.java
index 80e9f93..f57d573 100644
--- a/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingAbstractGeoSelfTest.java
+++ b/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingAbstractGeoSelfTest.java
@@ -151,7 +151,7 @@ public abstract class H2IndexingAbstractGeoSelfTest extends GridCacheAbstractSel
 
             Collection<QueryIndex> idxs = new ArrayList<>(entity.getIndexes());
 
-            entity.clearIndexes();
+            entity.setIndexes(null);
 
             IgniteCache<K, V> cache = grid(0).getOrCreateCache(ccfg);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/1968e4f5/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractBasicSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractBasicSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractBasicSelfTest.java
index fc3529b..6621bb4 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractBasicSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractBasicSelfTest.java
@@ -670,23 +670,35 @@ public abstract class DynamicIndexAbstractBasicSelfTest extends DynamicIndexAbst
     public void checkDrop(CacheMode mode, CacheAtomicityMode atomicityMode, boolean near) throws Exception {
         initialize(mode, atomicityMode, near);
 
-        QueryIndex idx = index(IDX_NAME_1, field(FIELD_NAME_1));
+        // Create target index.
+        QueryIndex idx1 = index(IDX_NAME_1, field(FIELD_NAME_1));
 
-        dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx, false);
+        dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx1, false);
         assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1, field(FIELD_NAME_1));
 
         assertIndexUsed(IDX_NAME_1, SQL_SIMPLE_FIELD_1, SQL_ARG_1);
 
         assertSimpleIndexOperations(SQL_SIMPLE_FIELD_1);
 
+        // Create another index which must stay intact afterwards.
+        QueryIndex idx2 = index(IDX_NAME_2, field(alias(FIELD_NAME_2)));
+
+        dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx2, false);
+        assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_2, field(alias(FIELD_NAME_2)));
+
+        // Load some data.
         loadInitialData();
 
+        // Drop index.
         dynamicIndexDrop(CACHE_NAME, IDX_NAME_1, false);
         assertNoIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1);
 
         assertSimpleIndexOperations(SQL_SIMPLE_FIELD_1);
 
         assertIndexNotUsed(IDX_NAME_1, SQL_SIMPLE_FIELD_1, SQL_ARG_1);
+
+        // Make sure the second index is still there.
+        assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_2, field(alias(FIELD_NAME_2)));
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/1968e4f5/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/QueryEntityValidationSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/QueryEntityValidationSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/QueryEntityValidationSelfTest.java
new file mode 100644
index 0000000..97c9aa1
--- /dev/null
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/QueryEntityValidationSelfTest.java
@@ -0,0 +1,162 @@
+/*
+ * 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.index;
+
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.cache.QueryEntity;
+import org.apache.ignite.cache.QueryIndex;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.concurrent.Callable;
+
+/**
+ * Tests for query entity validation.
+ */
+@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
+public class QueryEntityValidationSelfTest extends GridCommonAbstractTest {
+    /** Cache name. */
+    private static final String CACHE_NAME = "cache";
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        startGrid(0);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTestsStopped() throws Exception {
+        stopAllGrids();
+    }
+
+    /**
+     * Test null value type.
+     *
+     * @throws Exception If failed.
+     */
+    public void testValueTypeNull() throws Exception {
+        final CacheConfiguration ccfg = new CacheConfiguration().setName(CACHE_NAME);
+
+        QueryEntity entity = new QueryEntity();
+
+        entity.setKeyType("Key");
+
+        ccfg.setQueryEntities(Collections.singleton(entity));
+
+        GridTestUtils.assertThrows(log, new Callable<Void>() {
+            @Override public Void call() throws Exception {
+                grid(0).createCache(ccfg);
+
+                return null;
+            }
+        }, IgniteCheckedException.class, "Value type cannot be null or empty");
+    }
+
+    /**
+     * Test failure if index type is null.
+     *
+     * @throws Exception If failed.
+     */
+    public void testIndexTypeNull() throws Exception {
+        final CacheConfiguration ccfg = new CacheConfiguration().setName(CACHE_NAME);
+
+        QueryEntity entity = new QueryEntity();
+
+        entity.setKeyType("Key");
+        entity.setValueType("Value");
+
+        LinkedHashMap<String, String> fields = new LinkedHashMap<>();
+
+        fields.put("a", Integer.class.getName());
+
+        entity.setFields(fields);
+
+        LinkedHashMap<String, Boolean> idxFields = new LinkedHashMap<>();
+
+        idxFields.put("a", true);
+
+        QueryIndex idx = new QueryIndex().setName("idx").setFields(idxFields).setIndexType(null);
+
+        List<QueryIndex> idxs = new ArrayList<>();
+
+        idxs.add(idx);
+
+        entity.setIndexes(idxs);
+
+        ccfg.setQueryEntities(Collections.singleton(entity));
+
+        GridTestUtils.assertThrows(log, new Callable<Void>() {
+            @Override public Void call() throws Exception {
+                grid(0).createCache(ccfg);
+
+                return null;
+            }
+        }, IgniteCheckedException.class, "Index type is not set");
+    }
+
+    /**
+     * Test duplicated index name.
+     *
+     * @throws Exception If failed.
+     */
+    public void testIndexNameDuplicate() throws Exception {
+        final CacheConfiguration ccfg = new CacheConfiguration().setName(CACHE_NAME);
+
+        QueryEntity entity = new QueryEntity();
+
+        entity.setKeyType("Key");
+        entity.setValueType("Value");
+
+        LinkedHashMap<String, String> fields = new LinkedHashMap<>();
+
+        fields.put("a", Integer.class.getName());
+        fields.put("b", Integer.class.getName());
+
+        entity.setFields(fields);
+
+        LinkedHashMap<String, Boolean> idx1Fields = new LinkedHashMap<>();
+        LinkedHashMap<String, Boolean> idx2Fields = new LinkedHashMap<>();
+
+        idx1Fields.put("a", true);
+        idx1Fields.put("b", true);
+
+        QueryIndex idx1 = new QueryIndex().setName("idx").setFields(idx1Fields);
+        QueryIndex idx2 = new QueryIndex().setName("idx").setFields(idx2Fields);
+
+        List<QueryIndex> idxs = new ArrayList<>();
+
+        idxs.add(idx1);
+        idxs.add(idx2);
+
+        entity.setIndexes(idxs);
+
+        ccfg.setQueryEntities(Collections.singleton(entity));
+
+        GridTestUtils.assertThrows(log, new Callable<Void>() {
+            @Override public Void call() throws Exception {
+                grid(0).createCache(ccfg);
+
+                return null;
+            }
+        }, IgniteCheckedException.class, "Duplicate index name");
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/1968e4f5/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
index 405e1f6..862d1a2 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
@@ -93,6 +93,7 @@ import org.apache.ignite.internal.processors.cache.index.DynamicIndexServerCoord
 import org.apache.ignite.internal.processors.cache.index.DynamicIndexServerNodeFIlterBasicSelfTest;
 import org.apache.ignite.internal.processors.cache.index.DynamicIndexServerNodeFilterCoordinatorBasicSelfTest;
 import org.apache.ignite.internal.processors.cache.index.DynamicIndexServerBasicSelfTest;
+import org.apache.ignite.internal.processors.cache.index.QueryEntityValidationSelfTest;
 import org.apache.ignite.internal.processors.cache.index.SchemaExchangeSelfTest;
 import org.apache.ignite.internal.processors.cache.local.IgniteCacheLocalAtomicQuerySelfTest;
 import org.apache.ignite.internal.processors.cache.local.IgniteCacheLocalFieldsQuerySelfTest;
@@ -130,6 +131,8 @@ public class IgniteCacheQuerySelfTestSuite extends TestSuite {
         IgniteTestSuite suite = new IgniteTestSuite("Ignite Cache Queries Test Suite");
 
         // Misc tests.
+        // TODO: Enable when IGNITE-1094 is fixed.
+        // suite.addTest(new TestSuite(QueryEntityValidationSelfTest.class));
         suite.addTest(new TestSuite(DuplicateKeyValueClassesSelfTest.class));
 
         // Dynamic index create/drop tests.


[09/29] ignite git commit: IGNITE-5057 .NET: Fix build.ps1 to handle Any CPU config on PowerShell 4.0 and lower

Posted by ag...@apache.org.
IGNITE-5057 .NET: Fix build.ps1 to handle Any CPU config on PowerShell 4.0 and lower


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

Branch: refs/heads/ignite-5024
Commit: de421ffc492e3536b885f2d90c21bcfa71e435a5
Parents: 7c249d7
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Mon Apr 24 15:37:42 2017 +0300
Committer: Pavel Tupitsyn <pt...@apache.org>
Committed: Mon Apr 24 15:37:42 2017 +0300

----------------------------------------------------------------------
 modules/platforms/dotnet/build.ps1 | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/de421ffc/modules/platforms/dotnet/build.ps1
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/build.ps1 b/modules/platforms/dotnet/build.ps1
index 4b5d937..b8e6a37 100644
--- a/modules/platforms/dotnet/build.ps1
+++ b/modules/platforms/dotnet/build.ps1
@@ -143,9 +143,12 @@ echo "MSBuild detected at '$msbuildExe'."
 # Detect NuGet
 $ng = "nuget"
 if ((Get-Command $ng -ErrorAction SilentlyContinue) -eq $null) { 
-    echo "Downloading NuGet..."
-    (New-Object System.Net.WebClient).DownloadFile("https://dist.nuget.org/win-x86-commandline/v3.3.0/nuget.exe", "nuget.exe");    
     $ng = ".\nuget.exe"
+
+    if (-not (Test-Path $ng)) {
+        echo "Downloading NuGet..."
+        (New-Object System.Net.WebClient).DownloadFile("https://dist.nuget.org/win-x86-commandline/v3.3.0/nuget.exe", "nuget.exe");    
+    }
 }
 
 # Restore NuGet packages
@@ -153,10 +156,11 @@ echo "Restoring NuGet..."
 & $ng restore
 
 # Build
-echo "Starting MsBuild..."
 $targets = if ($clean) {"Clean;Rebuild"} else {"Build"}
 $codeAnalysis = if ($skipCodeAnalysis) {"/p:RunCodeAnalysis=false"} else {""}
-& $msbuildExe Apache.Ignite.sln /target:$targets /p:Configuration=$configuration /p:Platform=`"$platform`" $codeAnalysis /p:UseSharedCompilation=false
+$msBuildCommand = "`"$msBuildExe`" Apache.Ignite.sln /target:$targets /p:Configuration=$configuration /p:Platform=`"$platform`" $codeAnalysis /p:UseSharedCompilation=false"
+echo "Starting MsBuild: '$msBuildCommand'"
+cmd /c $msBuildCommand
 
 # Check result
 if ($LastExitCode -ne 0) {


[16/29] ignite git commit: Fixed failures in IgniteCacheJoinQueryWithAffinityKeyTest.

Posted by ag...@apache.org.
Fixed failures in IgniteCacheJoinQueryWithAffinityKeyTest.


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

Branch: refs/heads/ignite-5024
Commit: 8d0da14c547022f8c9cc429531faee59a812f9a5
Parents: 234bb5a
Author: devozerov <vo...@gridgain.com>
Authored: Tue Apr 25 11:02:31 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Tue Apr 25 11:02:31 2017 +0300

----------------------------------------------------------------------
 ...IgniteCacheJoinQueryWithAffinityKeyTest.java | 20 +++-----------------
 1 file changed, 3 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/8d0da14c/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheJoinQueryWithAffinityKeyTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheJoinQueryWithAffinityKeyTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheJoinQueryWithAffinityKeyTest.java
index e08fa55..de81da3 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheJoinQueryWithAffinityKeyTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheJoinQueryWithAffinityKeyTest.java
@@ -23,9 +23,7 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.concurrent.Callable;
 import java.util.concurrent.ThreadLocalRandom;
-import javax.cache.CacheException;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.cache.CacheKeyConfiguration;
@@ -42,7 +40,6 @@ import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
-import org.apache.ignite.testframework.GridTestUtils;
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 
 import static org.apache.ignite.cache.CacheMode.PARTITIONED;
@@ -181,22 +178,11 @@ public class IgniteCacheJoinQueryWithAffinityKeyTest extends GridCommonAbstractT
             for (int i = 0; i < NODES; i++) {
                 log.info("Test node: " + i);
 
-                final IgniteCache cache0 = ignite(i).cache(ccfg.getName());
+                IgniteCache cache0 = ignite(i).cache(ccfg.getName());
 
-                if (cacheMode == REPLICATED && !ignite(i).configuration().isClientMode()) {
-                    GridTestUtils.assertThrows(log, new Callable<Object>() {
-                        @Override public Object call() throws Exception {
-                            checkPersonAccountsJoin(cache0, putData.personAccounts, affKey);
+                checkPersonAccountsJoin(cache0, putData.personAccounts, affKey);
 
-                            return null;
-                        }
-                    }, CacheException.class, "Queries using distributed JOINs have to be run on partitioned cache");
-                }
-                else {
-                    checkPersonAccountsJoin(cache0, putData.personAccounts, affKey);
-
-                    checkOrganizationPersonsJoin(cache0, putData.orgPersons);
-                }
+                checkOrganizationPersonsJoin(cache0, putData.orgPersons);
             }
         }
         finally {


[13/29] ignite git commit: Fixed AtomicSequence test

Posted by ag...@apache.org.
Fixed AtomicSequence test


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

Branch: refs/heads/ignite-5024
Commit: 26c222bd46e5fc725c2ad20815078792298d7869
Parents: b41ecd1
Author: Dmitriy Govorukhin <dm...@gmail.com>
Authored: Mon Apr 24 20:20:41 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Mon Apr 24 20:20:41 2017 +0300

----------------------------------------------------------------------
 .../datastructures/GridCacheAtomicReferenceImpl.java |  2 ++
 .../internal/IgniteClientReconnectAtomicsTest.java   | 15 +++++++--------
 2 files changed, 9 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/26c222bd/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicReferenceImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicReferenceImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicReferenceImpl.java
index 0b0c202..d6fa2ac 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicReferenceImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicReferenceImpl.java
@@ -166,6 +166,8 @@ public final class GridCacheAtomicReferenceImpl<T> implements GridCacheAtomicRef
 
     /** {@inheritDoc} */
     @Override public boolean compareAndSet(final T expVal, final T newVal) {
+        checkRemoved();
+
         try {
             if (ctx.dataStructures().knownType(expVal) && ctx.dataStructures().knownType(newVal)) {
                 EntryProcessorResult<Boolean> res =

http://git-wip-us.apache.org/repos/asf/ignite/blob/26c222bd/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectAtomicsTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectAtomicsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectAtomicsTest.java
index 4622fff..00daf5f 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectAtomicsTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectAtomicsTest.java
@@ -31,6 +31,7 @@ import org.apache.ignite.IgniteCountDownLatch;
 import org.apache.ignite.IgniteLock;
 import org.apache.ignite.IgniteSemaphore;
 import org.apache.ignite.internal.processors.cache.distributed.near.GridNearLockResponse;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxPrepareResponse;
 import org.apache.ignite.testframework.GridTestUtils;
 
 /**
@@ -363,7 +364,7 @@ public class IgniteClientReconnectAtomicsTest extends IgniteClientReconnectAbstr
 
         BlockTcpCommunicationSpi servCommSpi = commSpi(srv);
 
-        servCommSpi.blockMessage(GridNearLockResponse.class);
+        servCommSpi.blockMessage(GridNearTxPrepareResponse.class);
 
         final IgniteInternalFuture<Object> fut = GridTestUtils.runAsync(new Callable<Object>() {
             @Override public Object call() throws Exception {
@@ -396,8 +397,6 @@ public class IgniteClientReconnectAtomicsTest extends IgniteClientReconnectAbstr
         assertTrue((Boolean)fut.get(2, TimeUnit.SECONDS));
 
         // Check that after reconnect working.
-        assertEquals("3st value", clientAtomicRef.get());
-        assertTrue(clientAtomicRef.compareAndSet("3st value", "4st value"));
         assertEquals("4st value", clientAtomicRef.get());
 
         assertEquals("4st value", srvAtomicRef.get());
@@ -523,7 +522,7 @@ public class IgniteClientReconnectAtomicsTest extends IgniteClientReconnectAbstr
 
         BlockTcpCommunicationSpi servCommSpi = commSpi(srv);
 
-        servCommSpi.blockMessage(GridNearLockResponse.class);
+        servCommSpi.blockMessage(GridNearTxPrepareResponse.class);
 
         final IgniteInternalFuture<Object> fut = GridTestUtils.runAsync(new Callable<Object>() {
             @Override public Object call() throws Exception {
@@ -556,7 +555,7 @@ public class IgniteClientReconnectAtomicsTest extends IgniteClientReconnectAbstr
         assertTrue((Boolean)fut.get(2, TimeUnit.SECONDS));
 
         // Check that after reconnect working.
-        assertEquals(true, clientAtomicStamped.compareAndSet(2, 3, 2, 3));
+        assertEquals(false, clientAtomicStamped.compareAndSet(2, 3, 2, 3));
         assertEquals(3, clientAtomicStamped.value());
         assertEquals(3, clientAtomicStamped.stamp());
 
@@ -655,7 +654,7 @@ public class IgniteClientReconnectAtomicsTest extends IgniteClientReconnectAbstr
 
         final IgniteAtomicLong srvAtomicLong = srv.atomicLong("atomicLongInProggress", 0, false);
 
-        commSpi.blockMessage(GridNearLockResponse.class);
+        commSpi.blockMessage(GridNearTxPrepareResponse.class);
 
         final IgniteInternalFuture<Object> fut = GridTestUtils.runAsync(new Callable<Object>() {
             @Override public Object call() throws Exception {
@@ -688,8 +687,8 @@ public class IgniteClientReconnectAtomicsTest extends IgniteClientReconnectAbstr
         assertTrue((Boolean)fut.get(2, TimeUnit.SECONDS));
 
         // Check that after reconnect working.
-        assertEquals(1, clientAtomicLong.addAndGet(1));
-        assertEquals(2, srvAtomicLong.addAndGet(1));
+        assertEquals(2, clientAtomicLong.addAndGet(1));
+        assertEquals(3, srvAtomicLong.addAndGet(1));
 
         clientAtomicLong.close();
     }


[08/29] ignite git commit: IGNITE-3521: IGFS: Removed "maxSpace" property. This closes #1854.

Posted by ag...@apache.org.
IGNITE-3521: IGFS: Removed "maxSpace" property. This closes #1854.


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

Branch: refs/heads/ignite-5024
Commit: 7c249d7bbb3c6f65e2781e0da3cd21c62d2ce078
Parents: 5a43346
Author: tledkov-gridgain <tl...@gridgain.com>
Authored: Mon Apr 24 15:17:49 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Mon Apr 24 15:17:49 2017 +0300

----------------------------------------------------------------------
 .../configuration/FileSystemConfiguration.java  |  25 ----
 .../org/apache/ignite/igfs/IgfsMetrics.java     |   5 +-
 .../processors/cache/GridCacheAdapter.java      |  14 ---
 .../processors/cache/GridCacheProcessor.java    |   5 +-
 .../processors/cache/GridCacheProxyImpl.java    |  12 --
 .../processors/cache/IgniteInternalCache.java   |   7 --
 .../dht/GridDhtTransactionalCacheAdapter.java   |   1 -
 .../dht/preloader/GridDhtPartitionDemander.java |  12 --
 .../distributed/near/GridNearCacheAdapter.java  |   5 -
 .../processors/igfs/IgfsDataManager.java        |  36 +-----
 .../internal/visor/igfs/VisorIgfsMetrics.java   |   3 +-
 .../visor/node/VisorIgfsConfiguration.java      |  13 --
 .../processors/igfs/IgfsMaxSizeSelfTest.java    | 121 -------------------
 .../processors/igfs/IgfsSizeSelfTest.java       |  50 +++++---
 .../ignite/testsuites/IgniteIgfsTestSuite.java  |   3 -
 .../HadoopIgfs20FileSystemAbstractSelfTest.java |   1 -
 .../cache/hibernate/HibernateCacheProxy.java    |   5 -
 .../cache/hibernate/HibernateCacheProxy.java    |   5 -
 18 files changed, 47 insertions(+), 276 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/7c249d7b/modules/core/src/main/java/org/apache/ignite/configuration/FileSystemConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/FileSystemConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/FileSystemConfiguration.java
index af5be3c..e36f857 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/FileSystemConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/FileSystemConfiguration.java
@@ -136,9 +136,6 @@ public class FileSystemConfiguration {
     /** Path modes. */
     private Map<String, IgfsMode> pathModes;
 
-    /** Maximum space. */
-    private long maxSpace;
-
     /** Maximum range length. */
     private long maxTaskRangeLen;
 
@@ -187,7 +184,6 @@ public class FileSystemConfiguration {
         secondaryFs = cfg.getSecondaryFileSystem();
         ipcEndpointCfg = cfg.getIpcEndpointConfiguration();
         ipcEndpointEnabled = cfg.isIpcEndpointEnabled();
-        maxSpace = cfg.getMaxSpaceSize();
         maxTaskRangeLen = cfg.getMaximumTaskRangeLength();
         metaCacheCfg = cfg.getMetaCacheConfiguration();
         mgmtPort = cfg.getManagementPort();
@@ -682,27 +678,6 @@ public class FileSystemConfiguration {
     }
 
     /**
-     * Get maximum space available for data cache to store file system entries.
-     *
-     * @return Maximum space available for data cache.
-     */
-    public long getMaxSpaceSize() {
-        return maxSpace;
-    }
-
-    /**
-     * Set maximum space in bytes available in data cache.
-     *
-     * @param maxSpace Maximum space available in data cache.
-     * @return {@code this} for chaining.
-     */
-    public FileSystemConfiguration setMaxSpaceSize(long maxSpace) {
-        this.maxSpace = maxSpace;
-
-        return this;
-    }
-
-    /**
      * Get maximum default range size of a file being split during IGFS task execution. When IGFS task is about to
      * be executed, it requests file block locations first. Each location is defined as {@link org.apache.ignite.igfs.mapreduce.IgfsFileRange} which
      * has length. In case this parameter is set to positive value, then IGFS will split single file range into smaller

http://git-wip-us.apache.org/repos/asf/ignite/blob/7c249d7b/modules/core/src/main/java/org/apache/ignite/igfs/IgfsMetrics.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/igfs/IgfsMetrics.java b/modules/core/src/main/java/org/apache/ignite/igfs/IgfsMetrics.java
index 3283eaf..28225fc 100644
--- a/modules/core/src/main/java/org/apache/ignite/igfs/IgfsMetrics.java
+++ b/modules/core/src/main/java/org/apache/ignite/igfs/IgfsMetrics.java
@@ -32,9 +32,8 @@ public interface IgfsMetrics {
     public long localSpaceSize();
 
     /**
-     * Gets maximum amount of data that can be stored on local node. This metrics is either
-     * equal to {@link org.apache.ignite.configuration.FileSystemConfiguration#getMaxSpaceSize()}, or, if it is {@code 0}, equal to
-     * {@code 80%} of maximum heap size allocated for JVM.
+     * Gets maximum amount of data that can be stored on local node. This metrics is related to
+     * to the {@link org.apache.ignite.configuration.MemoryPolicyConfiguration#getSize()} of the IGFS data cache.
      *
      * @return Maximum IGFS local space size.
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/7c249d7b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
index c9f7430..b364df8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
@@ -278,9 +278,6 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
     /** Current IGFS data cache size. */
     private LongAdder8 igfsDataCacheSize;
 
-    /** Max space for IGFS. */
-    private long igfsDataSpaceMax;
-
     /** Asynchronous operations limit semaphore. */
     private Semaphore asyncOpsSem;
 
@@ -338,12 +335,6 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
                     if (!ctx.isNear()) {
                         igfsDataCache = true;
                         igfsDataCacheSize = new LongAdder8();
-
-                        igfsDataSpaceMax = igfsCfg.getMaxSpaceSize();
-
-                        // Do we have limits?
-                        if (igfsDataSpaceMax <= 0)
-                            igfsDataSpaceMax = Long.MAX_VALUE;
                     }
 
                     break;
@@ -4363,11 +4354,6 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
     }
 
     /** {@inheritDoc} */
-    @Override public long igfsDataSpaceMax() {
-        return igfsDataSpaceMax;
-    }
-
-    /** {@inheritDoc} */
     @Override public boolean isMongoDataCache() {
         return mongoDataCache;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/7c249d7b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
index a555b55..4b79361 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
@@ -738,10 +738,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
             else
                 cacheType = CacheType.USER;
 
-        if (cacheType != CacheType.USER)
-            cfg.setMemoryPolicyName(sharedCtx.database().systemMemoryPolicyName());
-
-        if (cacheType != CacheType.USER)
+        if (cacheType != CacheType.USER && cfg.getMemoryPolicyName() == null)
             cfg.setMemoryPolicyName(sharedCtx.database().systemMemoryPolicyName());
 
         boolean template = cfg.getName() != null && cfg.getName().endsWith("*");

http://git-wip-us.apache.org/repos/asf/ignite/blob/7c249d7b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
index 2979a57..837c22a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
@@ -454,18 +454,6 @@ public class GridCacheProxyImpl<K, V> implements IgniteInternalCache<K, V>, Exte
     }
 
     /** {@inheritDoc} */
-    @Override public long igfsDataSpaceMax() {
-        CacheOperationContext prev = gate.enter(opCtx);
-
-        try {
-            return delegate.igfsDataSpaceMax();
-        }
-        finally {
-            gate.leave(prev);
-        }
-    }
-
-    /** {@inheritDoc} */
     @Override public boolean isMongoDataCache() {
         CacheOperationContext prev = gate.enter(opCtx);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/7c249d7b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java
index ce65fd2..cc7fd3a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java
@@ -1719,13 +1719,6 @@ public interface IgniteInternalCache<K, V> extends Iterable<Cache.Entry<K, V>> {
     public long igfsDataSpaceUsed();
 
     /**
-     * Get maximum space available for IGFS.
-     *
-     * @return Amount of space available for IGFS in bytes.
-     */
-    public long igfsDataSpaceMax();
-
-    /**
      * Checks whether this cache is Mongo data cache.
      *
      * @return {@code True} if this cache is mongo data cache.

http://git-wip-us.apache.org/repos/asf/ignite/blob/7c249d7b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
index 6af1ef7..c91eb7a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
@@ -55,7 +55,6 @@ import org.apache.ignite.internal.processors.cache.distributed.near.GridNearSing
 import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTransactionalCache;
 import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxRemote;
 import org.apache.ignite.internal.processors.cache.distributed.near.GridNearUnlockRequest;
-import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
 import org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry;
 import org.apache.ignite.internal.processors.cache.transactions.IgniteTxKey;
 import org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalEx;

http://git-wip-us.apache.org/repos/asf/ignite/blob/7c249d7b/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 d71a3ad..75cbd00 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
@@ -56,7 +56,6 @@ import org.apache.ignite.internal.util.tostring.GridToStringExclude;
 import org.apache.ignite.internal.util.tostring.GridToStringInclude;
 import org.apache.ignite.internal.util.typedef.CI1;
 import org.apache.ignite.internal.util.typedef.T2;
-import org.apache.ignite.internal.util.typedef.internal.LT;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteInClosure;
@@ -744,17 +743,6 @@ public class GridDhtPartitionDemander {
                 if (log.isDebugEnabled())
                     log.debug("Rebalancing key [key=" + entry.key() + ", part=" + p + ", node=" + pick.id() + ']');
 
-                if (cctx.dht().isIgfsDataCache() &&
-                    cctx.dht().igfsDataSpaceUsed() > cctx.dht().igfsDataSpaceMax()) {
-                    LT.error(log, null, "Failed to rebalance IGFS data cache (IGFS space size exceeded maximum " +
-                        "value, will ignore rebalance entries)");
-
-                    if (cached.markObsoleteIfEmpty(null))
-                        cached.context().cache().removeEntry(cached);
-
-                    return true;
-                }
-
                 if (preloadPred == null || preloadPred.apply(entry)) {
                     if (cached.initialValue(
                         entry.value(),

http://git-wip-us.apache.org/repos/asf/ignite/blob/7c249d7b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java
index f4ba043..59d986a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java
@@ -403,11 +403,6 @@ public abstract class GridNearCacheAdapter<K, V> extends GridDistributedCacheAda
     }
 
     /** {@inheritDoc} */
-    @Override public long igfsDataSpaceMax() {
-        return dht().igfsDataSpaceMax();
-    }
-
-    /** {@inheritDoc} */
     @Override public void onIgfsDataSizeChanged(long delta) {
         dht().onIgfsDataSizeChanged(delta);
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/7c249d7b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
index acd0a1f..7fa2355 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
@@ -65,6 +65,7 @@ import org.apache.ignite.internal.managers.communication.GridIoPolicy;
 import org.apache.ignite.internal.managers.communication.GridMessageListener;
 import org.apache.ignite.internal.managers.eventstorage.GridLocalEventListener;
 import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
+import org.apache.ignite.internal.processors.cache.database.MemoryPolicy;
 import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
 import org.apache.ignite.internal.processors.datastreamer.DataStreamerCacheUpdaters;
 import org.apache.ignite.internal.processors.igfs.data.IgfsDataPutProcessor;
@@ -242,7 +243,11 @@ public class IgfsDataManager extends IgfsManager {
      * @return Maximum number of bytes for IGFS data cache.
      */
     public long maxSpaceSize() {
-        return (igfsCtx.configuration().getMaxSpaceSize() <= 0) ? 0 : dataCachePrj.igfsDataSpaceMax();
+        MemoryPolicy plc = dataCachePrj.context().memoryPolicy();
+
+        long size = plc != null ? plc.config().getSize() : 0;
+
+        return (size <= 0) ? 0 : size ;
     }
 
     /**
@@ -1022,27 +1027,6 @@ public class IgfsDataManager extends IgfsManager {
      */
     private void processPartialBlockWrite(IgniteUuid fileId, IgfsBlockKey colocatedKey, int startOff,
         byte[] data, int blockSize) throws IgniteCheckedException {
-        if (dataCachePrj.igfsDataSpaceUsed() >= dataCachePrj.igfsDataSpaceMax()) {
-            final WriteCompletionFuture completionFut = pendingWrites.get(fileId);
-
-            if (completionFut == null) {
-                if (log.isDebugEnabled())
-                    log.debug("Missing completion future for file write request (most likely exception occurred " +
-                        "which will be thrown upon stream close) [fileId=" + fileId + ']');
-
-                return;
-            }
-
-            IgfsOutOfSpaceException e = new IgfsOutOfSpaceException("Failed to write data block " +
-                "(IGFS maximum data size exceeded) [used=" + dataCachePrj.igfsDataSpaceUsed() +
-                ", allowed=" + dataCachePrj.igfsDataSpaceMax() + ']');
-
-            completionFut.onDone(new IgniteCheckedException("Failed to write data (not enough space on node): " +
-                igfsCtx.kernalContext().localNodeId(), e));
-
-            return;
-        }
-
         // No affinity key present, just concat and return.
         if (colocatedKey.affinityKey() == null) {
             dataCachePrj.invoke(colocatedKey, new UpdateProcessor(startOff, data));
@@ -1097,14 +1081,6 @@ public class IgfsDataManager extends IgfsManager {
     @SuppressWarnings("unchecked")
     private IgniteInternalFuture<?> storeBlocksAsync(Map<IgfsBlockKey, byte[]> blocks) {
         assert !blocks.isEmpty();
-
-        if (dataCachePrj.igfsDataSpaceUsed() >= dataCachePrj.igfsDataSpaceMax()) {
-            return new GridFinishedFuture<Object>(
-                new IgfsOutOfSpaceException("Failed to write data block (IGFS maximum data size " +
-                    "exceeded) [used=" + dataCachePrj.igfsDataSpaceUsed() +
-                    ", allowed=" + dataCachePrj.igfsDataSpaceMax() + ']'));
-        }
-
         return dataCachePrj.putAllAsync(blocks);
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/7c249d7b/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsMetrics.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsMetrics.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsMetrics.java
index 6ce5d80..f90ca89 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsMetrics.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsMetrics.java
@@ -22,6 +22,7 @@ import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import org.apache.ignite.IgniteFileSystem;
 import org.apache.ignite.igfs.IgfsMetrics;
+import org.apache.ignite.internal.processors.igfs.IgfsEx;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.internal.visor.VisorDataTransferObject;
 
@@ -91,7 +92,7 @@ public class VisorIgfsMetrics extends VisorDataTransferObject {
 
         IgfsMetrics m = igfs.metrics();
 
-        totalSpaceSz = igfs.configuration().getMaxSpaceSize();
+        totalSpaceSz = ((IgfsEx)igfs).context().data().maxSpaceSize();
         usedSpaceSz = m.localSpaceSize();
         foldersCnt = m.directoriesCount();
         filesCnt = m.filesCount();

http://git-wip-us.apache.org/repos/asf/ignite/blob/7c249d7b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorIgfsConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorIgfsConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorIgfsConfiguration.java
index 3b97129..db91982 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorIgfsConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorIgfsConfiguration.java
@@ -92,9 +92,6 @@ public class VisorIgfsConfiguration extends VisorDataTransferObject {
     /** IPC endpoint enabled flag. */
     private boolean ipcEndpointEnabled;
 
-    /** Maximum space. */
-    private long maxSpace;
-
     /** Management port. */
     private int mgmtPort;
 
@@ -135,7 +132,6 @@ public class VisorIgfsConfiguration extends VisorDataTransferObject {
         ipcEndpointCfg = endpointCfg != null ? endpointCfg.toString() : null;
 
         ipcEndpointEnabled = igfs.isIpcEndpointEnabled();
-        maxSpace = igfs.getMaxSpaceSize();
         mgmtPort = igfs.getManagementPort();
         seqReadsBeforePrefetch = igfs.getSequentialReadsBeforePrefetch();
     }
@@ -277,13 +273,6 @@ public class VisorIgfsConfiguration extends VisorDataTransferObject {
     }
 
     /**
-     * @return Maximum space.
-     */
-    public long getMaxSpace() {
-        return maxSpace;
-    }
-
-    /**
      * @return Management port.
      */
     public int getManagementPort() {
@@ -316,7 +305,6 @@ public class VisorIgfsConfiguration extends VisorDataTransferObject {
         out.writeLong(fragmentizerThrottlingDelay);
         U.writeString(out, ipcEndpointCfg);
         out.writeBoolean(ipcEndpointEnabled);
-        out.writeLong(maxSpace);
         out.writeInt(mgmtPort);
         out.writeInt(seqReadsBeforePrefetch);
     }
@@ -340,7 +328,6 @@ public class VisorIgfsConfiguration extends VisorDataTransferObject {
         fragmentizerThrottlingDelay = in.readLong();
         ipcEndpointCfg = U.readString(in);
         ipcEndpointEnabled = in.readBoolean();
-        maxSpace = in.readLong();
         mgmtPort = in.readInt();
         seqReadsBeforePrefetch = in.readInt();
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/7c249d7b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMaxSizeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMaxSizeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMaxSizeSelfTest.java
deleted file mode 100644
index 2e0be3f..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMaxSizeSelfTest.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.igfs;
-
-import org.apache.ignite.cache.CacheAtomicityMode;
-import org.apache.ignite.cache.CacheMode;
-import org.apache.ignite.cache.CacheWriteSynchronizationMode;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.FileSystemConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.igfs.IgfsGroupDataBlocksKeyMapper;
-import org.apache.ignite.internal.IgniteEx;
-
-/**
- * Check max size limit.
- */
-@SuppressWarnings("ConstantConditions")
-public class IgfsMaxSizeSelfTest extends IgfsCommonAbstractTest {
-    /** Work directory. */
-    private static long maxSize;
-
-    /** {@inheritDoc} */
-    @SuppressWarnings("unchecked")
-    @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
-        IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
-
-        FileSystemConfiguration igfsCfg = new FileSystemConfiguration();
-
-        igfsCfg.setName("test");
-
-        if (maxSize > 0)
-            igfsCfg.setMaxSpaceSize(maxSize);
-
-        CacheConfiguration dataCacheCfg = defaultCacheConfiguration();
-
-        dataCacheCfg.setName("dataCache");
-        dataCacheCfg.setCacheMode(CacheMode.PARTITIONED);
-        dataCacheCfg.setNearConfiguration(null);
-        dataCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
-        dataCacheCfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(2));
-        dataCacheCfg.setBackups(0);
-        dataCacheCfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
-
-        CacheConfiguration metaCacheCfg = defaultCacheConfiguration();
-
-        metaCacheCfg.setName("metaCache");
-        metaCacheCfg.setNearConfiguration(null);
-        metaCacheCfg.setCacheMode(CacheMode.REPLICATED);
-        metaCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
-        metaCacheCfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
-
-        igfsCfg.setDataCacheConfiguration(dataCacheCfg);
-        igfsCfg.setMetaCacheConfiguration(metaCacheCfg);
-
-        cfg.setFileSystemConfiguration(igfsCfg);
-        cfg.setIgniteInstanceName(igniteInstanceName);
-
-        return cfg;
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testDefaultOrZero() throws  Exception {
-        IgniteEx ig = startGrid(0);
-
-        try {
-            assertEquals(0, ((IgfsImpl)ig.igfsx("test")).globalSpace().spaceTotal());
-        }
-        finally {
-            stopAllGrids();
-        }
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testNegative() throws  Exception {
-        maxSize = -1;
-
-        IgniteEx ig = startGrid(0);
-
-        try {
-            assertEquals(0, ((IgfsImpl)ig.igfsx("test")).globalSpace().spaceTotal());
-        }
-        finally {
-            stopAllGrids();
-        }
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testPositive() throws  Exception {
-        maxSize = 1 << 20;
-
-        IgniteEx ig = startGrid(0);
-
-        try {
-            assertEquals(maxSize, ((IgfsImpl)ig.igfsx("test")).globalSpace().spaceTotal());
-        }
-        finally {
-            stopAllGrids();
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/7c249d7b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsSizeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsSizeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsSizeSelfTest.java
index 645f341..fbe0872 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsSizeSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsSizeSelfTest.java
@@ -17,6 +17,8 @@
 
 package org.apache.ignite.internal.processors.igfs;
 
+import java.io.IOException;
+import java.util.concurrent.Callable;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.cache.CacheMode;
 import org.apache.ignite.cache.CacheWriteSynchronizationMode;
@@ -24,17 +26,20 @@ import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.FileSystemConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.MemoryConfiguration;
+import org.apache.ignite.configuration.MemoryPolicyConfiguration;
 import org.apache.ignite.configuration.NearCacheConfiguration;
 import org.apache.ignite.igfs.IgfsGroupDataBlocksKeyMapper;
 import org.apache.ignite.igfs.IgfsInputStream;
-import org.apache.ignite.igfs.IgfsOutOfSpaceException;
 import org.apache.ignite.igfs.IgfsOutputStream;
 import org.apache.ignite.igfs.IgfsPath;
 import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.mem.IgniteOutOfMemoryException;
 import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
 import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
 import org.apache.ignite.internal.util.typedef.G;
 import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteInClosure;
 import org.apache.ignite.lang.IgniteUuid;
 import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
@@ -42,14 +47,12 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
 import org.apache.ignite.testframework.GridTestUtils;
 import org.jsr166.ThreadLocalRandom8;
 
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.UUID;
-import java.util.concurrent.Callable;
 
 import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
 import static org.apache.ignite.cache.CacheMode.PARTITIONED;
@@ -87,14 +90,13 @@ public class IgfsSizeSelfTest extends IgfsCommonAbstractTest {
     /** Whether near cache is enabled (applicable for PARTITIONED cache only). */
     private boolean nearEnabled;
 
-    /** IGFS maximum space. */
-    private long igfsMaxData;
+    /** Mem policy setter. */
+    private IgniteInClosure<IgniteConfiguration> memIgfsdDataPlcSetter;
 
     /** {@inheritDoc} */
     @Override protected void beforeTest() throws Exception {
         cacheMode = null;
         nearEnabled = false;
-        igfsMaxData = 0;
 
         mgmtPort = 11400;
     }
@@ -113,7 +115,6 @@ public class IgfsSizeSelfTest extends IgfsCommonAbstractTest {
         igfsCfg.setName(IGFS_NAME);
         igfsCfg.setBlockSize(BLOCK_SIZE);
         igfsCfg.setFragmentizerEnabled(false);
-        igfsCfg.setMaxSpaceSize(igfsMaxData);
         igfsCfg.setManagementPort(++mgmtPort);
 
         CacheConfiguration dataCfg = defaultCacheConfiguration();
@@ -150,6 +151,9 @@ public class IgfsSizeSelfTest extends IgfsCommonAbstractTest {
         cfg.setDiscoverySpi(discoSpi);
         cfg.setFileSystemConfiguration(igfsCfg);
 
+        if (memIgfsdDataPlcSetter != null)
+            memIgfsdDataPlcSetter.apply(cfg);
+
         return cfg;
     }
 
@@ -221,7 +225,7 @@ public class IgfsSizeSelfTest extends IgfsCommonAbstractTest {
         cacheMode = PARTITIONED;
         nearEnabled = false;
 
-        check();
+        checkOversize();
     }
 
     /**
@@ -232,7 +236,7 @@ public class IgfsSizeSelfTest extends IgfsCommonAbstractTest {
     public void testReplicatedOversize() throws Exception {
         cacheMode = REPLICATED;
 
-        check();
+        checkOversize();
     }
 
     /**
@@ -386,15 +390,32 @@ public class IgfsSizeSelfTest extends IgfsCommonAbstractTest {
      * @throws Exception If failed.
      */
     private void checkOversize() throws Exception {
-        igfsMaxData = BLOCK_SIZE;
+        final long maxSize = 32 * 1024 * 1024;
+
+        memIgfsdDataPlcSetter = new IgniteInClosure<IgniteConfiguration>() {
+            @Override public void apply(IgniteConfiguration cfg) {
+                String memPlcName = "igfsDataMemPlc";
+
+                cfg.setMemoryConfiguration(new MemoryConfiguration().setMemoryPolicies(
+                    new MemoryPolicyConfiguration().setSize(maxSize).setName(memPlcName)));
+
+                FileSystemConfiguration igfsCfg = cfg.getFileSystemConfiguration()[0];
+
+                igfsCfg.getDataCacheConfiguration().setMemoryPolicyName(memPlcName);
+
+                cfg.setCacheConfiguration(new CacheConfiguration().setName("QQQ").setMemoryPolicyName(memPlcName));
+            }
+        };
 
         startUp();
 
         final IgfsPath path = new IgfsPath("/file");
 
+        final int writeChunkSize = (int)(maxSize / 1024);
+
         // This write is expected to be successful.
         IgfsOutputStream os = igfs(0).create(path, false);
-        os.write(chunk(BLOCK_SIZE - 1));
+        os.write(chunk(writeChunkSize));
         os.close();
 
         // This write must be successful as well.
@@ -408,7 +429,9 @@ public class IgfsSizeSelfTest extends IgfsCommonAbstractTest {
                 IgfsOutputStream osErr = igfs(0).append(path, false);
 
                 try {
-                    osErr.write(chunk(BLOCK_SIZE));
+                    for (int i = 0; i < maxSize / writeChunkSize * GRID_CNT; ++i)
+                        osErr.write(chunk(writeChunkSize));
+
                     osErr.close();
 
                     return null;
@@ -425,8 +448,7 @@ public class IgfsSizeSelfTest extends IgfsCommonAbstractTest {
                     U.closeQuiet(osErr);
                 }
             }
-        }, IgfsOutOfSpaceException.class, "Failed to write data block (IGFS maximum data size exceeded) [used=" +
-            igfsMaxData + ", allowed=" + igfsMaxData + ']');
+        }, IgniteOutOfMemoryException.class, "Not enough memory allocated");
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/7c249d7b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java
index 7efc7de..b16f7e9 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java
@@ -32,7 +32,6 @@ import org.apache.ignite.internal.processors.igfs.IgfsCacheSelfTest;
 import org.apache.ignite.internal.processors.igfs.IgfsDualAsyncClientSelfTest;
 import org.apache.ignite.internal.processors.igfs.IgfsDualSyncClientSelfTest;
 import org.apache.ignite.internal.processors.igfs.IgfsLocalSecondaryFileSystemProxyClientSelfTest;
-import org.apache.ignite.internal.processors.igfs.IgfsMaxSizeSelfTest;
 import org.apache.ignite.internal.processors.igfs.IgfsPrimaryClientSelfTest;
 import org.apache.ignite.internal.processors.igfs.IgfsDataManagerSelfTest;
 import org.apache.ignite.internal.processors.igfs.IgfsDualAsyncSelfTest;
@@ -150,8 +149,6 @@ public class IgniteIgfsTestSuite extends TestSuite {
         // TODO: Enable when IGFS failover is fixed.
         //suite.addTestSuite(IgfsBackupFailoverSelfTest.class);
 
-        suite.addTestSuite(IgfsMaxSizeSelfTest.class);
-
         suite.addTestSuite(IgfsProxySelfTest.class);
         suite.addTestSuite(IgfsLocalSecondaryFileSystemProxySelfTest.class);
         suite.addTestSuite(IgfsLocalSecondaryFileSystemProxyClientSelfTest.class);

http://git-wip-us.apache.org/repos/asf/ignite/blob/7c249d7b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/HadoopIgfs20FileSystemAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/HadoopIgfs20FileSystemAbstractSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/HadoopIgfs20FileSystemAbstractSelfTest.java
index 77e6757..016fadf 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/HadoopIgfs20FileSystemAbstractSelfTest.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/HadoopIgfs20FileSystemAbstractSelfTest.java
@@ -305,7 +305,6 @@ public abstract class HadoopIgfs20FileSystemAbstractSelfTest extends IgfsCommonA
 
         cfg.setName("igfs");
         cfg.setPrefetchBlocks(1);
-        cfg.setMaxSpaceSize(64 * 1024 * 1024);
         cfg.setDefaultMode(mode);
         cfg.setMetaCacheConfiguration(metaCacheConfiguration(igniteInstanceName));
         cfg.setDataCacheConfiguration(dataCacheConfiguration(igniteInstanceName));

http://git-wip-us.apache.org/repos/asf/ignite/blob/7c249d7b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateCacheProxy.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateCacheProxy.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateCacheProxy.java
index 48fc1f8..7204083 100644
--- a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateCacheProxy.java
+++ b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateCacheProxy.java
@@ -627,11 +627,6 @@ public class HibernateCacheProxy implements IgniteInternalCache<Object, Object>
     }
 
     /** {@inheritDoc} */
-    @Override public long igfsDataSpaceMax() {
-        return delegate.igfsDataSpaceMax();
-    }
-
-    /** {@inheritDoc} */
     @Override public boolean isMongoDataCache() {
         return delegate.isMongoDataCache();
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/7c249d7b/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateCacheProxy.java
----------------------------------------------------------------------
diff --git a/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateCacheProxy.java b/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateCacheProxy.java
index 48fc1f8..7204083 100644
--- a/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateCacheProxy.java
+++ b/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateCacheProxy.java
@@ -627,11 +627,6 @@ public class HibernateCacheProxy implements IgniteInternalCache<Object, Object>
     }
 
     /** {@inheritDoc} */
-    @Override public long igfsDataSpaceMax() {
-        return delegate.igfsDataSpaceMax();
-    }
-
-    /** {@inheritDoc} */
     @Override public boolean isMongoDataCache() {
         return delegate.isMongoDataCache();
     }


[05/29] ignite git commit: IgniteCacheClientMultiNodeUpdateTopologyLockTest minor.

Posted by ag...@apache.org.
IgniteCacheClientMultiNodeUpdateTopologyLockTest minor.


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

Branch: refs/heads/ignite-5024
Commit: 319280678515e4e12c10c0362883f207919e87c2
Parents: 1968e4f
Author: sboikov <sb...@gridgain.com>
Authored: Mon Apr 24 13:20:59 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Mon Apr 24 13:20:59 2017 +0300

----------------------------------------------------------------------
 ...heClientMultiNodeUpdateTopologyLockTest.java | 28 +++++++++++++-------
 1 file changed, 18 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/31928067/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientMultiNodeUpdateTopologyLockTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientMultiNodeUpdateTopologyLockTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientMultiNodeUpdateTopologyLockTest.java
index 4adf5f4..7711bbb 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientMultiNodeUpdateTopologyLockTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientMultiNodeUpdateTopologyLockTest.java
@@ -100,7 +100,7 @@ public class IgniteCacheClientMultiNodeUpdateTopologyLockTest extends GridCommon
 
         TestRecordingCommunicationSpi spi2 = TestRecordingCommunicationSpi.spi(ignite(2));
 
-        TestRecordingCommunicationSpi clientSpi = TestRecordingCommunicationSpi.spi(clientNode);
+        final TestRecordingCommunicationSpi clientSpi = TestRecordingCommunicationSpi.spi(clientNode);
 
         final UUID node0Id = ignite(0).cluster().localNode().id();
         final UUID node2Id = ignite(2).cluster().localNode().id();
@@ -115,22 +115,30 @@ public class IgniteCacheClientMultiNodeUpdateTopologyLockTest extends GridCommon
             }
         });
 
-        clientSpi.record(new IgniteBiPredicate<ClusterNode, Message>() {
-            @Override public boolean apply(ClusterNode node, Message msg) {
+        clientSpi.blockMessages(new IgniteBiPredicate<ClusterNode, Message>() {
+            @Override public boolean apply(final ClusterNode node, final Message msg) {
                 if (!node2Id.equals(node.id()))
                     return false;
 
                 if (msg instanceof GridNearTxFinishRequest) {
                     log.info("Delay message [msg=" + msg + ']');
 
-                    try {
-                        Thread.sleep(5000);
-                    }
-                    catch (InterruptedException e) {
-                        e.printStackTrace();
-                    }
+                    GridTestUtils.runAsync(new Runnable() {
+                        @Override public void run() {
+                            try {
+                                Thread.sleep(5000);
+                            }
+                            catch (InterruptedException e) {
+                                e.printStackTrace();
+                            }
+
+                            log.info("Send delayed message [msg=" + msg + ']');
+
+                            clientSpi.stopBlock(true);
+                        }
+                    });
 
-                    log.info("Send delayed message [msg=" + msg + ']');
+                    return true;
                 }
 
                 return false;


[26/29] ignite git commit: Formatting

Posted by ag...@apache.org.
Formatting


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

Branch: refs/heads/ignite-5024
Commit: 1ccb943b48cb5ce385b767f0a888980d2d7bd9e0
Parents: 9649733
Author: Yakov Zhdanov <yz...@gridgain.com>
Authored: Wed Apr 26 06:02:23 2017 +0300
Committer: Yakov Zhdanov <yz...@gridgain.com>
Committed: Wed Apr 26 06:02:23 2017 +0300

----------------------------------------------------------------------
 .../apache/ignite/examples/streaming/wordcount/QueryWords.java    | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/1ccb943b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/QueryWords.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/QueryWords.java b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/QueryWords.java
index 54aa97f..94949b4 100644
--- a/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/QueryWords.java
+++ b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/QueryWords.java
@@ -75,7 +75,8 @@ public class QueryWords {
                     List<?> row = stats.get(0);
 
                     if (row.get(0) != null)
-                        System.out.printf("Query results [avg=%d, min=%d, max=%d]%n", row.get(0), row.get(1), row.get(2));
+                        System.out.printf("Query results [avg=%d, min=%d, max=%d]%n",
+                            row.get(0), row.get(1), row.get(2));
 
                     // Print top 10 words.
                     ExamplesUtils.printQueryResults(top10);


[19/29] ignite git commit: IGNITE-5025 - Do not allow null names for memory policies

Posted by ag...@apache.org.
IGNITE-5025 - Do not allow null names for memory policies


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

Branch: refs/heads/ignite-5024
Commit: 1dc9e69851c19610e9357e35ae17ef2599733e5f
Parents: 4739458
Author: Sergey Chugunov <se...@gmail.com>
Authored: Tue Apr 25 11:17:24 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Tue Apr 25 11:23:30 2017 +0300

----------------------------------------------------------------------
 .../configuration/MemoryConfiguration.java      |  12 +-
 .../MemoryPolicyConfiguration.java              |   6 +-
 .../IgniteCacheDatabaseSharedManager.java       | 130 ++++----
 .../cache/MemoryPolicyConfigValidationTest.java |   6 +-
 .../MemoryPolicyInitializationTest.java         | 307 +++++++++++++++++++
 .../testsuites/IgniteCacheTestSuite2.java       |   2 +
 .../Cache/Configuration/MemoryConfiguration.cs  |   7 +
 .../Configuration/MemoryPolicyConfiguration.cs  |   3 +
 8 files changed, 415 insertions(+), 58 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/1dc9e698/modules/core/src/main/java/org/apache/ignite/configuration/MemoryConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/MemoryConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/MemoryConfiguration.java
index cd7c1fe..f88a95a 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/MemoryConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/MemoryConfiguration.java
@@ -71,6 +71,9 @@ public class MemoryConfiguration implements Serializable {
     /** Default memory page size. */
     public static final int DFLT_PAGE_SIZE = 2 * 1024;
 
+    /** This name is assigned to default MemoryPolicy if no user-defined default MemPlc is specified */
+    public static final String DFLT_MEM_PLC_DEFAULT_NAME = "default";
+
     /** Size of a memory chunk reserved for system cache needs. */
     private long sysCacheMemSize = DFLT_SYS_CACHE_MEM_SIZE;
 
@@ -81,7 +84,7 @@ public class MemoryConfiguration implements Serializable {
     private int concLvl;
 
     /** A name of the memory policy that defines the default memory region. */
-    private String dfltMemPlcName;
+    private String dfltMemPlcName = DFLT_MEM_PLC_DEFAULT_NAME;
 
     /** Memory policies. */
     private MemoryPolicyConfiguration[] memPlcs;
@@ -98,6 +101,8 @@ public class MemoryConfiguration implements Serializable {
     /**
      * Sets the size of a memory chunk reserved for system cache needs.
      *
+     * Default value is {@link #DFLT_SYS_CACHE_MEM_SIZE}
+     *
      * @param sysCacheMemSize Size in bytes.
      */
     public MemoryConfiguration setSystemCacheMemorySize(long sysCacheMemSize) {
@@ -119,6 +124,8 @@ public class MemoryConfiguration implements Serializable {
     /**
      * Changes the page size.
      *
+     * Default value is {@link #DFLT_PAGE_SIZE}
+     *
      * @param pageSize Page size in bytes.
      */
     public MemoryConfiguration setPageSize(int pageSize) {
@@ -164,7 +171,6 @@ public class MemoryConfiguration implements Serializable {
     public MemoryPolicyConfiguration createDefaultPolicyConfig() {
         MemoryPolicyConfiguration memPlc = new MemoryPolicyConfiguration();
 
-        memPlc.setName(null);
         memPlc.setSize(DFLT_MEMORY_POLICY_SIZE);
 
         return memPlc;
@@ -207,6 +213,8 @@ public class MemoryConfiguration implements Serializable {
      * {@link MemoryConfiguration#setMemoryPolicies(MemoryPolicyConfiguration...)} method and change the name of the
      * default memory policy with {@code MemoryConfiguration#setDefaultMemoryPolicyName(String)}.
      *
+     * If nothing is specified by user, it is set to {@link #DFLT_MEM_PLC_DEFAULT_NAME} value.
+     *
      * @param dfltMemPlcName Name of a memory policy to be used as default one.
      */
     public MemoryConfiguration setDefaultMemoryPolicyName(String dfltMemPlcName) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/1dc9e698/modules/core/src/main/java/org/apache/ignite/configuration/MemoryPolicyConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/MemoryPolicyConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/MemoryPolicyConfiguration.java
index 6d5fe8c..d0adcf9 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/MemoryPolicyConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/MemoryPolicyConfiguration.java
@@ -19,6 +19,8 @@ package org.apache.ignite.configuration;
 import java.io.Serializable;
 import org.apache.ignite.internal.mem.IgniteOutOfMemoryException;
 
+import static org.apache.ignite.configuration.MemoryConfiguration.DFLT_MEM_PLC_DEFAULT_NAME;
+
 /**
  * This class allows defining custom memory policies' configurations with various parameters for Apache Ignite
  * page memory (see {@link MemoryConfiguration}. For each configured memory policy Apache Ignite instantiates
@@ -61,7 +63,7 @@ public final class MemoryPolicyConfiguration implements Serializable {
     private static final long serialVersionUID = 0L;
 
     /** Memory policy name. */
-    private String name;
+    private String name = DFLT_MEM_PLC_DEFAULT_NAME;
 
     /** Memory policy maximum size. */
     private long size;
@@ -93,6 +95,8 @@ public final class MemoryPolicyConfiguration implements Serializable {
     /**
      * Sets memory policy name. The name must be non empty and must not be equal to the reserved 'sysMemPlc' one.
      *
+     * If not specified, {@link MemoryConfiguration#DFLT_MEM_PLC_DEFAULT_NAME} value is used.
+     *
      * @param name Memory policy name.
      */
     public MemoryPolicyConfiguration setName(String name) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/1dc9e698/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheDatabaseSharedManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheDatabaseSharedManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheDatabaseSharedManager.java
index 705e74c..ae594fa 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheDatabaseSharedManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheDatabaseSharedManager.java
@@ -57,12 +57,14 @@ import org.apache.ignite.internal.processors.cluster.IgniteChangeGlobalStateSupp
 import org.apache.ignite.mxbean.MemoryMetricsMXBean;
 import org.jetbrains.annotations.Nullable;
 
+import static org.apache.ignite.configuration.MemoryConfiguration.DFLT_MEM_PLC_DEFAULT_NAME;
+
 /**
  *
  */
 public class IgniteCacheDatabaseSharedManager extends GridCacheSharedManagerAdapter implements IgniteChangeGlobalStateSupport {
     /** MemoryPolicyConfiguration name reserved for internal caches. */
-    private static final String SYSTEM_MEMORY_POLICY_NAME = "sysMemPlc";
+    static final String SYSTEM_MEMORY_POLICY_NAME = "sysMemPlc";
 
     /** Minimum size of memory chunk */
     private static final long MIN_PAGE_MEMORY_SIZE = 1024 * 1024;
@@ -109,6 +111,8 @@ public class IgniteCacheDatabaseSharedManager extends GridCacheSharedManagerAdap
 
             initPageMemoryPolicies(memCfg);
 
+            registerMetricsMBeans();
+
             startMemoryPolicies();
 
             initPageMemoryDataStructures(memCfg);
@@ -116,6 +120,34 @@ public class IgniteCacheDatabaseSharedManager extends GridCacheSharedManagerAdap
     }
 
     /**
+     * Registers MBeans for all MemoryMetrics configured in this instance.
+     */
+    private void registerMetricsMBeans() {
+        IgniteConfiguration cfg = cctx.gridConfig();
+
+        for (MemoryMetrics memMetrics : memMetricsMap.values())
+            registerMetricsMBean((MemoryMetricsImpl) memMetrics, cfg);
+    }
+
+    /**
+     * @param memMetrics Memory metrics.
+     */
+    private void registerMetricsMBean(MemoryMetricsImpl memMetrics, IgniteConfiguration cfg) {
+        try {
+            U.registerMBean(
+                    cfg.getMBeanServer(),
+                    cfg.getIgniteInstanceName(),
+                    "MemoryMetrics",
+                    memMetrics.getName(),
+                    memMetrics,
+                    MemoryMetricsMXBean.class);
+        }
+        catch (JMException e) {
+            log.warning("Failed to register MBean for MemoryMetrics with name: '" + memMetrics.getName() + "'");
+        }
+    }
+
+    /**
      * @param dbCfg Database config.
      */
     protected void initPageMemoryDataStructures(MemoryConfiguration dbCfg) throws IgniteCheckedException {
@@ -172,87 +204,81 @@ public class IgniteCacheDatabaseSharedManager extends GridCacheSharedManagerAdap
         if (memPlcsCfgs == null) {
             //reserve place for default and system memory policies
             memPlcMap = U.newHashMap(2);
-
             memMetricsMap = U.newHashMap(2);
 
-            MemoryPolicyConfiguration dfltPlcCfg = dbCfg.createDefaultPolicyConfig();
-
-            MemoryMetricsImpl memMetrics = new MemoryMetricsImpl(dfltPlcCfg);
-
-            registerMetricsMBean(memMetrics);
-
-            dfltMemPlc = createDefaultMemoryPolicy(dbCfg, dfltPlcCfg, memMetrics);
-
-            memPlcMap.put(null, dfltMemPlc);
-            memMetricsMap.put(null, memMetrics);
+            addMemoryPolicy(dbCfg,
+                    dbCfg.createDefaultPolicyConfig(),
+                    DFLT_MEM_PLC_DEFAULT_NAME);
 
             log.warning("No user-defined default MemoryPolicy found; system default of 1GB size will be used.");
         }
         else {
             String dfltMemPlcName = dbCfg.getDefaultMemoryPolicyName();
 
-            if (dfltMemPlcName == null) {
+            if (DFLT_MEM_PLC_DEFAULT_NAME.equals(dfltMemPlcName) && !hasCustomDefaultMemoryPolicy(memPlcsCfgs)) {
                 //reserve additional place for default and system memory policies
                 memPlcMap = U.newHashMap(memPlcsCfgs.length + 2);
                 memMetricsMap = U.newHashMap(memPlcsCfgs.length + 2);
 
-                MemoryPolicyConfiguration dfltPlcCfg = dbCfg.createDefaultPolicyConfig();
-
-                MemoryMetricsImpl memMetrics = new MemoryMetricsImpl(dfltPlcCfg);
+                addMemoryPolicy(dbCfg,
+                        dbCfg.createDefaultPolicyConfig(),
+                        DFLT_MEM_PLC_DEFAULT_NAME);
 
-                dfltMemPlc = createDefaultMemoryPolicy(dbCfg, dfltPlcCfg, memMetrics);
-                memPlcMap.put(null, dfltMemPlc);
-                memMetricsMap.put(null, memMetrics);
-
-                log.warning("No user-defined default MemoryPolicy found; system default of 1GB size will be used.");
+                log.warning("No user-defined default MemoryPolicy found; system default will be allocated.");
             }
             else {
-                //reserve additional place for system memory policy only
+                //reserve additional space for system memory policy only
                 memPlcMap = U.newHashMap(memPlcsCfgs.length + 1);
-                memMetricsMap = U.newHashMap(memPlcsCfgs.length + 1);;
+                memMetricsMap = U.newHashMap(memPlcsCfgs.length + 1);
             }
 
-            for (MemoryPolicyConfiguration memPlcCfg : memPlcsCfgs) {
-                MemoryMetricsImpl memMetrics = new MemoryMetricsImpl(memPlcCfg);
+            for (MemoryPolicyConfiguration memPlcCfg : memPlcsCfgs)
+                addMemoryPolicy(dbCfg, memPlcCfg, memPlcCfg.getName());
+        }
 
-                MemoryPolicy memPlc = initMemory(dbCfg, memPlcCfg, memMetrics);
+        addMemoryPolicy(dbCfg,
+                createSystemMemoryPolicy(dbCfg.getSystemCacheMemorySize()),
+                SYSTEM_MEMORY_POLICY_NAME);
+    }
 
-                memPlcMap.put(memPlcCfg.getName(), memPlc);
+    /**
+     * @param dbCfg Database config.
+     * @param memPlcCfg Memory policy config.
+     * @param memPlcName Memory policy name.
+     */
+    private void addMemoryPolicy(MemoryConfiguration dbCfg,
+                                 MemoryPolicyConfiguration memPlcCfg,
+                                 String memPlcName) {
+        String dfltMemPlcName = dbCfg.getDefaultMemoryPolicyName();
 
-                memMetricsMap.put(memPlcCfg.getName(), memMetrics);
+        if (dfltMemPlcName == null)
+            dfltMemPlcName = DFLT_MEM_PLC_DEFAULT_NAME;
 
-                if (memPlcCfg.getName().equals(dfltMemPlcName))
-                    dfltMemPlc = memPlc;
-            }
-        }
+        MemoryMetricsImpl memMetrics = new MemoryMetricsImpl(memPlcCfg);
 
-        MemoryPolicyConfiguration sysPlcCfg = createSystemMemoryPolicy(dbCfg.getSystemCacheMemorySize());
+        MemoryPolicy memPlc = initMemory(dbCfg, memPlcCfg, memMetrics);
 
-        MemoryMetricsImpl sysMemMetrics = new MemoryMetricsImpl(sysPlcCfg);
+        memPlcMap.put(memPlcName, memPlc);
 
-        memPlcMap.put(SYSTEM_MEMORY_POLICY_NAME, initMemory(dbCfg, sysPlcCfg, sysMemMetrics));
+        memMetricsMap.put(memPlcName, memMetrics);
 
-        memMetricsMap.put(SYSTEM_MEMORY_POLICY_NAME, sysMemMetrics);
+        if (memPlcName.equals(dfltMemPlcName))
+            dfltMemPlc = memPlc;
+        else if (memPlcName.equals(DFLT_MEM_PLC_DEFAULT_NAME))
+            log.warning("Memory Policy with name 'default' isn't used as a default. " +
+                    "Please check Memory Policies configuration.");
     }
 
     /**
-     * @param memMetrics Mem metrics.
+     * @param memPlcsCfgs User-defined memory policy configurations.
      */
-    private void registerMetricsMBean(MemoryMetricsImpl memMetrics) {
-        IgniteConfiguration cfg = cctx.gridConfig();
-
-        try {
-            U.registerMBean(
-                    cfg.getMBeanServer(),
-                    cfg.getIgniteInstanceName(),
-                    "MemoryMetrics",
-                    memMetrics.getName(),
-                    memMetrics,
-                    MemoryMetricsMXBean.class);
-        }
-        catch (JMException e) {
-            log.warning("Failed to register MBean for MemoryMetrics with name: '" + memMetrics.getName() + "'");
+    private boolean hasCustomDefaultMemoryPolicy(MemoryPolicyConfiguration[] memPlcsCfgs) {
+        for (MemoryPolicyConfiguration memPlcsCfg : memPlcsCfgs) {
+            if (DFLT_MEM_PLC_DEFAULT_NAME.equals(memPlcsCfg.getName()))
+                return true;
         }
+
+        return false;
     }
 
     /**
@@ -305,7 +331,7 @@ public class IgniteCacheDatabaseSharedManager extends GridCacheSharedManagerAdap
      * @throws IgniteCheckedException In case of validation violation.
      */
     private static void checkDefaultPolicyConfiguration(String dfltPlcName, Set<String> plcNames) throws IgniteCheckedException {
-        if (dfltPlcName != null) {
+        if (!DFLT_MEM_PLC_DEFAULT_NAME.equals(dfltPlcName)) {
             if (dfltPlcName.isEmpty())
                 throw new IgniteCheckedException("User-defined default MemoryPolicy name must be non-empty");
             if (!plcNames.contains(dfltPlcName))

http://git-wip-us.apache.org/repos/asf/ignite/blob/1dc9e698/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MemoryPolicyConfigValidationTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MemoryPolicyConfigValidationTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MemoryPolicyConfigValidationTest.java
index c0f74d0..154e562 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MemoryPolicyConfigValidationTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MemoryPolicyConfigValidationTest.java
@@ -43,7 +43,7 @@ public class MemoryPolicyConfigValidationTest extends GridCommonAbstractTest {
 
                 break;
 
-            case RESERVED_MEMORY_POLICY_MISUSE:
+            case SYSTEM_MEMORY_POLICY_NAME_MISUSE:
                 plcs = createPlcWithReservedNameMisuseCfg();
 
                 break;
@@ -147,7 +147,7 @@ public class MemoryPolicyConfigValidationTest extends GridCommonAbstractTest {
      * 'sysMemPlc' name is reserved for MemoryPolicyConfiguration for system caches.
      */
     public void testReservedMemoryPolicyMisuse() throws Exception {
-        violationType = ValidationViolationType.RESERVED_MEMORY_POLICY_MISUSE;
+        violationType = ValidationViolationType.SYSTEM_MEMORY_POLICY_NAME_MISUSE;
 
         doTest(violationType);
     }
@@ -217,7 +217,7 @@ public class MemoryPolicyConfigValidationTest extends GridCommonAbstractTest {
         NAMES_CONFLICT("Two MemoryPolicies have the same name: "),
 
         /** */
-        RESERVED_MEMORY_POLICY_MISUSE("'sysMemPlc' policy name is reserved for internal use."),
+        SYSTEM_MEMORY_POLICY_NAME_MISUSE("'sysMemPlc' policy name is reserved for internal use."),
 
         /** */
         TOO_SMALL_MEMORY_SIZE("MemoryPolicy must have size more than 1MB: "),

http://git-wip-us.apache.org/repos/asf/ignite/blob/1dc9e698/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/database/MemoryPolicyInitializationTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/database/MemoryPolicyInitializationTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/database/MemoryPolicyInitializationTest.java
new file mode 100644
index 0000000..1e3f328
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/database/MemoryPolicyInitializationTest.java
@@ -0,0 +1,307 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ignite.internal.processors.cache.database;
+
+import java.util.Collection;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.MemoryConfiguration;
+import org.apache.ignite.configuration.MemoryPolicyConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.processors.cache.GridCacheContext;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import static org.apache.ignite.configuration.MemoryConfiguration.DFLT_MEM_PLC_DEFAULT_NAME;
+
+/**
+ *
+ */
+public class MemoryPolicyInitializationTest extends GridCommonAbstractTest {
+    /** */
+    private static final String CUSTOM_NON_DEFAULT_MEM_PLC_NAME = "custom_mem_plc";
+
+    /** */
+    private static final long USER_CUSTOM_MEM_PLC_SIZE = 10 * 1024 * 1024;
+
+    /** */
+    private static final long USER_DEFAULT_MEM_PLC_SIZE = 99 * 1024 * 1024;
+
+    /** */
+    private MemoryConfiguration memCfg;
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
+
+        cfg.setMemoryConfiguration(memCfg);
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        memCfg = null;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        stopAllGrids();
+    }
+
+    /**
+     * Verifies that expected memory policies are allocated when used doesn't provide any MemoryPolicyConfiguration.
+     */
+    public void testNoConfigProvided() throws Exception {
+        memCfg = null;
+
+        IgniteEx ignite = startGrid(0);
+
+        Collection<MemoryPolicy> allMemPlcs = ignite.context().cache().context().database().memoryPolicies();
+
+        assertTrue(allMemPlcs.size() == 2);
+
+        verifyDefaultAndSystemMemoryPolicies(allMemPlcs);
+    }
+
+    /**
+     * Verifies that expected memory policies are allocated when used provides MemoryPolicyConfiguration
+     * with non-default custom MemoryPolicy.
+     */
+    public void testCustomConfigNoDefault() throws Exception {
+        prepareCustomNoDefaultConfig();
+
+        IgniteEx ignite = startGrid(0);
+
+        Collection<MemoryPolicy> allMemPlcs = ignite.context().cache().context().database().memoryPolicies();
+
+        assertTrue(allMemPlcs.size() == 3);
+
+        verifyDefaultAndSystemMemoryPolicies(allMemPlcs);
+
+        assertTrue("Custom non-default memory policy is not presented",
+                isMemoryPolicyPresented(allMemPlcs, CUSTOM_NON_DEFAULT_MEM_PLC_NAME));
+    }
+
+    /**
+     * User is allowed to configure memory policy with 'default' name,
+     * in that case Ignite instance will use this user-defined memory policy as a default one.
+     */
+    public void testCustomConfigOverridesDefault() throws Exception {
+        prepareCustomConfigWithOverridingDefault();
+
+        IgniteEx ignite = startGrid(0);
+
+        IgniteCacheDatabaseSharedManager dbMgr = ignite.context().cache().context().database();
+
+        Collection<MemoryPolicy> allMemPlcs = dbMgr.memoryPolicies();
+
+        assertTrue(allMemPlcs.size() == 2);
+
+        verifyDefaultAndSystemMemoryPolicies(allMemPlcs);
+
+        MemoryPolicy dfltMemPlc = U.field(dbMgr, "dfltMemPlc");
+
+        assertTrue(dfltMemPlc.config().getSize() == USER_DEFAULT_MEM_PLC_SIZE);
+    }
+
+    /**
+     * User is allowed to define fully custom memory policy and make it default by setting its name to memory config.
+     *
+     * At the same time user still can create a memory policy with name 'default'
+     * which although won't be used as default.
+     */
+    public void testCustomConfigOverridesDefaultNameAndDeclaresDefault() throws Exception {
+        prepareCustomConfigWithOverriddenDefaultName();
+
+        IgniteEx ignite = startGrid(0);
+
+        IgniteCacheDatabaseSharedManager dbMgr = ignite.context().cache().context().database();
+
+        Collection<MemoryPolicy> allMemPlcs = dbMgr.memoryPolicies();
+
+        assertTrue(allMemPlcs.size() == 3);
+
+        verifyDefaultAndSystemMemoryPolicies(allMemPlcs);
+
+        MemoryPolicy dfltMemPlc = U.field(dbMgr, "dfltMemPlc");
+
+        assertTrue(dfltMemPlc.config().getSize() == USER_CUSTOM_MEM_PLC_SIZE);
+    }
+
+    /**
+     * Test for verification that caches with not specified memory policy name,
+     * with specified default memory policy name and specified custom memory policy name
+     * all started with correct memory policy.
+     */
+    public void testCachesOnOverriddenMemoryPolicy() throws Exception {
+        prepareCustomConfigWithOverridingDefaultAndCustom();
+
+        IgniteEx ignite = startGrid(0);
+
+        CacheConfiguration cache1Cfg = new CacheConfiguration()
+                .setName("cache1");
+
+        IgniteCache cache1 = ignite.createCache(cache1Cfg);
+
+        verifyCacheMemoryPolicy(cache1, DFLT_MEM_PLC_DEFAULT_NAME);
+
+        CacheConfiguration cache2Cfg = new CacheConfiguration()
+                .setName("cache2")
+                .setMemoryPolicyName(CUSTOM_NON_DEFAULT_MEM_PLC_NAME);
+
+        IgniteCache cache2 = ignite.createCache(cache2Cfg);
+
+        verifyCacheMemoryPolicy(cache2, CUSTOM_NON_DEFAULT_MEM_PLC_NAME);
+
+        CacheConfiguration cache3Cfg = new CacheConfiguration()
+                .setName("cache3")
+                .setMemoryPolicyName(DFLT_MEM_PLC_DEFAULT_NAME);
+
+        IgniteCache cache3 = ignite.createCache(cache3Cfg);
+
+        verifyCacheMemoryPolicy(cache3, DFLT_MEM_PLC_DEFAULT_NAME);
+    }
+
+    /**
+     * Test for verification that caches with not specified memory policy name,
+     * with specified default memory policy name and specified custom memory policy name
+     * all started with correct memory policy.
+     */
+    public void testCachesOnUserDefinedDefaultMemoryPolicy() throws Exception {
+        prepareCustomConfigWithOverriddenDefaultName();
+
+        IgniteEx ignite = startGrid(0);
+
+        CacheConfiguration cache1Cfg = new CacheConfiguration()
+                .setName("cache1");
+
+        IgniteCache cache1 = ignite.createCache(cache1Cfg);
+
+        verifyCacheMemoryPolicy(cache1, CUSTOM_NON_DEFAULT_MEM_PLC_NAME);
+
+        CacheConfiguration cache2Cfg = new CacheConfiguration()
+                .setName("cache2")
+                .setMemoryPolicyName(CUSTOM_NON_DEFAULT_MEM_PLC_NAME);
+
+        IgniteCache cache2 = ignite.createCache(cache2Cfg);
+
+        verifyCacheMemoryPolicy(cache2, CUSTOM_NON_DEFAULT_MEM_PLC_NAME);
+
+        CacheConfiguration cache3Cfg = new CacheConfiguration()
+                .setName("cache3")
+                .setMemoryPolicyName(DFLT_MEM_PLC_DEFAULT_NAME);
+
+        IgniteCache cache3 = ignite.createCache(cache3Cfg);
+
+        verifyCacheMemoryPolicy(cache3, DFLT_MEM_PLC_DEFAULT_NAME);
+    }
+
+    /**
+     * @param cache Cache.
+     * @param plcName Policy name.
+     */
+    private void verifyCacheMemoryPolicy(IgniteCache cache, String plcName) {
+        GridCacheContext ctx = U.field(cache, "ctx");
+
+        assertEquals(plcName, ctx.memoryPolicy().config().getName());
+    }
+
+    /**
+     *
+     */
+    private void prepareCustomConfigWithOverriddenDefaultName() {
+        memCfg = new MemoryConfiguration();
+
+        memCfg.setDefaultMemoryPolicyName(CUSTOM_NON_DEFAULT_MEM_PLC_NAME);
+
+        memCfg.setMemoryPolicies(new MemoryPolicyConfiguration()
+                .setName(CUSTOM_NON_DEFAULT_MEM_PLC_NAME)
+                .setSize(USER_CUSTOM_MEM_PLC_SIZE),
+
+                new MemoryPolicyConfiguration()
+                .setName(DFLT_MEM_PLC_DEFAULT_NAME)
+                .setSize(USER_DEFAULT_MEM_PLC_SIZE)
+        );
+    }
+
+
+    /**
+     *
+     */
+    private void prepareCustomConfigWithOverridingDefault() {
+        memCfg = new MemoryConfiguration();
+
+        memCfg.setMemoryPolicies(new MemoryPolicyConfiguration()
+                .setName(DFLT_MEM_PLC_DEFAULT_NAME)
+                .setSize(USER_DEFAULT_MEM_PLC_SIZE)
+        );
+    }
+
+    /**
+     *
+     */
+    private void prepareCustomConfigWithOverridingDefaultAndCustom() {
+        memCfg = new MemoryConfiguration();
+
+        memCfg.setMemoryPolicies(new MemoryPolicyConfiguration()
+                .setName(DFLT_MEM_PLC_DEFAULT_NAME)
+                .setSize(USER_DEFAULT_MEM_PLC_SIZE),
+
+                new MemoryPolicyConfiguration()
+                .setName(CUSTOM_NON_DEFAULT_MEM_PLC_NAME)
+                .setSize(USER_CUSTOM_MEM_PLC_SIZE)
+        );
+    }
+
+    /**
+     * @param allMemPlcs Collection of all memory policies.
+     */
+    private void verifyDefaultAndSystemMemoryPolicies(Collection<MemoryPolicy> allMemPlcs) {
+        assertTrue("Default memory policy is not presented",
+                isMemoryPolicyPresented(allMemPlcs, DFLT_MEM_PLC_DEFAULT_NAME));
+
+        assertTrue("System memory policy is not presented",
+                isMemoryPolicyPresented(allMemPlcs, IgniteCacheDatabaseSharedManager.SYSTEM_MEMORY_POLICY_NAME));
+    }
+
+    /**
+     *
+     */
+    private void prepareCustomNoDefaultConfig() {
+        memCfg = new MemoryConfiguration();
+
+        memCfg.setMemoryPolicies(new MemoryPolicyConfiguration()
+                .setName(CUSTOM_NON_DEFAULT_MEM_PLC_NAME)
+                .setSize(USER_CUSTOM_MEM_PLC_SIZE)
+        );
+    }
+
+    /**
+     * @param memPlcs Collection of memory policies.
+     * @param nameToVerify Excepted name of memory policy.
+     */
+    private boolean isMemoryPolicyPresented(Collection<MemoryPolicy> memPlcs, String nameToVerify) {
+        for (MemoryPolicy memPlc : memPlcs) {
+            if (nameToVerify.equals(memPlc.config().getName()))
+                return true;
+        }
+
+        return false;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/1dc9e698/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java
index 89e8f01..04a3753 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java
@@ -44,6 +44,7 @@ import org.apache.ignite.internal.processors.cache.IgniteCachePartitionMapUpdate
 import org.apache.ignite.internal.processors.cache.IgniteDynamicCacheAndNodeStop;
 import org.apache.ignite.internal.processors.cache.IgniteOnePhaseCommitInvokeTest;
 import org.apache.ignite.internal.processors.cache.MemoryPolicyConfigValidationTest;
+import org.apache.ignite.internal.processors.cache.database.MemoryPolicyInitializationTest;
 import org.apache.ignite.internal.processors.cache.distributed.CacheLoadingConcurrentGridStartSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.CacheLoadingConcurrentGridStartSelfTestAllowOverwrite;
 import org.apache.ignite.internal.processors.cache.distributed.CacheLockReleaseNodeLeaveTest;
@@ -250,6 +251,7 @@ public class IgniteCacheTestSuite2 extends TestSuite {
         suite.addTest(new TestSuite(NearCacheSyncUpdateTest.class));
         suite.addTest(new TestSuite(CacheConfigurationLeakTest.class));
         suite.addTest(new TestSuite(MemoryPolicyConfigValidationTest.class));
+        suite.addTest(new TestSuite(MemoryPolicyInitializationTest.class));
         suite.addTest(new TestSuite(CacheMemoryPolicyConfigurationTest.class));
         suite.addTest(new TestSuite(CacheEnumOperationsSingleNodeTest.class));
         suite.addTest(new TestSuite(CacheEnumOperationsTest.class));

http://git-wip-us.apache.org/repos/asf/ignite/blob/1dc9e698/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryConfiguration.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryConfiguration.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryConfiguration.cs
index 9b1016d..9c4bb35 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryConfiguration.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryConfiguration.cs
@@ -56,12 +56,18 @@ namespace Apache.Ignite.Core.Cache.Configuration
         public const int DefaultPageSize = 2 * 1024;
 
         /// <summary>
+        /// The default value for <see cref="DefaultMemoryPolicyName"/>.
+        /// </summary>
+        public const string DefaultDefaultMemoryPolicyName = "default";
+
+        /// <summary>
         /// Initializes a new instance of the <see cref="MemoryConfiguration"/> class.
         /// </summary>
         public MemoryConfiguration()
         {
             SystemCacheMemorySize = DefaultSystemCacheMemorySize;
             PageSize = DefaultPageSize;
+            DefaultMemoryPolicyName = DefaultDefaultMemoryPolicyName;
         }
 
         /// <summary>
@@ -140,6 +146,7 @@ namespace Apache.Ignite.Core.Cache.Configuration
         /// <summary>
         /// Gets or sets the name of the default memory policy in <see cref="MemoryPolicies"/>.
         /// </summary>
+        [DefaultValue(DefaultDefaultMemoryPolicyName)]
         public string DefaultMemoryPolicyName { get; set; }
 
         /// <summary>

http://git-wip-us.apache.org/repos/asf/ignite/blob/1dc9e698/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryPolicyConfiguration.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryPolicyConfiguration.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryPolicyConfiguration.cs
index 9e21910..fe4e91f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryPolicyConfiguration.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryPolicyConfiguration.cs
@@ -42,6 +42,7 @@ namespace Apache.Ignite.Core.Cache.Configuration
         {
             EvictionThreshold = DefaultEvictionThreshold;
             EmptyPagesPoolSize = DefaultEmptyPagesPoolSize;
+            Name = MemoryConfiguration.DefaultDefaultMemoryPolicyName;
         }
 
         /// <summary>
@@ -73,7 +74,9 @@ namespace Apache.Ignite.Core.Cache.Configuration
 
         /// <summary>
         /// Gets or sets the memory policy name.
+        /// Defaults to <see cref="MemoryConfiguration.DefaultDefaultMemoryPolicyName"/>.
         /// </summary>
+        [DefaultValue(MemoryConfiguration.DefaultDefaultMemoryPolicyName)]
         public string Name { get; set; }
 
         /// <summary>


[24/29] ignite git commit: IGNITE-4523 Allow distributed SQL query execution over explicit set of partitions - Fixes #1858.

Posted by ag...@apache.org.
IGNITE-4523 Allow distributed SQL query execution over explicit set of partitions - Fixes #1858.

Signed-off-by: Sergi Vladykin <se...@gmail.com>


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

Branch: refs/heads/ignite-5024
Commit: 5ef610c07c947c7cf4884b946ef1649e5ce4da34
Parents: 712398e
Author: ascherbakoff <al...@gmail.com>
Authored: Tue Apr 25 14:01:33 2017 +0300
Committer: Sergi Vladykin <se...@gmail.com>
Committed: Tue Apr 25 14:01:33 2017 +0300

----------------------------------------------------------------------
 .../org/apache/ignite/cache/query/Query.java    |  48 ++
 .../ignite/cache/query/SqlFieldsQuery.java      |  26 +
 .../org/apache/ignite/cache/query/SqlQuery.java |  26 +
 .../processors/cache/IgniteCacheProxy.java      |  14 +
 .../processors/query/GridQueryProcessor.java    |   4 +-
 .../ignite/internal/util/GridIntIterator.java   |  33 +
 .../ignite/internal/util/GridIntList.java       |  21 +-
 .../ignite/internal/util/IgniteUtils.java       |  21 +-
 .../processors/query/h2/IgniteH2Indexing.java   |  14 +-
 .../query/h2/twostep/GridMapQueryExecutor.java  |   5 +-
 .../h2/twostep/GridReduceQueryExecutor.java     | 222 ++++++-
 .../h2/twostep/msg/GridH2QueryRequest.java      |  64 +-
 ...stributedPartitionQueryAbstractSelfTest.java | 655 +++++++++++++++++++
 ...utedPartitionQueryConfigurationSelfTest.java |  92 +++
 ...butedPartitionQueryNodeRestartsSelfTest.java | 114 ++++
 ...eCacheDistributedPartitionQuerySelfTest.java |  90 +++
 .../IgniteCacheQueryNodeRestartSelfTest2.java   |   8 +
 .../IgniteCacheQuerySelfTestSuite.java          |   6 +
 18 files changed, 1419 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/5ef610c0/modules/core/src/main/java/org/apache/ignite/cache/query/Query.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/Query.java b/modules/core/src/main/java/org/apache/ignite/cache/query/Query.java
index 71161e7..c9ed464 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/query/Query.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/query/Query.java
@@ -18,7 +18,10 @@
 package org.apache.ignite.cache.query;
 
 import java.io.Serializable;
+import java.util.Arrays;
 import org.apache.ignite.IgniteCache;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.internal.util.typedef.internal.A;
 import org.apache.ignite.internal.util.typedef.internal.S;
 
 /**
@@ -93,6 +96,51 @@ public abstract class Query<R> implements Serializable {
         return this;
     }
 
+    /**
+     * Prepares the partitions.
+     *
+     * @param parts Partitions.
+     */
+    protected int[] prepare(int[] parts) {
+        if (parts == null)
+            return null;
+
+        A.notEmpty(parts, "Partitions");
+
+        boolean sorted = true;
+
+        // Try to do validation in one pass, if array is already sorted.
+        for (int i = 0; i < parts.length; i++) {
+            if (i < parts.length - 1)
+                if (parts[i] > parts[i + 1])
+                    sorted = false;
+                else if (sorted)
+                    validateDups(parts[i], parts[i + 1]);
+
+            A.ensure(0 <= parts[i] && parts[i] < CacheConfiguration.MAX_PARTITIONS_COUNT, "Illegal partition");
+        }
+
+        // Sort and validate again.
+        if (!sorted) {
+            Arrays.sort(parts);
+
+            for (int i = 0; i < parts.length; i++) {
+                if (i < parts.length - 1)
+                    validateDups(parts[i], parts[i + 1]);
+            }
+        }
+
+        return parts;
+    }
+
+    /**
+     * @param p1 Part 1.
+     * @param p2 Part 2.
+     */
+    private void validateDups(int p1, int p2) {
+        A.ensure(p1 != p2, "Partition duplicates are not allowed: " + p1);
+    }
+
     /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(Query.class, this);

http://git-wip-us.apache.org/repos/asf/ignite/blob/5ef610c0/modules/core/src/main/java/org/apache/ignite/cache/query/SqlFieldsQuery.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/SqlFieldsQuery.java b/modules/core/src/main/java/org/apache/ignite/cache/query/SqlFieldsQuery.java
index 8c3a4fe..9a7211b 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/query/SqlFieldsQuery.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/query/SqlFieldsQuery.java
@@ -24,6 +24,7 @@ import org.apache.ignite.internal.processors.query.QueryUtils;
 import org.apache.ignite.internal.util.tostring.GridToStringInclude;
 import org.apache.ignite.internal.util.typedef.internal.A;
 import org.apache.ignite.internal.util.typedef.internal.S;
+import org.jetbrains.annotations.Nullable;
 
 /**
  * SQL Fields query. This query can return specific fields of data based
@@ -70,6 +71,9 @@ public class SqlFieldsQuery extends Query<List<?>> {
     /** */
     private boolean replicatedOnly;
 
+    /** Partitions for query */
+    private int[] parts;
+
     /**
      * Constructs SQL fields query.
      *
@@ -261,6 +265,28 @@ public class SqlFieldsQuery extends Query<List<?>> {
         return replicatedOnly;
     }
 
+    /**
+     * Gets partitions for query, in ascending order.
+     */
+    @Nullable public int[] getPartitions() {
+        return parts;
+    }
+
+    /**
+     * Sets partitions for a query.
+     * The query will be executed only on nodes which are primary for specified partitions.
+     * <p>
+     * Note what passed array'll be sorted in place for performance reasons, if it wasn't sorted yet.
+     *
+     * @param parts Partitions.
+     * @return {@code this} for chaining.
+     */
+    public SqlFieldsQuery setPartitions(@Nullable int... parts) {
+        this.parts = prepare(parts);
+
+        return this;
+    }
+
     /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(SqlFieldsQuery.class, this);

http://git-wip-us.apache.org/repos/asf/ignite/blob/5ef610c0/modules/core/src/main/java/org/apache/ignite/cache/query/SqlQuery.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/SqlQuery.java b/modules/core/src/main/java/org/apache/ignite/cache/query/SqlQuery.java
index 944c70e..a5994b9 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/query/SqlQuery.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/query/SqlQuery.java
@@ -24,6 +24,7 @@ import org.apache.ignite.internal.processors.query.QueryUtils;
 import org.apache.ignite.internal.util.tostring.GridToStringInclude;
 import org.apache.ignite.internal.util.typedef.internal.A;
 import org.apache.ignite.internal.util.typedef.internal.S;
+import org.jetbrains.annotations.Nullable;
 
 /**
  * SQL Query.
@@ -56,6 +57,9 @@ public final class SqlQuery<K, V> extends Query<Cache.Entry<K, V>> {
     /** */
     private boolean replicatedOnly;
 
+    /** Partitions for query */
+    private int[] parts;
+
     /**
      * Constructs query for the given type name and SQL query.
      *
@@ -250,6 +254,28 @@ public final class SqlQuery<K, V> extends Query<Cache.Entry<K, V>> {
         return replicatedOnly;
     }
 
+    /**
+     * Gets partitions for query, in ascending order.
+     */
+    @Nullable public int[] getPartitions() {
+        return parts;
+    }
+
+    /**
+     * Sets partitions for a query.
+     * The query will be executed only on nodes which are primary for specified partitions.
+     * <p>
+     * Note what passed array'll be sorted in place for performance reasons, if it wasn't sorted yet.
+     *
+     * @param parts Partitions.
+     * @return {@code this} for chaining.
+     */
+    public SqlQuery setPartitions(@Nullable int... parts) {
+        this.parts = prepare(parts);
+
+        return this;
+    }
+
     /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(SqlQuery.class, this);

http://git-wip-us.apache.org/repos/asf/ignite/blob/5ef610c0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
index b38520d..dfe817e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
@@ -776,6 +776,13 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
             if (qry instanceof SqlQuery) {
                 final SqlQuery p = (SqlQuery)qry;
 
+                if (p.isReplicatedOnly() && p.getPartitions() != null)
+                    throw new CacheException("Partitions are not supported in replicated only mode.");
+
+                if (p.isDistributedJoins() && p.getPartitions() != null)
+                    throw new CacheException(
+                        "Using both partitions and distributed JOINs is not supported for the same query");
+
                 if ((p.isReplicatedOnly() && isReplicatedDataNode()) || ctx.isLocal() || qry.isLocal())
                      return (QueryCursor<R>)ctx.kernalContext().query().queryLocal(ctx, p,
                                 opCtxCall != null && opCtxCall.isKeepBinary());
@@ -786,6 +793,13 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
             if (qry instanceof SqlFieldsQuery) {
                 SqlFieldsQuery p = (SqlFieldsQuery)qry;
 
+                if (p.isReplicatedOnly() && p.getPartitions() != null)
+                    throw new CacheException("Partitions are not supported in replicated only mode.");
+
+                if (p.isDistributedJoins() && p.getPartitions() != null)
+                    throw new CacheException(
+                        "Using both partitions and distributed JOINs is not supported for the same query");
+
                 if ((p.isReplicatedOnly() && isReplicatedDataNode()) || ctx.isLocal() || qry.isLocal())
                     return (QueryCursor<R>)ctx.kernalContext().query().queryLocalFields(ctx, p);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/5ef610c0/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
index 015646d..448639b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
@@ -1754,7 +1754,7 @@ public class GridQueryProcessor extends GridProcessorAdapter {
                             qry.getArgs(),
                             cctx.name());
 
-                        return idx.queryLocalSql(cctx, qry, idx.backupFilter(requestTopVer.get(), null), keepBinary);
+                        return idx.queryLocalSql(cctx, qry, idx.backupFilter(requestTopVer.get(), qry.getPartitions()), keepBinary);
                     }
                 }, true);
         }
@@ -1938,7 +1938,7 @@ public class GridQueryProcessor extends GridProcessorAdapter {
                     GridQueryCancel cancel = new GridQueryCancel();
 
                     final QueryCursor<List<?>> cursor = idx.queryLocalSqlFields(cctx, qry,
-                        idx.backupFilter(requestTopVer.get(), null), cancel);
+                        idx.backupFilter(requestTopVer.get(), qry.getPartitions()), cancel);
 
                     return new QueryCursorImpl<List<?>>(new Iterable<List<?>>() {
                         @Override public Iterator<List<?>> iterator() {

http://git-wip-us.apache.org/repos/asf/ignite/blob/5ef610c0/modules/core/src/main/java/org/apache/ignite/internal/util/GridIntIterator.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/GridIntIterator.java b/modules/core/src/main/java/org/apache/ignite/internal/util/GridIntIterator.java
new file mode 100644
index 0000000..ea863e7
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/GridIntIterator.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.util;
+
+/**
+ * Iterator over integer primitives.
+ */
+public interface GridIntIterator {
+    /**
+     * @return {@code true} if the iteration has more elements.
+     */
+    public boolean hasNext();
+
+    /**
+     * @return Next int.
+     */
+    public int next();
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/5ef610c0/modules/core/src/main/java/org/apache/ignite/internal/util/GridIntList.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/GridIntList.java b/modules/core/src/main/java/org/apache/ignite/internal/util/GridIntList.java
index 968b88e..e5b7b1b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/GridIntList.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/GridIntList.java
@@ -582,5 +582,22 @@ public class GridIntList implements Message, Externalizable {
     /** {@inheritDoc} */
     @Override public byte fieldsCount() {
         return 2;
-    }    
-}
+    }
+
+    /**
+     * @return Iterator.
+     */
+    public GridIntIterator iterator() {
+        return new GridIntIterator() {
+            int c = 0;
+
+            @Override public boolean hasNext() {
+                return c < idx;
+            }
+
+            @Override public int next() {
+                return arr[c++];
+            }
+        };
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/5ef610c0/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
index 7d7d071..59d334a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
@@ -10094,4 +10094,23 @@ public abstract class IgniteUtils {
             throw new IgniteCheckedException(e);
         }
     }
-}
+
+    /**
+     * Returns {@link GridIntIterator} for range of primitive integers.
+     * @param start Start.
+     * @param cnt Count.
+     */
+    public static GridIntIterator forRange(final int start, final int cnt) {
+        return new GridIntIterator() {
+            int c = 0;
+
+            @Override public boolean hasNext() {
+                return c < cnt;
+            }
+
+            @Override public int next() {
+                return start + c++;
+            }
+        };
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/5ef610c0/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 798ca9b..361b55b 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
@@ -1471,6 +1471,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
      * @param qry Query.
      * @param keepCacheObj Flag to keep cache object.
      * @param enforceJoinOrder Enforce join order of tables.
+     * @param parts Partitions.
      * @return Iterable result.
      */
     private Iterable<List<?>> runQueryTwoStep(
@@ -1480,11 +1481,12 @@ public class IgniteH2Indexing implements GridQueryIndexing {
         final boolean enforceJoinOrder,
         final int timeoutMillis,
         final GridQueryCancel cancel,
-        final Object[] params
+        final Object[] params,
+        final int[] parts
     ) {
         return new Iterable<List<?>>() {
             @Override public Iterator<List<?>> iterator() {
-                return rdcQryExec.query(cctx, qry, keepCacheObj, enforceJoinOrder, timeoutMillis, cancel, params);
+                return rdcQryExec.query(cctx, qry, keepCacheObj, enforceJoinOrder, timeoutMillis, cancel, params, parts);
             }
         };
     }
@@ -1515,6 +1517,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
         fqry.setArgs(qry.getArgs());
         fqry.setPageSize(qry.getPageSize());
         fqry.setDistributedJoins(qry.isDistributedJoins());
+        fqry.setPartitions(qry.getPartitions());
         fqry.setLocal(qry.isLocal());
 
         if (qry.getTimeout() > 0)
@@ -1730,7 +1733,8 @@ public class IgniteH2Indexing implements GridQueryIndexing {
             cancel = new GridQueryCancel();
 
         QueryCursorImpl<List<?>> cursor = new QueryCursorImpl<>(
-            runQueryTwoStep(cctx, twoStepQry, cctx.keepBinary(), enforceJoinOrder, qry.getTimeout(), cancel, qry.getArgs()),
+            runQueryTwoStep(cctx, twoStepQry, cctx.keepBinary(), enforceJoinOrder, qry.getTimeout(), cancel, 
+                    qry.getArgs(), qry.getPartitions()),
             cancel);
 
         cursor.fieldsMeta(meta);
@@ -1750,12 +1754,12 @@ public class IgniteH2Indexing implements GridQueryIndexing {
         if (caches.isEmpty())
             return; // Nothing to check
 
-        GridCacheSharedContext sharedContext = ctx.cache().context();
+        GridCacheSharedContext sharedCtx = ctx.cache().context();
 
         int expectedParallelism = 0;
 
         for (int i = 0; i < caches.size(); i++) {
-            GridCacheContext cctx = sharedContext.cacheContext(caches.get(i));
+            GridCacheContext cctx = sharedCtx.cacheContext(caches.get(i));
 
             assert cctx != null;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/5ef610c0/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java
index e4347b5..45d8f50 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java
@@ -426,8 +426,11 @@ public class GridMapQueryExecutor {
      * @param req Query request.
      */
     private void onQueryRequest(final ClusterNode node, final GridH2QueryRequest req) throws IgniteCheckedException {
+        int[] qryParts = req.queryPartitions();
+
         final Map<UUID,int[]> partsMap = req.partitions();
-        final int[] parts = partsMap == null ? null : partsMap.get(ctx.localNodeId());
+
+        final int[] parts = qryParts == null ? partsMap == null ? null : partsMap.get(ctx.localNodeId()) : qryParts;
 
         assert !F.isEmpty(req.caches());
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/5ef610c0/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 d307c00..3d81cb5 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
@@ -32,6 +32,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.UUID;
+import java.util.Arrays;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
@@ -73,6 +74,8 @@ import org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQuery
 import org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryNextPageRequest;
 import org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryNextPageResponse;
 import org.apache.ignite.internal.processors.query.h2.twostep.msg.GridH2QueryRequest;
+import org.apache.ignite.internal.util.GridIntIterator;
+import org.apache.ignite.internal.util.GridIntList;
 import org.apache.ignite.internal.util.GridSpinBusyLock;
 import org.apache.ignite.internal.util.typedef.CIX2;
 import org.apache.ignite.internal.util.typedef.F;
@@ -80,6 +83,7 @@ import org.apache.ignite.internal.util.typedef.X;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteBiClosure;
 import org.apache.ignite.lang.IgniteFuture;
+import org.apache.ignite.lang.IgnitePredicate;
 import org.apache.ignite.plugin.extensions.communication.Message;
 import org.h2.command.ddl.CreateTableData;
 import org.h2.engine.Session;
@@ -113,6 +117,9 @@ public class GridReduceQueryExecutor {
     private static final String MERGE_INDEX_SORTED = "merge_sorted";
 
     /** */
+    private static final Set<ClusterNode> UNMAPPED_PARTS = Collections.emptySet();
+
+    /** */
     private GridKernalContext ctx;
 
     /** */
@@ -376,21 +383,78 @@ public class GridReduceQueryExecutor {
     }
 
     /**
+     * @param topVer Topology version.
+     * @param cctx Cache context.
+     * @param parts Partitions.
+     */
+    private Map<ClusterNode, IntArray> stableDataNodesMap(AffinityTopologyVersion topVer,
+        final GridCacheContext<?, ?> cctx, @Nullable final int[] parts) {
+
+        Map<ClusterNode, IntArray> mapping = new HashMap<>();
+
+        // Explicit partitions mapping is not applicable to replicated cache.
+        if (cctx.isReplicated()) {
+            for (ClusterNode clusterNode : cctx.affinity().assignment(topVer).primaryPartitionNodes())
+                mapping.put(clusterNode, null);
+
+            return mapping;
+        }
+
+        List<List<ClusterNode>> assignment = cctx.affinity().assignment(topVer).assignment();
+
+        boolean needPartsFilter = parts != null;
+
+        GridIntIterator iter = needPartsFilter ? new GridIntList(parts).iterator() :
+            U.forRange(0, cctx.affinity().partitions());
+
+        while(iter.hasNext()) {
+            int partId = iter.next();
+
+            List<ClusterNode> partNodes = assignment.get(partId);
+
+            if (partNodes.size() > 0) {
+                ClusterNode prim = partNodes.get(0);
+
+                if (!needPartsFilter) {
+                    mapping.put(prim, null);
+
+                    continue;
+                }
+
+                IntArray partIds = mapping.get(prim);
+
+                if (partIds == null) {
+                    partIds = new IntArray();
+
+                    mapping.put(prim, partIds);
+                }
+
+                partIds.add(partId);
+            }
+        }
+
+        return mapping;
+    }
+
+    /**
      * @param isReplicatedOnly If we must only have replicated caches.
      * @param topVer Topology version.
      * @param cctx Cache context for main space.
      * @param extraSpaces Extra spaces.
+     * @param parts Partitions.
      * @return Data nodes or {@code null} if repartitioning started and we need to retry.
      */
-    private Collection<ClusterNode> stableDataNodes(
-        boolean isReplicatedOnly,
-        AffinityTopologyVersion topVer,
-        final GridCacheContext<?, ?> cctx,
-        List<Integer> extraSpaces
-    ) {
-        Set<ClusterNode> nodes = new HashSet<>(cctx.affinity().assignment(topVer).primaryPartitionNodes());
+    private Map<ClusterNode, IntArray> stableDataNodes(
+            boolean isReplicatedOnly,
+            AffinityTopologyVersion topVer,
+            final GridCacheContext<?, ?> cctx,
+            List<Integer> extraSpaces,
+            int[] parts) {
+        Map<ClusterNode, IntArray> map = stableDataNodesMap(topVer, cctx, parts);
 
-        if (F.isEmpty(nodes))
+        Set<ClusterNode> nodes = map.keySet();
+
+        if (F.isEmpty(map))
             throw new CacheException("Failed to find data nodes for cache: " + cctx.name());
 
         if (!F.isEmpty(extraSpaces)) {
@@ -406,7 +470,7 @@ public class GridReduceQueryExecutor {
                     throw new CacheException("Queries running on replicated cache should not contain JOINs " +
                         "with partitioned tables [rCache=" + cctx.name() + ", pCache=" + extraSpace + "]");
 
-                Collection<ClusterNode> extraNodes = extraCctx.affinity().assignment(topVer).primaryPartitionNodes();
+                Set<ClusterNode> extraNodes = stableDataNodesMap(topVer, extraCctx, parts).keySet();
 
                 if (F.isEmpty(extraNodes))
                     throw new CacheException("Failed to find data nodes for cache: " + extraSpace);
@@ -414,7 +478,7 @@ public class GridReduceQueryExecutor {
                 if (isReplicatedOnly && extraCctx.isReplicated()) {
                     nodes.retainAll(extraNodes);
 
-                    if (nodes.isEmpty()) {
+                    if (map.isEmpty()) {
                         if (isPreloadingActive(cctx, extraSpaces))
                             return null; // Retry.
                         else
@@ -431,7 +495,7 @@ public class GridReduceQueryExecutor {
                                 ", cache2=" + extraSpace + "]");
                 }
                 else if (!isReplicatedOnly && !extraCctx.isReplicated()) {
-                    if (extraNodes.size() != nodes.size() || !nodes.containsAll(extraNodes))
+                    if (!extraNodes.equals(nodes))
                         if (isPreloadingActive(cctx, extraSpaces))
                             return null; // Retry.
                         else
@@ -443,7 +507,7 @@ public class GridReduceQueryExecutor {
             }
         }
 
-        return nodes;
+        return map;
     }
 
     /**
@@ -454,6 +518,7 @@ public class GridReduceQueryExecutor {
      * @param timeoutMillis Timeout in milliseconds.
      * @param cancel Query cancel.
      * @param params Query parameters.
+     * @param parts Partitions.
      * @return Rows iterator.
      */
     public Iterator<List<?>> query(
@@ -463,13 +528,17 @@ public class GridReduceQueryExecutor {
         boolean enforceJoinOrder,
         int timeoutMillis,
         GridQueryCancel cancel,
-        Object[] params
+        Object[] params,
+        final int[] parts
     ) {
         if (F.isEmpty(params))
             params = EMPTY_PARAMS;
 
         final boolean isReplicatedOnly = qry.isReplicatedOnly();
 
+        // Fail if all caches are replicated and explicit partitions are set.
+
+
         for (int attempt = 0;; attempt++) {
             if (attempt != 0) {
                 try {
@@ -494,11 +563,30 @@ public class GridReduceQueryExecutor {
 
             List<Integer> extraSpaces = qry.extraCaches();
 
-            Collection<ClusterNode> nodes;
+            Collection<ClusterNode> nodes = null;
 
             // Explicit partition mapping for unstable topology.
             Map<ClusterNode, IntArray> partsMap = null;
 
+            // Explicit partitions mapping for query.
+            Map<ClusterNode, IntArray> qryMap = null;
+
+            // Partitions are not supported for queries over all replicated caches.
+            if (cctx.isReplicated() && parts != null) {
+                boolean failIfReplicatedOnly = true;
+
+                for (Integer cacheId : extraSpaces) {
+                    if (!cacheContext(cacheId).isReplicated()) {
+                        failIfReplicatedOnly = false;
+
+                        break;
+                    }
+                }
+
+                if (failIfReplicatedOnly)
+                    throw new CacheException("Partitions are not supported for replicated caches");
+            }
+
             if (qry.isLocal())
                 nodes = singletonList(ctx.discovery().localNode());
             else {
@@ -508,11 +596,18 @@ public class GridReduceQueryExecutor {
                     else {
                         partsMap = partitionedUnstableDataNodes(cctx, extraSpaces);
 
-                        nodes = partsMap == null ? null : partsMap.keySet();
+                        if (partsMap != null) {
+                            qryMap = narrowForQuery(partsMap, parts);
+
+                            nodes = qryMap == null ? null : qryMap.keySet();
+                        }
                     }
+                } else {
+                    qryMap = stableDataNodes(isReplicatedOnly, topVer, cctx, extraSpaces, parts);
+
+                    if (qryMap != null)
+                        nodes = qryMap.keySet();
                 }
-                else
-                    nodes = stableDataNodes(isReplicatedOnly, topVer, cctx, extraSpaces);
 
                 if (nodes == null)
                     continue; // Retry.
@@ -633,19 +728,18 @@ public class GridReduceQueryExecutor {
 
                 if (send(nodes,
                         new GridH2QueryRequest()
-                            .requestId(qryReqId)
-                            .topologyVersion(topVer)
-                            .pageSize(r.pageSize)
-                            .caches(qry.caches())
-                            .tables(distributedJoins ? qry.tables() : null)
-                            .partitions(convert(partsMap))
-                            .queries(mapQrys)
-                            .parameters(params)
-                            .flags(flags)
-                            .timeout(timeoutMillis),
-                    null,
-                    false)) {
-
+                                .requestId(qryReqId)
+                                .topologyVersion(topVer)
+                                .pageSize(r.pageSize)
+                                .caches(qry.caches())
+                                .tables(distributedJoins ? qry.tables() : null)
+                                .partitions(convert(partsMap))
+                                .queries(mapQrys)
+                                .parameters(params)
+                                .flags(flags)
+                                .timeout(timeoutMillis),
+                        parts == null ? null : new ExplicitPartitionsSpecializer(qryMap),
+                        false)) {
                     awaitAllReplies(r, nodes, cancel);
 
                     Object state = r.state.get();
@@ -1034,7 +1128,13 @@ public class GridReduceQueryExecutor {
             List<ClusterNode> owners = cctx.topology().owners(p);
 
             if (F.isEmpty(owners)) {
-                if (!F.isEmpty(dataNodes(cctx.name(), NONE)))
+                // Handle special case: no mapping is configured for a partition.
+                if (F.isEmpty(cctx.affinity().assignment(NONE).get(p))) {
+                    partLocs[p] = UNMAPPED_PARTS; // Mark unmapped partition.
+
+                    continue;
+                }
+                else if (!F.isEmpty(dataNodes(cctx.name(), NONE)))
                     return null; // Retry.
 
                 throw new CacheException("Failed to find data nodes [cache=" + cctx.name() + ", part=" + p + "]");
@@ -1059,6 +1159,9 @@ public class GridReduceQueryExecutor {
                 for (int p = 0, parts =  extraCctx.affinity().partitions(); p < parts; p++) {
                     List<ClusterNode> owners = extraCctx.topology().owners(p);
 
+                    if (partLocs[p] == UNMAPPED_PARTS)
+                        continue; // Skip unmapped partitions.
+
                     if (F.isEmpty(owners)) {
                         if (!F.isEmpty(dataNodes(extraCctx.name(), NONE)))
                             return null; // Retry.
@@ -1090,6 +1193,9 @@ public class GridReduceQueryExecutor {
                     return null; // Retry.
 
                 for (Set<ClusterNode> partLoc : partLocs) {
+                    if (partLoc == UNMAPPED_PARTS)
+                        continue; // Skip unmapped partition.
+
                     partLoc.retainAll(dataNodes);
 
                     if (partLoc.isEmpty())
@@ -1105,6 +1211,10 @@ public class GridReduceQueryExecutor {
         for (int p = 0; p < partLocs.length; p++) {
             Set<ClusterNode> pl = partLocs[p];
 
+            // Skip unmapped partitions.
+            if (pl == UNMAPPED_PARTS)
+                continue;
+
             assert !F.isEmpty(pl) : pl;
 
             ClusterNode n = pl.size() == 1 ? F.first(pl) : F.rand(pl);
@@ -1429,4 +1539,52 @@ public class GridReduceQueryExecutor {
             state(e, null);
         }
     }
-}
+
+    /** */
+    private Map<ClusterNode, IntArray> narrowForQuery(Map<ClusterNode, IntArray> partsMap, int[] parts) {
+        if (parts == null)
+            return partsMap;
+
+        Map<ClusterNode, IntArray> cp = U.newHashMap(partsMap.size());
+
+        for (Map.Entry<ClusterNode, IntArray> entry : partsMap.entrySet()) {
+            IntArray filtered = new IntArray(parts.length);
+
+            IntArray orig = entry.getValue();
+
+            for (int i = 0; i < orig.size(); i++) {
+                int p = orig.get(i);
+
+                if (Arrays.binarySearch(parts, p) >= 0)
+                    filtered.add(p);
+            }
+
+            if (filtered.size() > 0)
+                cp.put(entry.getKey(), filtered);
+        }
+
+        return cp.isEmpty() ? null : cp;
+    }
+
+    /** */
+    private static class ExplicitPartitionsSpecializer implements IgniteBiClosure<ClusterNode, Message, Message> {
+        /** Partitions map. */
+        private final Map<ClusterNode, IntArray> partsMap;
+
+        /**
+         * @param partsMap Partitions map.
+         */
+        public ExplicitPartitionsSpecializer(Map<ClusterNode, IntArray> partsMap) {
+            this.partsMap = partsMap;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Message apply(ClusterNode node, Message msg) {
+            GridH2QueryRequest rq = new GridH2QueryRequest((GridH2QueryRequest)msg);
+
+            rq.queryPartitions(toArray(partsMap.get(node)));
+
+            return rq;
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/5ef610c0/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2QueryRequest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2QueryRequest.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2QueryRequest.java
index 9e7dcbf..6741d89 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2QueryRequest.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2QueryRequest.java
@@ -17,6 +17,7 @@
 
 package org.apache.ignite.internal.processors.query.h2.twostep.msg;
 
+import java.io.Externalizable;
 import java.nio.ByteBuffer;
 import java.util.Collection;
 import java.util.List;
@@ -92,6 +93,10 @@ public class GridH2QueryRequest implements Message, GridCacheQueryMarshallable {
     @GridDirectMap(keyType = UUID.class, valueType = int[].class)
     private Map<UUID, int[]> parts;
 
+    /** Query partitions. */
+    @GridToStringInclude
+    private int[] qryParts;
+
     /** */
     private int pageSize;
 
@@ -120,6 +125,32 @@ public class GridH2QueryRequest implements Message, GridCacheQueryMarshallable {
     private byte[] paramsBytes;
 
     /**
+     * Required by {@link Externalizable}
+     */
+    public GridH2QueryRequest() {
+        // No-op.
+    }
+
+    /**
+     * @param req Request.
+     * @return {@code this}.
+     */
+    public GridH2QueryRequest(GridH2QueryRequest req) {
+        this.reqId = req.reqId;
+        this.caches = req.caches;
+        this.topVer = req.topVer;
+        this.parts = req.parts;
+        this.qryParts = req.qryParts;
+        this.pageSize = req.pageSize;
+        this.qrys = req.qrys;
+        this.flags = req.flags;
+        this.tbls = req.tbls;
+        this.timeout = req.timeout;
+        this.params = req.params;
+        this.paramsBytes = req.paramsBytes;
+    }
+
+    /**
      * @return Parameters.
      */
     public Object[] parameters() {
@@ -225,6 +256,23 @@ public class GridH2QueryRequest implements Message, GridCacheQueryMarshallable {
     }
 
     /**
+     * @return Query partitions.
+     */
+    public int[] queryPartitions() {
+        return qryParts;
+    }
+
+    /**
+     * @param qryParts Query partitions.
+     * @return {@code this}.
+     */
+    public GridH2QueryRequest queryPartitions(int[] qryParts) {
+        this.qryParts = qryParts;
+
+        return this;
+    }
+
+    /**
      * @param pageSize Page size.
      * @return {@code this}.
      */
@@ -403,6 +451,12 @@ public class GridH2QueryRequest implements Message, GridCacheQueryMarshallable {
 
                 writer.incrementState();
 
+
+            case 10:
+                if (!writer.writeIntArray("qryParts", qryParts))
+                    return false;
+
+                writer.incrementState();
         }
 
         return true;
@@ -496,6 +550,14 @@ public class GridH2QueryRequest implements Message, GridCacheQueryMarshallable {
 
                 reader.incrementState();
 
+
+            case 10:
+                qryParts = reader.readIntArray("qryParts");
+
+                if (!reader.isLastRead())
+                    return false;
+
+                reader.incrementState();
         }
 
         return reader.afterMessageRead(GridH2QueryRequest.class);
@@ -508,7 +570,7 @@ public class GridH2QueryRequest implements Message, GridCacheQueryMarshallable {
 
     /** {@inheritDoc} */
     @Override public byte fieldsCount() {
-        return 10;
+        return 11;
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/5ef610c0/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQueryAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQueryAbstractSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQueryAbstractSelfTest.java
new file mode 100644
index 0000000..708fb1d
--- /dev/null
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQueryAbstractSelfTest.java
@@ -0,0 +1,655 @@
+/*
+ * 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.near;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+import java.util.NavigableMap;
+import java.util.TreeMap;
+import java.util.UUID;
+import javax.cache.Cache;
+import javax.cache.CacheException;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteDataStreamer;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.affinity.AffinityFunction;
+import org.apache.ignite.cache.affinity.AffinityFunctionContext;
+import org.apache.ignite.cache.affinity.AffinityKeyMapped;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.cache.query.SqlQuery;
+import org.apache.ignite.cache.query.annotations.QuerySqlField;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.MemoryConfiguration;
+import org.apache.ignite.configuration.MemoryPolicyConfiguration;
+import org.apache.ignite.internal.IgniteInterruptedCheckedException;
+import org.apache.ignite.internal.util.GridRandom;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.X;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.ignite.util.AttributeNodeFilter;
+import org.jsr166.ThreadLocalRandom8;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheRebalanceMode.SYNC;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
+
+/**
+ * Abstract test for queries over explicit partitions.
+ */
+public abstract class IgniteCacheDistributedPartitionQueryAbstractSelfTest extends GridCommonAbstractTest {
+    /** Join query for test. */
+    private static final String JOIN_QRY = "select cl._KEY, de.depositId, de.regionId from " +
+        "\"cl\".Client cl, \"de\".Deposit de, \"re\".Region re where cl.clientId=de.clientId and de.regionId=re._KEY";
+
+    /** Region node attribute name. */
+    private static final String REGION_ATTR_NAME = "reg";
+
+    /** Grids count. */
+    protected static final int GRIDS_COUNT = 10;
+
+    /** IP finder. */
+    private static final TcpDiscoveryVmIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+    /** Partitions per region distribution. */
+    protected static final int[] PARTS_PER_REGION = new int[] {10, 20, 30, 40, 24};
+
+    /** Unmapped region id. */
+    protected static final int UNMAPPED_REGION = PARTS_PER_REGION.length;
+
+    /** Clients per partition. */
+    protected static final int CLIENTS_PER_PARTITION = 1;
+
+    /** Total clients. */
+    private static final int TOTAL_CLIENTS;
+
+    /** Affinity function to use on partitioned caches. */
+    private static final AffinityFunction AFFINITY = new RegionAwareAffinityFunction();
+
+    /** Partitions count. */
+    private static final int PARTS_COUNT;
+
+    /** Regions to partitions mapping. */
+    protected static final NavigableMap<Integer, List<Integer>> REGION_TO_PART_MAP = new TreeMap<>();
+
+    /** Query threads count. */
+    protected static final int QUERY_THREADS_CNT = 4;
+
+    /** Restarting threads count. */
+    protected static final int RESTART_THREADS_CNT = 2;
+
+    /** Node stop time. */
+    protected static final int NODE_RESTART_TIME = 1_000;
+
+    static {
+        int total = 0, parts = 0, p = 0, regionId = 1;
+
+        for (int regCnt : PARTS_PER_REGION) {
+            total += regCnt * CLIENTS_PER_PARTITION;
+
+            parts += regCnt;
+
+            REGION_TO_PART_MAP.put(regionId++, Arrays.asList(p, regCnt));
+
+            p += regCnt;
+        }
+
+        /** Last region was left empty intentionally, see {@link #UNMAPPED_REGION} */
+        TOTAL_CLIENTS = total - PARTS_PER_REGION[PARTS_PER_REGION.length - 1] * CLIENTS_PER_PARTITION;
+
+        PARTS_COUNT = parts;
+    }
+
+    /** Deposits per client. */
+    public static final int DEPOSITS_PER_CLIENT = 10;
+
+    /** Rnd. */
+    protected GridRandom rnd = new GridRandom();
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        MemoryConfiguration memCfg = new MemoryConfiguration();
+        memCfg.setDefaultMemoryPolicyName("default");
+        memCfg.setMemoryPolicies(new MemoryPolicyConfiguration().setName("default").setSize(20 * 1024 * 1024));
+
+        cfg.setMemoryConfiguration(memCfg);
+
+        TcpDiscoverySpi spi = (TcpDiscoverySpi)cfg.getDiscoverySpi();
+        spi.setIpFinder(IP_FINDER);
+
+        cfg.setDiscoverySpi(spi);
+
+        /** Clients cache */
+        CacheConfiguration<ClientKey, Client> clientCfg = new CacheConfiguration<>();
+        clientCfg.setName("cl");
+        clientCfg.setWriteSynchronizationMode(FULL_SYNC);
+        clientCfg.setAtomicityMode(TRANSACTIONAL);
+        clientCfg.setRebalanceMode(SYNC);
+        clientCfg.setBackups(2);
+        clientCfg.setAffinity(AFFINITY);
+        clientCfg.setIndexedTypes(ClientKey.class, Client.class);
+
+        /** Deposits cache */
+        CacheConfiguration<DepositKey, Deposit> depoCfg = new CacheConfiguration<>();
+        depoCfg.setName("de");
+        depoCfg.setWriteSynchronizationMode(FULL_SYNC);
+        depoCfg.setAtomicityMode(TRANSACTIONAL);
+        depoCfg.setRebalanceMode(SYNC);
+        depoCfg.setBackups(2);
+        depoCfg.setAffinity(AFFINITY);
+        depoCfg.setIndexedTypes(DepositKey.class, Deposit.class);
+
+        /** Regions cache. Uses default affinity. */
+        CacheConfiguration<Integer, Region> regionCfg = new CacheConfiguration<>();
+        regionCfg.setName("re");
+        regionCfg.setWriteSynchronizationMode(FULL_SYNC);
+        regionCfg.setAtomicityMode(TRANSACTIONAL);
+        regionCfg.setRebalanceMode(SYNC);
+        regionCfg.setCacheMode(CacheMode.REPLICATED);
+        regionCfg.setIndexedTypes(Integer.class, Region.class);
+
+        cfg.setCacheConfiguration(clientCfg, depoCfg, regionCfg);
+
+        if ("client".equals(gridName))
+            cfg.setClientMode(true);
+        else {
+            Integer reg = regionForGrid(gridName);
+
+            cfg.setUserAttributes(F.asMap(REGION_ATTR_NAME, reg));
+
+            log().info("Assigned region " + reg + " to grid " + gridName);
+        }
+
+        return cfg;
+    }
+
+    /** */
+    private static final class RegionAwareAffinityFunction implements AffinityFunction {
+        /** {@inheritDoc} */
+        @Override public void reset() {
+            // No-op.
+        }
+
+        /** {@inheritDoc} */
+        @Override public int partitions() {
+            return PARTS_COUNT;
+        }
+
+        /** {@inheritDoc} */
+        @Override public int partition(Object key) {
+            Integer regionId;
+
+            if (key instanceof RegionKey)
+                regionId = ((RegionKey)key).regionId;
+            else if (key instanceof BinaryObject) {
+                BinaryObject bo = (BinaryObject)key;
+
+                regionId = bo.field("regionId");
+            }
+            else
+                throw new IgniteException("Unsupported key for region aware affinity");
+
+            List<Integer> range = REGION_TO_PART_MAP.get(regionId);
+
+            Integer cnt = range.get(1);
+
+            return U.safeAbs(key.hashCode() % cnt) + range.get(0); // Assign partition in region's range.
+        }
+
+        /** {@inheritDoc} */
+        @Override public List<List<ClusterNode>> assignPartitions(AffinityFunctionContext affCtx) {
+            List<ClusterNode> nodes = affCtx.currentTopologySnapshot();
+
+            List<List<ClusterNode>> assignment = new ArrayList<>(PARTS_COUNT);
+
+            for (int p = 0; p < PARTS_COUNT; p++) {
+                // Get region for partition.
+                int regionId = regionForPart(p);
+
+                // Filter all nodes for region.
+                AttributeNodeFilter f = new AttributeNodeFilter(REGION_ATTR_NAME, regionId);
+
+                List<ClusterNode> regionNodes = new ArrayList<>();
+
+                for (ClusterNode node : nodes)
+                    if (f.apply(node))
+                        regionNodes.add(node);
+
+                final int cp = p;
+
+                Collections.sort(regionNodes, new Comparator<ClusterNode>() {
+                    @Override public int compare(ClusterNode o1, ClusterNode o2) {
+                        return Long.compare(hash(cp, o1), hash(cp, o2));
+                    }
+                });
+
+                assignment.add(regionNodes);
+            }
+
+            return assignment;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void removeNode(UUID nodeId) {
+            // No-op.
+        }
+
+        /**
+         * @param part Partition.
+         */
+        protected int regionForPart(int part) {
+            for (Map.Entry<Integer, List<Integer>> entry : REGION_TO_PART_MAP.entrySet()) {
+                List<Integer> range = entry.getValue();
+
+                if (range.get(0) <= part && part < range.get(0) + range.get(1))
+                    return entry.getKey();
+            }
+
+            throw new IgniteException("Failed to find zone for partition");
+        }
+
+        /**
+         * @param part Partition.
+         * @param obj Object.
+         */
+        private long hash(int part, Object obj) {
+            long x = ((long)part << 32) | obj.hashCode();
+            x ^= x >>> 12;
+            x ^= x << 25;
+            x ^= x >>> 27;
+            return x * 2685821657736338717L;
+        }
+    }
+
+    /**
+     * Assigns a region to grid part.
+     *
+     * @param gridName Grid name.
+     */
+    protected Integer regionForGrid(String gridName) {
+        char c = gridName.charAt(gridName.length() - 1);
+        switch (c) {
+            case '0':
+                return 1;
+            case '1':
+            case '2':
+                return 2;
+            case '3':
+            case '4':
+            case '5':
+                return 3;
+            default:
+                return 4;
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        super.beforeTestsStarted();
+
+        int sum1 = 0;
+        for (List<Integer> range : REGION_TO_PART_MAP.values())
+            sum1 += range.get(1);
+
+        assertEquals("Illegal partition per region distribution", PARTS_COUNT, sum1);
+
+        startGridsMultiThreaded(GRIDS_COUNT);
+
+        startGrid("client");
+
+        // Fill caches.
+        int clientId = 1;
+        int depositId = 1;
+        int regionId = 1;
+        int p = 1; // Percents counter. Log message will be printed 10 times.
+
+        try (IgniteDataStreamer<ClientKey, Client> clStr = grid(0).dataStreamer("cl");
+             IgniteDataStreamer<DepositKey, Deposit> depStr = grid(0).dataStreamer("de")) {
+            for (int cnt : PARTS_PER_REGION) {
+                // Last region was left empty intentionally.
+                if (regionId < PARTS_PER_REGION.length) {
+                    for (int i = 0; i < cnt * CLIENTS_PER_PARTITION; i++) {
+                        ClientKey ck = new ClientKey(clientId, regionId);
+
+                        Client cl = new Client();
+                        cl.firstName = "First_Name_" + clientId;
+                        cl.lastName = "Last_Name_" + clientId;
+                        cl.passport = clientId * 1_000;
+
+                        clStr.addData(ck, cl);
+
+                        for (int j = 0; j < DEPOSITS_PER_CLIENT; j++) {
+                            DepositKey dk = new DepositKey(depositId++, new ClientKey(clientId, regionId));
+
+                            Deposit depo = new Deposit();
+                            depo.amount = ThreadLocalRandom8.current().nextLong(1_000_001);
+                            depStr.addData(dk, depo);
+                        }
+
+                        if (clientId / (float)TOTAL_CLIENTS >= p / 10f) {
+                            log().info("Loaded " + clientId + " of " + TOTAL_CLIENTS);
+
+                            p++;
+                        }
+
+                        clientId++;
+                    }
+                }
+
+                Region region = new Region();
+                region.name = "Region_" + regionId;
+                region.code = regionId * 10;
+
+                grid(0).cache("re").put(regionId, region);
+
+                regionId++;
+            }
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTestsStopped() throws Exception {
+        super.afterTestsStopped();
+
+        stopAllGrids();
+    }
+
+    /**
+     * @param orig Originator.
+     */
+    protected void doTestRegionQuery(Ignite orig) {
+        IgniteCache<ClientKey, Client> cl = orig.cache("cl");
+
+        for (int regionId = 1; regionId <= PARTS_PER_REGION.length; regionId++) {
+            SqlQuery<ClientKey, Client> qry1 = new SqlQuery<>(Client.class, "regionId=?");
+            qry1.setArgs(regionId);
+
+            List<Cache.Entry<ClientKey, Client>> clients1 = cl.query(qry1).getAll();
+
+            int expRegionCnt = regionId == 5 ? 0 : PARTS_PER_REGION[regionId - 1] * CLIENTS_PER_PARTITION;
+
+            assertEquals("Region " + regionId + " count", expRegionCnt, clients1.size());
+
+            validateClients(regionId, clients1);
+
+            // Repeat the same query with partition set condition.
+            List<Integer> range = REGION_TO_PART_MAP.get(regionId);
+
+            SqlQuery<ClientKey, Client> qry2 = new SqlQuery<>(Client.class, "1=1");
+            qry2.setPartitions(createRange(range.get(0), range.get(1)));
+
+            try {
+                List<Cache.Entry<ClientKey, Client>> clients2 = cl.query(qry2).getAll();
+
+                assertEquals("Region " + regionId + " count with partition set", expRegionCnt, clients2.size());
+
+                // Query must produce only results from single region.
+                validateClients(regionId, clients2);
+
+                if (regionId == UNMAPPED_REGION)
+                    fail();
+            } catch (CacheException ignored) {
+                if (regionId != UNMAPPED_REGION)
+                    fail();
+            }
+        }
+    }
+
+    /** */
+    protected int[] createRange(int start, int cnt) {
+        int[] vals = new int[cnt];
+
+        for (int i = 0; i < cnt; i++)
+            vals[i] = start + i;
+
+        return vals;
+    }
+
+    /**
+     * @param orig Originator.
+     */
+    protected void doTestPartitionsQuery(Ignite orig) {
+        IgniteCache<ClientKey, Client> cl = orig.cache("cl");
+
+        for (int regionId = 1; regionId <= PARTS_PER_REGION.length; regionId++) {
+            log().info("Running test queries for region " + regionId);
+
+            List<Integer> range = REGION_TO_PART_MAP.get(regionId);
+
+            int[] parts = createRange(range.get(0), range.get(1));
+
+            int off = rnd.nextInt(parts.length);
+
+            int p1 = parts[off], p2 = parts[(off + (1 + rnd.nextInt(parts.length-1))) % parts.length];
+
+            log().info("Parts: " + p1 + " " + p2);
+
+            SqlQuery<ClientKey, Client> qry = new SqlQuery<>(Client.class, "1=1");
+
+            qry.setPartitions(p1, p2);
+
+            try {
+                List<Cache.Entry<ClientKey, Client>> clients = cl.query(qry).getAll();
+
+                // Query must produce only results from two partitions.
+                for (Cache.Entry<ClientKey, Client> client : clients) {
+                    int p = orig.affinity("cl").partition(client.getKey());
+
+                    assertTrue("Incorrect partition for key", p == p1 || p == p2);
+                }
+
+                if (regionId == UNMAPPED_REGION)
+                    fail();
+            } catch (CacheException ignored) {
+                if (regionId != UNMAPPED_REGION)
+                    fail();
+            }
+        }
+    }
+
+    /**
+     * @param orig Query originator.
+     * @param regionIds Region ids.
+     */
+    protected void doTestJoinQuery(Ignite orig, int... regionIds) {
+        IgniteCache<ClientKey, Client> cl = orig.cache("cl");
+
+        if (regionIds == null) {
+            regionIds = new int[PARTS_PER_REGION.length];
+
+            for (int i = 0; i < regionIds.length; i++)
+                regionIds[i] = i + 1;
+        }
+
+        for (int regionId : regionIds) {
+            List<Integer> range = REGION_TO_PART_MAP.get(regionId);
+
+            SqlFieldsQuery qry = new SqlFieldsQuery(JOIN_QRY);
+
+            int[] pSet = createRange(range.get(0), 1 + rnd.nextInt(range.get(1) - 1));
+
+            qry.setPartitions(pSet);
+
+            try {
+                List<List<?>> rows = cl.query(qry).getAll();
+
+                for (List<?> row : rows) {
+                    ClientKey key = (ClientKey)row.get(0);
+
+                    int p = orig.affinity("cl").partition(key);
+
+                    assertTrue(Arrays.binarySearch(pSet, p) >= 0);
+                }
+
+                // Query must produce only results from single region.
+                for (List<?> row : rows)
+                    assertEquals("Region id", regionId, ((Integer)row.get(2)).intValue());
+
+                if (regionId == UNMAPPED_REGION)
+                    fail();
+            }
+            catch (CacheException ignored) {
+                if (X.hasCause(ignored, InterruptedException.class, IgniteInterruptedCheckedException.class))
+                    return; // Allow interruptions.
+
+                if (regionId != UNMAPPED_REGION)
+                    fail();
+            }
+        }
+    }
+
+    /**
+     * @param regionId Region id.
+     * @param clients Clients.
+     */
+    protected void validateClients(int regionId, List<Cache.Entry<ClientKey, Client>> clients) {
+        for (Cache.Entry<ClientKey, Client> entry : clients) {
+            List<Integer> range = REGION_TO_PART_MAP.get(regionId);
+
+            int start = range.get(0) * CLIENTS_PER_PARTITION;
+            int end = start + range.get(1) * CLIENTS_PER_PARTITION;
+
+            int clientId = entry.getKey().clientId;
+
+            assertTrue("Client id in range", start < clientId && start <= end);
+        }
+    }
+
+    /** */
+    protected static class ClientKey extends RegionKey {
+        /** Client id. */
+        @QuerySqlField(index = true)
+        protected int clientId;
+
+        /**
+         * @param clientId Client id.
+         * @param regionId Region id.
+         */
+        public ClientKey(int clientId, int regionId) {
+            this.clientId = clientId;
+            this.regionId = regionId;
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean equals(Object o) {
+            if (this == o)
+                return true;
+            if (o == null || getClass() != o.getClass())
+                return false;
+
+            ClientKey clientKey = (ClientKey)o;
+
+            return clientId == clientKey.clientId;
+
+        }
+
+        /** {@inheritDoc} */
+        @Override public int hashCode() {
+            return clientId;
+        }
+    }
+
+    /** */
+    protected static class DepositKey extends RegionKey {
+        @QuerySqlField(index = true)
+        protected int depositId;
+
+        @QuerySqlField(index = true)
+        protected int clientId;
+
+        /** Client id. */
+        @AffinityKeyMapped
+        protected ClientKey clientKey;
+
+        /**
+         * @param depositId Client id.
+         * @param clientKey Client key.
+         */
+        public DepositKey(int depositId, ClientKey clientKey) {
+            this.depositId = depositId;
+            this.clientId = clientKey.clientId;
+            this.regionId = clientKey.regionId;
+            this.clientKey = clientKey;
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean equals(Object o) {
+            if (this == o)
+                return true;
+            if (o == null || getClass() != o.getClass())
+                return false;
+
+            DepositKey that = (DepositKey)o;
+
+            return depositId == that.depositId;
+        }
+
+        /** {@inheritDoc} */
+        @Override public int hashCode() {
+            return depositId;
+        }
+    }
+
+    /** */
+    protected static class RegionKey implements Serializable {
+        /** Region id. */
+        @QuerySqlField(index = true)
+        protected int regionId;
+    }
+
+    /** */
+    protected static class Client {
+        @QuerySqlField
+        protected String firstName;
+
+        @QuerySqlField
+        protected String lastName;
+
+        @QuerySqlField(index = true)
+        protected int passport;
+    }
+
+    /** */
+    protected static class Deposit {
+        @QuerySqlField
+        protected long amount;
+    }
+
+    /** */
+    protected static class Region {
+        @QuerySqlField
+        protected String name;
+
+        @QuerySqlField
+        protected int code;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/5ef610c0/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQueryConfigurationSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQueryConfigurationSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQueryConfigurationSelfTest.java
new file mode 100644
index 0000000..0253fe8
--- /dev/null
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQueryConfigurationSelfTest.java
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.distributed.near;
+
+import java.util.Arrays;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ * Tests cache query configuration.
+ */
+public class IgniteCacheDistributedPartitionQueryConfigurationSelfTest extends GridCommonAbstractTest {
+    /** Tests partition validation. */
+    public void testPartitions() {
+        final SqlFieldsQuery qry = new SqlFieldsQuery("select 1");
+
+        // Empty set is not allowed.
+        failIfNotThrown(new Runnable() {
+            @Override public void run() {
+                qry.setPartitions();
+            }
+        });
+
+        // Duplicates are not allowed.
+        failIfNotThrown(new Runnable() {
+            @Override public void run() {
+                qry.setPartitions(0, 1, 2, 1);
+            }
+        });
+
+        // Values out of range are not allowed.
+        failIfNotThrown(new Runnable() {
+            @Override public void run() {
+                qry.setPartitions(-1, 0, 1);
+            }
+        });
+
+        // Duplicates with unordered input are not allowed.
+        failIfNotThrown(new Runnable() {
+            @Override public void run() {
+                qry.setPartitions(3, 2, 2);
+            }
+        });
+
+        // Values out of range are not allowed.
+        failIfNotThrown(new Runnable() {
+            @Override public void run() {
+                qry.setPartitions(-1, 0, 1);
+            }
+        });
+
+        // Expecting ordered set.
+        int[] tmp = new int[] {6, 2 ,3};
+        qry.setPartitions(tmp);
+
+        assertTrue(Arrays.equals(new int[]{2, 3, 6}, tmp));
+
+        // If already ordered expecting same instance.
+        qry.setPartitions((tmp = new int[] {0, 1, 2}));
+
+        assertTrue(tmp == qry.getPartitions());
+    }
+
+    /**
+     * @param r Runnable.
+     */
+    private void failIfNotThrown(Runnable r) {
+        try {
+            r.run();
+
+            fail();
+        }
+        catch (Exception ignored) {
+            // No-op.
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/5ef610c0/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQueryNodeRestartsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQueryNodeRestartsSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQueryNodeRestartsSelfTest.java
new file mode 100644
index 0000000..68f9842
--- /dev/null
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQueryNodeRestartsSelfTest.java
@@ -0,0 +1,114 @@
+/*
+ * 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.near;
+
+import java.util.concurrent.Callable;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicIntegerArray;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.internal.IgniteFutureTimeoutCheckedException;
+import org.apache.ignite.internal.IgniteInternalFuture;
+
+/**
+ * Tests distributed queries over set of partitions on unstable topology.
+ */
+public class IgniteCacheDistributedPartitionQueryNodeRestartsSelfTest
+        extends IgniteCacheDistributedPartitionQueryAbstractSelfTest {
+    /**
+     * Tests join query within region on unstable topology.
+     */
+    public void testJoinQueryUnstableTopology() throws Exception {
+        final AtomicBoolean stop = new AtomicBoolean();
+
+        final AtomicIntegerArray states = new AtomicIntegerArray(GRIDS_COUNT);
+
+        final Ignite client = grid("client");
+
+        final AtomicInteger cnt = new AtomicInteger();
+
+        IgniteInternalFuture<?> fut = multithreadedAsync(new Runnable() {
+            @Override
+            public void run() {
+                while (!stop.get()) {
+                    doTestJoinQuery(client, rnd.nextInt(PARTS_PER_REGION.length) + 1);
+
+                    int cur = cnt.incrementAndGet();
+
+                    if (cur % 100 == 0)
+                        log().info("Queries count: " + cur);
+                }
+            }
+        }, QUERY_THREADS_CNT);
+
+        final AtomicIntegerArray restartStats = new AtomicIntegerArray(GRIDS_COUNT);
+
+        IgniteInternalFuture<?> fut2 = multithreadedAsync(new Callable<Void>() {
+            @Override
+            public Void call() throws Exception {
+                while (!stop.get()) {
+                    int grid = rnd.nextInt(GRIDS_COUNT);
+
+                    String name = getTestIgniteInstanceName(grid);
+
+                    Integer regionId = regionForGrid(name);
+
+                    // Restart nodes only from region with enough number of nodes.
+                    if (regionId != 3 && regionId != 4)
+                        continue;
+
+                    if (states.compareAndSet(grid, 0, 1)) {
+                        restartStats.incrementAndGet(grid);
+
+                        try {
+                            stopGrid(grid);
+
+                            Thread.sleep(rnd.nextInt(NODE_RESTART_TIME));
+
+                            startGrid(grid);
+
+                            Thread.sleep(rnd.nextInt(NODE_RESTART_TIME));
+                        } finally {
+                            states.set(grid, 0);
+                        }
+                    }
+                }
+
+                return null;
+            }
+        }, RESTART_THREADS_CNT);
+
+        try {
+            fut2.get(60, TimeUnit.SECONDS);
+        } catch (IgniteFutureTimeoutCheckedException ignored) {
+            stop.set(true);
+        }
+
+        try {
+            fut.get();
+        } finally {
+            log().info("Queries count: " + cnt.get());
+
+            for (int i = 0; i < GRIDS_COUNT; i++)
+                log().info("Grid [name = " + getTestIgniteInstanceName(i) + ", idx=" + i + " ] restarts count: " +
+                        restartStats.get(i));
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/5ef610c0/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQuerySelfTest.java
new file mode 100644
index 0000000..00c3848
--- /dev/null
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQuerySelfTest.java
@@ -0,0 +1,90 @@
+/*
+ * 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.near;
+
+import java.util.Arrays;
+import java.util.List;
+import javax.cache.Cache;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.affinity.Affinity;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.cache.query.SqlQuery;
+
+/**
+ * Tests distributed queries over set of partitions on stable topology.
+ */
+public class IgniteCacheDistributedPartitionQuerySelfTest extends IgniteCacheDistributedPartitionQueryAbstractSelfTest {
+    /** Tests query within region. */
+    public void testRegionQuery() {
+        doTestRegionQuery(grid(0));
+    }
+
+    /** Tests query within region (client). */
+    public void testRegionQueryClient() throws Exception {
+        doTestRegionQuery(grid("client"));
+    }
+
+    /** Test query within partitions. */
+    public void testPartitionsQuery() {
+        doTestPartitionsQuery(grid(0));
+    }
+
+    /** Test query within partitions (client). */
+    public void testPartitionsQueryClient() throws Exception {
+        doTestPartitionsQuery(grid("client"));
+    }
+
+    /** Tests join query within region. */
+    public void testJoinQuery() {
+        doTestJoinQuery(grid(0));
+    }
+
+    /** Tests join query within region. */
+    public void testJoinQueryClient() throws Exception {
+        doTestJoinQuery(grid("client"));
+    }
+
+    /** Tests local query over partitions. */
+    public void testLocalQuery() {
+        Affinity<Object> affinity = grid(0).affinity("cl");
+
+        int[] parts = affinity.primaryPartitions(grid(0).localNode());
+
+        Arrays.sort(parts);
+
+        IgniteCache<ClientKey, Client> cl = grid(0).cache("cl");
+
+        SqlQuery<ClientKey, Client> qry1 = new SqlQuery<>(Client.class, "1=1");
+        qry1.setLocal(true);
+        qry1.setPartitions(parts[0]);
+
+        List<Cache.Entry<ClientKey, Client>> clients = cl.query(qry1).getAll();
+
+        for (Cache.Entry<ClientKey, Client> client : clients)
+            assertEquals("Incorrect partition", parts[0], affinity.partition(client.getKey()));
+
+        SqlFieldsQuery qry2 = new SqlFieldsQuery("select cl._KEY, cl._VAL from \"cl\".Client cl");
+        qry2.setLocal(true);
+        qry2.setPartitions(parts[0]);
+
+        List<List<?>> rows = cl.query(qry2).getAll();
+
+        for (List<?> row : rows)
+            assertEquals("Incorrect partition", parts[0], affinity.partition(row.get(0)));
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/5ef610c0/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartSelfTest2.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartSelfTest2.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartSelfTest2.java
index 6fc9c39..001f40b 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartSelfTest2.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartSelfTest2.java
@@ -33,6 +33,8 @@ import org.apache.ignite.cache.query.SqlFieldsQuery;
 import org.apache.ignite.cache.query.annotations.QuerySqlField;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.MemoryConfiguration;
+import org.apache.ignite.configuration.MemoryPolicyConfiguration;
 import org.apache.ignite.internal.IgniteFutureTimeoutCheckedException;
 import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.IgniteInterruptedCheckedException;
@@ -89,6 +91,12 @@ public class IgniteCacheQueryNodeRestartSelfTest2 extends GridCommonAbstractTest
     @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
         IgniteConfiguration c = super.getConfiguration(igniteInstanceName);
 
+        MemoryConfiguration memCfg = new MemoryConfiguration();
+        memCfg.setDefaultMemoryPolicyName("default");
+        memCfg.setMemoryPolicies(new MemoryPolicyConfiguration().setName("default").setSize(50 * 1024 * 1024));
+
+        c.setMemoryConfiguration(memCfg);
+
         TcpDiscoverySpi disco = new TcpDiscoverySpi();
 
         disco.setIpFinder(ipFinder);

http://git-wip-us.apache.org/repos/asf/ignite/blob/5ef610c0/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
index 862d1a2..032e544 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
@@ -68,6 +68,8 @@ import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheA
 import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheAtomicNearEnabledFieldsQuerySelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheAtomicNearEnabledQuerySelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheAtomicQuerySelfTest;
+import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheDistributedPartitionQueryNodeRestartsSelfTest;
+import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheDistributedPartitionQuerySelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheDistributedQueryCancelSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCachePartitionedFieldsQueryP2PEnabledSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCachePartitionedFieldsQuerySelfTest;
@@ -75,6 +77,7 @@ import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheP
 import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCachePartitionedQuerySelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCachePartitionedSnapshotEnabledQuerySelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheQueryAbstractDistributedJoinSelfTest;
+import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheDistributedPartitionQueryConfigurationSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheQueryNoRebalanceSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.replicated.IgniteCacheReplicatedFieldsQueryP2PEnabledSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.replicated.IgniteCacheReplicatedFieldsQueryROSelfTest;
@@ -277,6 +280,9 @@ public class IgniteCacheQuerySelfTestSuite extends TestSuite {
         suite.addTestSuite(IgniteQueryDedicatedPoolTest.class);
         suite.addTestSuite(IgniteSqlEntryCacheModeAgnosticTest.class);
         suite.addTestSuite(QueryEntityCaseMismatchTest.class);
+        suite.addTestSuite(IgniteCacheDistributedPartitionQuerySelfTest.class);
+        suite.addTestSuite(IgniteCacheDistributedPartitionQueryNodeRestartsSelfTest.class);
+        suite.addTestSuite(IgniteCacheDistributedPartitionQueryConfigurationSelfTest.class);
 
         return suite;
     }


[10/29] ignite git commit: ignite-2.0 - SQL: Geo tests fixed + distributed join on replicated cache

Posted by ag...@apache.org.
ignite-2.0 - SQL: Geo tests fixed + distributed join on replicated cache


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

Branch: refs/heads/ignite-5024
Commit: b58d584290fc4ca5f18031fac582130ffab59a24
Parents: de421ff
Author: Sergi Vladykin <se...@gmail.com>
Authored: Mon Apr 24 16:31:25 2017 +0300
Committer: Sergi Vladykin <se...@gmail.com>
Committed: Mon Apr 24 16:31:25 2017 +0300

----------------------------------------------------------------------
 .../processors/cache/IgniteCacheProxy.java      |  8 ----
 .../query/h2/H2IndexingAbstractGeoSelfTest.java |  2 +-
 .../processors/query/h2/IgniteH2Indexing.java   |  2 +-
 .../query/IgniteSqlSplitterSelfTest.java        | 46 ++++++++++++++++----
 4 files changed, 40 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/b58d5842/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
index 186212d..b38520d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
@@ -774,10 +774,6 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
                     opCtxCall != null && opCtxCall.isKeepBinary());
 
             if (qry instanceof SqlQuery) {
-                if (isReplicatedDataNode() && ((SqlQuery)qry).isDistributedJoins())
-                    throw new CacheException("Queries using distributed JOINs have to be run on partitioned cache, " +
-                        "not on replicated.");
-
                 final SqlQuery p = (SqlQuery)qry;
 
                 if ((p.isReplicatedOnly() && isReplicatedDataNode()) || ctx.isLocal() || qry.isLocal())
@@ -788,10 +784,6 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
             }
 
             if (qry instanceof SqlFieldsQuery) {
-                if (isReplicatedDataNode() && ((SqlFieldsQuery)qry).isDistributedJoins())
-                    throw new CacheException("Queries using distributed JOINs have to be run on partitioned cache, " +
-                        "not on replicated.");
-
                 SqlFieldsQuery p = (SqlFieldsQuery)qry;
 
                 if ((p.isReplicatedOnly() && isReplicatedDataNode()) || ctx.isLocal() || qry.isLocal())

http://git-wip-us.apache.org/repos/asf/ignite/blob/b58d5842/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingAbstractGeoSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingAbstractGeoSelfTest.java b/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingAbstractGeoSelfTest.java
index f57d573..2a83941 100644
--- a/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingAbstractGeoSelfTest.java
+++ b/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingAbstractGeoSelfTest.java
@@ -632,7 +632,7 @@ public abstract class H2IndexingAbstractGeoSelfTest extends GridCacheAbstractSel
      */
     private static class Enemy {
         /** */
-        @QuerySqlField
+        @QuerySqlField(index = true)
         int campId;
 
         /** */

http://git-wip-us.apache.org/repos/asf/ignite/blob/b58d5842/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 bf0276a..798ca9b 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
@@ -1569,7 +1569,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
         Connection c = connectionForSpace(space);
 
         final boolean enforceJoinOrder = qry.isEnforceJoinOrder();
-        final boolean distributedJoins = qry.isDistributedJoins() && cctx.isPartitioned();
+        final boolean distributedJoins = qry.isDistributedJoins();
         final boolean grpByCollocated = qry.isCollocated();
 
         final DistributedJoinMode distributedJoinMode = distributedJoinMode(qry.isLocal(), distributedJoins);

http://git-wip-us.apache.org/repos/asf/ignite/blob/b58d5842/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java
index 4578171..fa4eded 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java
@@ -290,6 +290,35 @@ public class IgniteSqlSplitterSelfTest extends GridCommonAbstractTest {
         }
     }
 
+    /**
+     * @throws InterruptedException If failed.
+     */
+    public void testDistributedJoinFromReplicatedCache() throws InterruptedException {
+        CacheConfiguration ccfg1 = cacheConfig("pers", true,
+            Integer.class, Person2.class);
+
+        CacheConfiguration ccfg2 = cacheConfig("org", true,
+            Integer.class, Organization.class);
+
+        CacheConfiguration ccfg3 = cacheConfig("orgRepl", false,
+            Integer.class, Organization.class);
+
+        IgniteCache<Integer, Person2> c1 = ignite(0).getOrCreateCache(ccfg1);
+        IgniteCache<Integer, Organization> c2 = ignite(0).getOrCreateCache(ccfg2);
+        IgniteCache<Integer, Organization> c3 = ignite(0).getOrCreateCache(ccfg3);
+
+        try {
+            awaitPartitionMapExchange();
+
+            doTestDistributedJoins(c3, c1, c2, 300, 2000, 5, false);
+            doTestDistributedJoins(c3, c1, c2, 300, 2000, 5, true);
+        }
+        finally {
+            c1.destroy();
+            c2.destroy();
+        }
+    }
+
     @SuppressWarnings("SuspiciousMethodCalls")
     public void testExists() {
         IgniteCache<Integer,Person2> x = ignite(0).getOrCreateCache(cacheConfig("x", true,
@@ -523,14 +552,14 @@ public class IgniteSqlSplitterSelfTest extends GridCommonAbstractTest {
         try {
             awaitPartitionMapExchange();
 
-            doTestDistributedJoins(c1, c2, 30, 100, 1000, false);
-            doTestDistributedJoins(c1, c2, 30, 100, 1000, true);
+            doTestDistributedJoins(c2, c1, c2, 30, 100, 1000, false);
+            doTestDistributedJoins(c2, c1, c2, 30, 100, 1000, true);
 
-            doTestDistributedJoins(c1, c2, 3, 10, 3, false);
-            doTestDistributedJoins(c1, c2, 3, 10, 3, true);
+            doTestDistributedJoins(c2, c1, c2, 3, 10, 3, false);
+            doTestDistributedJoins(c2, c1, c2, 3, 10, 3, true);
 
-            doTestDistributedJoins(c1, c2, 300, 2000, 5, false);
-            doTestDistributedJoins(c1, c2, 300, 2000, 5, true);
+            doTestDistributedJoins(c2, c1, c2, 300, 2000, 5, false);
+            doTestDistributedJoins(c2, c1, c2, 300, 2000, 5, true);
         }
         finally {
             c1.destroy();
@@ -1409,6 +1438,7 @@ public class IgniteSqlSplitterSelfTest extends GridCommonAbstractTest {
      * @param enforceJoinOrder Enforce join order.
      */
     private void doTestDistributedJoins(
+        IgniteCache<?,?> qryCache,
         IgniteCache<Integer, Person2> c1,
         IgniteCache<Integer, Organization> c2,
         int orgs,
@@ -1442,7 +1472,7 @@ public class IgniteSqlSplitterSelfTest extends GridCommonAbstractTest {
 
         String select = "select count(*) from \"org\".Organization o, \"pers\".Person2 p where p.orgId = o._key";
 
-        String plan = (String)c2.query(new SqlFieldsQuery("explain " + select)
+        String plan = (String)qryCache.query(new SqlFieldsQuery("explain " + select)
             .setDistributedJoins(true).setEnforceJoinOrder(enforceJoinOrder).setPageSize(pageSize))
             .getAll().get(0).get(0);
 
@@ -1453,7 +1483,7 @@ public class IgniteSqlSplitterSelfTest extends GridCommonAbstractTest {
         else
             assertTrue(plan, plan.contains("batched:unicast"));
 
-        assertEquals(Long.valueOf(persons), c2.query(new SqlFieldsQuery(select).setDistributedJoins(true)
+        assertEquals((long)persons, qryCache.query(new SqlFieldsQuery(select).setDistributedJoins(true)
             .setEnforceJoinOrder(enforceJoinOrder).setPageSize(pageSize)).getAll().get(0).get(0));
 
         c1.clear();


[17/29] ignite git commit: Fixed failures in IgniteCrosscacheJoinsQueryTest.

Posted by ag...@apache.org.
Fixed failures in IgniteCrosscacheJoinsQueryTest.


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

Branch: refs/heads/ignite-5024
Commit: 645581ee7b76ed40800b47049fa4aea7e4d5605e
Parents: 8d0da14
Author: devozerov <vo...@gridgain.com>
Authored: Tue Apr 25 11:06:09 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Tue Apr 25 11:06:09 2017 +0300

----------------------------------------------------------------------
 .../cache/IgniteCrossCachesJoinsQueryTest.java  | 77 +-------------------
 1 file changed, 3 insertions(+), 74 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/645581ee/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCrossCachesJoinsQueryTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCrossCachesJoinsQueryTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCrossCachesJoinsQueryTest.java
index cd35788..3ad316f 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCrossCachesJoinsQueryTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCrossCachesJoinsQueryTest.java
@@ -31,8 +31,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.Random;
 import java.util.Set;
-import java.util.concurrent.Callable;
-import javax.cache.CacheException;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.cache.CacheMode;
@@ -53,7 +51,6 @@ import org.apache.ignite.internal.util.typedef.internal.SB;
 import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
-import org.apache.ignite.testframework.GridTestUtils;
 
 import static org.apache.ignite.cache.CacheMode.PARTITIONED;
 import static org.apache.ignite.cache.CacheMode.REPLICATED;
@@ -428,6 +425,7 @@ public class IgniteCrossCachesJoinsQueryTest extends AbstractH2CompareQueryTest
      * @param cacheList Caches.
      * @throws Exception If failed.
      */
+    @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
     private void checkAllCacheCombinations(
         boolean idx,
         List<List<TestCache>> cacheList) throws Exception {
@@ -552,8 +550,8 @@ public class IgniteCrossCachesJoinsQueryTest extends AbstractH2CompareQueryTest
                 boolean distributeJoins0 = distributedJoins;
 
                 if (replicated(cache)) {
-                    if (!testNode.configuration().isClientMode())
-                        assertProperException(cache);
+//                    if (!testNode.configuration().isClientMode())
+//                        assertProperException(cache);
 
                     boolean all3CachesAreReplicated =
                         replicated(ignite(0).cache(ACC_CACHE_NAME)) &&
@@ -603,36 +601,6 @@ public class IgniteCrossCachesJoinsQueryTest extends AbstractH2CompareQueryTest
     }
 
     /**
-     * @param cache Cache.
-     */
-    private void assertProperException(final IgniteCache cache) {
-        qry = "assertProperException";
-
-        GridTestUtils.assertThrows(log, new Callable<Object>() {
-            @Override public Object call() throws Exception {
-                cache.query(new SqlFieldsQuery("select p.name from " +
-                    "\"" + PERSON_CACHE_NAME + "\".Person p, " +
-                    "\"" + ACC_CACHE_NAME + "\".Account a " +
-                    "where p._key = a.personId").setDistributedJoins(true));
-
-                return null;
-            }
-        }, CacheException.class, "Queries using distributed JOINs have to be run on partitioned cache");
-
-        GridTestUtils.assertThrows(log, new Callable<Object>() {
-            @Override public Object call() throws Exception {
-                cache.query(new SqlQuery(Person.class,
-                    "from \"" + PERSON_CACHE_NAME + "\".Person , " +
-                        "\"" + ACC_CACHE_NAME + "\".Account  " +
-                        "where Person._key = Account.personId")
-                    .setDistributedJoins(true));
-
-                return null;
-            }
-        }, CacheException.class, "Queries using distributed JOINs have to be run on partitioned cache");
-    }
-
-    /**
      * Organization ids: [0, 9]. Person ids: randoms at [10, 9999]. Accounts ids: randoms at [10000, 999_999]
      *
      * @return Data.
@@ -1195,45 +1163,6 @@ public class IgniteCrossCachesJoinsQueryTest extends AbstractH2CompareQueryTest
     }
 
     /**
-     * @param cache Cache.
-     */
-    private void checkPersonAccountOrganizationGroupBy(IgniteCache cache) {
-        qry = "checkPersonAccountOrganizationGroupBy";
-
-        // Max count of accounts at org.
-        SqlFieldsQuery q = new SqlFieldsQuery("select max(count(a.id)) " +
-            "from " +
-            "\"" + PERSON_CACHE_NAME + "\".Person p " +
-            "\"" + ORG_CACHE_NAME + "\".Organization o " +
-            "\"" + ACC_CACHE_NAME + "\".Account a " +
-            "where p.id = a.personId and p.orgStrId = o.strId " +
-            "group by org.id " +
-            "having o.id = ?");
-
-        q.setDistributedJoins(distributedJoins());
-
-        for (Map.Entry<Integer, Integer> e : data.accountsPerPerson.entrySet()) {
-            Integer personId = e.getKey();
-            Integer cnt = e.getValue();
-
-            q.setArgs(personId);
-
-            List<List<?>> res = cache.query(q).getAll();
-
-            String errMsg = "Expected data [personId=" + personId + ", cnt=" + cnt + ", data=" + data + "]";
-
-            // Cnt == 0 means that there are no accounts for the person.
-            if (cnt > 0) {
-                assertEquals(errMsg, 1, res.size());
-                assertEquals(errMsg, 1, res.get(0).size());
-                assertEquals(errMsg, (long)cnt, res.get(0).get(0));
-            }
-            else
-                assertEquals(errMsg, 0, res.size());
-        }
-    }
-
-    /**
      * @throws Exception If failed.
      */
     private void checkGroupBy() throws Exception {


[03/29] ignite git commit: IGNITE-5018 review and improve javadocs in ML module

Posted by ag...@apache.org.
IGNITE-5018 review and improve javadocs in ML module


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

Branch: refs/heads/ignite-5024
Commit: 33079fc9c6fb6970ff24e88466e5edbf41ff1a28
Parents: 1968e4f
Author: Oleg Ignatenko <oi...@gridgain.com>
Authored: Mon Apr 24 13:18:40 2017 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Mon Apr 24 13:18:40 2017 +0300

----------------------------------------------------------------------
 .../java/org/apache/ignite/ml/math/Algebra.java |  89 +++++++++-------
 .../ignite/ml/math/IdentityValueMapper.java     |   3 +-
 .../java/org/apache/ignite/ml/math/Matrix.java  |  33 +++---
 .../org/apache/ignite/ml/math/MurmurHash.java   |  16 +--
 .../java/org/apache/ignite/ml/math/Tracer.java  |   4 +-
 .../java/org/apache/ignite/ml/math/Vector.java  |   3 +-
 .../decompositions/CholeskyDecomposition.java   |   8 +-
 .../math/decompositions/EigenDecomposition.java |   4 +-
 .../ml/math/decompositions/LUDecomposition.java |   8 +-
 .../ignite/ml/math/functions/Functions.java     |  21 +++-
 .../ml/math/impls/matrix/PivotedMatrixView.java |   3 +-
 .../impls/matrix/SparseDistributedMatrix.java   |  12 +--
 .../storage/matrix/CacheMatrixStorage.java      |  16 ++-
 .../matrix/DenseOffHeapMatrixStorage.java       |  15 ++-
 .../storage/matrix/FunctionMatrixStorage.java   |  17 +--
 .../matrix/SparseLocalOnHeapMatrixStorage.java  |  20 ++--
 .../storage/vector/CacheVectorStorage.java      |  13 +--
 .../storage/vector/ConstantVectorStorage.java   |  10 +-
 .../storage/vector/DelegateVectorStorage.java   |   1 +
 .../storage/vector/FunctionVectorStorage.java   |  17 +--
 .../storage/vector/MatrixVectorStorage.java     |  19 ++--
 .../storage/vector/PivotedVectorStorage.java    |  16 +--
 .../SingleElementVectorDelegateStorage.java     |  13 +--
 .../vector/SingleElementVectorStorage.java      |  11 +-
 .../vector/SparseLocalOffHeapVectorStorage.java |   3 +
 .../vector/SparseLocalOnHeapVectorStorage.java  |  11 +-
 .../ml/math/impls/vector/AbstractVector.java    |   1 +
 .../ml/math/impls/vector/DelegatingVector.java  |   1 +
 .../ml/math/impls/vector/MatrixVectorView.java  |  20 ++--
 .../ml/math/impls/vector/PivotedVectorView.java |  14 +--
 .../ml/math/impls/vector/RandomVector.java      |   4 +-
 .../math/impls/vector/SingleElementVector.java  | 103 +------------------
 .../org/apache/ignite/ml/math/TracerTest.java   |  12 ++-
 .../ml/math/impls/matrix/CacheMatrixTest.java   |  10 +-
 .../impls/matrix/MatrixKeyMapperForTests.java   |  19 ++--
 .../storage/matrix/MatrixStorageFixtures.java   |  19 ++--
 .../SparseLocalOffHeapVectorStorageTest.java    |   3 +-
 .../math/impls/vector/AbstractVectorTest.java   |  42 ++++----
 .../ml/math/impls/vector/CacheVectorTest.java   |   5 +-
 39 files changed, 331 insertions(+), 308 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/Algebra.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/Algebra.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/Algebra.java
index b13d9fc..c54e390 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/Algebra.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/Algebra.java
@@ -31,7 +31,8 @@ package org.apache.ignite.ml.math;
  * Lifted from Apache Mahout.
  */
 public class Algebra extends Constants {
-    /** */ private static final double[] STIRLING_CORRECTION = {
+    /** */
+    private static final double[] STIRLING_CORRECTION = {
         0.0,
         8.106146679532726e-02, 4.134069595540929e-02,
         2.767792568499834e-02, 2.079067210376509e-02,
@@ -50,7 +51,8 @@ public class Algebra extends Constants {
         2.873449362352470e-03, 2.777674929752690e-03,
     };
 
-    /** */ private static final double[] LOG_FACTORIALS = {
+    /** */
+    private static final double[] LOG_FACTORIALS = {
         0.00000000000000000, 0.00000000000000000, 0.69314718055994531,
         1.79175946922805500, 3.17805383034794562, 4.78749174278204599,
         6.57925121201010100, 8.52516136106541430, 10.60460290274525023,
@@ -63,7 +65,8 @@ public class Algebra extends Constants {
         64.55753862700633106, 67.88974313718153498, 71.25703896716800901
     };
 
-    /** */ private static final long[] LONG_FACTORIALS = {
+    /** */
+    private static final long[] LONG_FACTORIALS = {
         1L,
         1L,
         2L,
@@ -87,7 +90,8 @@ public class Algebra extends Constants {
         2432902008176640000L
     };
 
-    /** */ private static final double[] DOUBLE_FACTORIALS = {
+    /** */
+    private static final double[] DOUBLE_FACTORIALS = {
         5.109094217170944E19,
         1.1240007277776077E21,
         2.585201673888498E22,
@@ -337,19 +341,27 @@ public class Algebra extends Constants {
 
     /**
      * Evaluates the series of Chebyshev polynomials Ti at argument x/2. The series is given by
-     * <pre>
-     *        N-1
-     *         - '
-     *  y  =   &gt;   coef[i] T (x/2)
-     *         -            i
-     *        i=0
+     * <pre class="snippet">
+     * N-1
+     * - '
+     * y  =   &gt;   coef[i] T (x/2)
+     * -            i
+     * i=0
      * </pre>
      * Coefficients are stored in reverse order, i.e. the zero order term is last in the array.  Note N is the number of
-     * coefficients, not the order. <p> If coefficients are for the interval a to b, x must have been transformed to x
+     * coefficients, not the order.
+     * <p>
+     * If coefficients are for the interval a to b, x must have been transformed to x
      * -&lt; 2(2x - b - a)/(b-a) before entering the routine.  This maps x from (a, b) to (-1, 1), over which the
-     * Chebyshev polynomials are defined. <p> If the coefficients are for the inverted interval, in which (a, b) is
+     * Chebyshev polynomials are defined.</p>
+     * <p>
+     * If the coefficients are for the inverted interval, in which (a, b) is
      * mapped to (1/b, 1/a), the transformation required is {@code x -> 2(2ab/x - b - a)/(b-a)}.  If b is infinity, this
-     * becomes {@code x -> 4a/x - 1}. <p> SPEED: <p> Taking advantage of the recurrence properties of the Chebyshev
+     * becomes {@code x -> 4a/x - 1}.</p>
+     * <p>
+     * SPEED:
+     * </p>
+     * Taking advantage of the recurrence properties of the Chebyshev
      * polynomials, the routine requires one more addition per loop than evaluating a nested polynomial of the same
      * degree.
      *
@@ -466,11 +478,11 @@ public class Algebra extends Constants {
 
     /**
      * Returns the StirlingCorrection.
-     *
+     * <p>
      * Correction term of the Stirling approximation for {@code log(k!)} (series in
-     * 1/k, or table values for small k) with int parameter k. </p> {@code  log k! = (k + 1/2)log(k + 1) - (k + 1) +
+     * 1/k, or table values for small k) with int parameter k. {@code  log k! = (k + 1/2)log(k + 1) - (k + 1) +
      * (1/2)log(2Pi) + STIRLING_CORRECTION(k + 1) log k! = (k + 1/2)log(k)     -  k      + (1/2)log(2Pi) +
-     * STIRLING_CORRECTION(k) }
+     * STIRLING_CORRECTION(k) } </p>
      */
     public static double stirlingCorrection(int k) {
         if (k > 30) {
@@ -490,21 +502,24 @@ public class Algebra extends Constants {
     /**
      * Evaluates the given polynomial of degree {@code N} at {@code x}, assuming coefficient of N is 1.0. Otherwise same
      * as {@link #evalPoly(double, double[], int)}.
-     * <pre>
-     *                     2          N
+     * <pre class="snippet">
+     * 2          N
      * y  =  C  + C x + C x  +...+ C x
-     *        0    1     2          N
-     *
-     * where C  = 1 and hence is omitted from the array.
-     *        N
-     *
-     * Coefficients are stored in reverse order:
-     *
+     * 0    1     2          N
+     * </pre>
+     * where <pre class="snippet">
+     * C  = 1
+     * N
+     * </pre>
+     * and hence is omitted from the array.
+     * <p>
+     * Coefficients are stored in reverse order:</p>
+     * <pre class="snippet">
      * coef[0] = C  , ..., coef[N-1] = C  .
-     *            N-1                   0
-     *
-     * Calling arguments are otherwise the same as {@link #evalPoly(double, double[], int)}.
+     * N-1                   0
      * </pre>
+     * Calling arguments are otherwise the same as {@link #evalPoly(double, double[], int)}.
+     * <p>
      * In the interest of speed, there are no checks for out of bounds arithmetic.
      *
      * @param x Argument to the polynomial.
@@ -522,17 +537,19 @@ public class Algebra extends Constants {
 
     /**
      * Evaluates the given polynomial of degree {@code N} at {@code x}.
-     * <pre>
-     *                     2          N
+     * <pre class="snippet">
+     * 2          N
      * y  =  C  + C x + C x  +...+ C x
-     *        0    1     2          N
-     *
-     * Coefficients are stored in reverse order:
-     *
+     * 0    1     2          N
+     * </pre>
+     * <p>
+     * Coefficients are stored in reverse order:</p>
+     * <pre class="snippet">
      * coef[0] = C  , ..., coef[N] = C  .
-     *            N                   0
+     * N                   0
      * </pre>
-     * In the interest of speed, there are no checks for out of bounds arithmetic.
+     * <p>
+     * In the interest of speed, there are no checks for out of bounds arithmetic.</p>
      *
      * @param x Argument to the polynomial.
      * @param coef Coefficients of the polynomial.

http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/IdentityValueMapper.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/IdentityValueMapper.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/IdentityValueMapper.java
index 00bf915..3c94edd 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/IdentityValueMapper.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/IdentityValueMapper.java
@@ -21,7 +21,8 @@ package org.apache.ignite.ml.math;
  * Identity value mapper.
  */
 public class IdentityValueMapper implements ValueMapper<Double> {
-    /** */ private static final long serialVersionUID = -8010078306142216389L;
+    /** */
+    private static final long serialVersionUID = -8010078306142216389L;
 
     /** {@inheritDoc} */
     @Override public Double fromDouble(double v) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/Matrix.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/Matrix.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/Matrix.java
index cc858b7..798d831 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/Matrix.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/Matrix.java
@@ -18,6 +18,7 @@
 package org.apache.ignite.ml.math;
 
 import java.io.Externalizable;
+
 import org.apache.ignite.lang.IgniteUuid;
 import org.apache.ignite.ml.math.exceptions.CardinalityException;
 import org.apache.ignite.ml.math.exceptions.IndexException;
@@ -29,17 +30,17 @@ import org.apache.ignite.ml.math.functions.IntIntToDoubleFunction;
 
 /**
  * A matrix interface.
- *
+ * <p>
  * Based on its flavor it can have vastly different implementations tailored for
  * for different types of data (e.g. dense vs. sparse), different sizes of data or different operation
- * optimizations.
- *
+ * optimizations.</p>
+ * <p>
  * Note also that not all operations can be supported by all underlying implementations. If an operation is not
  * supported a {@link UnsupportedOperationException} is thrown. This exception can also be thrown in partial cases
  * where an operation is unsupported only in special cases, e.g. where a given operation cannot be deterministically
- * completed in polynomial time.
- *
- * Based on ideas from <a href="http://mahout.apache.org/">Apache Mahout</a>.
+ * completed in polynomial time.</p>
+ * <p>
+ * Based on ideas from <a href="http://mahout.apache.org/">Apache Mahout</a>.</p>
  */
 public interface Matrix extends MetaAttributes, Externalizable, StorageOpsMetrics, Destroyable {
     /**
@@ -174,10 +175,10 @@ public interface Matrix extends MetaAttributes, Externalizable, StorageOpsMetric
 
     /**
      * Maps all values in this matrix through a given function.
-     *
-     * For this matrix <code>A</code>, argument matrix <code>B</code> and the
-     * function <code>F</code> this method maps every cell <code>x, y</code> as:
-     * <code>A(x,y) = fun(A(x,y), B(x,y))</code>
+     * <p>
+     * For this matrix {@code A}, argument matrix {@code B} and the
+     * function {@code F} this method maps every cell {@code x, y} as:
+     * {@code A(x,y) = fun(A(x,y), B(x,y))}.</p>
      *
      * @param mtx Argument matrix.
      * @param fun Mapping function.
@@ -306,8 +307,8 @@ public interface Matrix extends MetaAttributes, Externalizable, StorageOpsMetric
 
     /**
      * Clones this matrix.
-     *
-     * NOTE: new matrix will have the same flavor as the this matrix but a different ID.
+     * <p>
+     * NOTE: new matrix will have the same flavor as the this matrix but a different ID.</p>
      *
      * @return New matrix of the same underlying class, the same size and the same values.
      */
@@ -315,8 +316,8 @@ public interface Matrix extends MetaAttributes, Externalizable, StorageOpsMetric
 
     /**
      * Creates new empty matrix of the same underlying class but of different size.
-     *
-     * NOTE: new matrix will have the same flavor as the this matrix but a different ID.
+     * <p>
+     * NOTE: new matrix will have the same flavor as the this matrix but a different ID.</p>
      *
      * @param rows Number of rows for new matrix.
      * @param cols Number of columns for new matrix.
@@ -463,8 +464,8 @@ public interface Matrix extends MetaAttributes, Externalizable, StorageOpsMetric
     /**
      * Creates new view into this matrix. Changes to the view will be propagated to this matrix.
      *
-     * @param off View offset as <code>int[x,y]</code>.
-     * @param size View size as <code>int[rows, cols]</code>
+     * @param off View offset as {@code int[x,y]}.
+     * @param size View size as {@code int[rows, cols]}.
      * @return New view.
      * @throws CardinalityException Thrown if cardinalities mismatch.
      * @throws IndexException Thrown in case of offset is out of bound.

http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/MurmurHash.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/MurmurHash.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/MurmurHash.java
index c7dd36b..d1ebf53 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/MurmurHash.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/MurmurHash.java
@@ -22,8 +22,8 @@ import java.nio.ByteOrder;
 
 /**
  * This is a very fast, non-cryptographic hash suitable for general hash-based lookup.
- *
- * See http://murmurhash.googlepages.com/ for mre details.
+ * <p>
+ * See http://murmurhash.googlepages.com/ for mre details.</p>
  */
 public class MurmurHash {
     /** Hide it. */
@@ -33,13 +33,13 @@ public class MurmurHash {
     /**
      * This produces exactly the same hash values as the final C+ version of MurmurHash3 and is
      * thus suitable for producing the same hash values across platforms.
-     *
-     * The 32 bit x86 version of this hash should be the fastest variant for relatively short keys like IDs.
-     *
+     * <p>
+     * The 32 bit x86 version of this hash should be the fastest variant for relatively short keys like IDs.</p>
+     * <p>
      * Note - The x86 and x64 versions do _not_ produce the same results, as the algorithms are
-     * optimized for their respective platforms.
-     *
-     * See also http://github.com/yonik/java_util for future updates to this method.
+     * optimized for their respective platforms.</p>
+     * <p>
+     * See also http://github.com/yonik/java_util for future updates to this method.</p>
      *
      * @param data Data to hash.
      * @param off Where to start munging.

http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/Tracer.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/Tracer.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/Tracer.java
index 007a8fe..07cc63c 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/Tracer.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/Tracer.java
@@ -71,8 +71,10 @@ public class Tracer {
         return defaultColorMapper(vec.minValue(), vec.maxValue());
     }
 
-    /** Default matrix color mapper implementation that map given double value
+    /**
+     * Default matrix color mapper implementation that map given double value
      * to continuous red-blue (R_B) specter.
+     *
      * @param mtx Matrix to be mapped.
      * @return Color mapper for given matrix.
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/Vector.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/Vector.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/Vector.java
index b5e1d69..e1c5df0 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/Vector.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/Vector.java
@@ -470,7 +470,8 @@ public interface Vector extends MetaAttributes, Externalizable, StorageOpsMetric
      * @return Folded value of these vectors.
      * @throws CardinalityException Thrown when cardinalities mismatch.
      */
-    public <T> T foldMap(Vector vec, IgniteBiFunction<T, Double, T> foldFun, IgniteBiFunction<Double, Double, Double> combFun,
+    public <T> T foldMap(Vector vec, IgniteBiFunction<T, Double, T> foldFun,
+        IgniteBiFunction<Double, Double, Double> combFun,
         T zeroVal);
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/CholeskyDecomposition.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/CholeskyDecomposition.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/CholeskyDecomposition.java
index 59ebbe0..6053e1c 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/CholeskyDecomposition.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/CholeskyDecomposition.java
@@ -25,8 +25,8 @@ import org.apache.ignite.ml.math.exceptions.NonSymmetricMatrixException;
 
 /**
  * Calculates the Cholesky decomposition of a matrix.
- *
- * This class inspired by class from Apache Common Math with similar name.
+ * <p>
+ * This class inspired by class from Apache Common Math with similar name.</p>
  *
  * @see <a href="http://mathworld.wolfram.com/CholeskyDecomposition.html">MathWorld</a>
  * @see <a href="http://en.wikipedia.org/wiki/Cholesky_decomposition">Wikipedia</a>
@@ -55,10 +55,10 @@ public class CholeskyDecomposition extends DecompositionSupport {
 
     /**
      * Calculates the Cholesky decomposition of the given matrix.
-     *
+     * <p>
      * Calling this constructor is equivalent to call {@link #CholeskyDecomposition(Matrix, double, double)} with the
      * thresholds set to the default values {@link #DFLT_REL_SYMMETRY_THRESHOLD} and
-     * {@link #DFLT_ABS_POSITIVITY_THRESHOLD}.
+     * {@link #DFLT_ABS_POSITIVITY_THRESHOLD}.</p>
      *
      * @param mtx the matrix to decompose.
      * @throws CardinalityException if matrix is not square.

http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/EigenDecomposition.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/EigenDecomposition.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/EigenDecomposition.java
index 0353bff..698cbef 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/EigenDecomposition.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/EigenDecomposition.java
@@ -24,8 +24,8 @@ import org.apache.ignite.ml.math.functions.Functions;
 /**
  * This class provides EigenDecomposition of given matrix. The class is based on
  * class with similar name from <a href="http://mahout.apache.org/">Apache Mahout</a> library.
- * <p>
- * @see <a href=http://mathworld.wolfram.com/EigenDecomposition.html>MathWorld</a></p>
+ *
+ * @see <a href=http://mathworld.wolfram.com/EigenDecomposition.html>MathWorld</a>
  */
 public class EigenDecomposition extends DecompositionSupport {
     /** Row and column dimension (square matrix). */

http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/LUDecomposition.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/LUDecomposition.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/LUDecomposition.java
index 4e9730c..02a3123 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/LUDecomposition.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/LUDecomposition.java
@@ -25,8 +25,8 @@ import org.apache.ignite.ml.math.exceptions.SingularMatrixException;
 /**
  * Calculates the LU-decomposition of a square matrix.
  * <p>
- * This class is inspired by class from Apache Common Math with similar name.
- * </p>
+ * This class is inspired by class from Apache Common Math with similar name.</p>
+ *
  * @see <a href="http://mathworld.wolfram.com/LUDecomposition.html">MathWorld</a>
  * @see <a href="http://en.wikipedia.org/wiki/LU_decomposition">Wikipedia</a>
  */
@@ -36,18 +36,22 @@ public class LUDecomposition extends DecompositionSupport {
 
     /** Pivot permutation associated with LU decomposition. */
     private final Vector pivot;
+
     /** Parity of the permutation associated with the LU decomposition. */
     private boolean even;
     /** Singularity indicator. */
     private boolean singular;
+
     /** Cached value of L. */
     private Matrix cachedL;
     /** Cached value of U. */
     private Matrix cachedU;
     /** Cached value of P. */
     private Matrix cachedP;
+
     /** Original matrix. */
     private Matrix matrix;
+
     /** Entries of LU decomposition. */
     private Matrix lu;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/Functions.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/Functions.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/Functions.java
index 2693fce..2f97067 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/Functions.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/Functions.java
@@ -78,15 +78,14 @@ public final class Functions {
     /** Function that returns {@code (a - b) * (a - b)} */
     public static final IgniteBiFunction<Double, Double, Double> MINUS_SQUARED = (a, b) -> (a - b) * (a - b);
 
-    /**
-     * Function that returns {@code a &lt; b ? -1 : a &gt; b ? 1 : 0}.
-     */
+    /** Function that returns {@code a &lt; b ? -1 : a &gt; b ? 1 : 0}. */
     public static final IgniteBiFunction<Double, Double, Double> COMPARE = (a, b) -> a < b ? -1.0 : a > b ? 1.0 : 0.0;
 
     /**
      * Function that returns {@code a + b}. {@code a} is a variable, {@code b} is fixed.
      *
      * @param b Value to add.
+     * @return Function for this operation.
      */
     public static IgniteDoubleFunction<Double> plus(final double b) {
         return (a) -> a + b;
@@ -96,12 +95,18 @@ public final class Functions {
      * Function that returns {@code a * b}. {@code a} is a variable, {@code b} is fixed.
      *
      * @param b Value to multiply to.
+     * @return Function for this operation.
      */
     public static IgniteDoubleFunction<Double> mult(final double b) {
         return (a) -> a * b;
     }
 
-    /** Function that returns {@code a / b}. {@code a} is a variable, {@code b} is fixed. */
+    /**
+     * Function that returns {@code a / b}. {@code a} is a variable, {@code b} is fixed.
+     *
+     * @param b Value to divide to.
+     * @return Function for this operation.
+     */
     public static IgniteDoubleFunction<Double> div(double b) {
         return mult(1 / b);
     }
@@ -109,6 +114,9 @@ public final class Functions {
     /**
      * Function that returns {@code a + b*constant}. {@code a} and {@code b} are variables,
      * {@code constant} is fixed.
+     *
+     * @param constant Value to use in multiply.
+     * @return Function for this operation.
      */
     public static IgniteBiFunction<Double, Double, Double> plusMult(double constant) {
         return (a, b) -> a + b * constant;
@@ -117,12 +125,17 @@ public final class Functions {
     /**
      * Function that returns {@code a - b*constant}. {@code a} and {@code b} are variables,
      * {@code constant} is fixed.
+     *
+     * @param constant Value to use in multiply.
+     * @return Function for this operation.
      */
     public static IgniteBiFunction<Double, Double, Double> minusMult(double constant) {
         return (a, b) -> a - b * constant;
     }
 
     /**
+     * Function that returns {@code Math.pow(a, b)}.
+     *
      * @param b Power value.
      * @return Function for given power.
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/PivotedMatrixView.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/PivotedMatrixView.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/PivotedMatrixView.java
index 334291e..16bdc3e 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/PivotedMatrixView.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/PivotedMatrixView.java
@@ -20,6 +20,7 @@ package org.apache.ignite.ml.math.impls.matrix;
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
+
 import org.apache.ignite.ml.math.Matrix;
 import org.apache.ignite.ml.math.MatrixStorage;
 import org.apache.ignite.ml.math.Vector;
@@ -63,7 +64,7 @@ public class PivotedMatrixView extends AbstractMatrix {
     }
 
     /**
-     * @param mtx  Parent matrix.
+     * @param mtx Parent matrix.
      * @param pivot Pivot array for rows and columns.
      */
     public PivotedMatrixView(Matrix mtx, int[] pivot) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/SparseDistributedMatrix.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/SparseDistributedMatrix.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/SparseDistributedMatrix.java
index cd75b83..10ebdd0 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/SparseDistributedMatrix.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/SparseDistributedMatrix.java
@@ -37,14 +37,14 @@ import org.apache.ignite.ml.math.impls.storage.matrix.SparseDistributedMatrixSto
 
 /**
  * Sparse distributed matrix implementation based on data grid.
- *
+ * <p>
  * Unlike {@link CacheMatrix} that is based on existing cache, this implementation creates distributed
- * cache internally and doesn't rely on pre-existing cache.
- *
+ * cache internally and doesn't rely on pre-existing cache.</p>
+ * <p>
  * You also need to call {@link #destroy()} to remove the underlying cache when you no longer need this
- * matrix.
- *
- * <b>Currently fold supports only commutative operations.<b/>
+ * matrix.</p>
+ * <p>
+ * <b>Currently fold supports only commutative operations.<b/></p>
  */
 public class SparseDistributedMatrix extends AbstractMatrix implements StorageConstants {
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/CacheMatrixStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/CacheMatrixStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/CacheMatrixStorage.java
index 1eec6f5..687216b 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/CacheMatrixStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/CacheMatrixStorage.java
@@ -20,6 +20,7 @@ package org.apache.ignite.ml.math.impls.storage.matrix;
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
+
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.Ignition;
 import org.apache.ignite.ml.math.MatrixKeyMapper;
@@ -30,11 +31,16 @@ import org.apache.ignite.ml.math.ValueMapper;
  * Matrix storage based on arbitrary cache and key and value mapping functions.
  */
 public class CacheMatrixStorage<K, V> implements MatrixStorage {
-    /** */ private int rows;
-    /** */  private int cols;
-    /** */ private IgniteCache<K, V> cache;
-    /** */ private MatrixKeyMapper<K> keyMapper;
-    /** */ private ValueMapper<V> valMapper;
+    /** */
+    private int rows;
+    /** */
+    private int cols;
+    /** */
+    private IgniteCache<K, V> cache;
+    /** */
+    private MatrixKeyMapper<K> keyMapper;
+    /** */
+    private ValueMapper<V> valMapper;
 
     /**
      *

http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/DenseOffHeapMatrixStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/DenseOffHeapMatrixStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/DenseOffHeapMatrixStorage.java
index c9e8de8..410da47 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/DenseOffHeapMatrixStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/DenseOffHeapMatrixStorage.java
@@ -20,6 +20,7 @@ package org.apache.ignite.ml.math.impls.storage.matrix;
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
+
 import org.apache.ignite.internal.util.GridUnsafe;
 import org.apache.ignite.ml.math.MatrixStorage;
 
@@ -27,11 +28,15 @@ import org.apache.ignite.ml.math.MatrixStorage;
  * Local, dense off-heap matrix storage.
  */
 public class DenseOffHeapMatrixStorage implements MatrixStorage {
-    /** */ private int rows;
-    /** */ private int cols;
-    /** */ private transient long ptr;
+    /** */
+    private int rows;
+    /** */
+    private int cols;
+    /** */
+    private transient long ptr;
     //TODO: temp solution.
-    /** */ private int ptrInitHash;
+    /** */
+    private int ptrInitHash;
 
     /** */
     public DenseOffHeapMatrixStorage() {
@@ -152,7 +157,7 @@ public class DenseOffHeapMatrixStorage implements MatrixStorage {
         GridUnsafe.freeMemory(ptr);
     }
 
-    /** {@inheritDoc} */
+    /** */
     private long pointerOffset(int x, int y) {
         return ptr + x * cols * Double.BYTES + y * Double.BYTES;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/FunctionMatrixStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/FunctionMatrixStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/FunctionMatrixStorage.java
index acd7c29..5bb2569 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/FunctionMatrixStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/FunctionMatrixStorage.java
@@ -20,6 +20,7 @@ package org.apache.ignite.ml.math.impls.storage.matrix;
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
+
 import org.apache.ignite.ml.math.MatrixStorage;
 import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
 import org.apache.ignite.ml.math.functions.IntIntDoubleToVoidFunction;
@@ -29,11 +30,15 @@ import org.apache.ignite.ml.math.functions.IntIntToDoubleFunction;
  * Read-only or read-write function-based matrix storage.
  */
 public class FunctionMatrixStorage implements MatrixStorage {
-    /** */ private int rows;
-    /** */ private int cols;
+    /** */
+    private int rows;
+    /** */
+    private int cols;
 
-    /** */ private IntIntToDoubleFunction getFunc;
-    /** */ private IntIntDoubleToVoidFunction setFunc;
+    /** */
+    private IntIntToDoubleFunction getFunc;
+    /** */
+    private IntIntDoubleToVoidFunction setFunc;
 
     /**
      *
@@ -83,14 +88,14 @@ public class FunctionMatrixStorage implements MatrixStorage {
     }
 
     /**
-     *
+     * @return Getter function.
      */
     public IntIntToDoubleFunction getFunction() {
         return getFunc;
     }
 
     /**
-     *
+     * @return Setter function.
      */
     public IntIntDoubleToVoidFunction setFunction() {
         return setFunc;

http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/SparseLocalOnHeapMatrixStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/SparseLocalOnHeapMatrixStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/SparseLocalOnHeapMatrixStorage.java
index 4530900..db85b0f 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/SparseLocalOnHeapMatrixStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/SparseLocalOnHeapMatrixStorage.java
@@ -19,11 +19,13 @@ package org.apache.ignite.ml.math.impls.storage.matrix;
 
 import it.unimi.dsi.fastutil.ints.Int2DoubleOpenHashMap;
 import it.unimi.dsi.fastutil.ints.Int2DoubleRBTreeMap;
+
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import java.util.HashMap;
 import java.util.Map;
+
 import org.apache.ignite.ml.math.MatrixStorage;
 import org.apache.ignite.ml.math.StorageConstants;
 
@@ -34,11 +36,15 @@ public class SparseLocalOnHeapMatrixStorage implements MatrixStorage, StorageCon
     /** Default zero value. */
     private static final double DEFAULT_VALUE = 0.0;
 
-    /** */ private int rows;
-    /** */ private int cols;
+    /** */
+    private int rows;
+    /** */
+    private int cols;
 
-    /** */ private int acsMode;
-    /** */ private int stoMode;
+    /** */
+    private int acsMode;
+    /** */
+    private int stoMode;
 
     /** Actual map storage. */
     private Map<Integer, Map<Integer, Double>> sto;
@@ -64,16 +70,14 @@ public class SparseLocalOnHeapMatrixStorage implements MatrixStorage, StorageCon
     }
 
     /**
-     *
-     *
+     * @return Matrix elements storage mode.
      */
     public int getStorageMode() {
         return stoMode;
     }
 
     /**
-     *
-     *
+     * @return Matrix elements access mode.
      */
     public int getAccessMode() {
         return acsMode;

http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/CacheVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/CacheVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/CacheVectorStorage.java
index f99a216..bec232d 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/CacheVectorStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/CacheVectorStorage.java
@@ -20,6 +20,7 @@ package org.apache.ignite.ml.math.impls.storage.vector;
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
+
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.Ignition;
 import org.apache.ignite.ml.math.ValueMapper;
@@ -32,10 +33,12 @@ import org.apache.ignite.ml.math.VectorStorage;
 public class CacheVectorStorage<K, V> implements VectorStorage {
     /** Storage size. */
     private int size;
+
     /** Key mapper. */
     private VectorKeyMapper<K> keyMapper;
     /** Value mapper. */
     private ValueMapper<V> valMapper;
+
     /** Underlying ignite cache. */
     private IgniteCache<K, V> cache;
 
@@ -66,24 +69,21 @@ public class CacheVectorStorage<K, V> implements VectorStorage {
     }
 
     /**
-     *
-     *
+     * @return Ignite cache.
      */
     public IgniteCache<K, V> cache() {
         return cache;
     }
 
     /**
-     *
-     *
+     * @return Key mapper to validate cache keys.
      */
     public VectorKeyMapper<K> keyMapper() {
         return keyMapper;
     }
 
     /**
-     *
-     *
+     * @return Value mapper to obtain vector element values.
      */
     public ValueMapper<V> valueMapper() {
         return valMapper;
@@ -113,6 +113,7 @@ public class CacheVectorStorage<K, V> implements VectorStorage {
     }
 
     /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
     @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
         size = in.readInt();
         keyMapper = (VectorKeyMapper<K>)in.readObject();

http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/ConstantVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/ConstantVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/ConstantVectorStorage.java
index 31469ea..1b899a1 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/ConstantVectorStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/ConstantVectorStorage.java
@@ -20,6 +20,7 @@ package org.apache.ignite.ml.math.impls.storage.vector;
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
+
 import org.apache.ignite.ml.math.VectorStorage;
 import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
 
@@ -27,8 +28,10 @@ import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
  * Constant read-only vector storage.
  */
 public class ConstantVectorStorage implements VectorStorage {
-    /** */ private int size;
-    /** */ private double val;
+    /** */
+    private int size;
+    /** */
+    private double val;
 
     /**
      *
@@ -49,8 +52,7 @@ public class ConstantVectorStorage implements VectorStorage {
     }
 
     /**
-     *
-     *
+     * @return Constant stored in Vector elements.
      */
     public double constant() {
         return val;

http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/DelegateVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/DelegateVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/DelegateVectorStorage.java
index 6775d44..2a48653 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/DelegateVectorStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/DelegateVectorStorage.java
@@ -20,6 +20,7 @@ package org.apache.ignite.ml.math.impls.storage.vector;
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
+
 import org.apache.ignite.ml.math.VectorStorage;
 
 /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/FunctionVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/FunctionVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/FunctionVectorStorage.java
index 0f13bb6..a17eb0b 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/FunctionVectorStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/FunctionVectorStorage.java
@@ -20,6 +20,7 @@ package org.apache.ignite.ml.math.impls.storage.vector;
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
+
 import org.apache.ignite.ml.math.VectorStorage;
 import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
 import org.apache.ignite.ml.math.functions.IgniteFunction;
@@ -29,9 +30,12 @@ import org.apache.ignite.ml.math.functions.IntDoubleToVoidFunction;
  * Read-only or read-write function-based vector storage.
  */
 public class FunctionVectorStorage implements VectorStorage {
-    /** */ private IgniteFunction<Integer, Double> getFunc;
-    /** */ private IntDoubleToVoidFunction setFunc;
-    /** */ private int size;
+    /** */
+    private IgniteFunction<Integer, Double> getFunc;
+    /** */
+    private IntDoubleToVoidFunction setFunc;
+    /** */
+    private int size;
 
     /**
      *
@@ -57,16 +61,14 @@ public class FunctionVectorStorage implements VectorStorage {
     }
 
     /**
-     *
-     *
+     * @return Getter function.
      */
     public IgniteFunction<Integer, Double> getFunction() {
         return getFunc;
     }
 
     /**
-     *
-     *
+     * @return Setter function.
      */
     public IntDoubleToVoidFunction setFunction() {
         return setFunc;
@@ -108,6 +110,7 @@ public class FunctionVectorStorage implements VectorStorage {
     }
 
     /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
     @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
         setFunc = (IntDoubleToVoidFunction)in.readObject();
         getFunc = (IgniteFunction<Integer, Double>)in.readObject();

http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/MatrixVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/MatrixVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/MatrixVectorStorage.java
index 66aa049..59545a4 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/MatrixVectorStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/MatrixVectorStorage.java
@@ -20,6 +20,7 @@ package org.apache.ignite.ml.math.impls.storage.vector;
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
+
 import org.apache.ignite.ml.math.Matrix;
 import org.apache.ignite.ml.math.VectorStorage;
 import org.apache.ignite.ml.math.exceptions.IndexException;
@@ -28,15 +29,21 @@ import org.apache.ignite.ml.math.exceptions.IndexException;
  * Row, column or diagonal vector-based view of the matrix
  */
 public class MatrixVectorStorage implements VectorStorage {
-    /** */ private Matrix parent;
+    /** */
+    private Matrix parent;
 
-    /** */ private int row;
-    /** */ private int col;
+    /** */
+    private int row;
+    /** */
+    private int col;
 
-    /** */ private int rowStride;
-    /** */  private int colStride;
+    /** */
+    private int rowStride;
+    /** */
+    private int colStride;
 
-    /** */ private int size;
+    /** */
+    private int size;
 
     /**
      *

http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/PivotedVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/PivotedVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/PivotedVectorStorage.java
index a524838..537d651 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/PivotedVectorStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/PivotedVectorStorage.java
@@ -21,16 +21,20 @@ import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import java.util.Arrays;
+
 import org.apache.ignite.ml.math.VectorStorage;
 
 /**
  * Pivoted (index mapped) view over another vector storage implementation.
  */
 public class PivotedVectorStorage implements VectorStorage {
-    /** */ private VectorStorage sto;
+    /** */
+    private VectorStorage sto;
 
-    /** */ private int[] pivot;
-    /** */ private int[] unpivot;
+    /** */
+    private int[] pivot;
+    /** */
+    private int[] unpivot;
 
     /**
      * @param pivot Pivot array.
@@ -45,16 +49,14 @@ public class PivotedVectorStorage implements VectorStorage {
     }
 
     /**
-     *
-     *
+     * @return Pivot array for this vector view.
      */
     public int[] pivot() {
         return pivot;
     }
 
     /**
-     *
-     *
+     * @return Unpivot array for this vector view.
      */
     public int[] unpivot() {
         return unpivot;

http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorDelegateStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorDelegateStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorDelegateStorage.java
index d472e3a..453c0f7 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorDelegateStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorDelegateStorage.java
@@ -20,6 +20,7 @@ package org.apache.ignite.ml.math.impls.storage.vector;
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
+
 import org.apache.ignite.ml.math.Vector;
 import org.apache.ignite.ml.math.VectorStorage;
 import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
@@ -28,8 +29,10 @@ import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
  * Single value view storage over another vector.
  */
 public class SingleElementVectorDelegateStorage implements VectorStorage {
-    /** */ private int idx;
-    /** */ private Vector vec;
+    /** */
+    private int idx;
+    /** */
+    private Vector vec;
 
     /**
      *
@@ -51,16 +54,14 @@ public class SingleElementVectorDelegateStorage implements VectorStorage {
     }
 
     /**
-     *
-     *
+     * @return Index of the element in the parent vector.
      */
     public int index() {
         return idx;
     }
 
     /**
-     *
-     *
+     * @return Parent vector.
      */
     public Vector delegate() {
         return vec;

http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorStorage.java
index 854b732..6378399 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorStorage.java
@@ -20,6 +20,7 @@ package org.apache.ignite.ml.math.impls.storage.vector;
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
+
 import org.apache.ignite.ml.math.VectorStorage;
 import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
 
@@ -27,9 +28,12 @@ import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
  * Vector storage holding a single non-zero value at some index.
  */
 public class SingleElementVectorStorage implements VectorStorage {
-    /** */ private int idx;
-    /** */ private double val;
-    /** */ private int size;
+    /** */
+    private int idx;
+    /** */
+    private double val;
+    /** */
+    private int size;
 
     /**
      *
@@ -53,7 +57,6 @@ public class SingleElementVectorStorage implements VectorStorage {
     }
 
     /**
-     *
      * @return Index of the element in the parent vector.
      */
     public int index() {

http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOffHeapVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOffHeapVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOffHeapVectorStorage.java
index 035a565..fe70fbd 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOffHeapVectorStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOffHeapVectorStorage.java
@@ -21,6 +21,7 @@ import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import java.nio.ByteBuffer;
+
 import org.apache.ignite.internal.util.offheap.GridOffHeapMap;
 import org.apache.ignite.internal.util.offheap.GridOffHeapMapFactory;
 import org.apache.ignite.ml.math.VectorStorage;
@@ -33,8 +34,10 @@ import org.apache.ignite.ml.math.impls.vector.SparseLocalOffHeapVector;
 public class SparseLocalOffHeapVectorStorage implements VectorStorage {
     /** Assume 10% density. */
     private static final int INIT_DENSITY = 10;
+
     /** Storage capacity. */
     private int size;
+
     /** Local off heap map. */
     private GridOffHeapMap gridOffHeapMap;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOnHeapVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOnHeapVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOnHeapVectorStorage.java
index 75318d6..d3dba8e 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOnHeapVectorStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOnHeapVectorStorage.java
@@ -19,10 +19,12 @@ package org.apache.ignite.ml.math.impls.storage.vector;
 
 import it.unimi.dsi.fastutil.ints.Int2DoubleOpenHashMap;
 import it.unimi.dsi.fastutil.ints.Int2DoubleRBTreeMap;
+
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import java.util.Map;
+
 import org.apache.ignite.ml.math.StorageConstants;
 import org.apache.ignite.ml.math.VectorStorage;
 
@@ -30,8 +32,10 @@ import org.apache.ignite.ml.math.VectorStorage;
  * Sparse, local, on-heap vector storage.
  */
 public class SparseLocalOnHeapVectorStorage implements VectorStorage, StorageConstants {
-    /** */ private int size;
-    /** */ private int acsMode;
+    /** */
+    private int size;
+    /** */
+    private int acsMode;
 
     /** Actual map storage. */
     private Map<Integer, Double> sto;
@@ -61,8 +65,7 @@ public class SparseLocalOnHeapVectorStorage implements VectorStorage, StorageCon
     }
 
     /**
-     *
-     *
+     * @return Vector elements access mode.
      */
     public int getAccessMode() {
         return acsMode;

http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/AbstractVector.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/AbstractVector.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/AbstractVector.java
index 83ac837..d59964b 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/AbstractVector.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/AbstractVector.java
@@ -28,6 +28,7 @@ import java.util.NoSuchElementException;
 import java.util.Spliterator;
 import java.util.function.Consumer;
 import java.util.function.IntToDoubleFunction;
+
 import org.apache.ignite.lang.IgniteUuid;
 import org.apache.ignite.ml.math.Matrix;
 import org.apache.ignite.ml.math.Vector;

http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/DelegatingVector.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/DelegatingVector.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/DelegatingVector.java
index c868160..545d728 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/DelegatingVector.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/DelegatingVector.java
@@ -24,6 +24,7 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.Spliterator;
 import java.util.function.IntToDoubleFunction;
+
 import org.apache.ignite.lang.IgniteUuid;
 import org.apache.ignite.ml.math.Matrix;
 import org.apache.ignite.ml.math.Vector;

http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/MatrixVectorView.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/MatrixVectorView.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/MatrixVectorView.java
index 1eda7d8..e479945 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/MatrixVectorView.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/MatrixVectorView.java
@@ -20,6 +20,7 @@ package org.apache.ignite.ml.math.impls.vector;
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
+
 import org.apache.ignite.ml.math.Matrix;
 import org.apache.ignite.ml.math.Vector;
 import org.apache.ignite.ml.math.exceptions.IndexException;
@@ -29,13 +30,18 @@ import org.apache.ignite.ml.math.impls.storage.vector.MatrixVectorStorage;
  * Row or column vector view off the matrix.
  */
 public class MatrixVectorView extends AbstractVector {
-    /** */ private Matrix parent;
-
-    /** */ private int row;
-    /** */ private int col;
-
-    /** */ private int rowStride;
-    /** */ private int colStride;
+    /** */
+    private Matrix parent;
+
+    /** */
+    private int row;
+    /** */
+    private int col;
+
+    /** */
+    private int rowStride;
+    /** */
+    private int colStride;
 
     /**
      *

http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/PivotedVectorView.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/PivotedVectorView.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/PivotedVectorView.java
index 5ad6b89..0d53e71 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/PivotedVectorView.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/PivotedVectorView.java
@@ -20,6 +20,7 @@ package org.apache.ignite.ml.math.impls.vector;
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
+
 import org.apache.ignite.ml.math.Matrix;
 import org.apache.ignite.ml.math.Vector;
 import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
@@ -30,7 +31,8 @@ import org.apache.ignite.ml.math.impls.storage.vector.PivotedVectorStorage;
  * Pivoted (index mapped) view over another vector.
  */
 public class PivotedVectorView extends AbstractVector {
-    /** */ private Vector vec;
+    /** */
+    private Vector vec;
 
     /**
      * @param vec Parent vector.
@@ -47,7 +49,7 @@ public class PivotedVectorView extends AbstractVector {
     }
 
     /**
-     * @param vec  Parent vector.
+     * @param vec Parent vector.
      * @param pivot Mapping from external index to internal.
      */
     public PivotedVectorView(Vector vec, int[] pivot) {
@@ -79,7 +81,7 @@ public class PivotedVectorView extends AbstractVector {
 
     /**
      * @param i Index to pivot.
-     * @return  Mapping from external index to internal for given index.
+     * @return Mapping from external index to internal for given index.
      */
     public int pivot(int i) {
         return storage().pivot()[i];
@@ -104,17 +106,17 @@ public class PivotedVectorView extends AbstractVector {
         int exIdx = storage().pivot()[idx];
 
         return new Vector.Element() {
-            /** {@inheritDoc */
+            /** {@inheritDoc} */
             @Override public double get() {
                 return storageGet(idx);
             }
 
-            /** {@inheritDoc */
+            /** {@inheritDoc} */
             @Override public int index() {
                 return exIdx;
             }
 
-            /** {@inheritDoc */
+            /** {@inheritDoc} */
             @Override public void set(double val) {
                 storageSet(idx, val);
             }

http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/RandomVector.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/RandomVector.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/RandomVector.java
index d216a90..df6f791 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/RandomVector.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/RandomVector.java
@@ -21,6 +21,7 @@ import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import java.util.Map;
+
 import org.apache.ignite.ml.math.Matrix;
 import org.apache.ignite.ml.math.VectorStorage;
 import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
@@ -33,7 +34,8 @@ import org.apache.ignite.ml.math.Vector;
  * that by default, the value is determined by a relatively simple hash of the index.
  */
 public class RandomVector extends AbstractReadOnlyVector {
-    /** */ private boolean fastHash;
+    /** */
+    private boolean fastHash;
 
     /**
      * @param size Vector cardinality.

http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/SingleElementVector.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/SingleElementVector.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/SingleElementVector.java
index b47dad8..21e8141 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/SingleElementVector.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/SingleElementVector.java
@@ -1,102 +1 @@
-/*
- * 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.ml.math.impls.vector;
-
-import java.util.Map;
-import org.apache.ignite.ml.math.Matrix;
-import org.apache.ignite.ml.math.Vector;
-import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
-import org.apache.ignite.ml.math.impls.storage.vector.SingleElementVectorStorage;
-
-/**
- * Read-write vector holding a single non-zero value at some index.
- */
-public class SingleElementVector extends AbstractVector {
-    /**
-     *
-     */
-    public SingleElementVector() {
-        // No-op
-    }
-
-    /**
-     * @param size Parent vector size.
-     * @param idx Index of the parent vector element.
-     * @param val Value of the vector element.
-     */
-    public SingleElementVector(int size, int idx, double val) {
-        super(new SingleElementVectorStorage(size, idx, val));
-    }
-
-    /**
-     * @param args Parameters to create new vector instance.
-     */
-    public SingleElementVector(Map<String, Object> args) {
-        assert args != null;
-
-        if (args.containsKey("size") && args.containsKey("index") && args.containsKey("value")) {
-            int size = (int)args.get("size");
-            int idx = (int)args.get("index");
-            double val = (double)args.get("value");
-
-            setStorage(new SingleElementVectorStorage(size, idx, val));
-        }
-        else
-            throw new UnsupportedOperationException("Invalid constructor argument(s).");
-    }
-
-    /**
-     *
-     *
-     */
-    private SingleElementVectorStorage storage() {
-        return (SingleElementVectorStorage)getStorage();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Element minElement() {
-        return makeElement(storage().index());
-    }
-
-    /** {@inheritDoc} */
-    @Override public Element maxElement() {
-        return makeElement(storage().index());
-    }
-
-    /** {@inheritDoc} */
-    @Override public double sum() {
-        return getX(storage().index());
-    }
-
-    /** {@inheritDoc} */
-    @Override public int nonZeroElements() {
-        return isZero(get(storage().index())) ? 0 : 1;
-    }
-
-    /** {@inheritDoc} */
-    @Override public Vector like(int crd) {
-        int idx = storage().index();
-
-        return new SingleElementVector(crd, idx, getX(idx));
-    }
-
-    /** {@inheritDoc} */
-    @Override public Matrix likeMatrix(int rows, int cols) {
-        throw new UnsupportedOperationException();
-    }
-}
+/*
 * 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.ml.math.impls.vector;

import java.util.Map;

import org.apache.ignite.ml.math.Matrix;
import org.apache.ignite.ml.math.Vector;
import org.apache.ignite.ml.math.except
 ions.UnsupportedOperationException;
import org.apache.ignite.ml.math.impls.storage.vector.SingleElementVectorStorage;

/**
 * Read-write vector holding a single non-zero value at some index.
 */
public class SingleElementVector extends AbstractVector {
    /**
     *
     */
    public SingleElementVector() {
        // No-op
    }

    /**
     * @param size Parent vector size.
     * @param idx Index of the parent vector element.
     * @param val Value of the vector element.
     */
    public SingleElementVector(int size, int idx, double val) {
        super(new SingleElementVectorStorage(size, idx, val));
    }

    /**
     * @param args Parameters to create new vector instance.
     */
    public SingleElementVector(Map<String, Object> args) {
        assert args != null;

        if (args.containsKey("size") && args.containsKey("index") && args.containsKey("value")) {
            int size = (int)args.get("size");
            int idx = (int)args.get("index");
            doub
 le val = (double)args.get("value");

            setStorage(new SingleElementVectorStorage(size, idx, val));
        }
        else
            throw new UnsupportedOperationException("Invalid constructor argument(s).");
    }

    /**
     *
     *
     */
    private SingleElementVectorStorage storage() {
        return (SingleElementVectorStorage)getStorage();
    }

    /** {@inheritDoc} */
    @Override public Element minElement() {
        return makeElement(storage().index());
    }

    /** {@inheritDoc} */
    @Override public Element maxElement() {
        return makeElement(storage().index());
    }

    /** {@inheritDoc} */
    @Override public double sum() {
        return getX(storage().index());
    }

    /** {@inheritDoc} */
    @Override public int nonZeroElements() {
        return isZero(get(storage().index())) ? 0 : 1;
    }

    /** {@inheritDoc} */
    @Override public Vector like(int crd) {
        int idx = storage().index();

        return new SingleElemen
 tVector(crd, idx, getX(idx));
    }

    /** {@inheritDoc} */
    @Override public Matrix likeMatrix(int rows, int cols) {
        throw new UnsupportedOperationException();
    }
}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/test/java/org/apache/ignite/ml/math/TracerTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/TracerTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/TracerTest.java
index d7c746d..b4f7330 100644
--- a/modules/ml/src/test/java/org/apache/ignite/ml/math/TracerTest.java
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/TracerTest.java
@@ -23,6 +23,7 @@ import java.nio.file.Files;
 import java.nio.file.Path;
 import java.util.List;
 import java.util.Optional;
+
 import org.apache.ignite.ml.math.impls.MathTestConstants;
 import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
 import org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector;
@@ -35,8 +36,11 @@ import static org.junit.Assert.assertEquals;
  * Tests for {@link Tracer}.
  */
 public class TracerTest {
-    /** */ private static final String DEFAULT_FORMAT = "%.10f";
-    /** */ private static final double DEFAULT_DELTA = 0.000000001d;
+    /** */
+    private static final String DEFAULT_FORMAT = "%.10f";
+
+    /** */
+    private static final double DEFAULT_DELTA = 0.000000001d;
 
     /**
      * Color mapper that maps [0, 1] range into three distinct RGB segments.
@@ -153,7 +157,7 @@ public class TracerTest {
 
         List<String> strings = Files.readAllLines(file);
         Optional<String> reduce = strings.stream().reduce((s1, s2) -> s1 + s2);
-        String[] csvVals = reduce.get().split(",");
+        String[] csvVals = reduce.orElse("").split(",");
 
         for (int i = 0; i < vector.size(); i++) {
             Double csvVal = Double.valueOf(csvVals[i]);
@@ -181,7 +185,7 @@ public class TracerTest {
 
         List<String> strings = Files.readAllLines(file);
         Optional<String> reduce = strings.stream().reduce((s1, s2) -> s1 + s2);
-        String[] csvVals = reduce.get().split(",");
+        String[] csvVals = reduce.orElse("").split(",");
 
         for (int i = 0; i < matrix.rowSize(); i++)
             for (int j = 0; j < matrix.columnSize(); j++) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/CacheMatrixTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/CacheMatrixTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/CacheMatrixTest.java
index 52badbc..a7e9488 100644
--- a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/CacheMatrixTest.java
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/CacheMatrixTest.java
@@ -291,7 +291,7 @@ public class CacheMatrixTest extends GridCommonAbstractTest {
         final CacheMatrix<Integer, Double> cacheMatrix = new CacheMatrix<>(rows, cols, cache, keyMapper, new IdentityValueMapper());
 
         ExternalizeTest<CacheMatrix<Integer, Double>> externalizeTest = new ExternalizeTest<CacheMatrix<Integer, Double>>() {
-
+            /** {@inheritDoc} */
             @Override public void externalizeTest() {
                 super.externalizeTest(cacheMatrix);
             }
@@ -351,14 +351,18 @@ public class CacheMatrixTest extends GridCommonAbstractTest {
         return new MatrixKeyMapperForTests(rows, cols);
     }
 
-    /** Init the given matrix by random values. */
+    /**
+     * Init the given matrix by random values.
+     */
     private void fillMatrix(Matrix m) {
         for (int i = 0; i < m.rowSize(); i++)
             for (int j = 0; j < m.columnSize(); j++)
                 m.set(i, j, Math.random());
     }
 
-    /** Init the given matrix by zeros. */
+    /**
+     * Init the given matrix by zeros.
+     */
     private void initMatrix(Matrix m) {
         for (int i = 0; i < m.rowSize(); i++)
             for (int j = 0; j < m.columnSize(); j++)

http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/MatrixKeyMapperForTests.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/MatrixKeyMapperForTests.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/MatrixKeyMapperForTests.java
index bc628c9..cfdd0f3 100644
--- a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/MatrixKeyMapperForTests.java
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/MatrixKeyMapperForTests.java
@@ -20,31 +20,36 @@ import org.apache.ignite.ml.math.MatrixKeyMapper;
 
 /** */
 public class MatrixKeyMapperForTests implements MatrixKeyMapper<Integer> {
-    /** */ private int rows;
-    /** */ private int cols;
+    /** */
+    private int rows;
+    /** */
+    private int cols;
 
     /** */
     public MatrixKeyMapperForTests() {
         // No-op.
     }
 
-    /** */
+    /**
+     * @param rows Amount of rows in matrix.
+     * @param cols Amount of columns in matrix.
+     */
     public MatrixKeyMapperForTests(int rows, int cols) {
         this.rows = rows;
         this.cols = cols;
     }
 
-    /** */
+    /** {@inheritDoc} */
     @Override public Integer apply(int x, int y) {
         return x * cols + y;
     }
 
-    /** */
+    /** {@inheritDoc} */
     @Override public boolean isValid(Integer integer) {
         return (rows * cols) > integer;
     }
 
-    /** */
+    /** {@inheritDoc} */
     @Override public int hashCode() {
         int hash = 1;
 
@@ -54,7 +59,7 @@ public class MatrixKeyMapperForTests implements MatrixKeyMapper<Integer> {
         return hash;
     }
 
-    /** */
+    /** {@inheritDoc} */
     @Override public boolean equals(Object obj) {
         if (this == obj)
             return true;

http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/matrix/MatrixStorageFixtures.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/matrix/MatrixStorageFixtures.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/matrix/MatrixStorageFixtures.java
index 03473cf..78f3dde 100644
--- a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/matrix/MatrixStorageFixtures.java
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/matrix/MatrixStorageFixtures.java
@@ -23,17 +23,18 @@ import java.util.List;
 import java.util.NoSuchElementException;
 import java.util.function.BiConsumer;
 import java.util.function.Supplier;
+
 import org.apache.ignite.ml.math.MatrixStorage;
 import org.apache.ignite.ml.math.StorageConstants;
 import org.jetbrains.annotations.NotNull;
 
 /**
- *
+ * Fixtures for matrix tests.
  */
 class MatrixStorageFixtures {
     /** */
     private static final List<Supplier<Iterable<MatrixStorage>>> suppliers = Collections.singletonList(
-        (Supplier<Iterable<MatrixStorage>>) SparseLocalMatrixStorageFixture::new
+        (Supplier<Iterable<MatrixStorage>>)SparseLocalMatrixStorageFixture::new
     );
 
     /** */
@@ -57,10 +58,12 @@ class MatrixStorageFixtures {
         private final Integer[] rows = new Integer[] {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 512, 1024, null};
         /** */
         private final Integer[] cols = new Integer[] {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 1024, 512, null};
+
         /** */
         private final Integer[] randomAccess = new Integer[] {StorageConstants.SEQUENTIAL_ACCESS_MODE, StorageConstants.RANDOM_ACCESS_MODE, null};
         /** */
         private final Integer[] rowStorage = new Integer[] {StorageConstants.ROW_STORAGE_MODE, StorageConstants.COLUMN_STORAGE_MODE, null};
+
         /** */
         private int sizeIdx = 0;
         /** */
@@ -118,19 +121,23 @@ class MatrixStorageFixtures {
                 ", access mode=" + randomAccess[acsModeIdx] + ", storage mode=" + rowStorage[stoModeIdx] + "}";
         }
 
-        /** */ private boolean hasNextRow(int idx) {
+        /** */
+        private boolean hasNextRow(int idx) {
             return rows[idx] != null;
         }
 
-        /** */ private boolean hasNextCol(int idx) {
+        /** */
+        private boolean hasNextCol(int idx) {
             return cols[idx] != null;
         }
 
-        /** */ private boolean hasNextAcsMode(int idx) {
+        /** */
+        private boolean hasNextAcsMode(int idx) {
             return randomAccess[idx] != null;
         }
 
-        /** */ private boolean hasNextStoMode(int idx) {
+        /** */
+        private boolean hasNextStoMode(int idx) {
             return rowStorage[idx] != null;
         }
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOffHeapVectorStorageTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOffHeapVectorStorageTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOffHeapVectorStorageTest.java
index 7e5fc48..0b4392e 100644
--- a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOffHeapVectorStorageTest.java
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOffHeapVectorStorageTest.java
@@ -33,7 +33,8 @@ import static org.junit.Assert.assertTrue;
  * Tests for {@link SparseLocalOffHeapVectorStorage}.
  */
 public class SparseLocalOffHeapVectorStorageTest extends ExternalizeTest<SparseLocalOffHeapVectorStorage> {
-    /** */ private SparseLocalOffHeapVectorStorage testVectorStorage;
+    /** */
+    private SparseLocalOffHeapVectorStorage testVectorStorage;
 
     /** */
     @Before

http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/AbstractVectorTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/AbstractVectorTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/AbstractVectorTest.java
index 7d12773..0707e0a 100644
--- a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/AbstractVectorTest.java
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/AbstractVectorTest.java
@@ -19,6 +19,7 @@ package org.apache.ignite.ml.math.impls.vector;
 
 import java.util.Arrays;
 import java.util.stream.StreamSupport;
+
 import org.apache.ignite.ml.math.Matrix;
 import org.apache.ignite.ml.math.Vector;
 import org.apache.ignite.ml.math.VectorStorage;
@@ -355,54 +356,55 @@ public class AbstractVectorTest {
      * @param storage {@link VectorStorage}
      * @return AbstractVector.
      */
+    @SuppressWarnings("ClassWithoutNoArgConstructor")
     private AbstractVector getAbstractVector(VectorStorage storage) {
         return new AbstractVector(storage) { // TODO: find out how to fix warning about missing constructor
-            /** */
+            /** {@inheritDoc} */
             @Override public boolean isDense() {
                 return false;
             }
 
-            /** */
+            /** {@inheritDoc} */
             @Override public boolean isSequentialAccess() {
                 return false;
             }
 
-            /** */
+            /** {@inheritDoc} */
             @Override public Matrix likeMatrix(int rows, int cols) {
                 return null;
             }
 
-            /** */
+            /** {@inheritDoc} */
             @Override public Vector copy() {
                 return getAbstractVector(this.getStorage());
             }
 
-            /** */
+            /** {@inheritDoc} */
             @Override public Vector like(int crd) {
                 return null;
             }
 
-            /** */
+            /** {@inheritDoc} */
             @Override public Vector normalize() {
                 return null;
             }
 
-            /** */
+            /** {@inheritDoc} */
             @Override public Vector normalize(double power) {
                 return null;
             }
 
-            /** */
+            /** {@inheritDoc} */
             @Override public Vector logNormalize() {
                 return null;
             }
 
-            /** */
+            /** {@inheritDoc} */
             @Override public Vector logNormalize(double power) {
                 return null;
             }
 
-            /** */
+            /** {@inheritDoc} */
             @Override public Vector viewPart(int off, int len) {
                 return null;
             }
@@ -426,52 +428,52 @@ public class AbstractVectorTest {
      */
     private AbstractVector getAbstractVector() {
         return new AbstractVector() { // TODO: find out how to fix warning about missing constructor
-            /** */
+            /** {@inheritDoc} */
             @Override public boolean isDense() {
                 return false;
             }
 
-            /** */
+            /** {@inheritDoc} */
             @Override public Matrix likeMatrix(int rows, int cols) {
                 return null;
             }
 
-            /** */
+            /** {@inheritDoc} */
             @Override public boolean isSequentialAccess() {
                 return false;
             }
 
-            /** */
+            /** {@inheritDoc} */
             @Override public Vector copy() {
                 return getAbstractVector(this.getStorage());
             }
 
-            /** */
+            /** {@inheritDoc} */
             @Override public Vector like(int crd) {
                 return null;
             }
 
-            /** */
+            /** {@inheritDoc} */
             @Override public Vector normalize() {
                 return null;
             }
 
-            /** */
+            /** {@inheritDoc} */
             @Override public Vector normalize(double power) {
                 return null;
             }
 
-            /** */
+            /** {@inheritDoc} */
             @Override public Vector logNormalize() {
                 return null;
             }
 
-            /** */
+            /** {@inheritDoc} */
             @Override public Vector logNormalize(double power) {
                 return null;
             }
 
-            /** */
+            /** {@inheritDoc} */
             @Override public Vector viewPart(int off, int len) {
                 return null;
             }

http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/CacheVectorTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/CacheVectorTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/CacheVectorTest.java
index 0026e2b..ce9f98a 100644
--- a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/CacheVectorTest.java
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/CacheVectorTest.java
@@ -23,6 +23,7 @@ import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.util.stream.IntStream;
+
 import junit.framework.TestCase;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
@@ -48,6 +49,7 @@ public class CacheVectorTest extends GridCommonAbstractTest {
     private static final String CACHE_NAME = "test-cache";
     /** Cache size. */
     private static final int size = MathTestConstants.STORAGE_SIZE;
+
     /** Grid instance. */
     private Ignite ignite;
     /** Default key mapper. */
@@ -420,7 +422,8 @@ public class CacheVectorTest extends GridCommonAbstractTest {
         return cache;
     }
 
-    /** */ private static class TestKeyMapper implements VectorKeyMapper<Integer> {
+    /** */
+    private static class TestKeyMapper implements VectorKeyMapper<Integer> {
         /** {@inheritDoc} */
         @Override public Integer apply(int i) {
             return i;


[12/29] ignite git commit: Try avoid timeout in IgniteCacheGetRestartTest.

Posted by ag...@apache.org.
Try avoid timeout in IgniteCacheGetRestartTest.


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

Branch: refs/heads/ignite-5024
Commit: b41ecd1e0b9dc6199a618e8d4df740c96372eba1
Parents: 3402043
Author: sboikov <sb...@gridgain.com>
Authored: Mon Apr 24 16:59:30 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Mon Apr 24 16:59:30 2017 +0300

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


http://git-wip-us.apache.org/repos/asf/ignite/blob/b41ecd1e/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheGetRestartTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheGetRestartTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheGetRestartTest.java
index aaa83cc..69d9123 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheGetRestartTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheGetRestartTest.java
@@ -219,7 +219,7 @@ public class IgniteCacheGetRestartTest extends GridCommonAbstractTest {
 
                         IgniteInternalFuture<?> syncFut = ((IgniteCacheProxy)cache).context().preloader().syncFuture();
 
-                        while (!syncFut.isDone())
+                        while (!syncFut.isDone() && U.currentTimeMillis() < stopTime)
                             checkGet(cache);
 
                         checkGet(cache);


[14/29] ignite git commit: GG-12132 Added magic header to protect from unexpected input.

Posted by ag...@apache.org.
GG-12132 Added magic header to protect from unexpected input.


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

Branch: refs/heads/ignite-5024
Commit: e4a926b2825eee507e1f58a3c1b19fdc2ac80cb4
Parents: 26c222b
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Tue Apr 25 14:02:26 2017 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Tue Apr 25 14:02:26 2017 +0700

----------------------------------------------------------------------
 .../marshaller/optimized/OptimizedMarshaller.java    |  3 ++-
 .../internal/visor/VisorDataTransferObject.java      | 15 +++++++++++++--
 .../internal/visor/binary/VisorBinaryMetadata.java   |  3 +--
 .../visor/cache/VisorCacheConfiguration.java         |  3 +--
 4 files changed, 17 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/e4a926b2/modules/core/src/main/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshaller.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshaller.java b/modules/core/src/main/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshaller.java
index 3f40d63..575c9a4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshaller.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshaller.java
@@ -232,7 +232,8 @@ public class OptimizedMarshaller extends AbstractNodeNameAwareMarshaller {
                 "[clsLdr=" + clsLdr + ", cls=" + e.getMessage() + "]", e);
         }
         catch (Exception e) {
-            throw new IgniteCheckedException("Failed to deserialize object with given class loader: " + clsLdr, e);
+            throw new IgniteCheckedException("Failed to deserialize object with given class loader: " +
+                "[clsLdr=" + clsLdr + ", err=" + e.getMessage() + "]", e);
         }
         finally {
             OptimizedObjectStreamRegistry.closeIn(objIn);

http://git-wip-us.apache.org/repos/asf/ignite/blob/e4a926b2/modules/core/src/main/java/org/apache/ignite/internal/visor/VisorDataTransferObject.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/VisorDataTransferObject.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/VisorDataTransferObject.java
index d8dcf4e..bdf01e7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/VisorDataTransferObject.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/VisorDataTransferObject.java
@@ -30,6 +30,9 @@ import org.jetbrains.annotations.Nullable;
  * Base class for data transfer objects.
  */
 public abstract class VisorDataTransferObject implements Externalizable {
+    /** Magic number to detect correct transfer objects. */
+    private static final int MAGIC = 0x42BEEF00;
+
     /**
      * @param col Source collection.
      * @param <T> Collection type.
@@ -59,7 +62,9 @@ public abstract class VisorDataTransferObject implements Externalizable {
 
     /** {@inheritDoc} */
     @Override public void writeExternal(ObjectOutput out) throws IOException {
-        out.writeByte(getProtocolVersion());
+        int hdr = MAGIC  + getProtocolVersion();
+
+        out.writeInt(hdr);
 
         try (VisorDataTransferObjectOutput dtout = new VisorDataTransferObjectOutput(out)) {
             writeExternalData(dtout);
@@ -78,7 +83,13 @@ public abstract class VisorDataTransferObject implements Externalizable {
 
     /** {@inheritDoc} */
     @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-        byte ver = in.readByte();
+        int hdr = in.readInt();
+
+        if ((hdr & MAGIC) != MAGIC)
+            throw new IOException("Unexpected VisorDataTransferObject header " +
+                "[actual=" + Integer.toHexString(hdr) + ", expected=" + Integer.toHexString(MAGIC) + "]");
+
+        byte ver = (byte)(hdr & 0xFF);
 
         try (VisorDataTransferObjectInput dtin = new VisorDataTransferObjectInput(in)) {
             readExternalData(ver, dtin);

http://git-wip-us.apache.org/repos/asf/ignite/blob/e4a926b2/modules/core/src/main/java/org/apache/ignite/internal/visor/binary/VisorBinaryMetadata.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/binary/VisorBinaryMetadata.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/binary/VisorBinaryMetadata.java
index 5e948c6..285bff9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/binary/VisorBinaryMetadata.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/binary/VisorBinaryMetadata.java
@@ -124,8 +124,7 @@ public class VisorBinaryMetadata extends VisorDataTransferObject {
     }
 
     /** {@inheritDoc} */
-    @Override protected void readExternalData(byte protoVer,
-        ObjectInput in) throws IOException, ClassNotFoundException {
+    @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException {
         typeName = U.readString(in);
         typeId = (Integer)in.readObject();
         affinityKeyFieldName = U.readString(in);

http://git-wip-us.apache.org/repos/asf/ignite/blob/e4a926b2/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java
index 391b120..5b5d3a8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java
@@ -418,8 +418,7 @@ public class VisorCacheConfiguration extends VisorDataTransferObject {
     }
 
     /** {@inheritDoc} */
-    @Override protected void readExternalData(byte protoVer,
-        ObjectInput in) throws IOException, ClassNotFoundException {
+    @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException {
         name = U.readString(in);
         mode = CacheMode.fromOrdinal(in.readByte());
         atomicityMode = CacheAtomicityMode.fromOrdinal(in.readByte());


[28/29] ignite git commit: ignite-2.0 - Javadoc fix + code style

Posted by ag...@apache.org.
ignite-2.0 - Javadoc fix + code style


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

Branch: refs/heads/ignite-5024
Commit: 4be320ac44f29b927f8b487caa00479fa6add3ff
Parents: 7d33dd5
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Wed Apr 26 10:59:13 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Wed Apr 26 10:59:13 2017 +0300

----------------------------------------------------------------------
 .../h2/twostep/msg/GridH2QueryRequest.java      | 26 ++++++++++----------
 1 file changed, 13 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/4be320ac/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2QueryRequest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2QueryRequest.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2QueryRequest.java
index 6741d89..17bb9f6 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2QueryRequest.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2QueryRequest.java
@@ -133,21 +133,20 @@ public class GridH2QueryRequest implements Message, GridCacheQueryMarshallable {
 
     /**
      * @param req Request.
-     * @return {@code this}.
      */
     public GridH2QueryRequest(GridH2QueryRequest req) {
-        this.reqId = req.reqId;
-        this.caches = req.caches;
-        this.topVer = req.topVer;
-        this.parts = req.parts;
-        this.qryParts = req.qryParts;
-        this.pageSize = req.pageSize;
-        this.qrys = req.qrys;
-        this.flags = req.flags;
-        this.tbls = req.tbls;
-        this.timeout = req.timeout;
-        this.params = req.params;
-        this.paramsBytes = req.paramsBytes;
+        reqId = req.reqId;
+        caches = req.caches;
+        topVer = req.topVer;
+        parts = req.parts;
+        qryParts = req.qryParts;
+        pageSize = req.pageSize;
+        qrys = req.qrys;
+        flags = req.flags;
+        tbls = req.tbls;
+        timeout = req.timeout;
+        params = req.params;
+        paramsBytes = req.paramsBytes;
     }
 
     /**
@@ -359,6 +358,7 @@ public class GridH2QueryRequest implements Message, GridCacheQueryMarshallable {
     }
 
     /** {@inheritDoc} */
+    @SuppressWarnings("IfMayBeConditional")
     @Override public void unmarshall(Marshaller m, GridKernalContext ctx) {
         if (params != null)
             return;


[18/29] ignite git commit: IGNITE-5069: Fixed failure in QueryWords example.

Posted by ag...@apache.org.
IGNITE-5069: Fixed failure in QueryWords example.


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

Branch: refs/heads/ignite-5024
Commit: 4739458cd23b28e435ec91608a747c612a767477
Parents: 645581e
Author: devozerov <vo...@gridgain.com>
Authored: Tue Apr 25 11:21:49 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Tue Apr 25 11:21:49 2017 +0300

----------------------------------------------------------------------
 .../org/apache/ignite/examples/streaming/wordcount/QueryWords.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/4739458c/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/QueryWords.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/QueryWords.java b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/QueryWords.java
index c1ce6e1..54aa97f 100644
--- a/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/QueryWords.java
+++ b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/QueryWords.java
@@ -75,7 +75,7 @@ public class QueryWords {
                     List<?> row = stats.get(0);
 
                     if (row.get(0) != null)
-                        System.out.printf("Query results [avg=%.2f, min=%d, max=%d]%n", row.get(0), row.get(1), row.get(2));
+                        System.out.printf("Query results [avg=%d, min=%d, max=%d]%n", row.get(0), row.get(1), row.get(2));
 
                     // Print top 10 words.
                     ExamplesUtils.printQueryResults(top10);


[25/29] ignite git commit: IGNITE-5036: @QuerySqlField and @QueryTextField can no longer be applied to methods. This closes #1863.

Posted by ag...@apache.org.
IGNITE-5036: @QuerySqlField and @QueryTextField can no longer be applied to methods. This closes #1863.


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

Branch: refs/heads/ignite-5024
Commit: 9649733ce561166e308b53393e252d7efa087964
Parents: 5ef610c
Author: tledkov-gridgain <tl...@gridgain.com>
Authored: Tue Apr 25 17:34:05 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Tue Apr 25 17:34:05 2017 +0300

----------------------------------------------------------------------
 .../examples/IndexingBridgeMethodTest.java      | 93 --------------------
 .../IgniteExamplesJ8SelfTestSuite.java          |  2 -
 .../cassandra/common/PropertyMappingHelper.java | 21 +----
 .../persistence/KeyPersistenceSettings.java     | 18 ++--
 .../store/cassandra/persistence/PojoField.java  | 21 +----
 .../cassandra/persistence/PojoKeyField.java     |  7 --
 .../cassandra/persistence/PojoValueField.java   |  6 --
 .../persistence/ValuePersistenceSettings.java   | 12 ++-
 .../org/apache/ignite/tests/pojos/Person.java   | 10 ++-
 .../org/apache/ignite/tests/pojos/Product.java  |  7 --
 .../apache/ignite/tests/pojos/ProductOrder.java |  8 --
 .../internal/jdbc2/JdbcResultSetSelfTest.java   |  2 +-
 .../cache/query/annotations/QuerySqlField.java  |  2 +-
 .../cache/query/annotations/QueryTextField.java |  4 +-
 .../configuration/CacheConfiguration.java       | 26 ------
 .../cache/GridCacheQueryTestValue.java          |  2 +-
 .../IgniteCacheAbstractFieldsQuerySelfTest.java | 29 +-----
 .../cache/IgniteCacheDistributedJoinTest.java   |  6 +-
 18 files changed, 30 insertions(+), 246 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/9649733c/examples/src/test/java8/org/apache/ignite/java8/examples/IndexingBridgeMethodTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/examples/IndexingBridgeMethodTest.java b/examples/src/test/java8/org/apache/ignite/java8/examples/IndexingBridgeMethodTest.java
deleted file mode 100644
index 2837ed6..0000000
--- a/examples/src/test/java8/org/apache/ignite/java8/examples/IndexingBridgeMethodTest.java
+++ /dev/null
@@ -1,93 +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.java8.examples;
-
-
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.cache.query.SqlFieldsQuery;
-import org.apache.ignite.cache.query.annotations.QuerySqlField;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-
-/**
- * Test covering bridge methods changes in Java 8.
- */
-public class IndexingBridgeMethodTest extends GridCommonAbstractTest {
-    /**
-     * @throws Exception If failed.
-     */
-    public void testBridgeMethod() throws Exception {
-        Ignite ignite = startGrid();
-
-        CacheConfiguration<Integer, MyType> ccfg = new CacheConfiguration<>();
-
-        ccfg.setName("mytype");
-        ccfg.setIndexedTypes(Integer.class, MyType.class);
-
-        IgniteCache<Integer,MyType> c = ignite.getOrCreateCache(ccfg);
-
-        for (int i = 0; i < 100; i++)
-            c.put(i, new MyType(i));
-
-        assertEquals(100L, c.query(new SqlFieldsQuery(
-            "select count(*) from MyType")).getAll().get(0).get(0));
-        assertEquals(15, c.query(new SqlFieldsQuery(
-            "select id from MyType where _key = 15")).getAll().get(0).get(0));
-        assertEquals(25, c.query(new SqlFieldsQuery(
-            "select _key from MyType where id = 25")).getAll().get(0).get(0));
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void afterTestsStopped() throws Exception {
-        stopAllGrids();
-    }
-
-    /**
-     * Classes implementing this method, will have bridge method.
-     */
-    private static interface HasId<T extends Number> {
-        /**
-         * @return ID.
-         */
-        public T getId();
-    }
-
-    /**
-     *
-     */
-    private static class MyType implements HasId<Integer> {
-        /** */
-        private int id;
-
-        /**
-         * @param id Id.
-         */
-        private MyType(int id) {
-            this.id = id;
-        }
-
-        /**
-         * @return ID.
-         */
-        @QuerySqlField(index = true)
-        @Override public Integer getId() {
-            return id;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/9649733c/examples/src/test/java8/org/apache/ignite/java8/testsuites/IgniteExamplesJ8SelfTestSuite.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/testsuites/IgniteExamplesJ8SelfTestSuite.java b/examples/src/test/java8/org/apache/ignite/java8/testsuites/IgniteExamplesJ8SelfTestSuite.java
index 7b62ea8..9a5f36a 100644
--- a/examples/src/test/java8/org/apache/ignite/java8/testsuites/IgniteExamplesJ8SelfTestSuite.java
+++ b/examples/src/test/java8/org/apache/ignite/java8/testsuites/IgniteExamplesJ8SelfTestSuite.java
@@ -24,7 +24,6 @@ import org.apache.ignite.java8.examples.CacheExamplesMultiNodeSelfTest;
 import org.apache.ignite.java8.examples.CacheExamplesSelfTest;
 import org.apache.ignite.java8.examples.EventsExamplesMultiNodeSelfTest;
 import org.apache.ignite.java8.examples.EventsExamplesSelfTest;
-import org.apache.ignite.java8.examples.IndexingBridgeMethodTest;
 import org.apache.ignite.java8.examples.MessagingExamplesSelfTest;
 import org.apache.ignite.testframework.GridTestUtils;
 
@@ -46,7 +45,6 @@ public class IgniteExamplesJ8SelfTestSuite extends TestSuite {
 
         TestSuite suite = new TestSuite("Ignite Examples Test Suite");
 
-        suite.addTest(new TestSuite(IndexingBridgeMethodTest.class));
         suite.addTest(new TestSuite(CacheExamplesSelfTest.class));
         suite.addTest(new TestSuite(BasicExamplesSelfTest.class));
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/9649733c/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/common/PropertyMappingHelper.java
----------------------------------------------------------------------
diff --git a/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/common/PropertyMappingHelper.java b/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/common/PropertyMappingHelper.java
index 64b784b..cb89bf0 100644
--- a/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/common/PropertyMappingHelper.java
+++ b/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/common/PropertyMappingHelper.java
@@ -20,7 +20,6 @@ package org.apache.ignite.cache.store.cassandra.common;
 import com.datastax.driver.core.DataType;
 import com.datastax.driver.core.Row;
 import java.beans.PropertyDescriptor;
-import java.lang.annotation.Annotation;
 import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.net.InetAddress;
@@ -103,25 +102,12 @@ public class PropertyMappingHelper {
      * Extracts all property descriptors from a class.
      *
      * @param clazz class which property descriptors should be extracted.
-     * @param primitive boolean flag indicating that only property descriptors for primitive properties should be extracted.
+     * @param primitive boolean flag indicating that only property descriptors for primitive properties
+     *      should be extracted.
      *
      * @return list of class property descriptors
      */
     public static List<PropertyDescriptor> getPojoPropertyDescriptors(Class clazz, boolean primitive) {
-        return getPojoPropertyDescriptors(clazz, null, primitive);
-    }
-
-    /**
-     * Extracts all property descriptors having specific annotation from a class.
-     *
-     * @param clazz class which property descriptors should be extracted.
-     * @param annotation annotation to look for.
-     * @param primitive boolean flag indicating that only property descriptors for primitive properties should be extracted.
-     *
-     * @return list of class property descriptors
-     */
-    public static <T extends Annotation> List<PropertyDescriptor> getPojoPropertyDescriptors(Class clazz,
-        Class<T> annotation, boolean primitive) {
         PropertyDescriptor[] descriptors = PropertyUtils.getPropertyDescriptors(clazz);
 
         List<PropertyDescriptor> list = new ArrayList<>(descriptors == null ? 1 : descriptors.length);
@@ -133,8 +119,7 @@ public class PropertyMappingHelper {
             if (descriptor.getReadMethod() == null || (primitive && !isPrimitivePropertyDescriptor(descriptor)))
                 continue;
 
-            if (annotation == null || descriptor.getReadMethod().getAnnotation(annotation) != null)
-                list.add(descriptor);
+            list.add(descriptor);
         }
 
         return list;

http://git-wip-us.apache.org/repos/asf/ignite/blob/9649733c/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/persistence/KeyPersistenceSettings.java
----------------------------------------------------------------------
diff --git a/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/persistence/KeyPersistenceSettings.java b/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/persistence/KeyPersistenceSettings.java
index c614abf..c12c3e8 100644
--- a/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/persistence/KeyPersistenceSettings.java
+++ b/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/persistence/KeyPersistenceSettings.java
@@ -22,8 +22,6 @@ import java.util.LinkedList;
 import java.util.List;
 
 import org.apache.ignite.IgniteException;
-import org.apache.ignite.cache.affinity.AffinityKeyMapped;
-import org.apache.ignite.cache.query.annotations.QuerySqlField;
 import org.apache.ignite.cache.store.cassandra.common.PropertyMappingHelper;
 import org.w3c.dom.Element;
 import org.w3c.dom.NodeList;
@@ -214,12 +212,8 @@ public class KeyPersistenceSettings extends PersistenceSettings {
 
         if (el == null) {
             for (PropertyDescriptor desc : descriptors) {
-                boolean valid = desc.getWriteMethod() != null ||
-                        desc.getReadMethod().getAnnotation(QuerySqlField.class) != null ||
-                        desc.getReadMethod().getAnnotation(AffinityKeyMapped.class) != null;
-
-                // Skip POJO field if it's read-only and is not annotated with @QuerySqlField or @AffinityKeyMapped.
-                if (valid)
+                // Skip POJO field if it's read-only
+                if (desc.getWriteMethod() != null)
                     list.add(new PojoKeyField(desc));
             }
 
@@ -256,11 +250,8 @@ public class KeyPersistenceSettings extends PersistenceSettings {
      * @return POJO field descriptors for partition key.
      */
     private List<PropertyDescriptor> getPartitionKeyDescriptors() {
-        List<PropertyDescriptor> primitivePropDescriptors = PropertyMappingHelper.getPojoPropertyDescriptors(getJavaClass(),
-            AffinityKeyMapped.class, true);
-
-        primitivePropDescriptors = primitivePropDescriptors != null && !primitivePropDescriptors.isEmpty() ?
-            primitivePropDescriptors : PropertyMappingHelper.getPojoPropertyDescriptors(getJavaClass(), true);
+        List<PropertyDescriptor> primitivePropDescriptors = PropertyMappingHelper.getPojoPropertyDescriptors(
+            getJavaClass(), true);
 
         boolean valid = false;
 
@@ -281,6 +272,7 @@ public class KeyPersistenceSettings extends PersistenceSettings {
     }
 
     /**
+     * @param partKeyFields List of fields.
      * @return POJO field descriptors for cluster key.
      */
     private List<PropertyDescriptor> getClusterKeyDescriptors(List<PojoField> partKeyFields) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/9649733c/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/persistence/PojoField.java
----------------------------------------------------------------------
diff --git a/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/persistence/PojoField.java b/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/persistence/PojoField.java
index 99b96d5..566c0b9 100644
--- a/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/persistence/PojoField.java
+++ b/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/persistence/PojoField.java
@@ -21,9 +21,7 @@ import com.datastax.driver.core.DataType;
 import com.datastax.driver.core.Row;
 import java.beans.PropertyDescriptor;
 import java.io.Serializable;
-import java.lang.reflect.Method;
 import org.apache.ignite.IgniteException;
-import org.apache.ignite.cache.query.annotations.QuerySqlField;
 import org.apache.ignite.cache.store.cassandra.common.PropertyMappingHelper;
 import org.apache.ignite.cache.store.cassandra.serializer.Serializer;
 import org.w3c.dom.Element;
@@ -86,19 +84,9 @@ public abstract class PojoField implements Serializable {
     public PojoField(PropertyDescriptor desc) {
         this.name = desc.getName();
 
-        Method rdMthd = desc.getReadMethod();
-
-        QuerySqlField sqlField = rdMthd != null && rdMthd.getAnnotation(QuerySqlField.class) != null
-            ? rdMthd.getAnnotation(QuerySqlField.class)
-            : desc.getWriteMethod() == null ? null : desc.getWriteMethod().getAnnotation(QuerySqlField.class);
-
-        col = sqlField != null && sqlField.name() != null &&
-            !sqlField.name().trim().isEmpty() ? sqlField.name() : name.toLowerCase();
+        col = name.toLowerCase();
 
         init(desc);
-
-        if (sqlField != null)
-            init(sqlField);
     }
 
     /**
@@ -202,13 +190,6 @@ public abstract class PojoField implements Serializable {
     }
 
     /**
-     * Initializes field info from annotation.
-     *
-     * @param sqlField {@link QuerySqlField} annotation.
-     */
-    protected abstract void init(QuerySqlField sqlField);
-
-    /**
      * Initializes field info from property descriptor.
      *
      * @param desc {@link PropertyDescriptor} descriptor.

http://git-wip-us.apache.org/repos/asf/ignite/blob/9649733c/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/persistence/PojoKeyField.java
----------------------------------------------------------------------
diff --git a/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/persistence/PojoKeyField.java b/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/persistence/PojoKeyField.java
index ec37411..bf1d40e 100644
--- a/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/persistence/PojoKeyField.java
+++ b/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/persistence/PojoKeyField.java
@@ -18,7 +18,6 @@
 package org.apache.ignite.cache.store.cassandra.persistence;
 
 import java.beans.PropertyDescriptor;
-import org.apache.ignite.cache.query.annotations.QuerySqlField;
 import org.w3c.dom.Element;
 
 /**
@@ -78,10 +77,4 @@ public class PojoKeyField extends PojoField {
     public SortOrder getSortOrder() {
         return sortOrder;
     }
-
-    /** {@inheritDoc} */
-    @Override protected void init(QuerySqlField sqlField) {
-        if (sqlField.descending())
-            sortOrder = SortOrder.DESC;
-    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/9649733c/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/persistence/PojoValueField.java
----------------------------------------------------------------------
diff --git a/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/persistence/PojoValueField.java b/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/persistence/PojoValueField.java
index fcdd408..9d25b60 100644
--- a/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/persistence/PojoValueField.java
+++ b/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/persistence/PojoValueField.java
@@ -18,7 +18,6 @@
 package org.apache.ignite.cache.store.cassandra.persistence;
 
 import java.beans.PropertyDescriptor;
-import org.apache.ignite.cache.query.annotations.QuerySqlField;
 import org.w3c.dom.Element;
 
 /**
@@ -135,9 +134,4 @@ public class PojoValueField extends PojoField {
 
         return builder.append(";").toString();
     }
-
-    /** {@inheritDoc} */
-    @Override protected void init(QuerySqlField sqlField) {
-        // No-op.
-    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/9649733c/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/persistence/ValuePersistenceSettings.java
----------------------------------------------------------------------
diff --git a/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/persistence/ValuePersistenceSettings.java b/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/persistence/ValuePersistenceSettings.java
index f117fb6..b737e2c 100644
--- a/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/persistence/ValuePersistenceSettings.java
+++ b/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/persistence/ValuePersistenceSettings.java
@@ -22,7 +22,6 @@ import java.util.Collections;
 import java.util.LinkedList;
 import java.util.List;
 
-import org.apache.ignite.cache.query.annotations.QuerySqlField;
 import org.apache.ignite.cache.store.cassandra.common.PropertyMappingHelper;
 import org.w3c.dom.Element;
 import org.w3c.dom.NodeList;
@@ -85,13 +84,12 @@ public class ValuePersistenceSettings extends PersistenceSettings {
         List<PojoField> list = new LinkedList<>();
 
         if (fieldNodes == null || fieldNodes.getLength() == 0) {
-            List<PropertyDescriptor> primitivePropDescriptors = PropertyMappingHelper.getPojoPropertyDescriptors(getJavaClass(), true);
-            for (PropertyDescriptor desc : primitivePropDescriptors) {
-                boolean valid = desc.getWriteMethod() != null ||
-                        desc.getReadMethod().getAnnotation(QuerySqlField.class) != null;
+            List<PropertyDescriptor> primitivePropDescriptors =
+                PropertyMappingHelper.getPojoPropertyDescriptors(getJavaClass(), true);
 
-                // Skip POJO field if it's read-only and is not annotated with @QuerySqlField.
-                if (valid)
+            for (PropertyDescriptor desc : primitivePropDescriptors) {
+                // Skip POJO field if it's read-only
+                if (desc.getWriteMethod() != null)
                     list.add(new PojoValueField(desc));
             }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/9649733c/modules/cassandra/store/src/test/java/org/apache/ignite/tests/pojos/Person.java
----------------------------------------------------------------------
diff --git a/modules/cassandra/store/src/test/java/org/apache/ignite/tests/pojos/Person.java b/modules/cassandra/store/src/test/java/org/apache/ignite/tests/pojos/Person.java
index 16b64bd..89d4851 100644
--- a/modules/cassandra/store/src/test/java/org/apache/ignite/tests/pojos/Person.java
+++ b/modules/cassandra/store/src/test/java/org/apache/ignite/tests/pojos/Person.java
@@ -17,8 +17,6 @@
 
 package org.apache.ignite.tests.pojos;
 
-import org.apache.ignite.cache.query.annotations.QuerySqlField;
-
 import java.io.Externalizable;
 import java.io.IOException;
 import java.io.ObjectInput;
@@ -40,6 +38,9 @@ public class Person implements Externalizable {
     private String lastName;
 
     /** */
+    private String fullName;
+
+    /** */
     private int age;
 
     /** */
@@ -178,6 +179,7 @@ public class Person implements Externalizable {
     @SuppressWarnings("UnusedDeclaration")
     public void setFirstName(String name) {
         firstName = name;
+        fullName = firstName + " " + lastName;
     }
 
     /** */
@@ -190,6 +192,7 @@ public class Person implements Externalizable {
     @SuppressWarnings("UnusedDeclaration")
     public void setLastName(String name) {
         lastName = name;
+        fullName = firstName + " " + lastName;
     }
 
     /** */
@@ -200,9 +203,8 @@ public class Person implements Externalizable {
 
     /** */
     @SuppressWarnings("UnusedDeclaration")
-    @QuerySqlField
     public String getFullName() {
-        return firstName + " " + lastName;
+        return fullName;
     }
 
     /** */

http://git-wip-us.apache.org/repos/asf/ignite/blob/9649733c/modules/cassandra/store/src/test/java/org/apache/ignite/tests/pojos/Product.java
----------------------------------------------------------------------
diff --git a/modules/cassandra/store/src/test/java/org/apache/ignite/tests/pojos/Product.java b/modules/cassandra/store/src/test/java/org/apache/ignite/tests/pojos/Product.java
index f8eadf4..624b27b 100644
--- a/modules/cassandra/store/src/test/java/org/apache/ignite/tests/pojos/Product.java
+++ b/modules/cassandra/store/src/test/java/org/apache/ignite/tests/pojos/Product.java
@@ -17,8 +17,6 @@
 
 package org.apache.ignite.tests.pojos;
 
-import org.apache.ignite.cache.query.annotations.QuerySqlField;
-
 /**
  * Simple POJO to store information about product
  */
@@ -72,7 +70,6 @@ public class Product {
     }
 
     /** */
-    @QuerySqlField(index = true)
     public long getId() {
         return id;
     }
@@ -83,7 +80,6 @@ public class Product {
     }
 
     /** */
-    @QuerySqlField
     public String getType() {
         return type;
     }
@@ -94,7 +90,6 @@ public class Product {
     }
 
     /** */
-    @QuerySqlField(index = true)
     public String getTitle() {
         return title;
     }
@@ -105,7 +100,6 @@ public class Product {
     }
 
     /** */
-    @QuerySqlField
     public String getDescription() {
         return description;
     }
@@ -116,7 +110,6 @@ public class Product {
     }
 
     /** */
-    @QuerySqlField
     public float getPrice() {
         return price;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/9649733c/modules/cassandra/store/src/test/java/org/apache/ignite/tests/pojos/ProductOrder.java
----------------------------------------------------------------------
diff --git a/modules/cassandra/store/src/test/java/org/apache/ignite/tests/pojos/ProductOrder.java b/modules/cassandra/store/src/test/java/org/apache/ignite/tests/pojos/ProductOrder.java
index bafc8f3..31c881e 100644
--- a/modules/cassandra/store/src/test/java/org/apache/ignite/tests/pojos/ProductOrder.java
+++ b/modules/cassandra/store/src/test/java/org/apache/ignite/tests/pojos/ProductOrder.java
@@ -17,8 +17,6 @@
 
 package org.apache.ignite.tests.pojos;
 
-import org.apache.ignite.cache.query.annotations.QuerySqlField;
-
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.Date;
@@ -91,7 +89,6 @@ public class ProductOrder {
     }
 
     /** */
-    @QuerySqlField(index = true)
     public long getId() {
         return id;
     }
@@ -102,7 +99,6 @@ public class ProductOrder {
     }
 
     /** */
-    @QuerySqlField(index = true)
     public long getProductId() {
         return productId;
     }
@@ -113,7 +109,6 @@ public class ProductOrder {
     }
 
     /** */
-    @QuerySqlField
     public Date getDate() {
         return date;
     }
@@ -124,7 +119,6 @@ public class ProductOrder {
     }
 
     /** */
-    @QuerySqlField
     public int getAmount() {
         return amount;
     }
@@ -135,13 +129,11 @@ public class ProductOrder {
     }
 
     /** */
-    @QuerySqlField
     public float getPrice() {
         return price;
     }
 
     /** */
-    @QuerySqlField
     public String getDayMillisecond() {
         return FORMAT.format(date);
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/9649733c/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcResultSetSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcResultSetSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcResultSetSelfTest.java
index 64a077e..8fb651d 100644
--- a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcResultSetSelfTest.java
+++ b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcResultSetSelfTest.java
@@ -654,10 +654,10 @@ public class JdbcResultSetSelfTest extends GridCommonAbstractTest {
         protected boolean boolVal3;
 
         /** */
+        @QuerySqlField(index = false)
         protected boolean boolVal4;
 
         /** */
-        @QuerySqlField(index = false)
         public boolean isBoolVal4() {
             return boolVal4;
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/9649733c/modules/core/src/main/java/org/apache/ignite/cache/query/annotations/QuerySqlField.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/annotations/QuerySqlField.java b/modules/core/src/main/java/org/apache/ignite/cache/query/annotations/QuerySqlField.java
index 48402b5..94dbea1 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/query/annotations/QuerySqlField.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/query/annotations/QuerySqlField.java
@@ -31,7 +31,7 @@ import org.apache.ignite.internal.processors.cache.query.CacheQuery;
  */
 @Documented
 @Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.METHOD, ElementType.FIELD})
+@Target({ElementType.FIELD})
 public @interface QuerySqlField {
     /**
      * Specifies whether cache should maintain an index for this field or not.

http://git-wip-us.apache.org/repos/asf/ignite/blob/9649733c/modules/core/src/main/java/org/apache/ignite/cache/query/annotations/QueryTextField.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/annotations/QueryTextField.java b/modules/core/src/main/java/org/apache/ignite/cache/query/annotations/QueryTextField.java
index 55809b6..1e01b6a 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/query/annotations/QueryTextField.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/query/annotations/QueryTextField.java
@@ -25,14 +25,14 @@ import java.lang.annotation.Target;
 import org.apache.ignite.internal.processors.cache.query.CacheQuery;
 
 /**
- * Annotation for fields or getters to be indexed for full text
+ * Annotation for fields to be indexed for full text
  * search using Lucene. For more information
  * refer to {@link CacheQuery} documentation.
  * @see CacheQuery
  */
 @Documented
 @Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.METHOD, ElementType.FIELD, ElementType.TYPE})
+@Target({ElementType.FIELD, ElementType.TYPE})
 public @interface QueryTextField {
     // No-op.
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/9649733c/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 219e0b1..8a3874f 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
@@ -2141,32 +2141,6 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
                     processAnnotation(key, sqlAnn, txtAnn, cls, c, field.getType(), prop, type);
                 }
             }
-
-            for (Method mtd : c.getDeclaredMethods()) {
-                if (mtd.isBridge())
-                    continue;
-
-                QuerySqlField sqlAnn = mtd.getAnnotation(QuerySqlField.class);
-                QueryTextField txtAnn = mtd.getAnnotation(QueryTextField.class);
-
-                if (sqlAnn != null || txtAnn != null) {
-                    if (mtd.getParameterTypes().length != 0)
-                        throw new CacheException("Getter with QuerySqlField " +
-                            "annotation cannot have parameters: " + mtd);
-
-                    ClassProperty prop = new ClassProperty(mtd);
-
-                    prop.parent(parent);
-
-                    // Add parent property before its possible nested properties so that
-                    // resulting parent column comes before columns corresponding to those
-                    // nested properties in the resulting table - that way nested
-                    // properties override will happen properly (first parent, then children).
-                    type.addProperty(prop, key, true);
-
-                    processAnnotation(key, sqlAnn, txtAnn, cls, c, mtd.getReturnType(), prop, type);
-                }
-            }
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/9649733c/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQueryTestValue.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQueryTestValue.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQueryTestValue.java
index 4d19b1a..116049f 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQueryTestValue.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQueryTestValue.java
@@ -32,6 +32,7 @@ public class GridCacheQueryTestValue implements Serializable {
     private String field1;
 
     /** */
+    @QuerySqlField
     private int field2;
 
     /** */
@@ -72,7 +73,6 @@ public class GridCacheQueryTestValue implements Serializable {
      *
      * @return Field.
      */
-    @QuerySqlField
     public int getField2() {
         return field2;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/9649733c/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 8c8828d..fedeef6 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
@@ -310,7 +310,7 @@ public abstract class IgniteCacheAbstractFieldsQuerySelfTest extends GridCommonA
                     Map<String, String> fields = meta.fields("Organization");
 
                     assert fields != null;
-                    assertEquals("Fields: " + fields, 5, fields.size());
+                    assertEquals("Fields: " + fields, 4, fields.size());
 
                     if (binaryMarshaller) {
                         assert Object.class.getName().equals(fields.get("_VAL"));
@@ -605,7 +605,7 @@ public abstract class IgniteCacheAbstractFieldsQuerySelfTest extends GridCommonA
         int cnt = 0;
 
         for (List<?> row : res) {
-            assertEquals(10, row.size());
+            assertEquals(9, row.size());
 
             if (cnt == 0) {
                 assert new AffinityKey<>("p1", "o1").equals(row.get(0));
@@ -860,23 +860,6 @@ public abstract class IgniteCacheAbstractFieldsQuerySelfTest extends GridCommonA
     /**
      * @throws Exception If failed.
      */
-    public void testMethodAnnotationWithoutGet() throws Exception {
-        if (!binaryMarshaller) {
-            QueryCursor<List<?>> qry =
-                orgCache.query(sqlFieldsQuery("select methodField from Organization where methodField='name-A'")
-                    .setPageSize(10));
-
-            List<List<?>> flds = qry.getAll();
-
-            assertEquals(1, flds.size());
-
-            assertEquals("name-A", flds.get(0).get(0));
-        }
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
     public void testPaginationGet() throws Exception {
         QueryCursor<List<?>> qry =
             intCache.query(sqlFieldsQuery("select _key, _val from Integer").setPageSize(10));
@@ -1060,14 +1043,6 @@ public abstract class IgniteCacheAbstractFieldsQuerySelfTest extends GridCommonA
             this.name = name;
         }
 
-        /**
-         * @return Generated method value.
-         */
-        @QuerySqlField
-        public String methodField() {
-            return "name-" + name;
-        }
-
         /** {@inheritDoc} */
         @Override public boolean equals(Object o) {
             if (this == o)

http://git-wip-us.apache.org/repos/asf/ignite/blob/9649733c/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinTest.java
index a553c3f..e69b5ec 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinTest.java
@@ -234,12 +234,15 @@ public class IgniteCacheDistributedJoinTest extends GridCommonAbstractTest {
      */
     public static class X {
         /** */
+        @QuerySqlField(index = true)
         public long a;
 
         /** */
+        @QuerySqlField(index = true)
         public long b;
 
         /** */
+        @QuerySqlField(index = true)
         public long c;
 
         /**
@@ -254,19 +257,16 @@ public class IgniteCacheDistributedJoinTest extends GridCommonAbstractTest {
         }
 
         /** */
-        @QuerySqlField(index = true)
         public long getA() {
             return a;
         }
 
         /** */
-        @QuerySqlField(index = true)
         public long getB() {
             return b;
         }
 
         /** */
-        @QuerySqlField(index = true)
         public long getC() {
             return c;
         }


[20/29] ignite git commit: CacheConfiguration code style fixes.

Posted by ag...@apache.org.
CacheConfiguration code style fixes.


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

Branch: refs/heads/ignite-5024
Commit: 8a5266e787d181dd98aeb3c597ea64e9c39af6ae
Parents: 1dc9e69
Author: sboikov <sb...@gridgain.com>
Authored: Tue Apr 25 11:42:56 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Tue Apr 25 11:42:56 2017 +0300

----------------------------------------------------------------------
 .../configuration/CacheConfiguration.java       | 57 +++++++++-----------
 1 file changed, 25 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/8a5266e7/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 d378343..219e0b1 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
@@ -143,15 +143,6 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
     /** Default rebalance batch size in bytes. */
     public static final int DFLT_REBALANCE_BATCH_SIZE = 512 * 1024; // 512K
 
-    /** Default maximum eviction queue ratio. */
-    public static final float DFLT_MAX_EVICTION_OVERFLOW_RATIO = 10;
-
-    /** Default synchronous eviction timeout in milliseconds. */
-    public static final long DFLT_EVICT_SYNCHRONIZED_TIMEOUT = 10000;
-
-    /** Default synchronous eviction concurrency level. */
-    public static final int DFLT_EVICT_SYNCHRONIZED_CONCURRENCY_LEVEL = 4;
-
     /** Default value for eager ttl flag. */
     public static final boolean DFLT_EAGER_TTL = true;
 
@@ -290,13 +281,13 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
     private int rebalanceBatchSize = DFLT_REBALANCE_BATCH_SIZE;
 
     /** Rebalance batches prefetch count. */
-    private long rebalanceBatchesPrefetchCount = DFLT_REBALANCE_BATCHES_PREFETCH_COUNT;
+    private long rebalanceBatchesPrefetchCnt = DFLT_REBALANCE_BATCHES_PREFETCH_COUNT;
 
     /** Maximum number of concurrent asynchronous operations. */
     private int maxConcurrentAsyncOps = DFLT_MAX_CONCURRENT_ASYNC_OPS;
 
     /** Maximum inline size for sql indexes. */
-    private int sqlIndexMaxInlineSize = DFLT_SQL_INDEX_MAX_INLINE_SIZE;
+    private int sqlIdxMaxInlineSize = DFLT_SQL_INDEX_MAX_INLINE_SIZE;
 
     /** Write-behind feature. */
     private boolean writeBehindEnabled = DFLT_WRITE_BEHIND_ENABLED;
@@ -374,7 +365,7 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
     private Collection<QueryEntity> qryEntities;
 
     /** Partition loss policy. */
-    private PartitionLossPolicy partitionLossPolicy = DFLT_PARTITION_LOSS_POLICY;
+    private PartitionLossPolicy partLossPlc = DFLT_PARTITION_LOSS_POLICY;
 
     /** */
     private int qryParallelism = DFLT_QUERY_PARALLELISM;
@@ -433,18 +424,18 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
         longQryWarnTimeout = cc.getLongQueryWarningTimeout();
         maxConcurrentAsyncOps = cc.getMaxConcurrentAsyncOperations();
         memPlcName = cc.getMemoryPolicyName();
-        sqlIndexMaxInlineSize = cc.getSqlIndexMaxInlineSize();
+        sqlIdxMaxInlineSize = cc.getSqlIndexMaxInlineSize();
         name = cc.getName();
         nearCfg = cc.getNearConfiguration();
         nodeFilter = cc.getNodeFilter();
         onheapCache = cc.isOnheapCacheEnabled();
-        partitionLossPolicy = cc.getPartitionLossPolicy();
+        partLossPlc = cc.getPartitionLossPolicy();
         pluginCfgs = cc.getPluginConfigurations();
         qryEntities = cc.getQueryEntities() == Collections.<QueryEntity>emptyList() ? null : cc.getQueryEntities();
         qryDetailMetricsSz = cc.getQueryDetailMetricsSize();
         readFromBackup = cc.isReadFromBackup();
         rebalanceBatchSize = cc.getRebalanceBatchSize();
-        rebalanceBatchesPrefetchCount = cc.getRebalanceBatchesPrefetchCount();
+        rebalanceBatchesPrefetchCnt = cc.getRebalanceBatchesPrefetchCount();
         rebalanceDelay = cc.getRebalanceDelay();
         rebalanceMode = cc.getRebalanceMode();
         rebalanceOrder = cc.getRebalanceOrder();
@@ -1088,7 +1079,7 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
      * @return batches count
      */
     public long getRebalanceBatchesPrefetchCount() {
-        return rebalanceBatchesPrefetchCount;
+        return rebalanceBatchesPrefetchCnt;
     }
 
     /**
@@ -1102,7 +1093,7 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
      * @return {@code this} for chaining.
      */
     public CacheConfiguration<K, V> setRebalanceBatchesPrefetchCount(long rebalanceBatchesCnt) {
-        this.rebalanceBatchesPrefetchCount = rebalanceBatchesCnt;
+        this.rebalanceBatchesPrefetchCnt = rebalanceBatchesCnt;
 
         return this;
     }
@@ -1145,16 +1136,17 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
      * @return Maximum payload size for offheap indexes.
      */
     public int getSqlIndexMaxInlineSize() {
-        return sqlIndexMaxInlineSize;
+        return sqlIdxMaxInlineSize;
     }
 
     /**
      * Sets maximum inline size for sql indexes.
      *
-     * @param sqlIndexMaxInlineSize Maximum inline size for sql indexes.
+     * @param sqlIdxMaxInlineSize Maximum inline size for sql indexes.
+     * @return {@code this} for chaining.
      */
-    public CacheConfiguration<K, V> setSqlIndexMaxInlineSize(int sqlIndexMaxInlineSize) {
-        this.sqlIndexMaxInlineSize = sqlIndexMaxInlineSize;
+    public CacheConfiguration<K, V> setSqlIndexMaxInlineSize(int sqlIdxMaxInlineSize) {
+        this.sqlIdxMaxInlineSize = sqlIdxMaxInlineSize;
 
         return this;
     }
@@ -1809,18 +1801,19 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
      * @see PartitionLossPolicy
      */
     public PartitionLossPolicy getPartitionLossPolicy() {
-        return partitionLossPolicy == null ? DFLT_PARTITION_LOSS_POLICY : partitionLossPolicy;
+        return partLossPlc == null ? DFLT_PARTITION_LOSS_POLICY : partLossPlc;
     }
 
     /**
      * Sets partition loss policy. This policy defines how Ignite will react to a situation when all nodes for
      * some partition leave the cluster.
      *
-     * @param partitionLossPolicy Partition loss policy.
+     * @param partLossPlc Partition loss policy.
+     * @return {@code this} for chaining.
      * @see PartitionLossPolicy
      */
-    public CacheConfiguration<K, V> setPartitionLossPolicy(PartitionLossPolicy partitionLossPolicy) {
-        this.partitionLossPolicy = partitionLossPolicy;
+    public CacheConfiguration<K, V> setPartitionLossPolicy(PartitionLossPolicy partLossPlc) {
+        this.partLossPlc = partLossPlc;
 
         return this;
     }
@@ -1991,7 +1984,7 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
         for (ClassProperty prop : desc.props.values())
             entity.addQueryField(prop.fullName(), U.box(prop.type()).getName(), prop.alias());
 
-        entity.setKeyFields(desc.keyProperties);
+        entity.setKeyFields(desc.keyProps);
 
         QueryIndex txtIdx = null;
 
@@ -2261,8 +2254,8 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
     }
 
     /** {@inheritDoc} */
-    @Override public CacheConfiguration<K, V> setTypes(Class<K> keyType, Class<V> valueType) {
-        super.setTypes(keyType, valueType);
+    @Override public CacheConfiguration<K, V> setTypes(Class<K> keyType, Class<V> valType) {
+        super.setTypes(keyType, valType);
 
         return this;
     }
@@ -2282,8 +2275,8 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
     }
 
     /** {@inheritDoc} */
-    @Override public CacheConfiguration<K, V> setStoreByValue(boolean isStoreByValue) {
-        super.setStoreByValue(isStoreByValue);
+    @Override public CacheConfiguration<K, V> setStoreByValue(boolean isStoreByVal) {
+        super.setStoreByValue(isStoreByVal);
 
         return this;
     }
@@ -2330,7 +2323,7 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
 
         /** */
         @GridToStringInclude
-        private final Set<String> keyProperties = new HashSet<>();
+        private final Set<String> keyProps = new HashSet<>();
 
         /** */
         @GridToStringInclude
@@ -2464,7 +2457,7 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
             fields.put(name, prop.type());
 
             if (key)
-                keyProperties.add(name);
+                keyProps.add(name);
         }
 
         /**


[15/29] ignite git commit: ignite-2.0 Update classnames.properties to run code from IDE.

Posted by ag...@apache.org.
ignite-2.0 Update classnames.properties to run code from IDE.


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

Branch: refs/heads/ignite-5024
Commit: 234bb5ad851d61b5f5236772a36724210dc8f445
Parents: e4a926b
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Tue Apr 25 14:03:20 2017 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Tue Apr 25 14:03:20 2017 +0700

----------------------------------------------------------------------
 .../resources/META-INF/classnames.properties    | 47 +++++++++++++++++---
 .../resources/META-INF/classnames.properties    |  1 +
 2 files changed, 43 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/234bb5ad/modules/core/src/main/resources/META-INF/classnames.properties
----------------------------------------------------------------------
diff --git a/modules/core/src/main/resources/META-INF/classnames.properties b/modules/core/src/main/resources/META-INF/classnames.properties
index e45f84a..2cc83a4 100644
--- a/modules/core/src/main/resources/META-INF/classnames.properties
+++ b/modules/core/src/main/resources/META-INF/classnames.properties
@@ -178,6 +178,7 @@ org.apache.ignite.igfs.mapreduce.records.IgfsByteDelimiterRecordResolver
 org.apache.ignite.igfs.mapreduce.records.IgfsFixedLengthRecordResolver
 org.apache.ignite.igfs.mapreduce.records.IgfsNewLineRecordResolver
 org.apache.ignite.igfs.mapreduce.records.IgfsStringDelimiterRecordResolver
+org.apache.ignite.internal.ExecutorAwareMessage
 org.apache.ignite.internal.GridClosureCallMode
 org.apache.ignite.internal.GridComponent$DiscoveryDataExchangeType
 org.apache.ignite.internal.GridEventConsumeHandler
@@ -322,7 +323,7 @@ org.apache.ignite.internal.managers.indexing.GridIndexingManager$1
 org.apache.ignite.internal.managers.loadbalancer.GridLoadBalancerAdapter
 org.apache.ignite.internal.managers.loadbalancer.GridLoadBalancerManager$1
 org.apache.ignite.internal.marshaller.optimized.OptimizedFieldType
-org.apache.ignite.internal.mem.OutOfMemoryException
+org.apache.ignite.internal.mem.IgniteOutOfMemoryException
 org.apache.ignite.internal.pagemem.impl.PageMemoryNoStoreImpl$Segment
 org.apache.ignite.internal.pagemem.snapshot.SnapshotFinishedMessage
 org.apache.ignite.internal.pagemem.snapshot.SnapshotProgressMessage
@@ -500,7 +501,6 @@ org.apache.ignite.internal.processors.cache.GridCacheProcessor$9
 org.apache.ignite.internal.processors.cache.GridCacheProcessor$LocalAffinityFunction
 org.apache.ignite.internal.processors.cache.GridCacheProxyImpl
 org.apache.ignite.internal.processors.cache.GridCacheReturn
-org.apache.ignite.internal.processors.cache.GridCacheTryPutFailedException
 org.apache.ignite.internal.processors.cache.GridCacheTtlManager$1
 org.apache.ignite.internal.processors.cache.GridCacheTtlManager$GridConcurrentSkipListSetEx
 org.apache.ignite.internal.processors.cache.GridCacheUpdateAtomicResult$UpdateOutcome
@@ -515,8 +515,12 @@ org.apache.ignite.internal.processors.cache.GridCacheUtils$15
 org.apache.ignite.internal.processors.cache.GridCacheUtils$16
 org.apache.ignite.internal.processors.cache.GridCacheUtils$17
 org.apache.ignite.internal.processors.cache.GridCacheUtils$18
+org.apache.ignite.internal.processors.cache.GridCacheUtils$19
 org.apache.ignite.internal.processors.cache.GridCacheUtils$2
 org.apache.ignite.internal.processors.cache.GridCacheUtils$20
+org.apache.ignite.internal.processors.cache.GridCacheUtils$21
+org.apache.ignite.internal.processors.cache.GridCacheUtils$22
+org.apache.ignite.internal.processors.cache.GridCacheUtils$24
 org.apache.ignite.internal.processors.cache.GridCacheUtils$3
 org.apache.ignite.internal.processors.cache.GridCacheUtils$4
 org.apache.ignite.internal.processors.cache.GridCacheUtils$5
@@ -915,6 +919,7 @@ org.apache.ignite.internal.processors.cache.query.jdbc.GridCacheQueryJdbcValidat
 org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter$1
 org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter$2
 org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter$3
+org.apache.ignite.internal.processors.cache.store.GridCacheWriteBehindStore$BatchingResult
 org.apache.ignite.internal.processors.cache.store.GridCacheWriteBehindStore$StatefulValue
 org.apache.ignite.internal.processors.cache.store.GridCacheWriteBehindStore$StoreOperation
 org.apache.ignite.internal.processors.cache.store.GridCacheWriteBehindStore$ValueStatus
@@ -1047,9 +1052,9 @@ org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor$19
 org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor$2
 org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor$20
 org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor$21
+org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor$22
 org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor$23
 org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor$24
-org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor$25
 org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor$3
 org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor$4
 org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor$5
@@ -1069,13 +1074,25 @@ org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor$Dat
 org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor$QueueInfo
 org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor$RemoveDataStructureProcessor
 org.apache.ignite.internal.processors.datastructures.GridCacheAtomicLongImpl
+org.apache.ignite.internal.processors.datastructures.GridCacheAtomicLongImpl$AddAndGetProcessor
+org.apache.ignite.internal.processors.datastructures.GridCacheAtomicLongImpl$CompareAndSetProcessor
+org.apache.ignite.internal.processors.datastructures.GridCacheAtomicLongImpl$DecrementAndGetProcessor
+org.apache.ignite.internal.processors.datastructures.GridCacheAtomicLongImpl$GetAndAddProcessor
+org.apache.ignite.internal.processors.datastructures.GridCacheAtomicLongImpl$GetAndDecrementProcessor
+org.apache.ignite.internal.processors.datastructures.GridCacheAtomicLongImpl$GetAndIncrementProcessor
+org.apache.ignite.internal.processors.datastructures.GridCacheAtomicLongImpl$GetAndSetProcessor
+org.apache.ignite.internal.processors.datastructures.GridCacheAtomicLongImpl$IncrementAndGetProcessor
 org.apache.ignite.internal.processors.datastructures.GridCacheAtomicLongValue
 org.apache.ignite.internal.processors.datastructures.GridCacheAtomicReferenceImpl
+org.apache.ignite.internal.processors.datastructures.GridCacheAtomicReferenceImpl$ReferenceCompareAndSetAndGetEntryProcessor
+org.apache.ignite.internal.processors.datastructures.GridCacheAtomicReferenceImpl$ReferenceCompareAndSetEntryProcessor
+org.apache.ignite.internal.processors.datastructures.GridCacheAtomicReferenceImpl$ReferenceSetEntryProcessor
 org.apache.ignite.internal.processors.datastructures.GridCacheAtomicReferenceValue
 org.apache.ignite.internal.processors.datastructures.GridCacheAtomicSequenceImpl
 org.apache.ignite.internal.processors.datastructures.GridCacheAtomicSequenceValue
 org.apache.ignite.internal.processors.datastructures.GridCacheAtomicStampedImpl
-org.apache.ignite.internal.processors.datastructures.GridCacheAtomicStampedImpl$5
+org.apache.ignite.internal.processors.datastructures.GridCacheAtomicStampedImpl$StampedCompareAndSetEntryProcessor
+org.apache.ignite.internal.processors.datastructures.GridCacheAtomicStampedImpl$StampedSetEntryProcessor
 org.apache.ignite.internal.processors.datastructures.GridCacheAtomicStampedValue
 org.apache.ignite.internal.processors.datastructures.GridCacheCountDownLatchImpl
 org.apache.ignite.internal.processors.datastructures.GridCacheCountDownLatchValue
@@ -1152,6 +1169,7 @@ org.apache.ignite.internal.processors.igfs.IgfsListingEntry
 org.apache.ignite.internal.processors.igfs.IgfsMetaManager$2
 org.apache.ignite.internal.processors.igfs.IgfsMetaManager$3
 org.apache.ignite.internal.processors.igfs.IgfsMetricsAdapter
+org.apache.ignite.internal.processors.igfs.IgfsModeResolver
 org.apache.ignite.internal.processors.igfs.IgfsNodePredicate
 org.apache.ignite.internal.processors.igfs.IgfsProcessor$1
 org.apache.ignite.internal.processors.igfs.IgfsSamplingKey
@@ -1275,17 +1293,31 @@ org.apache.ignite.internal.processors.platform.utils.PlatformFutureUtils$Interna
 org.apache.ignite.internal.processors.platform.websession.PlatformDotNetSessionLockProcessor
 org.apache.ignite.internal.processors.platform.websession.PlatformDotNetSessionSetAndUnlockProcessor
 org.apache.ignite.internal.processors.query.GridQueryFieldMetadata
-org.apache.ignite.internal.processors.query.GridQueryProcessor$3
 org.apache.ignite.internal.processors.query.GridQueryProcessor$4
 org.apache.ignite.internal.processors.query.GridQueryProcessor$5
 org.apache.ignite.internal.processors.query.GridQueryProcessor$6
 org.apache.ignite.internal.processors.query.GridQueryProcessor$7
 org.apache.ignite.internal.processors.query.GridQueryProcessor$8
+org.apache.ignite.internal.processors.query.GridQueryProcessor$9
+org.apache.ignite.internal.processors.query.GridQueryProcessor$SchemaOperation$1
 org.apache.ignite.internal.processors.query.IgniteSQLException
+org.apache.ignite.internal.processors.query.QueryIndexKey
+org.apache.ignite.internal.processors.query.QuerySchema
 org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryCancelRequest
 org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryFailResponse
 org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryNextPageRequest
 org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryNextPageResponse
+org.apache.ignite.internal.processors.query.schema.SchemaOperationException
+org.apache.ignite.internal.processors.query.schema.SchemaOperationManager$1
+org.apache.ignite.internal.processors.query.schema.SchemaOperationWorker$1
+org.apache.ignite.internal.processors.query.schema.message.SchemaAbstractDiscoveryMessage
+org.apache.ignite.internal.processors.query.schema.message.SchemaFinishDiscoveryMessage
+org.apache.ignite.internal.processors.query.schema.message.SchemaOperationStatusMessage
+org.apache.ignite.internal.processors.query.schema.message.SchemaProposeDiscoveryMessage
+org.apache.ignite.internal.processors.query.schema.operation.SchemaAbstractOperation
+org.apache.ignite.internal.processors.query.schema.operation.SchemaIndexAbstractOperation
+org.apache.ignite.internal.processors.query.schema.operation.SchemaIndexCreateOperation
+org.apache.ignite.internal.processors.query.schema.operation.SchemaIndexDropOperation
 org.apache.ignite.internal.processors.resource.GridResourceIoc$AnnotationSet
 org.apache.ignite.internal.processors.resource.GridResourceIoc$ResourceAnnotation
 org.apache.ignite.internal.processors.rest.GridRestCommand
@@ -1696,6 +1728,7 @@ org.apache.ignite.internal.visor.cache.VisorCacheResetMetricsTask
 org.apache.ignite.internal.visor.cache.VisorCacheResetMetricsTask$VisorCacheResetMetricsJob
 org.apache.ignite.internal.visor.cache.VisorCacheSqlIndexMetadata
 org.apache.ignite.internal.visor.cache.VisorCacheSqlMetadata
+org.apache.ignite.internal.visor.cache.VisorCacheStartArg
 org.apache.ignite.internal.visor.cache.VisorCacheStartTask
 org.apache.ignite.internal.visor.cache.VisorCacheStartTask$VisorCacheStartJob
 org.apache.ignite.internal.visor.cache.VisorCacheStartTaskArg
@@ -1726,6 +1759,7 @@ org.apache.ignite.internal.visor.event.VisorGridEventsLost
 org.apache.ignite.internal.visor.event.VisorGridJobEvent
 org.apache.ignite.internal.visor.event.VisorGridTaskEvent
 org.apache.ignite.internal.visor.file.VisorFileBlock
+org.apache.ignite.internal.visor.file.VisorFileBlockArg
 org.apache.ignite.internal.visor.file.VisorFileBlockTask
 org.apache.ignite.internal.visor.file.VisorFileBlockTask$VisorFileBlockJob
 org.apache.ignite.internal.visor.file.VisorFileBlockTaskArg
@@ -1750,6 +1784,7 @@ org.apache.ignite.internal.visor.igfs.VisorIgfsSamplingStateTask
 org.apache.ignite.internal.visor.igfs.VisorIgfsSamplingStateTask$VisorIgfsSamplingStateJob
 org.apache.ignite.internal.visor.igfs.VisorIgfsSamplingStateTaskArg
 org.apache.ignite.internal.visor.log.VisorLogFile
+org.apache.ignite.internal.visor.log.VisorLogSearchArg
 org.apache.ignite.internal.visor.log.VisorLogSearchResult
 org.apache.ignite.internal.visor.log.VisorLogSearchTask
 org.apache.ignite.internal.visor.log.VisorLogSearchTask$VisorLogSearchJob
@@ -1805,6 +1840,7 @@ org.apache.ignite.internal.visor.node.VisorSpiDescription
 org.apache.ignite.internal.visor.node.VisorSpisConfiguration
 org.apache.ignite.internal.visor.node.VisorSuppressedError
 org.apache.ignite.internal.visor.node.VisorTransactionConfiguration
+org.apache.ignite.internal.visor.query.VisorQueryArg
 org.apache.ignite.internal.visor.query.VisorQueryCancelTask
 org.apache.ignite.internal.visor.query.VisorQueryCancelTask$VisorCancelQueriesJob
 org.apache.ignite.internal.visor.query.VisorQueryCleanupTask
@@ -1833,6 +1869,7 @@ org.apache.ignite.internal.visor.query.VisorQueryTaskArg
 org.apache.ignite.internal.visor.query.VisorRunningQueriesCollectorTask
 org.apache.ignite.internal.visor.query.VisorRunningQueriesCollectorTask$VisorCollectRunningQueriesJob
 org.apache.ignite.internal.visor.query.VisorRunningQuery
+org.apache.ignite.internal.visor.query.VisorScanQueryArg
 org.apache.ignite.internal.visor.query.VisorScanQueryTask
 org.apache.ignite.internal.visor.query.VisorScanQueryTask$VisorScanQueryJob
 org.apache.ignite.internal.visor.query.VisorScanQueryTaskArg

http://git-wip-us.apache.org/repos/asf/ignite/blob/234bb5ad/modules/hadoop/src/main/resources/META-INF/classnames.properties
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/resources/META-INF/classnames.properties b/modules/hadoop/src/main/resources/META-INF/classnames.properties
index 051094d..a83b9ff 100644
--- a/modules/hadoop/src/main/resources/META-INF/classnames.properties
+++ b/modules/hadoop/src/main/resources/META-INF/classnames.properties
@@ -43,6 +43,7 @@ org.apache.ignite.internal.processors.hadoop.impl.igfs.HadoopIgfsInProc$13
 org.apache.ignite.internal.processors.hadoop.impl.igfs.HadoopIgfsInProc$14
 org.apache.ignite.internal.processors.hadoop.impl.igfs.HadoopIgfsInProc$15
 org.apache.ignite.internal.processors.hadoop.impl.igfs.HadoopIgfsInProc$16
+org.apache.ignite.internal.processors.hadoop.impl.igfs.HadoopIgfsInProc$17
 org.apache.ignite.internal.processors.hadoop.impl.igfs.HadoopIgfsInProc$2
 org.apache.ignite.internal.processors.hadoop.impl.igfs.HadoopIgfsInProc$3
 org.apache.ignite.internal.processors.hadoop.impl.igfs.HadoopIgfsInProc$4


[27/29] ignite git commit: Formatting

Posted by ag...@apache.org.
Formatting


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

Branch: refs/heads/ignite-5024
Commit: 7d33dd50b152eed29d9995dfd37403cda27f46a2
Parents: 1ccb943
Author: Yakov Zhdanov <yz...@gridgain.com>
Authored: Wed Apr 26 06:31:25 2017 +0300
Committer: Yakov Zhdanov <yz...@gridgain.com>
Committed: Wed Apr 26 06:31:25 2017 +0300

----------------------------------------------------------------------
 .../examples/datagrid/CacheQueryExample.java    | 54 +++++++++++---------
 1 file changed, 30 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/7d33dd50/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheQueryExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheQueryExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheQueryExample.java
index 85d74e0..aa52cc1 100644
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheQueryExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheQueryExample.java
@@ -90,23 +90,24 @@ public class CacheQueryExample {
             orgCacheCfg.setCacheMode(CacheMode.PARTITIONED); // Default.
             orgCacheCfg.setIndexedTypes(Long.class, Organization.class);
 
-            CacheConfiguration<AffinityKey<Long>, Person> colPersonCacheCfg = new CacheConfiguration<>(COLLOCATED_PERSON_CACHE);
+            CacheConfiguration<AffinityKey<Long>, Person> colPersonCacheCfg =
+                new CacheConfiguration<>(COLLOCATED_PERSON_CACHE);
 
             colPersonCacheCfg.setCacheMode(CacheMode.PARTITIONED); // Default.
             colPersonCacheCfg.setIndexedTypes(AffinityKey.class, Person.class);
 
-            CacheConfiguration<AffinityKey<Long>, Person> personCacheCfg = new CacheConfiguration<>(PERSON_CACHE);
+            CacheConfiguration<Long, Person> personCacheCfg = new CacheConfiguration<>(PERSON_CACHE);
 
             personCacheCfg.setCacheMode(CacheMode.PARTITIONED); // Default.
             personCacheCfg.setIndexedTypes(Long.class, Person.class);
 
-            // Auto-close cache at the end of the example.
-            try (
-                IgniteCache<Long, Organization> orgCache = ignite.getOrCreateCache(orgCacheCfg);
-                IgniteCache<AffinityKey<Long>, Person> colPersonCache = ignite.getOrCreateCache(colPersonCacheCfg);
-                IgniteCache<AffinityKey<Long>, Person> personCache = ignite.getOrCreateCache(personCacheCfg)
-            ) {
-                // Populate cache.
+            try {
+                // Create caches.
+                ignite.getOrCreateCache(orgCacheCfg);
+                ignite.getOrCreateCache(colPersonCacheCfg);
+                ignite.getOrCreateCache(personCacheCfg);
+
+                // Populate caches.
                 initialize();
 
                 // Example for SCAN-based query based on a predicate.
@@ -115,16 +116,19 @@ public class CacheQueryExample {
                 // Example for SQL-based querying employees based on salary ranges.
                 sqlQuery();
 
-                // Example for SQL-based querying employees for a given organization (includes SQL join for collocated objects).
+                // Example for SQL-based querying employees for a given organization
+                // (includes SQL join for collocated objects).
                 sqlQueryWithJoin();
 
-                // Example for SQL-based querying employees for a given organization (includes distributed SQL join).
+                // Example for SQL-based querying employees for a given organization
+                // (includes distributed SQL join).
                 sqlQueryWithDistributedJoin();
 
                 // Example for TEXT-based querying for a given string in peoples resumes.
                 textQuery();
 
-                // Example for SQL-based querying to calculate average salary among all employees within a company.
+                // Example for SQL-based querying to calculate average salary
+                // among all employees within a company.
                 sqlQueryWithAggregation();
 
                 // Example for SQL-based fields queries that return only required
@@ -135,7 +139,7 @@ public class CacheQueryExample {
                 sqlFieldsQueryWithJoin();
             }
             finally {
-                // Distributed cache could be removed from cluster only by #destroyCache() call.
+                // Distributed cache could be removed from cluster only by Ignite.destroyCache() call.
                 ignite.destroyCache(COLLOCATED_PERSON_CACHE);
                 ignite.destroyCache(PERSON_CACHE);
                 ignite.destroyCache(ORG_CACHE);
@@ -146,10 +150,11 @@ public class CacheQueryExample {
     }
 
     /**
-     * Example for scan query based on a predicate.
+     * Example for scan query based on a predicate using binary objects.
      */
     private static void scanQuery() {
-        IgniteCache<BinaryObject, BinaryObject> cache = Ignition.ignite().cache(COLLOCATED_PERSON_CACHE).withKeepBinary();
+        IgniteCache<BinaryObject, BinaryObject> cache = Ignition.ignite()
+            .cache(COLLOCATED_PERSON_CACHE).withKeepBinary();
 
         ScanQuery<BinaryObject, BinaryObject> scan = new ScanQuery<>(
             new IgniteBiPredicate<BinaryObject, BinaryObject>() {
@@ -167,7 +172,7 @@ public class CacheQueryExample {
      * Example for SQL queries based on salary ranges.
      */
     private static void sqlQuery() {
-        IgniteCache<AffinityKey<Long>, Person> cache = Ignition.ignite().cache(PERSON_CACHE);
+        IgniteCache<Long, Person> cache = Ignition.ignite().cache(PERSON_CACHE);
 
         // SQL clause which selects salaries based on range.
         String sql = "salary > ? and salary <= ?";
@@ -205,10 +210,11 @@ public class CacheQueryExample {
     }
 
     /**
-     * Example for SQL queries based on all employees working for a specific organization (query uses distributed join).
+     * Example for SQL queries based on all employees working
+     * for a specific organization (query uses distributed join).
      */
     private static void sqlQueryWithDistributedJoin() {
-        IgniteCache<AffinityKey<Long>, Person> cache = Ignition.ignite().cache(PERSON_CACHE);
+        IgniteCache<Long, Person> cache = Ignition.ignite().cache(PERSON_CACHE);
 
         // SQL clause query which joins on 2 types to select people for a specific organization.
         String joinSql =
@@ -234,15 +240,15 @@ public class CacheQueryExample {
      * Example for TEXT queries using LUCENE-based indexing of people's resumes.
      */
     private static void textQuery() {
-        IgniteCache<AffinityKey<Long>, Person> cache = Ignition.ignite().cache(PERSON_CACHE);
+        IgniteCache<Long, Person> cache = Ignition.ignite().cache(PERSON_CACHE);
 
         //  Query for all people with "Master Degree" in their resumes.
-        QueryCursor<Cache.Entry<AffinityKey<Long>, Person>> masters =
-            cache.query(new TextQuery<AffinityKey<Long>, Person>(Person.class, "Master"));
+        QueryCursor<Cache.Entry<Long, Person>> masters =
+            cache.query(new TextQuery<Long, Person>(Person.class, "Master"));
 
         // Query for all people with "Bachelor Degree" in their resumes.
-        QueryCursor<Cache.Entry<AffinityKey<Long>, Person>> bachelors =
-            cache.query(new TextQuery<AffinityKey<Long>, Person>(Person.class, "Bachelor"));
+        QueryCursor<Cache.Entry<Long, Person>> bachelors =
+            cache.query(new TextQuery<Long, Person>(Person.class, "Bachelor"));
 
         print("Following people have 'Master Degree' in their resumes: ", masters.getAll());
         print("Following people have 'Bachelor Degree' in their resumes: ", bachelors.getAll());
@@ -273,7 +279,7 @@ public class CacheQueryExample {
      * fields instead of whole key-value pairs.
      */
     private static void sqlFieldsQuery() {
-        IgniteCache<AffinityKey<Long>, Person> cache = Ignition.ignite().cache(PERSON_CACHE);
+        IgniteCache<Long, Person> cache = Ignition.ignite().cache(PERSON_CACHE);
 
         // Execute query to get names of all employees.
         QueryCursor<List<?>> cursor = cache.query(new SqlFieldsQuery(


[07/29] ignite git commit: IGNITE-5066 .NET: Add continuous query test to verify that the problem from 1.9 no longer reproduces

Posted by ag...@apache.org.
IGNITE-5066 .NET: Add continuous query test to verify that the problem from 1.9 no longer reproduces


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

Branch: refs/heads/ignite-5024
Commit: 5a433469afca394fc97b59cc16dbe83b2d24f8c5
Parents: 1214d7e
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Mon Apr 24 14:09:01 2017 +0300
Committer: Pavel Tupitsyn <pt...@apache.org>
Committed: Mon Apr 24 14:09:01 2017 +0300

----------------------------------------------------------------------
 .../Apache.Ignite.Core.Tests.csproj             |   1 +
 .../Query/Continuous/ContinuousQueryTest.cs     | 115 +++++++++++++++++++
 2 files changed, 116 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/5a433469/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
index f4f5e59..c6b183b 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
@@ -101,6 +101,7 @@
     <Compile Include="Cache\Query\CacheDmlQueriesTestSimpleName.cs" />
     <Compile Include="Cache\Query\CacheLinqTestSimpleName.cs" />
     <Compile Include="Cache\Query\CacheQueriesTestSimpleName.cs" />
+    <Compile Include="Cache\Query\Continuous\ContinuousQueryTest.cs" />
     <Compile Include="Cache\Store\CacheStoreAdapterTest.cs" />
     <Compile Include="Cache\Store\NamedNodeCacheStoreTest.cs" />
     <Compile Include="Cache\TestReferenceObject.cs" />

http://git-wip-us.apache.org/repos/asf/ignite/blob/5a433469/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryTest.cs
new file mode 100644
index 0000000..5148dcc
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryTest.cs
@@ -0,0 +1,115 @@
+\ufeff/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
+{
+    using System;
+    using System.Collections.Concurrent;
+    using System.Collections.Generic;
+    using System.Threading;
+    using Apache.Ignite.Core.Cache;
+    using Apache.Ignite.Core.Cache.Event;
+    using Apache.Ignite.Core.Cache.Query.Continuous;
+    using NUnit.Framework;
+
+    /// <summary>
+    /// Tests continuous queries.
+    /// </summary>
+    [Category(TestUtils.CategoryIntensive)]
+    public class ContinuousQueryTest
+    {
+        /// <summary>
+        /// Tests same query on multiple nodes.
+        /// This tests verifies that there are no exception on Java side during event delivery.
+        /// </summary>
+        [Test]
+        public void TestSameQueryMultipleNodes()
+        {
+            using (var ignite = StartIgnite())
+            {
+                var cache = ignite.GetOrCreateCache<Guid, Data>("data");
+                cache.QueryContinuous(new ContinuousQuery<Guid, Data>(new Listener()));
+
+                using (var ignite2 = StartIgnite())
+                {
+                    var cache2 = ignite2.GetOrCreateCache<Guid, Data>("data");
+                    cache2.QueryContinuous(new ContinuousQuery<Guid, Data>(new Listener()));
+
+                    for (var i = 0; i < 100; i++)
+                    {
+                        PutEntry(cache2);
+                        PutEntry(cache);
+                    }
+                }
+            }
+        }
+
+        /// <summary>
+        /// Puts the entry and verifies events.
+        /// </summary>
+        private static void PutEntry(ICache<Guid, Data> cache)
+        {
+            // Put new entry.
+            var entry = new Data {Id = Guid.NewGuid()};
+            cache.Put(entry.Id, entry);
+
+            // Wait for events.
+            Thread.Sleep(100);
+
+            ICacheEntryEvent<Guid, Data> e;
+
+            // Two listeners  - two events.
+            Assert.IsTrue(Listener.Events.TryPop(out e));
+            Assert.AreEqual(entry.Id, e.Key);
+
+            Assert.IsTrue(Listener.Events.TryPop(out e));
+            Assert.AreEqual(entry.Id, e.Key);
+        }
+
+        /// <summary>
+        /// Starts the ignite.
+        /// </summary>
+        private static IIgnite StartIgnite()
+        {
+            return Ignition.Start(new IgniteConfiguration(TestUtils.GetTestConfiguration())
+            {
+                BinaryConfiguration = new Core.Binary.BinaryConfiguration(typeof(Data)),
+                AutoGenerateIgniteInstanceName = true
+            });
+        }
+
+        private class Data
+        {
+            public Guid Id;
+        }
+
+        private class Listener : ICacheEntryEventListener<Guid, Data>
+        {
+            public static readonly ConcurrentStack<ICacheEntryEvent<Guid, Data>> Events 
+                = new ConcurrentStack<ICacheEntryEvent<Guid, Data>>();
+
+            public void OnEvent(IEnumerable<ICacheEntryEvent<Guid, Data>> evts)
+            {
+                foreach (var e in evts)
+                {
+                    Events.Push(e);
+                }
+            }
+        }
+    }
+}