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/03/30 17:25:11 UTC

[01/34] ignite git commit: ignite-3477-master fix GridMessagingSelfTest.testAsync

Repository: ignite
Updated Branches:
  refs/heads/ignite-3477-master 2c480b4fe -> 7b0eb4181


ignite-3477-master fix GridMessagingSelfTest.testAsync


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

Branch: refs/heads/ignite-3477-master
Commit: 6d7eb44d2f40e795e7bec77dccf4553784766361
Parents: fcc4906
Author: Dmitriy Govorukhin <dg...@gridgain.com>
Authored: Mon Mar 27 17:33:40 2017 +0300
Committer: Dmitriy Govorukhin <dg...@gridgain.com>
Committed: Mon Mar 27 17:33:40 2017 +0300

----------------------------------------------------------------------
 .../apache/ignite/messaging/GridMessagingSelfTest.java | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/6d7eb44d/modules/core/src/test/java/org/apache/ignite/messaging/GridMessagingSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/messaging/GridMessagingSelfTest.java b/modules/core/src/test/java/org/apache/ignite/messaging/GridMessagingSelfTest.java
index 3f66c5d..aa07988 100644
--- a/modules/core/src/test/java/org/apache/ignite/messaging/GridMessagingSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/messaging/GridMessagingSelfTest.java
@@ -44,6 +44,8 @@ import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage;
 import org.apache.ignite.internal.processors.continuous.StartRoutineDiscoveryMessage;
 import org.apache.ignite.internal.processors.continuous.StopRoutineDiscoveryMessage;
+import org.apache.ignite.internal.processors.marshaller.MappingAcceptedMessage;
+import org.apache.ignite.internal.processors.marshaller.MappingProposedMessage;
 import org.apache.ignite.internal.util.GridConcurrentHashSet;
 import org.apache.ignite.internal.util.typedef.P2;
 import org.apache.ignite.internal.util.typedef.PA;
@@ -1154,13 +1156,22 @@ public class GridMessagingSelfTest extends GridCommonAbstractTest implements Ser
             synchronized (mux) {
                 if (blockCustomEvt) {
                     DiscoveryCustomMessage msg0 = GridTestUtils.getFieldValue(msg, "delegate");
+
+                    if (msg0 instanceof MappingProposedMessage || msg0 instanceof MappingAcceptedMessage){
+                        super.sendCustomEvent(msg);
+
+                        return;
+                    }
+
                     if (msg0 instanceof StopRoutineDiscoveryMessage || msg0 instanceof StartRoutineDiscoveryMessage) {
                         log.info("Block custom message: " + msg0);
+
                         blockedMsgs.add(msg);
 
                         mux.notifyAll();
+
+                        return;
                     }
-                    return;
                 }
             }
 


[11/34] ignite git commit: schema usage is fixed

Posted by ag...@apache.org.
schema usage is fixed


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

Branch: refs/heads/ignite-3477-master
Commit: d2b8ee6d17e400388a23e429f7dc2ff9c133527d
Parents: b3f953a
Author: Sergey Chugunov <se...@gmail.com>
Authored: Wed Mar 29 19:03:00 2017 +0300
Committer: Sergey Chugunov <se...@gmail.com>
Committed: Wed Mar 29 19:03:00 2017 +0300

----------------------------------------------------------------------
 .../query/h2/sql/GridQueryParsingTest.java      | 112 +++++++++----------
 1 file changed, 53 insertions(+), 59 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/d2b8ee6d/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/GridQueryParsingTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/GridQueryParsingTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/GridQueryParsingTest.java
index a39337b..427008a 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/GridQueryParsingTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/GridQueryParsingTest.java
@@ -53,12 +53,6 @@ public class GridQueryParsingTest extends GridCommonAbstractTest {
     private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
 
     /** */
-    private static final String TEST_SCHEMA = "SCH";
-
-    /** */
-    private static final String TEST_CACHE = "my-cache";
-
-    /** */
     private static Ignite ignite;
 
     /** {@inheritDoc} */
@@ -73,8 +67,8 @@ public class GridQueryParsingTest extends GridCommonAbstractTest {
         c.setDiscoverySpi(disco);
 
         c.setCacheConfiguration(
-            cacheConfiguration(null, String.class, Person.class),
-            cacheConfiguration("addr", String.class, Address.class));
+            cacheConfiguration(null, "SCH1", String.class, Person.class),
+            cacheConfiguration("addr", "SCH2", String.class, Address.class));
 
         return c;
     }
@@ -85,7 +79,7 @@ public class GridQueryParsingTest extends GridCommonAbstractTest {
      * @param clsV Value class.
      * @return Cache configuration.
      */
-    private CacheConfiguration cacheConfiguration(String name, Class<?> clsK, Class<?> clsV) {
+    private CacheConfiguration cacheConfiguration(String name, String sqlSchema, Class<?> clsK, Class<?> clsV) {
         CacheConfiguration cc = defaultCacheConfiguration();
 
         cc.setName(name);
@@ -94,7 +88,7 @@ public class GridQueryParsingTest extends GridCommonAbstractTest {
         cc.setNearConfiguration(null);
         cc.setWriteSynchronizationMode(FULL_SYNC);
         cc.setRebalanceMode(SYNC);
-        cc.setSqlSchema(TEST_SCHEMA);
+        cc.setSqlSchema(sqlSchema);
         cc.setSqlFunctionClasses(GridQueryParsingTest.class);
         cc.setIndexedTypes(clsK, clsV);
 
@@ -164,18 +158,18 @@ public class GridQueryParsingTest extends GridCommonAbstractTest {
         checkQuery("select * from table0('aaa', 100) x left join table0('bbb', 100) y on x.a=y.a where x.b = 'bbb'");
         checkQuery("select * from table0('aaa', 100) x left join table0('bbb', 100) y where x.b = 'bbb'");
 
-        checkQuery("select avg(old) from Person left join \"addr\".Address on Person.addrId = Address.id " +
+        checkQuery("select avg(old) from Person left join sch2.Address on Person.addrId = Address.id " +
             "where lower(Address.street) = lower(?)");
 
-        checkQuery("select avg(old) from Person join \"addr\".Address on Person.addrId = Address.id " +
+        checkQuery("select avg(old) from sch1.Person join sch2.Address on Person.addrId = Address.id " +
             "where lower(Address.street) = lower(?)");
 
-        checkQuery("select avg(old) from Person left join \"addr\".Address where Person.addrId = Address.id " +
+        checkQuery("select avg(old) from Person left join sch2.Address where Person.addrId = Address.id " +
             "and lower(Address.street) = lower(?)");
-        checkQuery("select avg(old) from Person right join \"addr\".Address where Person.addrId = Address.id " +
+        checkQuery("select avg(old) from Person right join sch2.Address where Person.addrId = Address.id " +
             "and lower(Address.street) = lower(?)");
 
-        checkQuery("select avg(old) from Person, \"addr\".Address where Person.addrId = Address.id " +
+        checkQuery("select avg(old) from Person, sch2.Address where Person.addrId = Address.id " +
             "and lower(Address.street) = lower(?)");
 
         checkQuery("select name, name, date, date d from Person");
@@ -185,19 +179,19 @@ public class GridQueryParsingTest extends GridCommonAbstractTest {
         checkQuery("select distinct * from Person");
         checkQuery("select p.name, date from Person p");
 
-        checkQuery("select * from Person p, \"addr\".Address a");
-        checkQuery("select * from Person, \"addr\".Address");
-        checkQuery("select p.* from Person p, \"addr\".Address a");
-        checkQuery("select person.* from Person, \"addr\".Address a");
-        checkQuery("select p.*, street from Person p, \"addr\".Address a");
-        checkQuery("select p.name, a.street from Person p, \"addr\".Address a");
-        checkQuery("select p.name, a.street from \"addr\".Address a, Person p");
-        checkQuery("select distinct p.name, a.street from Person p, \"addr\".Address a");
-        checkQuery("select distinct name, street from Person, \"addr\".Address group by old");
-        checkQuery("select distinct name, street from Person, \"addr\".Address");
-        checkQuery("select p1.name, a2.street from Person p1, \"addr\".Address a1, Person p2, \"addr\".Address a2");
-
-        checkQuery("select p.name n, a.street s from Person p, \"addr\".Address a");
+        checkQuery("select * from Person p, sch2.Address a");
+        checkQuery("select * from Person, sch2.Address");
+        checkQuery("select p.* from Person p, sch2.Address a");
+        checkQuery("select person.* from Person, sch2.Address a");
+        checkQuery("select p.*, street from Person p, sch2.Address a");
+        checkQuery("select p.name, a.street from Person p, sch2.Address a");
+        checkQuery("select p.name, a.street from sch2.Address a, Person p");
+        checkQuery("select distinct p.name, a.street from Person p, sch2.Address a");
+        checkQuery("select distinct name, street from Person, sch2.Address group by old");
+        checkQuery("select distinct name, street from Person, sch2.Address");
+        checkQuery("select p1.name, a2.street from Person p1, sch2.Address a1, Person p2, sch2.Address a2");
+
+        checkQuery("select p.name n, a.street s from Person p, sch2.Address a");
         checkQuery("select p.name, 1 as i, 'aaa' s from Person p");
 
         checkQuery("select p.name + 'a', 1 * 3 as i, 'aaa' s, -p.old, -p.old as old from Person p");
@@ -209,7 +203,7 @@ public class GridQueryParsingTest extends GridCommonAbstractTest {
         checkQuery("select p.name from Person p where name <> 'ivan'");
         checkQuery("select p.name from Person p where name like 'i%'");
         checkQuery("select p.name from Person p where name regexp 'i%'");
-        checkQuery("select p.name from Person p, \"addr\".Address a " +
+        checkQuery("select p.name from Person p, sch2.Address a " +
             "where p.name <> 'ivan' and a.id > 10 or not (a.id = 100)");
 
         checkQuery("select case p.name when 'a' then 1 when 'a' then 2 end as a from Person p");
@@ -223,10 +217,10 @@ public class GridQueryParsingTest extends GridCommonAbstractTest {
         checkQuery("select * from Person p where p.name in ('a', 'b', '_' + RAND())"); // test ConditionIn
         checkQuery("select * from Person p where p.name in ('a', 'b', 'c')"); // test ConditionInConstantSet
         // test ConditionInConstantSet
-        checkQuery("select * from Person p where p.name in (select a.street from \"addr\".Address a)");
+        checkQuery("select * from Person p where p.name in (select a.street from sch2.Address a)");
 
         // test ConditionInConstantSet
-        checkQuery("select (select a.street from \"addr\".Address a where a.id = p.addrId) from Person p");
+        checkQuery("select (select a.street from sch2.Address a where a.id = p.addrId) from Person p");
 
         checkQuery("select p.name, ? from Person p where name regexp ? and p.old < ?");
 
@@ -258,36 +252,36 @@ public class GridQueryParsingTest extends GridCommonAbstractTest {
         checkQuery("select p.name n from Person p order by p.old + 10, p.name");
         checkQuery("select p.name n from Person p order by p.old + 10, p.name desc");
 
-        checkQuery("select p.name n from Person p, (select a.street from \"addr\".Address a " +
+        checkQuery("select p.name n from Person p, (select a.street from sch2.Address a " +
             "where a.street is not null) ");
-        checkQuery("select street from Person p, (select a.street from \"addr\".Address a " +
+        checkQuery("select street from Person p, (select a.street from sch2.Address a " +
             "where a.street is not null) ");
-        checkQuery("select addr.street from Person p, (select a.street from \"addr\".Address a " +
+        checkQuery("select addr.street from Person p, (select a.street from sch2.Address a " +
             "where a.street is not null) addr");
 
-        checkQuery("select p.name n from sch.Person p order by p.old + 10");
+        checkQuery("select p.name n from sch1.Person p order by p.old + 10");
 
-        checkQuery("select case when p.name is null then 'Vasya' end x from sch.Person p");
-        checkQuery("select case when p.name like 'V%' then 'Vasya' else 'Other' end x from sch.Person p");
+        checkQuery("select case when p.name is null then 'Vasya' end x from sch1.Person p");
+        checkQuery("select case when p.name like 'V%' then 'Vasya' else 'Other' end x from sch1.Person p");
         checkQuery("select case when upper(p.name) = 'VASYA' then 'Vasya' " +
-            "when p.name is not null then p.name else 'Other' end x from sch.Person p");
+            "when p.name is not null then p.name else 'Other' end x from sch1.Person p");
 
-        checkQuery("select case p.name when 'Vasya' then 1 end z from sch.Person p");
-        checkQuery("select case p.name when 'Vasya' then 1 when 'Petya' then 2 end z from sch.Person p");
-        checkQuery("select case p.name when 'Vasya' then 1 when 'Petya' then 2 else 3 end z from sch.Person p");
-        checkQuery("select case p.name when 'Vasya' then 1 else 3 end z from sch.Person p");
+        checkQuery("select case p.name when 'Vasya' then 1 end z from sch1.Person p");
+        checkQuery("select case p.name when 'Vasya' then 1 when 'Petya' then 2 end z from sch1.Person p");
+        checkQuery("select case p.name when 'Vasya' then 1 when 'Petya' then 2 else 3 end z from sch1.Person p");
+        checkQuery("select case p.name when 'Vasya' then 1 else 3 end z from sch1.Person p");
 
-        checkQuery("select count(*) as a from Person union select count(*) as a from \"addr\".Address");
+        checkQuery("select count(*) as a from Person union select count(*) as a from sch2.Address");
         checkQuery("select old, count(*) as a from Person group by old union select 1, count(*) as a " +
-            "from \"addr\".Address");
-        checkQuery("select name from Person MINUS select street from \"addr\".Address");
-        checkQuery("select name from Person EXCEPT select street from \"addr\".Address");
-        checkQuery("select name from Person INTERSECT select street from \"addr\".Address");
-        checkQuery("select name from Person UNION select street from \"addr\".Address limit 5");
-        checkQuery("select name from Person UNION select street from \"addr\".Address limit ?");
-        checkQuery("select name from Person UNION select street from \"addr\".Address limit ? offset ?");
+            "from sch2.Address");
+        checkQuery("select name from Person MINUS select street from sch2.Address");
+        checkQuery("select name from Person EXCEPT select street from sch2.Address");
+        checkQuery("select name from Person INTERSECT select street from sch2.Address");
+        checkQuery("select name from Person UNION select street from sch2.Address limit 5");
+        checkQuery("select name from Person UNION select street from sch2.Address limit ?");
+        checkQuery("select name from Person UNION select street from sch2.Address limit ? offset ?");
         checkQuery("(select name from Person limit 4) " +
-            "UNION (select street from \"addr\".Address limit 1) limit ? offset ?");
+            "UNION (select street from sch2.Address limit 1) limit ? offset ?");
         checkQuery("(select 2 a) union all (select 1) order by 1");
         checkQuery("(select 2 a) union all (select 1) order by a desc nulls first limit ? offset ?");
 
@@ -295,12 +289,12 @@ public class GridQueryParsingTest extends GridCommonAbstractTest {
 //        checkQuery("select sch.\"#\".\"@\" from (select 1 as \"@\") \"#\""); // Illegal query.
         checkQuery("select \"#\".\"@\" from (select 1 as \"@\") \"#\"");
         checkQuery("select \"@\" from (select 1 as \"@\") \"#\"");
-        checkQuery("select sch.\"#\".old from sch.Person \"#\"");
-        checkQuery("select sch.\"#\".old from Person \"#\"");
+        checkQuery("select sch1.\"#\".old from sch1.Person \"#\"");
+        checkQuery("select sch1.\"#\".old from Person \"#\"");
         checkQuery("select \"#\".old from Person \"#\"");
         checkQuery("select old from Person \"#\"");
 //        checkQuery("select Person.old from Person \"#\""); // Illegal query.
-        checkQuery("select sch.\"#\".* from Person \"#\"");
+        checkQuery("select \"#\".* from Person \"#\"");
     }
 
     /**
@@ -365,7 +359,7 @@ public class GridQueryParsingTest extends GridCommonAbstractTest {
         checkQuery("merge into Person(old, name) select 5, 'John'");
         checkQuery("merge into Person(old, name) select p1.old, 'Name' from person p1 join person p2 on " +
             "p2.name = p1.parentName where p2.old > 30");
-        checkQuery("merge into Person(old) select 5 from Person UNION select street from \"addr\".Address limit ? offset ?");
+        checkQuery("merge into Person(old) select 5 from Person UNION select street from sch2.Address limit ? offset ?");
     }
 
     /** */
@@ -406,7 +400,7 @@ public class GridQueryParsingTest extends GridCommonAbstractTest {
         checkQuery("insert into Person(old, name) select 5, 'John'");
         checkQuery("insert into Person(old, name) select p1.old, 'Name' from person p1 join person p2 on " +
             "p2.name = p1.parentName where p2.old > 30");
-        checkQuery("insert into Person(old) select 5 from Person UNION select street from \"addr\".Address limit ? offset ?");
+        checkQuery("insert into Person(old) select 5 from Person UNION select street from sch2.Address limit ? offset ?");
     }
 
     /** */
@@ -428,10 +422,10 @@ public class GridQueryParsingTest extends GridCommonAbstractTest {
         checkQuery("update Person p set name='Peter', old = length('zzz') limit 20");
         checkQuery("update Person p set name=DEFAULT, old = null limit ?");
         checkQuery("update Person p set name=? where old >= ? and old < ? limit ?");
-        checkQuery("update Person p set name=(select a.Street from \"addr\".Address a where a.id=p.addrId), old = (select 42)" +
+        checkQuery("update Person p set name=(select a.Street from sch2.Address a where a.id=p.addrId), old = (select 42)" +
             " where old = sqrt(?)");
         checkQuery("update Person p set (name, old) = (select 'Peter', 42)");
-        checkQuery("update Person p set (name, old) = (select street, id from \"addr\".Address where id > 5 and id <= ?)");
+        checkQuery("update Person p set (name, old) = (select street, id from sch2.Address where id > 5 and id <= ?)");
     }
 
     /**
@@ -444,7 +438,7 @@ public class GridQueryParsingTest extends GridCommonAbstractTest {
 
         IgniteH2Indexing idx = U.field(qryProcessor, "idx");
 
-        return (JdbcConnection)idx.connectionForSpace(TEST_CACHE);
+        return (JdbcConnection)idx.connectionForSpace(null);
     }
 
     /**


[19/34] ignite git commit: IGNITE-3477 - Fixed missing partition ID in iterators

Posted by ag...@apache.org.
IGNITE-3477 - Fixed missing partition ID in iterators


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

Branch: refs/heads/ignite-3477-master
Commit: 2bcf8f51f2420b33c9602a0ad27bb479dfceaae3
Parents: c4e7b4e
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Mon Mar 27 18:35:41 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Wed Mar 29 19:29:37 2017 +0300

----------------------------------------------------------------------
 .../cache/IgniteCacheOffheapManagerImpl.java         | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/2bcf8f51/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 156911b..16d3715 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
@@ -557,6 +557,9 @@ public class IgniteCacheOffheapManagerImpl extends GridCacheManagerAdapter imple
             private GridCursor<? extends CacheDataRow> cur;
 
             /** */
+            private int curPart;
+
+            /** */
             private CacheDataRow next;
 
             @Override protected CacheDataRow onNext() {
@@ -573,14 +576,19 @@ public class IgniteCacheOffheapManagerImpl extends GridCacheManagerAdapter imple
 
                 while (true) {
                     if (cur == null) {
-                        if (dataIt.hasNext())
-                            cur = dataIt.next().cursor();
+                        if (dataIt.hasNext()) {
+                            CacheDataStore ds = dataIt.next();
+
+                            curPart = ds.partId();
+                            cur = ds.cursor();
+                        }
                         else
                             break;
                     }
 
                     if (cur.next()) {
                         next = cur.get();
+                        next.key().partition(curPart);
 
                         break;
                     }
@@ -801,6 +809,9 @@ public class IgniteCacheOffheapManagerImpl extends GridCacheManagerAdapter imple
                 if (amount != -1 && cleared > amount)
                     return true;
 
+                if (row.key.partition() == -1)
+                    row.key.partition(cctx.affinity().partition(row.key));
+
                 assert row.key != null && row.link != 0 && row.expireTime != 0 : row;
 
                 if (pendingEntries.remove(row) != null) {


[32/34] ignite git commit: ignite-3477-master fix license header

Posted by ag...@apache.org.
ignite-3477-master fix license header


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

Branch: refs/heads/ignite-3477-master
Commit: f767925030ac32a54e051bee350aa486c8dbc29b
Parents: fd8ea27
Author: Dmitriy Govorukhin <dg...@gridgain.com>
Authored: Thu Mar 30 18:41:23 2017 +0300
Committer: Dmitriy Govorukhin <dg...@gridgain.com>
Committed: Thu Mar 30 18:41:23 2017 +0300

----------------------------------------------------------------------
 scripts/git-remoteless-branches.sh | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/f7679250/scripts/git-remoteless-branches.sh
----------------------------------------------------------------------
diff --git a/scripts/git-remoteless-branches.sh b/scripts/git-remoteless-branches.sh
index 8676e87..c712187 100755
--- a/scripts/git-remoteless-branches.sh
+++ b/scripts/git-remoteless-branches.sh
@@ -1,4 +1,20 @@
 #!/bin/bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
 
 # Prints list of all local branches, which doesn't have remote.
 #


[27/34] ignite git commit: Merge remote-tracking branch 'professional/ignite-3477-master' into ignite-3477-master

Posted by ag...@apache.org.
Merge remote-tracking branch 'professional/ignite-3477-master' into ignite-3477-master


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

Branch: refs/heads/ignite-3477-master
Commit: cefddcb082372959dd65fbecd80362746313055a
Parents: c48e3d6 31ffef4
Author: Dmitriy Govorukhin <dg...@gridgain.com>
Authored: Thu Mar 30 15:23:58 2017 +0300
Committer: Dmitriy Govorukhin <dg...@gridgain.com>
Committed: Thu Mar 30 15:23:58 2017 +0300

----------------------------------------------------------------------
 .../ignite/internal/processors/cache/GridCacheAdapter.java     | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------



[03/34] ignite git commit: ignite-3477-master fix TcpDiscoveryNodeAttributesUpdateOnReconnectTest.testReconnect

Posted by ag...@apache.org.
ignite-3477-master fix TcpDiscoveryNodeAttributesUpdateOnReconnectTest.testReconnect


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

Branch: refs/heads/ignite-3477-master
Commit: 9ef380e4bd355d7e785aa403491afdff141baef0
Parents: 5626f1c
Author: Dmitriy Govorukhin <dg...@gridgain.com>
Authored: Mon Mar 27 20:09:24 2017 +0300
Committer: Dmitriy Govorukhin <dg...@gridgain.com>
Committed: Mon Mar 27 20:09:24 2017 +0300

----------------------------------------------------------------------
 .../META-INF/services/org.apache.ignite.plugin.PluginProvider     | 3 ++-
 .../META-INF/services/org.apache.ignite.plugin.PluginProvider     | 1 -
 2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/9ef380e4/modules/core/src/test/java/META-INF/services/org.apache.ignite.plugin.PluginProvider
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/META-INF/services/org.apache.ignite.plugin.PluginProvider b/modules/core/src/test/java/META-INF/services/org.apache.ignite.plugin.PluginProvider
index 2601c7d..f030386 100644
--- a/modules/core/src/test/java/META-INF/services/org.apache.ignite.plugin.PluginProvider
+++ b/modules/core/src/test/java/META-INF/services/org.apache.ignite.plugin.PluginProvider
@@ -1 +1,2 @@
-org.apache.ignite.platform.plugin.PlatformTestPluginProvider
\ No newline at end of file
+org.apache.ignite.platform.plugin.PlatformTestPluginProvider
+org.apache.ignite.spi.discovery.tcp.TestReconnectPluginProvider
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/9ef380e4/modules/core/src/test/resources/META-INF/services/org.apache.ignite.plugin.PluginProvider
----------------------------------------------------------------------
diff --git a/modules/core/src/test/resources/META-INF/services/org.apache.ignite.plugin.PluginProvider b/modules/core/src/test/resources/META-INF/services/org.apache.ignite.plugin.PluginProvider
deleted file mode 100644
index a7fdf43..0000000
--- a/modules/core/src/test/resources/META-INF/services/org.apache.ignite.plugin.PluginProvider
+++ /dev/null
@@ -1 +0,0 @@
-org.apache.ignite.spi.discovery.tcp.TestReconnectPluginProvider
\ No newline at end of file


[30/34] ignite git commit: IdentityResolver tests were forced to fail with JIRA number

Posted by ag...@apache.org.
IdentityResolver tests were forced to fail with JIRA number


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

Branch: refs/heads/ignite-3477-master
Commit: fb32854fd3398cbf812774773c26acdde9a43ebe
Parents: cefddcb
Author: Sergey Chugunov <se...@gmail.com>
Authored: Thu Mar 30 18:38:27 2017 +0300
Committer: Sergey Chugunov <se...@gmail.com>
Committed: Thu Mar 30 18:38:27 2017 +0300

----------------------------------------------------------------------
 .../processors/cache/IgniteCacheInsertSqlQuerySelfTest.java      | 4 ++++
 .../processors/cache/IgniteCacheMergeSqlQuerySelfTest.java       | 4 ++++
 2 files changed, 8 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/fb32854f/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInsertSqlQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInsertSqlQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInsertSqlQuerySelfTest.java
index a2240b5..8a4d1cd 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInsertSqlQuerySelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInsertSqlQuerySelfTest.java
@@ -177,6 +177,8 @@ public class IgniteCacheInsertSqlQuerySelfTest extends IgniteCacheAbstractInsert
         if (!isBinaryMarshaller())
             return;
 
+        fail("https://issues.apache.org/jira/browse/IGNITE-4889");
+
         IgniteCache<Key3, Person> p = ignite(0).cache("K32P").withKeepBinary();
 
         p.query(new SqlFieldsQuery(
@@ -195,6 +197,8 @@ public class IgniteCacheInsertSqlQuerySelfTest extends IgniteCacheAbstractInsert
         if (!isBinaryMarshaller())
             return;
 
+        fail("https://issues.apache.org/jira/browse/IGNITE-4889");
+
         IgniteCache<Key4, Person> p = ignite(0).cache("K42P").withKeepBinary();
 
         p.query(new SqlFieldsQuery(

http://git-wip-us.apache.org/repos/asf/ignite/blob/fb32854f/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheMergeSqlQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheMergeSqlQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheMergeSqlQuerySelfTest.java
index d9a2d9e..e8c4e75 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheMergeSqlQuerySelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheMergeSqlQuerySelfTest.java
@@ -127,6 +127,8 @@ public class IgniteCacheMergeSqlQuerySelfTest extends IgniteCacheAbstractInsertS
         if (!isBinaryMarshaller())
             return;
 
+        fail("https://issues.apache.org/jira/browse/IGNITE-4889");
+
         IgniteCache<Key3, Person> p = ignite(0).cache("K32P").withKeepBinary();
 
         p.query(new SqlFieldsQuery(
@@ -144,6 +146,8 @@ public class IgniteCacheMergeSqlQuerySelfTest extends IgniteCacheAbstractInsertS
         if (!isBinaryMarshaller())
             return;
 
+        fail("https://issues.apache.org/jira/browse/IGNITE-4889");
+
         IgniteCache<Key4, Person> p = ignite(0).cache("K42P").withKeepBinary();
 
         p.query(new SqlFieldsQuery(


[25/34] ignite git commit: IGNITE-3477 - Fixed concurrent read-through

Posted by ag...@apache.org.
IGNITE-3477 - Fixed concurrent read-through


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

Branch: refs/heads/ignite-3477-master
Commit: 31ffef4c741bd469e2014be72bdba87a060d833b
Parents: 3fcab0d
Author: Ivan Rakov <iv...@gmail.com>
Authored: Thu Mar 30 14:56:40 2017 +0300
Committer: Ivan Rakov <iv...@gmail.com>
Committed: Thu Mar 30 14:56:40 2017 +0300

----------------------------------------------------------------------
 .../ignite/internal/processors/cache/GridCacheAdapter.java     | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/31ffef4c/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 61cbba5..56a7539 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
@@ -2090,9 +2090,13 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
                                         CacheObject cacheVal = ctx.toCacheObject(val);
 
                                         while (true) {
-                                            GridCacheEntryEx entry = entryEx(key);
+                                            GridCacheEntryEx entry = null;
 
                                             try {
+                                                entry = entryEx(key);
+
+                                                entry.unswap();
+
                                                 EntryGetResult verVal = entry.versionedValue(
                                                     cacheVal,
                                                     res.version(),


[15/34] ignite git commit: More info in toString for lock futures.

Posted by ag...@apache.org.
More info in toString for lock futures.


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

Branch: refs/heads/ignite-3477-master
Commit: 5d9323ccbf86c84fa5c9b77a9e8cd51a9b07d3f8
Parents: 0308e68
Author: sboikov <sb...@gridgain.com>
Authored: Tue Mar 21 14:15:52 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Wed Mar 29 19:29:36 2017 +0300

----------------------------------------------------------------------
 .../cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java | 1 +
 .../processors/cache/distributed/near/GridNearLockFuture.java       | 1 +
 2 files changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/5d9323cc/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
index 56dc322..46fb30c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
@@ -105,6 +105,7 @@ public final class GridDhtColocatedLockFuture extends GridCompoundIdentityFuture
     private final long threadId;
 
     /** Keys to lock. */
+    @GridToStringInclude
     private Collection<KeyCacheObject> keys;
 
     /** Future ID. */

http://git-wip-us.apache.org/repos/asf/ignite/blob/5d9323cc/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
index 0900bac..eb953d9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
@@ -100,6 +100,7 @@ public final class GridNearLockFuture extends GridCompoundIdentityFuture<Boolean
     private long threadId;
 
     /** Keys to lock. */
+    @GridToStringInclude
     private final Collection<KeyCacheObject> keys;
 
     /** Future ID. */


[28/34] ignite git commit: ignite-3477-master fix CacheConfigurationLeakTest.testCacheCreateLeak

Posted by ag...@apache.org.
ignite-3477-master fix CacheConfigurationLeakTest.testCacheCreateLeak


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

Branch: refs/heads/ignite-3477-master
Commit: 50acffa99f7e256dc96966a205d3ccab411abf6a
Parents: cefddcb
Author: Dmitriy Govorukhin <dg...@gridgain.com>
Authored: Thu Mar 30 16:14:44 2017 +0300
Committer: Dmitriy Govorukhin <dg...@gridgain.com>
Committed: Thu Mar 30 16:14:44 2017 +0300

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


http://git-wip-us.apache.org/repos/asf/ignite/blob/50acffa9/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationLeakTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationLeakTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationLeakTest.java
index 820cff3..b51932f 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationLeakTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationLeakTest.java
@@ -47,6 +47,7 @@ public class CacheConfigurationLeakTest extends GridCommonAbstractTest {
 
         MemoryPolicyConfiguration plc = new MemoryPolicyConfiguration();
 
+        plc.setName("dfltMemPlc");
         plc.setSize(MemoryConfiguration.DFLT_MEMORY_POLICY_SIZE * 10);
 
         memCfg.setMemoryPolicies(plc);


[34/34] ignite git commit: IGNITE-3477 - Merge remote branch

Posted by ag...@apache.org.
IGNITE-3477 - Merge remote branch


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

Branch: refs/heads/ignite-3477-master
Commit: 7b0eb418145eca9b50c8d3a1f4756aa0769c40a8
Parents: 2c480b4 2859bd0
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Thu Mar 30 20:24:55 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Thu Mar 30 20:24:55 2017 +0300

----------------------------------------------------------------------
 .../internal/processors/cache/GridCacheAdapter.java |  6 +++++-
 .../cache/CacheConfigurationLeakTest.java           |  1 +
 .../cache/MemoryPolicyConfigValidationTest.java     |  2 +-
 .../marshaller/MarshallerContextSelfTest.java       | 10 +++++++++-
 .../cache/IgniteCacheInsertSqlQuerySelfTest.java    |  4 ++++
 .../cache/IgniteCacheMergeSqlQuerySelfTest.java     |  4 ++++
 .../cache/IncorrectCacheTypeMetadataTest.java       |  8 ++++++--
 .../processors/cache/IncorrectQueryEntityTest.java  |  8 ++++++--
 scripts/git-remoteless-branches.sh                  | 16 ++++++++++++++++
 9 files changed, 52 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/7b0eb418/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/ignite/blob/7b0eb418/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 6b93936,c0f74d0..363c284
--- 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
@@@ -226,7 -226,7 +226,7 @@@ public class MemoryPolicyConfigValidati
          NULL_NAME_ON_USER_DEFINED_POLICY("User-defined MemoryPolicyConfiguration must have non-null and non-empty name."),
  
          /** */
-         MISSING_USER_DEFINED_DEFAULT("User-defined default MemoryPolicy name is not presented among configured MemoryPolicies: ");
 -        MISSING_USER_DEFINED_DEFAULT("User-defined default MemoryPolicy name must be presented among configured MemoryPolices: ");
++        MISSING_USER_DEFINED_DEFAULT("User-defined default MemoryPolicy name is not presented among configured MemoryPolices: ");
  
          /**
           * @param violationMsg Violation message.

http://git-wip-us.apache.org/repos/asf/ignite/blob/7b0eb418/modules/core/src/test/java/org/apache/ignite/marshaller/MarshallerContextSelfTest.java
----------------------------------------------------------------------


[08/34] ignite git commit: ignite-3477-master fix testLocalTransactional

Posted by ag...@apache.org.
ignite-3477-master fix testLocalTransactional


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

Branch: refs/heads/ignite-3477-master
Commit: 9c89b9b3a7f1acc8123477cacc481f6fedf91cf6
Parents: 6c6a9a3
Author: Dmitriy Govorukhin <dg...@gridgain.com>
Authored: Wed Mar 29 15:36:17 2017 +0300
Committer: Dmitriy Govorukhin <dg...@gridgain.com>
Committed: Wed Mar 29 15:36:17 2017 +0300

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


http://git-wip-us.apache.org/repos/asf/ignite/blob/9c89b9b3/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
index dc70a98..2c46d52 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
@@ -1564,6 +1564,8 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
 
                     boolean read = serOrder != null && txEntry1.op() == READ;
 
+                    entry1.unswap();
+
                     if (!entry1.tmLock(tx, timeout, serOrder, serReadVer, read)) {
                         // Unlock locks locked so far.
                         for (IgniteTxEntry txEntry2 : entries) {


[20/34] ignite git commit: IGNITE-4758 - Introduced multiple memory policies. Fixes #1595

Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/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 6710087..09c0c4c 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
@@ -28,6 +28,7 @@ import org.apache.ignite.internal.processors.cache.CacheDhtLocalPartitionAfterRe
 import org.apache.ignite.internal.processors.cache.CacheEnumOperationsSingleNodeTest;
 import org.apache.ignite.internal.processors.cache.CacheEnumOperationsTest;
 import org.apache.ignite.internal.processors.cache.CacheExchangeMessageDuplicatedStateTest;
+import org.apache.ignite.internal.processors.cache.CacheMemoryPolicyConfigurationTest;
 import org.apache.ignite.internal.processors.cache.CrossCacheTxRandomOperationsTest;
 import org.apache.ignite.internal.processors.cache.GridCacheAtomicMessageCountSelfTest;
 import org.apache.ignite.internal.processors.cache.GridCacheFinishPartitionsSelfTest;
@@ -36,6 +37,7 @@ import org.apache.ignite.internal.processors.cache.GridCachePartitionedGetSelfTe
 import org.apache.ignite.internal.processors.cache.GridCachePartitionedProjectionAffinitySelfTest;
 import org.apache.ignite.internal.processors.cache.GridCacheVariableTopologySelfTest;
 import org.apache.ignite.internal.processors.cache.IgniteAtomicCacheEntryProcessorNodeJoinTest;
+import org.apache.ignite.internal.processors.cache.MemoryPolicyConfigValidationTest;
 import org.apache.ignite.internal.processors.cache.IgniteCacheEntryProcessorNodeJoinTest;
 import org.apache.ignite.internal.processors.cache.IgniteCacheIncrementTxTest;
 import org.apache.ignite.internal.processors.cache.IgniteCachePartitionMapUpdateTest;
@@ -258,6 +260,8 @@ public class IgniteCacheTestSuite2 extends TestSuite {
         suite.addTest(new TestSuite(CacheLockReleaseNodeLeaveTest.class));
         suite.addTest(new TestSuite(NearCacheSyncUpdateTest.class));
         suite.addTest(new TestSuite(CacheConfigurationLeakTest.class));
+        suite.addTest(new TestSuite(MemoryPolicyConfigValidationTest.class));
+        suite.addTest(new TestSuite(CacheMemoryPolicyConfigurationTest.class));
         suite.addTest(new TestSuite(CacheEnumOperationsSingleNodeTest.class));
         suite.addTest(new TestSuite(CacheEnumOperationsTest.class));
         suite.addTest(new TestSuite(IgniteCacheIncrementTxTest.class));

http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2TreeIndex.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2TreeIndex.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2TreeIndex.java
index 74ff9c7..51a997b 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2TreeIndex.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2TreeIndex.java
@@ -107,10 +107,9 @@ public class H2TreeIndex extends GridH2IndexBase {
                 RootPage page = getMetaPage(name, i);
 
                 segments[i] = new H2Tree(
-                    name,
-                    cctx.offheap().reuseListForIndex(name),
+                    name,cctx.offheap().reuseListForIndex(name),
                     cctx.cacheId(),
-                    dbMgr.pageMemory(),
+                    cctx.memoryPolicy().pageMemory(),
                     cctx.shared().wal(),
                     cctx.offheap().globalRemoveId(),
                     tbl.rowFactory(),

http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java
index 70c46e8..791de5f 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java
@@ -18,21 +18,30 @@
 package org.apache.ignite.internal.processors.query.h2;
 
 import java.nio.ByteBuffer;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.Iterator;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import org.apache.ignite.IgniteCache;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.binary.BinaryObjectBuilder;
+import org.apache.ignite.cache.QueryEntity;
+import org.apache.ignite.cache.QueryIndex;
 import org.apache.ignite.cache.QueryIndexType;
 import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.binary.BinaryMarshaller;
+import org.apache.ignite.internal.binary.BinaryObjectImpl;
 import org.apache.ignite.internal.processors.cache.CacheObject;
 import org.apache.ignite.internal.processors.cache.CacheObjectContext;
 import org.apache.ignite.internal.processors.cache.KeyCacheObject;
-import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
 import org.apache.ignite.internal.processors.query.GridQueryFieldsResult;
 import org.apache.ignite.internal.processors.query.GridQueryIndexDescriptor;
 import org.apache.ignite.internal.processors.query.GridQueryProperty;
@@ -58,75 +67,101 @@ public abstract class GridIndexingSpiAbstractSelfTest extends GridCommonAbstract
     private static final TextIndex textIdx = new TextIndex(F.asList("txt"));
 
     /** */
-    private static final Map<String, Class<?>> fieldsAA = new HashMap<>();
+    private static final LinkedHashMap<String, String> fieldsAA = new LinkedHashMap<>();
 
     /** */
-    private static final Map<String, Class<?>> fieldsAB = new HashMap<>();
+    private static final LinkedHashMap<String, String> fieldsAB = new LinkedHashMap<>();
 
     /** */
-    private static final Map<String, Class<?>> fieldsBA = new HashMap<>();
+    private static final LinkedHashMap<String, String> fieldsBA = new LinkedHashMap<>();
+
+    /** */
+    private IgniteEx ignite0;
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        cfg.setMarshaller(new BinaryMarshaller());
+
+        return cfg;
+    }
 
     /**
      * Fields initialization.
      */
     static {
-        fieldsAA.put("id", Long.class);
-        fieldsAA.put("name", String.class);
-        fieldsAA.put("age", Integer.class);
+        fieldsAA.put("id", Long.class.getName());
+        fieldsAA.put("name", String.class.getName());
+        fieldsAA.put("age", Integer.class.getName());
 
         fieldsAB.putAll(fieldsAA);
-        fieldsAB.put("txt", String.class);
+        fieldsAB.put("txt", String.class.getName());
 
         fieldsBA.putAll(fieldsAA);
-        fieldsBA.put("sex", Boolean.class);
+        fieldsBA.put("sex", Boolean.class.getName());
     }
 
     /** */
-    private static TypeDesc typeAA = new TypeDesc("A", "A", fieldsAA, null);
-
-    /** */
-    private static TypeDesc typeAB = new TypeDesc("A", "B", fieldsAB, textIdx);
+    private static TypeDesc typeAA = new TypeDesc("A", "A", Collections.<String, Class<?>>emptyMap(), null);
 
     /** */
-    private static TypeDesc typeBA = new TypeDesc("B", "A", fieldsBA, null);
+    private static TypeDesc typeAB = new TypeDesc("A", "B", Collections.<String, Class<?>>emptyMap(), textIdx);
 
     /** */
-    private IgniteH2Indexing idx = new IgniteH2Indexing();
+    private static TypeDesc typeBA = new TypeDesc("B", "A", Collections.<String, Class<?>>emptyMap(), null);
 
     /** {@inheritDoc} */
     @Override protected void beforeTest() throws Exception {
-        getTestResources().inject(idx);
-
-        startIndexing(idx);
+        ignite0 = startGrid(0);
     }
 
-    /** {@inheritDoc} */
-    protected void startIndexing(IgniteH2Indexing spi) throws Exception {
-        spi.start(null, null);
+    /**
+     */
+    private CacheConfiguration cacheACfg() {
+        CacheConfiguration<?,?> cfg = new CacheConfiguration<>();
+
+        cfg.setName("A");
+
+        QueryEntity eA = new QueryEntity(Integer.class.getName(), "A");
+        eA.setFields(fieldsAA);
+
+        QueryEntity eB = new QueryEntity(Integer.class.getName(), "B");
+        eB.setFields(fieldsAB);
+
+        List<QueryEntity> list = new ArrayList<>(2);
 
-        CacheConfiguration ccfgA = cacheCfg("A");
-        CacheConfiguration ccfgB = cacheCfg("B");
+        list.add(eA);
+        list.add(eB);
 
-        spi.registerCache(ccfgA.getName(), null, ccfgA);
-        spi.registerCache(ccfgB.getName(), null, ccfgB);
+        QueryIndex idx = new QueryIndex("txt");
+        idx.setIndexType(QueryIndexType.FULLTEXT);
+        eB.setIndexes(Collections.singleton(idx));
+
+        cfg.setQueryEntities(list);
+
+        return cfg;
     }
 
     /**
-     * @param name Name.
+     *
      */
-    private CacheConfiguration cacheCfg(String name) {
-        CacheConfiguration<?,?> cfg = new CacheConfiguration<>();
+    private CacheConfiguration cacheBCfg() {
+        CacheConfiguration cfg = new CacheConfiguration();
+
+        cfg.setName("B");
 
-        cfg.setName(name);
+        QueryEntity eA = new QueryEntity(Integer.class.getName(), "A");
+        eA.setFields(fieldsBA);
+
+        cfg.setQueryEntities(Collections.singleton(eA));
 
         return cfg;
     }
 
     /** {@inheritDoc} */
     @Override protected void afterTest() throws Exception {
-        idx.stop();
-
-        idx = null;
+        stopAllGrids();
     }
 
     /**
@@ -135,14 +170,13 @@ public abstract class GridIndexingSpiAbstractSelfTest extends GridCommonAbstract
      * @param age Age.
      * @return AA.
      */
-    private CacheObject aa(long id, String name, int age) {
-        Map<String, Object> map = new HashMap<>();
+    private BinaryObjectBuilder aa(String typeName, long id, String name, int age) {
+        BinaryObjectBuilder aBuilder = ignite0.binary().builder(typeName)
+                .setField("id", id)
+                .setField("name", name)
+                .setField("age", age);
 
-        map.put("id", id);
-        map.put("name", name);
-        map.put("age", age);
-
-        return new TestCacheObject(map);
+        return aBuilder;
     }
 
     /**
@@ -152,12 +186,12 @@ public abstract class GridIndexingSpiAbstractSelfTest extends GridCommonAbstract
      * @param txt Text.
      * @return AB.
      */
-    private CacheObject ab(long id, String name, int age, String txt) {
-        Map<String, Object> map = aa(id, name, age).value(null, false);
+    private BinaryObjectBuilder ab(long id, String name, int age, String txt) {
+        BinaryObjectBuilder aBuilder = aa("B", id, name, age);
 
-        map.put("txt", txt);
+        aBuilder.setField("txt", txt);
 
-        return new TestCacheObject(map);
+        return aBuilder;
     }
 
     /**
@@ -167,12 +201,12 @@ public abstract class GridIndexingSpiAbstractSelfTest extends GridCommonAbstract
      * @param sex Sex.
      * @return BA.
      */
-    private CacheObject ba(long id, String name, int age, boolean sex) {
-        Map<String, Object> map = aa(id, name, age).value(null, false);
+    private BinaryObjectBuilder ba(long id, String name, int age, boolean sex) {
+        BinaryObjectBuilder builder = aa("A", id, name, age);
 
-        map.put("sex", sex);
+        builder.setField("sex", sex);
 
-        return new TestCacheObject(map);
+        return builder;
     }
 
     /**
@@ -180,7 +214,7 @@ public abstract class GridIndexingSpiAbstractSelfTest extends GridCommonAbstract
      * @return Value.
      * @throws IgniteSpiException If failed.
      */
-    private Map<String, Object> value(IgniteBiTuple<Integer, Map<String, Object>> row) throws IgniteSpiException {
+    private BinaryObjectImpl value(IgniteBiTuple<Integer, BinaryObjectImpl> row) throws IgniteSpiException {
         return row.get2();
     }
 
@@ -188,7 +222,7 @@ public abstract class GridIndexingSpiAbstractSelfTest extends GridCommonAbstract
      * @return Indexing.
      */
     private IgniteH2Indexing getIndexing() {
-        return idx;
+        return U.field(ignite0.context().query(), "idx");
     }
 
     /**
@@ -216,19 +250,13 @@ public abstract class GridIndexingSpiAbstractSelfTest extends GridCommonAbstract
         assertEquals(-1, spi.size(typeAB.space(), typeAB));
         assertEquals(-1, spi.size(typeBA.space(), typeBA));
 
-        spi.registerType(typeAA.space(), typeAA);
-
-        assertEquals(0, spi.size(typeAA.space(), typeAA));
-        assertEquals(-1, spi.size(typeAB.space(), typeAB));
-        assertEquals(-1, spi.size(typeBA.space(), typeBA));
-
-        spi.registerType(typeAB.space(), typeAB);
+        IgniteCache<Integer, BinaryObject> cacheA = ignite0.createCache(cacheACfg());
 
         assertEquals(0, spi.size(typeAA.space(), typeAA));
         assertEquals(0, spi.size(typeAB.space(), typeAB));
         assertEquals(-1, spi.size(typeBA.space(), typeBA));
 
-        spi.registerType(typeBA.space(), typeBA);
+        IgniteCache<Integer, BinaryObject> cacheB = ignite0.createCache(cacheBCfg());
 
         // Initially all is empty.
         assertEquals(0, spi.size(typeAA.space(), typeAA));
@@ -258,105 +286,100 @@ public abstract class GridIndexingSpiAbstractSelfTest extends GridCommonAbstract
         assertFalse(spi.queryLocalSql(typeBA.space(), "select   ba.*   from B.A  as ba", null,
             Collections.emptySet(), typeBA.name(), null, null).hasNext());
 
-        // Nothing to remove.
-        spi.remove("A", typeAA, key(1), 0, aa(1, "", 10), null);
-        spi.remove("B", typeBA, key(1), 0, ba(1, "", 10, true), null);
-
-        spi.store(typeAA.space(), typeAA, key(1), 0, aa(1, "Vasya", 10), new GridCacheVersion(), 0, 0);
+        cacheA.put(1, aa("A", 1, "Vasya", 10).build());
 
         assertEquals(1, spi.size(typeAA.space(), typeAA));
         assertEquals(0, spi.size(typeAB.space(), typeAB));
         assertEquals(0, spi.size(typeBA.space(), typeBA));
 
-        spi.store(typeAB.space(), typeAB, key(1), 0, ab(1, "Vasya", 20, "Some text about Vasya goes here."),
-            new GridCacheVersion(), 0, 0);
+        cacheA.put(1, ab(1, "Vasya", 20, "Some text about Vasya goes here.").build());
 
         // In one space all keys must be unique.
         assertEquals(0, spi.size(typeAA.space(), typeAA));
         assertEquals(1, spi.size(typeAB.space(), typeAB));
         assertEquals(0, spi.size(typeBA.space(), typeBA));
 
-        spi.store(typeBA.space(), typeBA, key(1), 0, ba(2, "Petya", 25, true), new GridCacheVersion(), 0, 0);
+        cacheB.put(1, ba(2, "Petya", 25, true).build());
 
         // No replacement because of different space.
         assertEquals(0, spi.size(typeAA.space(), typeAA));
         assertEquals(1, spi.size(typeAB.space(), typeAB));
         assertEquals(1, spi.size(typeBA.space(), typeBA));
 
-        spi.store(typeBA.space(), typeBA, key(1), 0, ba(2, "Kolya", 25, true), new GridCacheVersion(), 0, 0);
+        cacheB.put(1, ba(2, "Kolya", 25, true).build());
 
         // Replacement in the same table.
         assertEquals(0, spi.size(typeAA.space(), typeAA));
         assertEquals(1, spi.size(typeAB.space(), typeAB));
         assertEquals(1, spi.size(typeBA.space(), typeBA));
 
-        spi.store(typeAA.space(), typeAA, key(2), 0, aa(2, "Valera", 19), new GridCacheVersion(), 0, 0);
+        cacheA.put(2, aa("A", 2, "Valera", 19).build());
 
         assertEquals(1, spi.size(typeAA.space(), typeAA));
         assertEquals(1, spi.size(typeAB.space(), typeAB));
         assertEquals(1, spi.size(typeBA.space(), typeBA));
 
-        spi.store(typeAA.space(), typeAA, key(3), 0, aa(3, "Borya", 18), new GridCacheVersion(), 0, 0);
+        cacheA.put(3, aa("A", 3, "Borya", 18).build());
 
         assertEquals(2, spi.size(typeAA.space(), typeAA));
         assertEquals(1, spi.size(typeAB.space(), typeAB));
         assertEquals(1, spi.size(typeBA.space(), typeBA));
 
-        spi.store(typeAB.space(), typeAB, key(4), 0, ab(4, "Vitalya", 20, "Very Good guy"), new GridCacheVersion(), 0, 0);
+        cacheA.put(4, ab(4, "Vitalya", 20, "Very Good guy").build());
 
         assertEquals(2, spi.size(typeAA.space(), typeAA));
         assertEquals(2, spi.size(typeAB.space(), typeAB));
         assertEquals(1, spi.size(typeBA.space(), typeBA));
 
         // Query data.
-        Iterator<IgniteBiTuple<Integer, Map<String, Object>>> res =
+        Iterator<IgniteBiTuple<Integer, BinaryObjectImpl>> res =
             spi.queryLocalSql(typeAA.space(), "from a order by age", null, Collections.emptySet(), typeAA.name(), null, null);
 
         assertTrue(res.hasNext());
-        assertEquals(aa(3, "Borya", 18).value(null, false), value(res.next()));
+        assertEquals(aa("A", 3, "Borya", 18).build(), value(res.next()));
         assertTrue(res.hasNext());
-        assertEquals(aa(2, "Valera", 19).value(null, false), value(res.next()));
+        assertEquals(aa("A", 2, "Valera", 19).build(), value(res.next()));
         assertFalse(res.hasNext());
 
         res = spi.queryLocalSql(typeAA.space(), "select aa.* from a aa order by aa.age", null,
             Collections.emptySet(), typeAA.name(), null, null);
 
         assertTrue(res.hasNext());
-        assertEquals(aa(3, "Borya", 18).value(null, false), value(res.next()));
+        assertEquals(aa("A", 3, "Borya", 18).build(), value(res.next()));
         assertTrue(res.hasNext());
-        assertEquals(aa(2, "Valera", 19).value(null, false), value(res.next()));
+        assertEquals(aa("A", 2, "Valera", 19).build(), value(res.next()));
         assertFalse(res.hasNext());
 
         res = spi.queryLocalSql(typeAB.space(), "from b order by name", null, Collections.emptySet(), typeAB.name(), null, null);
 
         assertTrue(res.hasNext());
-        assertEquals(ab(1, "Vasya", 20, "Some text about Vasya goes here.").value(null, false), value(res.next()));
+        assertEquals(ab(1, "Vasya", 20, "Some text about Vasya goes here.").build(), value(res.next()));
         assertTrue(res.hasNext());
-        assertEquals(ab(4, "Vitalya", 20, "Very Good guy").value(null, false), value(res.next()));
+        assertEquals(ab(4, "Vitalya", 20, "Very Good guy").build(), value(res.next()));
         assertFalse(res.hasNext());
 
         res = spi.queryLocalSql(typeAB.space(), "select bb.* from b as bb order by bb.name", null,
             Collections.emptySet(), typeAB.name(), null, null);
 
         assertTrue(res.hasNext());
-        assertEquals(ab(1, "Vasya", 20, "Some text about Vasya goes here.").value(null, false), value(res.next()));
+        assertEquals(ab(1, "Vasya", 20, "Some text about Vasya goes here.").build(), value(res.next()));
         assertTrue(res.hasNext());
-        assertEquals(ab(4, "Vitalya", 20, "Very Good guy").value(null, false), value(res.next()));
+        assertEquals(ab(4, "Vitalya", 20, "Very Good guy").build(), value(res.next()));
         assertFalse(res.hasNext());
 
 
         res = spi.queryLocalSql(typeBA.space(), "from a", null, Collections.emptySet(), typeBA.name(), null, null);
 
         assertTrue(res.hasNext());
-        assertEquals(ba(2, "Kolya", 25, true).value(null, false), value(res.next()));
+        assertEquals(ba(2, "Kolya", 25, true).build(), value(res.next()));
         assertFalse(res.hasNext());
 
         // Text queries
-        Iterator<IgniteBiTuple<Integer, Map<String, Object>>> txtRes = spi.queryLocalText(typeAB.space(), "good",
+        Iterator<IgniteBiTuple<Integer, BinaryObjectImpl>> txtRes = spi.queryLocalText(typeAB.space(), "good",
             typeAB, null);
 
         assertTrue(txtRes.hasNext());
-        assertEquals(ab(4, "Vitalya", 20, "Very Good guy").value(null, false), value(txtRes.next()));
+        assertEquals(ab(4, "Vitalya", 20, "Very Good guy").build(), value(txtRes.next()));
         assertFalse(txtRes.hasNext());
 
         // Fields query
@@ -385,13 +408,13 @@ public abstract class GridIndexingSpiAbstractSelfTest extends GridCommonAbstract
         assertFalse(it.hasNext());
 
         // Remove
-        spi.remove(typeAA.space(), typeAA, key(2), 0, aa(2, "Valera", 19), null);
+        cacheA.remove(2);
 
         assertEquals(1, spi.size(typeAA.space(), typeAA));
         assertEquals(2, spi.size(typeAB.space(), typeAB));
         assertEquals(1, spi.size(typeBA.space(), typeBA));
 
-        spi.remove(typeBA.space(), typeBA, key(1), 0, ba(2, "Kolya", 25, true), null);
+        cacheB.remove(1);
 
         assertEquals(1, spi.size(typeAA.space(), typeAA));
         assertEquals(2, spi.size(typeAB.space(), typeAB));
@@ -412,9 +435,6 @@ public abstract class GridIndexingSpiAbstractSelfTest extends GridCommonAbstract
 
         spi.unregisterType(typeBA.space(), typeBA);
 
-        // Should not store but should not fail as well.
-        spi.store(typeAA.space(), typeAA, key(10), 0, aa(1, "Fail", 100500), new GridCacheVersion(), 0, 0);
-
         assertEquals(-1, spi.size(typeAA.space(), typeAA));
     }
 
@@ -426,6 +446,8 @@ public abstract class GridIndexingSpiAbstractSelfTest extends GridCommonAbstract
     public void testLongQueries() throws Exception {
         IgniteH2Indexing spi = getIndexing();
 
+        ignite0.createCache(cacheACfg());
+
         long longQryExecTime = CacheConfiguration.DFLT_LONG_QRY_WARN_TIMEOUT;
 
         GridStringLogger log = new GridStringLogger(false, this.log);

http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/modules/platforms/cpp/core-test/config/cache-query-32.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/config/cache-query-32.xml b/modules/platforms/cpp/core-test/config/cache-query-32.xml
new file mode 100644
index 0000000..6927705
--- /dev/null
+++ b/modules/platforms/cpp/core-test/config/cache-query-32.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+
+<!--
+    Ignite Spring configuration file to startup grid cache.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:util="http://www.springframework.org/schema/util"
+       xsi:schemaLocation="
+        http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans.xsd
+        http://www.springframework.org/schema/util
+        http://www.springframework.org/schema/util/spring-util.xsd">
+    <import resource="cache-query-default.xml"/>
+
+    <bean parent="grid.cfg">
+        <property name="memoryConfiguration">
+            <bean class="org.apache.ignite.configuration.MemoryConfiguration">
+                <property name="systemCacheMemorySize" value="41943040"/>
+                <property name="defaultMemoryPolicyName" value="dfltPlc"/>
+
+                <property name="memoryPolicies">
+                    <list>
+                        <bean class="org.apache.ignite.configuration.MemoryPolicyConfiguration">
+                            <property name="name" value="dfltPlc"/>
+                            <property name="size" value="103833600"/>
+                        </bean>
+                    </list>
+                </property>
+            </bean>
+        </property>
+    </bean>
+</beans>

http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/modules/platforms/cpp/core-test/config/cache-query-continuous-32.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/config/cache-query-continuous-32.xml b/modules/platforms/cpp/core-test/config/cache-query-continuous-32.xml
new file mode 100644
index 0000000..b5f9854
--- /dev/null
+++ b/modules/platforms/cpp/core-test/config/cache-query-continuous-32.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:util="http://www.springframework.org/schema/util"
+       xsi:schemaLocation="
+        http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans.xsd
+        http://www.springframework.org/schema/util
+        http://www.springframework.org/schema/util/spring-util.xsd">
+    <import resource="cache-query-continuous-default.xml"/>
+
+    <bean parent="grid.cfg">
+        <property name="memoryConfiguration">
+            <bean class="org.apache.ignite.configuration.MemoryConfiguration">
+                <property name="systemCacheMemorySize" value="41943040"/>
+                <property name="defaultMemoryPolicyName" value="dfltPlc"/>
+
+                <property name="memoryPolicies">
+                    <list>
+                        <bean class="org.apache.ignite.configuration.MemoryPolicyConfiguration">
+                            <property name="name" value="dfltPlc"/>
+                            <property name="size" value="103833600"/>
+                        </bean>
+                    </list>
+                </property>
+            </bean>
+        </property>
+    </bean>
+</beans>

http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/modules/platforms/cpp/core-test/config/cache-query-continuous-default.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/config/cache-query-continuous-default.xml b/modules/platforms/cpp/core-test/config/cache-query-continuous-default.xml
new file mode 100644
index 0000000..2e43c5a
--- /dev/null
+++ b/modules/platforms/cpp/core-test/config/cache-query-continuous-default.xml
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:util="http://www.springframework.org/schema/util"
+       xsi:schemaLocation="
+        http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans.xsd
+        http://www.springframework.org/schema/util
+        http://www.springframework.org/schema/util/spring-util.xsd">
+    <bean abstract="true" id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+        <property name="localHost" value="127.0.0.1"/>
+        <property name="connectorConfiguration"><null/></property>
+
+        <property name="cacheConfiguration">
+            <list>
+                <bean class="org.apache.ignite.configuration.CacheConfiguration">
+                    <property name="name" value="transactional_no_backup"/>
+                    <property name="cacheMode" value="PARTITIONED"/>
+                    <property name="atomicityMode" value="TRANSACTIONAL"/>
+                    <property name="writeSynchronizationMode" value="FULL_SYNC"/>
+                    <property name="backups" value="0"/>
+                    <property name="startSize" value="10"/>
+                    <property name="queryEntities">
+                        <list>
+                            <bean class="org.apache.ignite.cache.QueryEntity">
+                                <property name="keyType" value="java.lang.Integer"/>
+                                <property name="valueType" value="TestEntry"/>
+
+                                <property name="fields">
+                                    <map>
+                                        <entry key="value" value="java.lang.Integer"/>
+                                    </map>
+                                </property>
+
+                                <property name="indexes">
+                                    <list>
+                                        <bean class="org.apache.ignite.cache.QueryIndex">
+                                            <property name="fields">
+                                                <map>
+                                                    <entry key="value" value="true"/>
+                                                </map>
+                                            </property>
+                                            <property name="indexType" value="FULLTEXT"/>
+                                        </bean>
+                                    </list>
+                                </property>
+                            </bean>
+                        </list>
+                    </property>
+                </bean>
+            </list>
+        </property>
+
+        <property name="discoverySpi">
+            <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+                <property name="ipFinder">
+                    <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+                        <property name="addresses">
+                            <list>
+                                <!-- In distributed environment, replace with actual host IP address. -->
+                                <value>127.0.0.1:47500</value>
+                            </list>
+                        </property>
+                    </bean>
+                </property>
+                <property name="socketTimeout" value="300" />
+            </bean>
+        </property>
+    </bean>
+</beans>

http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/modules/platforms/cpp/core-test/config/cache-query-continuous.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/config/cache-query-continuous.xml b/modules/platforms/cpp/core-test/config/cache-query-continuous.xml
index 1b940fd..1c4e275 100644
--- a/modules/platforms/cpp/core-test/config/cache-query-continuous.xml
+++ b/modules/platforms/cpp/core-test/config/cache-query-continuous.xml
@@ -24,64 +24,7 @@
         http://www.springframework.org/schema/beans/spring-beans.xsd
         http://www.springframework.org/schema/util
         http://www.springframework.org/schema/util/spring-util.xsd">
-    <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
-        <property name="localHost" value="127.0.0.1"/>
-        <property name="connectorConfiguration"><null/></property>
+    <import resource="cache-query-continuous-default.xml"/>
 
-        <property name="cacheConfiguration">
-            <list>
-                <bean class="org.apache.ignite.configuration.CacheConfiguration">
-                    <property name="name" value="transactional_no_backup"/>
-                    <property name="cacheMode" value="PARTITIONED"/>
-                    <property name="atomicityMode" value="TRANSACTIONAL"/>
-                    <property name="writeSynchronizationMode" value="FULL_SYNC"/>
-                    <property name="backups" value="0"/>
-                    <property name="startSize" value="10"/>
-                    <property name="queryEntities">
-                        <list>
-                            <bean class="org.apache.ignite.cache.QueryEntity">
-                                <property name="keyType" value="java.lang.Integer"/>
-                                <property name="valueType" value="TestEntry"/>
-
-                                <property name="fields">
-                                    <map>
-                                        <entry key="value" value="java.lang.Integer"/>
-                                    </map>
-                                </property>
-
-                                <property name="indexes">
-                                    <list>
-                                        <bean class="org.apache.ignite.cache.QueryIndex">
-                                            <property name="fields">
-                                                <map>
-                                                    <entry key="value" value="true"/>
-                                                </map>
-                                            </property>
-                                            <property name="indexType" value="FULLTEXT"/>
-                                        </bean>
-                                    </list>
-                                </property>
-                            </bean>
-                        </list>
-                    </property>
-                </bean>
-            </list>
-        </property>
-
-        <property name="discoverySpi">
-            <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
-                <property name="ipFinder">
-                    <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
-                        <property name="addresses">
-                            <list>
-                                <!-- In distributed environment, replace with actual host IP address. -->
-                                <value>127.0.0.1:47500</value>
-                            </list>
-                        </property>
-                    </bean>
-                </property>
-                <property name="socketTimeout" value="300" />
-            </bean>
-        </property>
-    </bean>
+    <bean parent="grid.cfg"/>
 </beans>

http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/modules/platforms/cpp/core-test/config/cache-query-default.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/config/cache-query-default.xml b/modules/platforms/cpp/core-test/config/cache-query-default.xml
new file mode 100644
index 0000000..28c57d6
--- /dev/null
+++ b/modules/platforms/cpp/core-test/config/cache-query-default.xml
@@ -0,0 +1,131 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+
+<!--
+    Ignite Spring configuration file to startup grid cache.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:util="http://www.springframework.org/schema/util"
+       xsi:schemaLocation="
+        http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans.xsd
+        http://www.springframework.org/schema/util
+        http://www.springframework.org/schema/util/spring-util.xsd">
+    <bean abstract="true" id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+        <property name="localHost" value="127.0.0.1"/>
+        <property name="connectorConfiguration"><null/></property>
+
+        <property name="cacheConfiguration">
+            <list>
+                <bean class="org.apache.ignite.configuration.CacheConfiguration">
+                    <property name="name" value="QueryPerson"/>
+                    <property name="cacheMode" value="PARTITIONED"/>
+                    <property name="atomicityMode" value="TRANSACTIONAL"/>
+                    <property name="writeSynchronizationMode" value="FULL_SYNC"/>
+
+                    <property name="affinity">
+                        <bean class="org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction">
+                            <property name="partitions" value="256"/>
+                        </bean>
+                    </property>
+                    
+                    <property name="typeMetadata">
+                        <list>
+                            <bean class="org.apache.ignite.cache.CacheTypeMetadata">
+                                <property name="valueType" value="QueryPerson"/>
+                                <property name="ascendingFields">
+                                    <map>
+                                        <entry key="age" value="java.lang.Integer"/>
+                                    </map>
+                                </property>
+                                <property name="queryFields">
+                                    <map>
+                                        <entry key="name" value="java.lang.String"/>
+                                        <entry key="age" value="java.lang.Integer"/>
+                                        <entry key="birthday" value="java.util.Date"/>
+                                        <entry key="recordCreated" value="java.sql.Timestamp"/>
+                                    </map>
+                                </property>
+                                <property name="textFields">
+                                    <list>
+                                        <value>name</value>
+                                    </list>
+                                </property>
+                            </bean>
+
+                            <bean class="org.apache.ignite.cache.CacheTypeMetadata">
+                                <property name="valueType" value="QueryRelation"/>
+                                <property name="queryFields">
+                                    <map>
+                                        <entry key="personId" value="java.lang.Integer"/>
+                                        <entry key="someVal" value="java.lang.Integer"/>
+                                    </map>
+                                </property>
+                            </bean>
+                        </list>
+                    </property>
+                </bean>
+
+                <bean class="org.apache.ignite.configuration.CacheConfiguration">
+                    <property name="name" value="QueryRelation"/>
+                    <property name="cacheMode" value="PARTITIONED"/>
+                    <property name="atomicityMode" value="TRANSACTIONAL"/>
+                    <property name="writeSynchronizationMode" value="FULL_SYNC"/>
+
+                    <property name="affinity">
+                        <bean class="org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction">
+                            <property name="partitions" value="256"/>
+                        </bean>
+                    </property>
+                    
+                    <property name="typeMetadata">
+                        <list>
+                            <bean class="org.apache.ignite.cache.CacheTypeMetadata">
+                                <property name="valueType" value="QueryRelation"/>
+                                <property name="queryFields">
+                                    <map>
+                                        <entry key="personId" value="java.lang.Integer"/>
+                                        <entry key="someVal" value="java.lang.Integer"/>
+                                    </map>
+                                </property>
+                            </bean>
+                        </list>
+                    </property>
+                </bean>
+            </list>
+        </property>
+
+        <property name="discoverySpi">
+            <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+                <property name="ipFinder">
+                    <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+                        <property name="addresses">
+                            <list>
+                                <!-- In distributed environment, replace with actual host IP address. -->
+                                <value>127.0.0.1:47500</value>
+                            </list>
+                        </property>
+                    </bean>
+                </property>
+                <property name="socketTimeout" value="300" />
+            </bean>
+        </property>
+    </bean>
+</beans>

http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/modules/platforms/cpp/core-test/config/cache-query.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/config/cache-query.xml b/modules/platforms/cpp/core-test/config/cache-query.xml
index 036c464..be7f939 100644
--- a/modules/platforms/cpp/core-test/config/cache-query.xml
+++ b/modules/platforms/cpp/core-test/config/cache-query.xml
@@ -28,117 +28,7 @@
         http://www.springframework.org/schema/beans/spring-beans.xsd
         http://www.springframework.org/schema/util
         http://www.springframework.org/schema/util/spring-util.xsd">
-    <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
-        <property name="localHost" value="127.0.0.1"/>
-        <property name="connectorConfiguration"><null/></property>
+    <import resource="cache-query-default.xml"/>
 
-        <property name="cacheConfiguration">
-            <list>
-                <bean class="org.apache.ignite.configuration.CacheConfiguration">
-                    <property name="name" value="QueryPerson"/>
-                    <property name="cacheMode" value="PARTITIONED"/>
-                    <property name="atomicityMode" value="TRANSACTIONAL"/>
-                    <property name="writeSynchronizationMode" value="FULL_SYNC"/>
-
-                    <property name="affinity">
-                        <bean class="org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction">
-                            <property name="partitions" value="256"/>
-                        </bean>
-                    </property>
-                    
-                    <property name="typeMetadata">
-                        <list>
-                            <bean class="org.apache.ignite.cache.CacheTypeMetadata">
-                                <property name="valueType" value="QueryPerson"/>
-                                <property name="ascendingFields">
-                                    <map>
-                                        <entry key="age" value="java.lang.Integer"/>
-                                    </map>
-                                </property>
-                                <property name="queryFields">
-                                    <map>
-                                        <entry key="name" value="java.lang.String"/>
-                                        <entry key="age" value="java.lang.Integer"/>
-                                        <entry key="birthday" value="java.util.Date"/>
-                                        <entry key="recordCreated" value="java.sql.Timestamp"/>
-                                    </map>
-                                </property>
-                                <property name="textFields">
-                                    <list>
-                                        <value>name</value>
-                                    </list>
-                                </property>
-                            </bean>
-                        </list>
-                    </property>
-                </bean>
-
-                <bean class="org.apache.ignite.configuration.CacheConfiguration">
-                    <property name="name" value="QueryRelation"/>
-                    <property name="cacheMode" value="PARTITIONED"/>
-                    <property name="atomicityMode" value="TRANSACTIONAL"/>
-                    <property name="writeSynchronizationMode" value="FULL_SYNC"/>
-
-                    <property name="affinity">
-                        <bean class="org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction">
-                            <property name="partitions" value="256"/>
-                        </bean>
-                    </property>
-                    
-                    <property name="typeMetadata">
-                        <list>
-                            <bean class="org.apache.ignite.cache.CacheTypeMetadata">
-                                <property name="valueType" value="QueryRelation"/>
-                                <property name="queryFields">
-                                    <map>
-                                        <entry key="personId" value="java.lang.Integer"/>
-                                        <entry key="someVal" value="java.lang.Integer"/>
-                                    </map>
-                                </property>
-                            </bean>
-                        </list>
-                    </property>
-                </bean>
-
-                <bean class="org.apache.ignite.configuration.CacheConfiguration">
-                    <property name="name" value="TimeCache"/>
-                    <property name="cacheMode" value="PARTITIONED"/>
-                    <property name="atomicityMode" value="TRANSACTIONAL"/>
-                    <property name="writeSynchronizationMode" value="FULL_SYNC"/>
-
-                    <property name="affinity">
-                        <bean class="org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction">
-                            <property name="partitions" value="256"/>
-                        </bean>
-                    </property>
-                    
-                    <!-- Configure type metadata to enable queries. -->
-                    <property name="queryEntities">
-                        <list>
-                            <bean class="org.apache.ignite.cache.QueryEntity">
-                                <property name="keyType" value="java.lang.Integer"/>
-                                <property name="valueType" value="java.sql.Time"/>
-                            </bean>
-                        </list>
-                    </property>
-                </bean>
-            </list>
-        </property>
-
-        <property name="discoverySpi">
-            <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
-                <property name="ipFinder">
-                    <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
-                        <property name="addresses">
-                            <list>
-                                <!-- In distributed environment, replace with actual host IP address. -->
-                                <value>127.0.0.1:47500</value>
-                            </list>
-                        </property>
-                    </bean>
-                </property>
-                <property name="socketTimeout" value="300" />
-            </bean>
-        </property>
-    </bean>
+    <bean parent="grid.cfg"/>
 </beans>

http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/modules/platforms/cpp/core-test/config/cache-test-32.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/config/cache-test-32.xml b/modules/platforms/cpp/core-test/config/cache-test-32.xml
new file mode 100644
index 0000000..3535ae4
--- /dev/null
+++ b/modules/platforms/cpp/core-test/config/cache-test-32.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+
+<!--
+    Ignite Spring configuration file to startup grid cache.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:util="http://www.springframework.org/schema/util"
+       xsi:schemaLocation="
+        http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans.xsd
+        http://www.springframework.org/schema/util
+        http://www.springframework.org/schema/util/spring-util.xsd">
+    <import resource="cache-test-default.xml"/>
+
+    <bean parent="grid.cfg">
+        <property name="memoryConfiguration">
+            <bean class="org.apache.ignite.configuration.MemoryConfiguration">
+                <property name="systemCacheMemorySize" value="41943040"/>
+                <property name="defaultMemoryPolicyName" value="dfltPlc"/>
+
+                <property name="memoryPolicies">
+                    <list>
+                        <bean class="org.apache.ignite.configuration.MemoryPolicyConfiguration">
+                            <property name="name" value="dfltPlc"/>
+                            <property name="size" value="103833600"/>
+                        </bean>
+                    </list>
+                </property>
+            </bean>
+        </property>
+    </bean>
+</beans>

http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/modules/platforms/cpp/core-test/config/cache-test-default.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/config/cache-test-default.xml b/modules/platforms/cpp/core-test/config/cache-test-default.xml
new file mode 100644
index 0000000..9a2bbd7
--- /dev/null
+++ b/modules/platforms/cpp/core-test/config/cache-test-default.xml
@@ -0,0 +1,135 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+
+<!--
+    Ignite Spring configuration file to startup grid cache.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:util="http://www.springframework.org/schema/util"
+       xsi:schemaLocation="
+        http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans.xsd
+        http://www.springframework.org/schema/util
+        http://www.springframework.org/schema/util/spring-util.xsd">
+    <bean abstract="true" id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+        <property name="localHost" value="127.0.0.1"/>
+        <property name="connectorConfiguration"><null/></property>
+
+        <property name="includeEventTypes">
+            <util:constant static-field="org.apache.ignite.events.EventType.EVTS_CACHE"/>
+        </property>
+
+        <property name="cacheConfiguration">
+            <list>
+                <bean parent="cache-template">
+                    <property name="name" value="local"/>
+                    <property name="cacheMode" value="LOCAL"/>
+                    <property name="atomicityMode" value="TRANSACTIONAL"/>
+                </bean>
+
+                <bean parent="cache-template">
+                    <property name="name" value="local_atomic"/>
+                    <property name="cacheMode" value="LOCAL"/>
+                    <property name="atomicityMode" value="ATOMIC"/>
+                </bean>
+
+                <bean parent="cache-template">
+                    <property name="name" value="partitioned"/>
+                    <property name="cacheMode" value="PARTITIONED"/>
+                    <property name="atomicityMode" value="TRANSACTIONAL"/>
+                </bean>
+				
+                <bean parent="cache-template">
+                    <property name="name" value="partitioned2"/>
+                    <property name="cacheMode" value="PARTITIONED"/>
+                    <property name="atomicityMode" value="TRANSACTIONAL"/>
+                </bean>
+
+                <bean parent="cache-template">
+                    <property name="name" value="partitioned_atomic"/>
+                    <property name="cacheMode" value="PARTITIONED"/>
+                    <property name="atomicityMode" value="ATOMIC"/>
+                    <property name="atomicWriteOrderMode" value="PRIMARY"/>
+                </bean>
+
+                <bean parent="cache-template">
+                    <property name="name" value="partitioned_near"/>
+                    <property name="cacheMode" value="PARTITIONED"/>
+                    <property name="atomicityMode" value="TRANSACTIONAL"/>
+                    <property name="nearConfiguration">
+                        <bean class="org.apache.ignite.configuration.NearCacheConfiguration" />
+                    </property>
+                </bean>
+
+                <bean parent="cache-template">
+                    <property name="name" value="partitioned_atomic_near"/>
+                    <property name="cacheMode" value="PARTITIONED"/>
+                    <property name="atomicityMode" value="ATOMIC"/>
+                    <property name="atomicWriteOrderMode" value="PRIMARY"/>
+                    <property name="nearConfiguration">
+                        <bean class="org.apache.ignite.configuration.NearCacheConfiguration" />
+                    </property>
+                </bean>
+
+                <bean parent="cache-template">
+                    <property name="name" value="replicated"/>
+                    <property name="cacheMode" value="REPLICATED"/>
+                    <property name="atomicityMode" value="TRANSACTIONAL"/>
+                </bean>
+
+                <bean parent="cache-template">
+                    <property name="name" value="replicated_atomic"/>
+                    <property name="cacheMode" value="REPLICATED"/>
+                    <property name="atomicityMode" value="ATOMIC"/>
+                    <property name="atomicWriteOrderMode" value="PRIMARY"/>
+                </bean>
+            </list>
+        </property>
+
+        <property name="discoverySpi">
+            <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+                <property name="ipFinder">
+                    <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+                        <property name="addresses">
+                            <list>
+                                <!-- In distributed environment, replace with actual host IP address. -->
+                                <value>127.0.0.1:47500..47501</value>
+                            </list>
+                        </property>
+                    </bean>
+                </property>
+                <property name="socketTimeout" value="300" />
+            </bean>
+        </property>
+
+        <property name="transactionConfiguration">
+            <bean class="org.apache.ignite.configuration.TransactionConfiguration">
+                <property name="txSerializableEnabled" value="true"/>
+            </bean>
+        </property>
+    </bean>
+
+    <bean id="cache-template" abstract="true" class="org.apache.ignite.configuration.CacheConfiguration">
+        <property name="rebalanceMode" value="SYNC"/>
+        <property name="writeSynchronizationMode" value="FULL_SYNC"/>
+        <property name="backups" value="1"/>
+        <property name="eagerTtl" value="true"/>
+    </bean>
+</beans>

http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/modules/platforms/cpp/core-test/config/cache-test.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/config/cache-test.xml b/modules/platforms/cpp/core-test/config/cache-test.xml
index fc11722..43ed8d2 100644
--- a/modules/platforms/cpp/core-test/config/cache-test.xml
+++ b/modules/platforms/cpp/core-test/config/cache-test.xml
@@ -28,108 +28,7 @@
         http://www.springframework.org/schema/beans/spring-beans.xsd
         http://www.springframework.org/schema/util
         http://www.springframework.org/schema/util/spring-util.xsd">
-    <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
-        <property name="localHost" value="127.0.0.1"/>
-        <property name="connectorConfiguration"><null/></property>
+    <import resource="cache-test-default.xml"/>
 
-        <property name="includeEventTypes">
-            <util:constant static-field="org.apache.ignite.events.EventType.EVTS_CACHE"/>
-        </property>
-
-        <property name="cacheConfiguration">
-            <list>
-                <bean parent="cache-template">
-                    <property name="name" value="local"/>
-                    <property name="cacheMode" value="LOCAL"/>
-                    <property name="atomicityMode" value="TRANSACTIONAL"/>
-                </bean>
-
-                <bean parent="cache-template">
-                    <property name="name" value="local_atomic"/>
-                    <property name="cacheMode" value="LOCAL"/>
-                    <property name="atomicityMode" value="ATOMIC"/>
-                </bean>
-
-                <bean parent="cache-template">
-                    <property name="name" value="partitioned"/>
-                    <property name="cacheMode" value="PARTITIONED"/>
-                    <property name="atomicityMode" value="TRANSACTIONAL"/>
-                </bean>
-				
-                <bean parent="cache-template">
-                    <property name="name" value="partitioned2"/>
-                    <property name="cacheMode" value="PARTITIONED"/>
-                    <property name="atomicityMode" value="TRANSACTIONAL"/>
-                </bean>
-
-                <bean parent="cache-template">
-                    <property name="name" value="partitioned_atomic"/>
-                    <property name="cacheMode" value="PARTITIONED"/>
-                    <property name="atomicityMode" value="ATOMIC"/>
-                    <property name="atomicWriteOrderMode" value="PRIMARY"/>
-                </bean>
-
-                <bean parent="cache-template">
-                    <property name="name" value="partitioned_near"/>
-                    <property name="cacheMode" value="PARTITIONED"/>
-                    <property name="atomicityMode" value="TRANSACTIONAL"/>
-                    <property name="nearConfiguration">
-                        <bean class="org.apache.ignite.configuration.NearCacheConfiguration" />
-                    </property>
-                </bean>
-
-                <bean parent="cache-template">
-                    <property name="name" value="partitioned_atomic_near"/>
-                    <property name="cacheMode" value="PARTITIONED"/>
-                    <property name="atomicityMode" value="ATOMIC"/>
-                    <property name="atomicWriteOrderMode" value="PRIMARY"/>
-                    <property name="nearConfiguration">
-                        <bean class="org.apache.ignite.configuration.NearCacheConfiguration" />
-                    </property>
-                </bean>
-
-                <bean parent="cache-template">
-                    <property name="name" value="replicated"/>
-                    <property name="cacheMode" value="REPLICATED"/>
-                    <property name="atomicityMode" value="TRANSACTIONAL"/>
-                </bean>
-
-                <bean parent="cache-template">
-                    <property name="name" value="replicated_atomic"/>
-                    <property name="cacheMode" value="REPLICATED"/>
-                    <property name="atomicityMode" value="ATOMIC"/>
-                    <property name="atomicWriteOrderMode" value="PRIMARY"/>
-                </bean>
-            </list>
-        </property>
-
-        <property name="discoverySpi">
-            <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
-                <property name="ipFinder">
-                    <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
-                        <property name="addresses">
-                            <list>
-                                <!-- In distributed environment, replace with actual host IP address. -->
-                                <value>127.0.0.1:47500..47501</value>
-                            </list>
-                        </property>
-                    </bean>
-                </property>
-                <property name="socketTimeout" value="300" />
-            </bean>
-        </property>
-
-        <property name="transactionConfiguration">
-            <bean class="org.apache.ignite.configuration.TransactionConfiguration">
-                <property name="txSerializableEnabled" value="true"/>
-            </bean>
-        </property>
-    </bean>
-
-    <bean id="cache-template" abstract="true" class="org.apache.ignite.configuration.CacheConfiguration">
-        <property name="rebalanceMode" value="SYNC"/>
-        <property name="writeSynchronizationMode" value="FULL_SYNC"/>
-        <property name="backups" value="1"/>
-        <property name="eagerTtl" value="true"/>
-    </bean>
+    <bean parent="grid.cfg"/>
 </beans>

http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj b/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj
index f22e885..d97f917 100644
--- a/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj
+++ b/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj
@@ -35,11 +35,18 @@
   <ItemGroup>
     <None Include="..\..\config\cache-identity.xml" />
     <None Include="..\..\config\cache-query-continuous.xml" />
+    <None Include="..\..\config\cache-query-32.xml" />
     <None Include="..\..\config\cache-query.xml" />
+    <None Include="..\..\config\cache-query-default.xml" />
+    <None Include="..\..\config\cache-test-32.xml" />
     <None Include="..\..\config\cache-store.xml">
       <SubType>Designer</SubType>
     </None>
     <None Include="..\..\config\cache-test.xml" />
+    <None Include="..\..\config\cache-test-default.xml" />
+    <None Include="..\..\config\cache-query-continuous-32.xml" />
+    <None Include="..\..\config\cache-query-continuous.xml" />
+    <None Include="..\..\config\cache-query-continuous-default.xml" />
     <None Include="..\..\config\invalid.xml" />
   </ItemGroup>
   <ItemGroup>

http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj.filters
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj.filters b/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj.filters
index fb0be1b..aa19e63 100644
--- a/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj.filters
+++ b/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj.filters
@@ -124,12 +124,33 @@
     </Filter>
   </ItemGroup>
   <ItemGroup>
+    <None Include="..\..\config\cache-test-32.xml">
+      <Filter>Configs</Filter>
+    </None>
     <None Include="..\..\config\cache-test.xml">
       <Filter>Configs</Filter>
     </None>
+    <None Include="..\..\config\cache-test-default.xml">
+      <Filter>Configs</Filter>
+    </None>
+    <None Include="..\..\config\cache-query-32.xml">
+      <Filter>Configs</Filter>
+    </None>
     <None Include="..\..\config\cache-query.xml">
       <Filter>Configs</Filter>
     </None>
+    <None Include="..\..\config\cache-query-default.xml">
+      <Filter>Configs</Filter>
+    </None>
+    <None Include="..\..\config\cache-query-continuous-32.xml">
+      <Filter>Configs</Filter>
+    </None>
+    <None Include="..\..\config\cache-query-continuous.xml">
+      <Filter>Configs</Filter>
+    </None>
+    <None Include="..\..\config\cache-query-continuous-default.xml">
+      <Filter>Configs</Filter>
+    </None>
     <None Include="..\..\config\invalid.xml">
       <Filter>Configs</Filter>
     </None>

http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/modules/platforms/cpp/core-test/src/cache_query_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/cache_query_test.cpp b/modules/platforms/cpp/core-test/src/cache_query_test.cpp
index abb374a..3a91c0e 100644
--- a/modules/platforms/cpp/core-test/src/cache_query_test.cpp
+++ b/modules/platforms/cpp/core-test/src/cache_query_test.cpp
@@ -591,7 +591,11 @@ struct CacheQueryTestSuiteFixture
 {
     Ignite StartNode(const char* name)
     {
+#ifdef IGNITE_TESTS_32
+        return ignite_test::StartNode("cache-query-32.xml", name);
+#else
         return ignite_test::StartNode("cache-query.xml", name);
+#endif
     }
 
     void CheckFieldsQueryPages(int32_t pageSize, int32_t pagesNum, int32_t additionalNum)

http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/modules/platforms/cpp/core-test/src/cache_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/cache_test.cpp b/modules/platforms/cpp/core-test/src/cache_test.cpp
index 437ed234..aa3ac8e 100644
--- a/modules/platforms/cpp/core-test/src/cache_test.cpp
+++ b/modules/platforms/cpp/core-test/src/cache_test.cpp
@@ -94,8 +94,13 @@ struct CacheTestSuiteFixture {
      */
     CacheTestSuiteFixture()
     {
+#ifdef IGNITE_TESTS_32
+        grid0 = ignite_test::StartNode("cache-test-32.xml", "grid-0");
+        grid1 = ignite_test::StartNode("cache-test-32.xml", "grid-1");
+#else
         grid0 = ignite_test::StartNode("cache-test.xml", "grid-0");
         grid1 = ignite_test::StartNode("cache-test.xml", "grid-1");
+#endif
     }
 
     /*

http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/modules/platforms/cpp/core-test/src/continuous_query_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/continuous_query_test.cpp b/modules/platforms/cpp/core-test/src/continuous_query_test.cpp
index 1be21c1..d730ae9 100644
--- a/modules/platforms/cpp/core-test/src/continuous_query_test.cpp
+++ b/modules/platforms/cpp/core-test/src/continuous_query_test.cpp
@@ -245,7 +245,11 @@ struct ContinuousQueryTestSuiteFixture
      * Constructor.
      */
     ContinuousQueryTestSuiteFixture() :
+#ifdef IGNITE_TESTS_32
+        grid(ignite_test::StartNode("cache-query-continuous-32.xml", "node-01")),
+#else
         grid(ignite_test::StartNode("cache-query-continuous.xml", "node-01")),
+#endif
         cache(grid.GetCache<int, TestEntry>("transactional_no_backup"))
     {
         // No-op.

http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/modules/platforms/cpp/core-test/src/ignition_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/ignition_test.cpp b/modules/platforms/cpp/core-test/src/ignition_test.cpp
index 52a51d0..b1ffa0a 100644
--- a/modules/platforms/cpp/core-test/src/ignition_test.cpp
+++ b/modules/platforms/cpp/core-test/src/ignition_test.cpp
@@ -34,7 +34,11 @@ BOOST_AUTO_TEST_CASE(TestIgnition)
 {
     IgniteConfiguration cfg;
 
+#ifdef IGNITE_TESTS_32
+    ignite_test::InitConfig(cfg, "cache-test-32.xml");
+#else
     ignite_test::InitConfig(cfg, "cache-test.xml");
+#endif
 
     IgniteError err;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/modules/platforms/cpp/core-test/src/interop_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/interop_test.cpp b/modules/platforms/cpp/core-test/src/interop_test.cpp
index b76d030..ac1f428 100644
--- a/modules/platforms/cpp/core-test/src/interop_test.cpp
+++ b/modules/platforms/cpp/core-test/src/interop_test.cpp
@@ -89,7 +89,11 @@ BOOST_AUTO_TEST_CASE(StringUtfInvalidCodePoint)
 
 BOOST_AUTO_TEST_CASE(StringUtfValid4ByteCodePoint)
 {
+#ifdef IGNITE_TESTS_32
+    Ignite ignite = ignite_test::StartNode("cache-test-32.xml");
+#else
     Ignite ignite = ignite_test::StartNode("cache-test.xml");
+#endif
 
     Cache<std::string, std::string> cache = ignite.CreateCache<std::string, std::string>("Test");
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/modules/platforms/cpp/core-test/src/transactions_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/transactions_test.cpp b/modules/platforms/cpp/core-test/src/transactions_test.cpp
index 3bf1ac6..0032412 100644
--- a/modules/platforms/cpp/core-test/src/transactions_test.cpp
+++ b/modules/platforms/cpp/core-test/src/transactions_test.cpp
@@ -40,7 +40,11 @@ struct TransactionsTestSuiteFixture {
      */
     TransactionsTestSuiteFixture()
     {
+#ifdef IGNITE_TESTS_32
+        grid = ignite_test::StartNode("cache-test-32.xml", "txTest");
+#else
         grid = ignite_test::StartNode("cache-test.xml", "txTest");
+#endif
     }
 
     /*

http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/modules/platforms/cpp/odbc-test/config/queries-test-32.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/config/queries-test-32.xml b/modules/platforms/cpp/odbc-test/config/queries-test-32.xml
new file mode 100644
index 0000000..dd7cfb6
--- /dev/null
+++ b/modules/platforms/cpp/odbc-test/config/queries-test-32.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:util="http://www.springframework.org/schema/util"
+       xsi:schemaLocation="
+        http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+    <!-- Imports no-ODBC Ignite configuration -->
+    <import resource="queries-test-default.xml"/>
+
+    <bean parent="queries.cfg">
+        <property name="memoryConfiguration">
+            <bean class="org.apache.ignite.configuration.MemoryConfiguration">
+                <property name="systemCacheMemorySize" value="41943040"/>
+                <property name="defaultMemoryPolicyName" value="dfltPlc"/>
+
+                <property name="memoryPolicies">
+                    <list>
+                        <bean class="org.apache.ignite.configuration.MemoryPolicyConfiguration">
+                            <property name="name" value="dfltPlc"/>
+                            <property name="size" value="103833600"/>
+                        </bean>
+                    </list>
+                </property>
+            </bean>
+        </property>
+    </bean>
+</beans>

http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/modules/platforms/cpp/odbc-test/config/queries-test-default.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/config/queries-test-default.xml b/modules/platforms/cpp/odbc-test/config/queries-test-default.xml
new file mode 100644
index 0000000..c157695
--- /dev/null
+++ b/modules/platforms/cpp/odbc-test/config/queries-test-default.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:util="http://www.springframework.org/schema/util"
+       xsi:schemaLocation="
+        http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+    <!-- Imports no-ODBC Ignite configuration -->
+    <import resource="queries-default.xml"/>
+
+    <bean abstract="true" id="queries.cfg" parent="ignite.cfg">
+        <!-- Enabling ODBC. -->
+        <property name="odbcConfiguration">
+            <bean class="org.apache.ignite.configuration.OdbcConfiguration">
+                <property name="endpointAddress" value="127.0.0.1:11110"/>
+            </bean>
+        </property>
+    </bean>
+</beans>

http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/modules/platforms/cpp/odbc-test/config/queries-test-noodbc-32.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/config/queries-test-noodbc-32.xml b/modules/platforms/cpp/odbc-test/config/queries-test-noodbc-32.xml
new file mode 100644
index 0000000..8060107
--- /dev/null
+++ b/modules/platforms/cpp/odbc-test/config/queries-test-noodbc-32.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:util="http://www.springframework.org/schema/util"
+       xsi:schemaLocation="
+        http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+    <!-- Imports no-ODBC Ignite configuration -->
+    <import resource="queries-default.xml"/>
+
+    <bean parent="ignite.cfg">
+        <property name="memoryConfiguration">
+            <bean class="org.apache.ignite.configuration.MemoryConfiguration">
+                <property name="systemCacheMemorySize" value="41943040"/>
+                <property name="defaultMemoryPolicyName" value="dfltPlc"/>
+
+                <property name="memoryPolicies">
+                    <list>
+                        <bean class="org.apache.ignite.configuration.MemoryPolicyConfiguration">
+                            <property name="name" value="dfltPlc"/>
+                            <property name="size" value="103833600"/>
+                        </bean>
+                    </list>
+                </property>
+            </bean>
+        </property>
+    </bean>
+</beans>

http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/modules/platforms/cpp/odbc-test/config/queries-test.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/config/queries-test.xml b/modules/platforms/cpp/odbc-test/config/queries-test.xml
index d08d4f1..882eb1e 100644
--- a/modules/platforms/cpp/odbc-test/config/queries-test.xml
+++ b/modules/platforms/cpp/odbc-test/config/queries-test.xml
@@ -25,14 +25,7 @@
         http://www.springframework.org/schema/beans/spring-beans.xsd">
 
     <!-- Imports no-ODBC Ignite configuration -->
-    <import resource="queries-default.xml"/>
+    <import resource="queries-test-default.xml"/>
 
-    <bean parent="ignite.cfg">
-        <!-- Enabling ODBC. -->
-        <property name="odbcConfiguration">
-            <bean class="org.apache.ignite.configuration.OdbcConfiguration">
-                <property name="endpointAddress" value="127.0.0.1:11110"/>
-            </bean>
-        </property>
-    </bean>
+    <bean parent="queries.cfg"/>
 </beans>

http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
index 0f467f7..7e9c738 100644
--- a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
+++ b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
@@ -209,7 +209,10 @@
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\config\queries-default.xml" />
+    <None Include="..\..\config\queries-test-noodbc-32.xml" />
     <None Include="..\..\config\queries-test-noodbc.xml" />
+    <None Include="..\..\config\queries-test-default.xml" />
+    <None Include="..\..\config\queries-test-32.xml" />
     <None Include="..\..\config\queries-test.xml" />
   </ItemGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
index a4d3292..6efc4b4 100644
--- a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
+++ b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
@@ -137,9 +137,15 @@
     </ClInclude>
   </ItemGroup>
   <ItemGroup>
+    <None Include="..\..\config\queries-test-32.xml">
+      <Filter>Configs</Filter>
+    </None>
     <None Include="..\..\config\queries-test.xml">
       <Filter>Configs</Filter>
     </None>
+    <None Include="..\..\config\queries-test-noodbc-32.xml">
+      <Filter>Configs</Filter>
+    </None>
     <None Include="..\..\config\queries-test-noodbc.xml">
       <Filter>Configs</Filter>
     </None>

http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/modules/platforms/cpp/odbc-test/src/api_robustness_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/api_robustness_test.cpp b/modules/platforms/cpp/odbc-test/src/api_robustness_test.cpp
index c0c68bf..3681ea1 100644
--- a/modules/platforms/cpp/odbc-test/src/api_robustness_test.cpp
+++ b/modules/platforms/cpp/odbc-test/src/api_robustness_test.cpp
@@ -114,7 +114,15 @@ struct ApiRobustnessTestSuiteFixture
 
     static Ignite StartAdditionalNode(const char* name)
     {
-        return StartNode("queries-test-noodbc.xml", name);
+        const char* config = NULL;
+
+#ifdef IGNITE_TESTS_32
+        config = "queries-test-noodbc-32.xml";
+#else
+        config = "queries-test-noodbc.xml";
+#endif
+
+        return StartNode(config, name);
     }
 
     /**
@@ -126,7 +134,15 @@ struct ApiRobustnessTestSuiteFixture
         dbc(NULL),
         stmt(NULL)
     {
-        grid = StartNode("queries-test.xml", "NodeMain");
+        const char* config = NULL;
+
+#ifdef IGNITE_TESTS_32
+          config = "queries-test-32.xml";
+#else
+          config = "queries-test.xml";
+#endif
+
+        grid = StartNode(config, "NodeMain");
 
         testCache = grid.GetCache<int64_t, TestType>("cache");
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/modules/platforms/cpp/odbc-test/src/queries_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/queries_test.cpp b/modules/platforms/cpp/odbc-test/src/queries_test.cpp
index 99f2994..eb0904f 100644
--- a/modules/platforms/cpp/odbc-test/src/queries_test.cpp
+++ b/modules/platforms/cpp/odbc-test/src/queries_test.cpp
@@ -116,7 +116,11 @@ struct QueriesTestSuiteFixture
 
     static Ignite StartAdditionalNode(const char* name)
     {
+#ifdef IGNITE_TESTS_32
+        return StartNode("queries-test-noodbc-32.xml", name);
+#else
         return StartNode("queries-test-noodbc.xml", name);
+#endif
     }
 
     /**
@@ -129,7 +133,11 @@ struct QueriesTestSuiteFixture
         dbc(NULL),
         stmt(NULL)
     {
+#ifdef IGNITE_TESTS_32
+        grid = StartNode("queries-test-32.xml", "NodeMain");
+#else
         grid = StartNode("queries-test.xml", "NodeMain");
+#endif
 
         cache1 = grid.GetCache<int64_t, TestType>("cache");
         cache2 = grid.GetCache<int64_t, ComplexType>("cache2");

http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/modules/platforms/cpp/odbc-test/src/sql_test_suite_fixture.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/sql_test_suite_fixture.cpp b/modules/platforms/cpp/odbc-test/src/sql_test_suite_fixture.cpp
index 03e4396..0f82fd0 100644
--- a/modules/platforms/cpp/odbc-test/src/sql_test_suite_fixture.cpp
+++ b/modules/platforms/cpp/odbc-test/src/sql_test_suite_fixture.cpp
@@ -29,7 +29,11 @@ namespace ignite
         dbc(NULL),
         stmt(NULL)
     {
+#ifdef IGNITE_TESTS_32
+        grid = StartNode("queries-test-32.xml");
+#else
         grid = StartNode("queries-test.xml");
+#endif
 
         testCache = grid.GetCache<int64_t, TestType>("cache");
 
@@ -306,7 +310,7 @@ namespace ignite
         Date actual = common::MakeDateGmt(res.year, res.month, res.day);
         BOOST_REQUIRE_EQUAL(actual.GetSeconds(), expected.GetSeconds());
     }
-    
+
     template<>
     void SqlTestSuiteFixture::CheckSingleResult<Timestamp>(const char* request, const Timestamp& expected)
     {


[12/34] ignite git commit: Merge branch 'ignite-3477-master' of https://github.com/gridgain/apache-ignite into ignite-3477-master

Posted by ag...@apache.org.
Merge branch 'ignite-3477-master' of https://github.com/gridgain/apache-ignite into ignite-3477-master


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

Branch: refs/heads/ignite-3477-master
Commit: 649c1e4d41da1722ca37624cfc31703f366f81d6
Parents: d2b8ee6 9642cbd
Author: Sergey Chugunov <se...@gmail.com>
Authored: Wed Mar 29 19:03:35 2017 +0300
Committer: Sergey Chugunov <se...@gmail.com>
Committed: Wed Mar 29 19:03:35 2017 +0300

----------------------------------------------------------------------
 .../dht/atomic/GridDhtAtomicCache.java          |   5 +
 .../cache/transactions/IgniteTxManager.java     |   2 +
 .../binary/BinaryObjectExceptionSelfTest.java   | 209 -------------------
 .../GridCacheAbstractFailoverSelfTest.java      |   4 +
 .../IgniteBinaryObjectsTestSuite.java           |   2 -
 5 files changed, 11 insertions(+), 211 deletions(-)
----------------------------------------------------------------------



[18/34] ignite git commit: IGNITE-3477 - Fixing segmented queries

Posted by ag...@apache.org.
IGNITE-3477 - Fixing segmented queries


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

Branch: refs/heads/ignite-3477-master
Commit: 96286f215ea35dd62fa619109cf6bb6edb5b74f8
Parents: 2bcf8f5
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Tue Mar 28 19:32:29 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Wed Mar 29 19:29:37 2017 +0300

----------------------------------------------------------------------
 .../processors/query/h2/database/H2TreeIndex.java | 18 +++++++-----------
 .../cache/IgniteCacheAbstractQuerySelfTest.java   | 13 ++++++++-----
 .../near/IgniteCachePartitionedQuerySelfTest.java |  2 +-
 3 files changed, 16 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/96286f21/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2TreeIndex.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2TreeIndex.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2TreeIndex.java
index 0185fa5..74ff9c7 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2TreeIndex.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2TreeIndex.java
@@ -155,7 +155,7 @@ public class H2TreeIndex extends GridH2IndexBase {
 
     /** {@inheritDoc} */
     @Override protected int segmentsCount() {
-        return 1;
+        return segments.length;
     }
 
     /** {@inheritDoc} */
@@ -184,7 +184,7 @@ public class H2TreeIndex extends GridH2IndexBase {
     /** {@inheritDoc} */
     @Override public GridH2Row findOne(GridH2Row row) {
         try {
-            int seg = threadLocalSegment();
+            int seg = segmentForRow(row);
 
             H2Tree tree = treeForRead(seg);
 
@@ -200,7 +200,7 @@ public class H2TreeIndex extends GridH2IndexBase {
         try {
             InlineIndexHelper.setCurrentInlineIndexes(inlineIdxs);
 
-            int seg = threadLocalSegment();
+            int seg = segmentForRow(row);
 
             H2Tree tree = treeForRead(seg);
 
@@ -219,7 +219,7 @@ public class H2TreeIndex extends GridH2IndexBase {
         try {
             InlineIndexHelper.setCurrentInlineIndexes(inlineIdxs);
 
-            int seg = threadLocalSegment();
+            int seg = segmentForRow(row);
 
             H2Tree tree = treeForRead(seg);
 
@@ -238,7 +238,7 @@ public class H2TreeIndex extends GridH2IndexBase {
         try {
             InlineIndexHelper.setCurrentInlineIndexes(inlineIdxs);
 
-            int seg = threadLocalSegment();
+            int seg = segmentForRow(row);
 
             H2Tree tree = treeForRead(seg);
 
@@ -257,7 +257,7 @@ public class H2TreeIndex extends GridH2IndexBase {
         try {
             InlineIndexHelper.setCurrentInlineIndexes(inlineIdxs);
 
-            int seg = threadLocalSegment();
+            int seg = segmentForRow(row);
 
             H2Tree tree = treeForRead(seg);
 
@@ -348,11 +348,7 @@ public class H2TreeIndex extends GridH2IndexBase {
         @Nullable SearchRow last,
         IndexingQueryFilter filter) {
         try {
-            int seg = threadLocalSegment();
-
-            H2Tree tree = treeForRead(seg);
-
-            GridCursor<GridH2Row> range = tree.find(first, last);
+            GridCursor<GridH2Row> range = t.find(first, last);
 
             if (range == null)
                 return EMPTY_CURSOR;

http://git-wip-us.apache.org/repos/asf/ignite/blob/96286f21/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
index 82e83ca..c1e54cd 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
@@ -205,7 +205,9 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
 
         qryEntity.setIndexes(Arrays.asList(strIdx));
 
-        entityList.add(qryEntity);cc.setQueryEntities(entityList);
+        entityList.add(qryEntity);
+
+        cc.setQueryEntities(entityList);
 
         if (cacheMode() != CacheMode.LOCAL)
             cc.setAffinity(new RendezvousAffinityFunction());
@@ -259,6 +261,7 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
     /** {@inheritDoc} */
     @Override protected void afterTest() throws Exception {
         super.afterTest();
+
         for(String cacheName : ignite().cacheNames())
             ignite().cache(cacheName).removeAll();
     }
@@ -366,7 +369,7 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
      * @throws Exception In case of error.
      */
     public void testTableAliasInSqlQuery() throws Exception {
-        IgniteCache<Integer, Integer> cache = ignite().cache(null);
+        IgniteCache<Integer, Integer> cache = jcache(Integer.class, Integer.class);
 
         int key = 898;
 
@@ -657,7 +660,7 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
      * @throws Exception In case of error.
      */
     public void testMixedCustomTableName() throws Exception {
-        final IgniteCache<Integer, Object> cache = ignite().cache(null);
+        final IgniteCache<Integer, Object> cache = jcache(Integer.class, Object.class);
 
         cache.put(10, new Type1(1, "Type1 record #1"));
         cache.put(20, new Type1(2, "Type1 record #2"));
@@ -703,7 +706,7 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
      * @throws Exception In case of error.
      */
     public void testDistributedJoinCustomTableName() throws Exception {
-        IgniteCache<Integer, Object> cache = ignite().cache(null);
+        IgniteCache<Integer, Object> cache = jcache(Integer.class, Object.class);
 
         cache.put(10, new Type1(1, "Type1 record #1"));
         cache.put(20, new Type1(2, "Type1 record #2"));
@@ -768,7 +771,7 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
      * @throws Exception In case of error.
      */
     public void testObjectWithString() throws Exception {
-        IgniteCache<Integer, ObjectValue2> cache = ignite().cache(null);
+        IgniteCache<Integer, ObjectValue2> cache = jcache(Integer.class, ObjectValue2.class);
 
         cache.put(1, new ObjectValue2("value 1"));
         cache.put(2, new ObjectValue2("value 2"));

http://git-wip-us.apache.org/repos/asf/ignite/blob/96286f21/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCachePartitionedQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCachePartitionedQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCachePartitionedQuerySelfTest.java
index db56fa4..30a825b 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCachePartitionedQuerySelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCachePartitionedQuerySelfTest.java
@@ -159,7 +159,7 @@ public class IgniteCachePartitionedQuerySelfTest extends IgniteCacheAbstractQuer
 
         final AtomicInteger pages = new AtomicInteger(0);
 
-        IgniteCache<Integer, Integer> cache = ignite().cache(null);
+        IgniteCache<Integer, Integer> cache = jcache(Integer.class, Integer.class);
 
         for (int i = 0; i < 50; i++)
             cache.put(i, i);


[10/34] ignite git commit: ignite-3477-master remove BinaryObjectExceptionSelfTest (unnecessary) update import

Posted by ag...@apache.org.
ignite-3477-master remove BinaryObjectExceptionSelfTest (unnecessary) update import


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

Branch: refs/heads/ignite-3477-master
Commit: 9642cbd584c44b790daa3ff6f27e0b23931fbca5
Parents: b30703a
Author: Dmitriy Govorukhin <dg...@gridgain.com>
Authored: Wed Mar 29 15:40:30 2017 +0300
Committer: Dmitriy Govorukhin <dg...@gridgain.com>
Committed: Wed Mar 29 15:40:30 2017 +0300

----------------------------------------------------------------------
 .../org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java | 2 --
 1 file changed, 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/9642cbd5/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java
index 1a348e0..3496dbf 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java
@@ -33,7 +33,6 @@ import org.apache.ignite.internal.binary.BinaryMarshallerSelfTest;
 import org.apache.ignite.internal.binary.BinaryObjectBuilderAdditionalSelfTest;
 import org.apache.ignite.internal.binary.BinaryObjectBuilderDefaultMappersSelfTest;
 import org.apache.ignite.internal.binary.BinaryObjectBuilderSimpleNameLowerCaseMappersSelfTest;
-import org.apache.ignite.internal.binary.BinaryObjectExceptionSelfTest;
 import org.apache.ignite.internal.binary.BinaryObjectToStringSelfTest;
 import org.apache.ignite.internal.binary.BinarySerialiedFieldComparatorSelfTest;
 import org.apache.ignite.internal.binary.BinarySimpleNameTestPropertySelfTest;
@@ -94,7 +93,6 @@ public class IgniteBinaryObjectsTestSuite extends TestSuite {
 
         suite.addTestSuite(BinaryTreeSelfTest.class);
         suite.addTestSuite(BinaryMarshallerSelfTest.class);
-        suite.addTestSuite(BinaryObjectExceptionSelfTest.class);
 
         suite.addTestSuite(BinarySerialiedFieldComparatorSelfTest.class);
         suite.addTestSuite(BinaryArrayIdentityResolverSelfTest.class);


[04/34] ignite git commit: IGNITE-3477 - Fixed query arguments in JettyRestProcessorAbstractSelfTest

Posted by ag...@apache.org.
IGNITE-3477 - Fixed query arguments in JettyRestProcessorAbstractSelfTest


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

Branch: refs/heads/ignite-3477-master
Commit: 75d0e7dd5db9df8c18f0378c05a3e41b34b41327
Parents: 9ef380e
Author: Ivan Rakov <iv...@gmail.com>
Authored: Wed Mar 29 15:00:41 2017 +0300
Committer: Ivan Rakov <iv...@gmail.com>
Committed: Wed Mar 29 15:00:41 2017 +0300

----------------------------------------------------------------------
 .../processors/rest/JettyRestProcessorAbstractSelfTest.java       | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/75d0e7dd/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
index f749a71..7433791 100644
--- a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
+++ b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
@@ -1403,7 +1403,8 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
 
         ret = content(new VisorGatewayArgument(VisorQueryTask.class)
             .forNode(locNode)
-            .argument(VisorQueryArg.class, "person", URLEncoder.encode("select * from Person", CHARSET), false, false, 1));
+            .argument(VisorQueryArg.class, "person", URLEncoder.encode("select * from Person", CHARSET), false, false,
+                false, 1));
 
         info("VisorQueryTask result: " + ret);
 


[22/34] ignite git commit: IGNITE-3477 - Fixed error message

Posted by ag...@apache.org.
IGNITE-3477 - Fixed error message


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

Branch: refs/heads/ignite-3477-master
Commit: 95b48a9ab61a90daf13b51d5ffc06c67de49545a
Parents: 7ac0fd0
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Wed Mar 29 15:37:12 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Wed Mar 29 19:29:38 2017 +0300

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


http://git-wip-us.apache.org/repos/asf/ignite/blob/95b48a9a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
index cfeb9d4..04c6ff2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
@@ -3202,7 +3202,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
                 }
             }
             catch (NodeStoppingException e){
-                U.error(log, "Failed to update key:" + key + " on backup, node stopping", e);
+                U.error(log, "Failed to update key on backup (local node is stopping):" + key, e);
 
                 return;
             }


[31/34] ignite git commit: Merge branch 'ignite-3477-master' of https://github.com/gridgain/apache-ignite into ignite-3477-master

Posted by ag...@apache.org.
Merge branch 'ignite-3477-master' of https://github.com/gridgain/apache-ignite into ignite-3477-master


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

Branch: refs/heads/ignite-3477-master
Commit: 6cd6978f9f02a3efc34cbdd7412d7968cbf653e0
Parents: fb32854 fd8ea27
Author: Sergey Chugunov <se...@gmail.com>
Authored: Thu Mar 30 18:38:36 2017 +0300
Committer: Sergey Chugunov <se...@gmail.com>
Committed: Thu Mar 30 18:38:36 2017 +0300

----------------------------------------------------------------------
 .../internal/processors/cache/CacheConfigurationLeakTest.java      | 1 +
 .../processors/cache/MemoryPolicyConfigValidationTest.java         | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------



[33/34] ignite git commit: Merge remote-tracking branch 'professional/ignite-3477-master' into ignite-3477-master

Posted by ag...@apache.org.
Merge remote-tracking branch 'professional/ignite-3477-master' into ignite-3477-master


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

Branch: refs/heads/ignite-3477-master
Commit: 2859bd0c170f4eb47d4ffce5834f1f7553cbd091
Parents: f767925 6cd6978
Author: Dmitriy Govorukhin <dg...@gridgain.com>
Authored: Thu Mar 30 18:41:47 2017 +0300
Committer: Dmitriy Govorukhin <dg...@gridgain.com>
Committed: Thu Mar 30 18:41:47 2017 +0300

----------------------------------------------------------------------
 .../processors/cache/IgniteCacheInsertSqlQuerySelfTest.java      | 4 ++++
 .../processors/cache/IgniteCacheMergeSqlQuerySelfTest.java       | 4 ++++
 2 files changed, 8 insertions(+)
----------------------------------------------------------------------



[05/34] ignite git commit: GridH2TableSelfTest tests fixes (one is still failing)

Posted by ag...@apache.org.
GridH2TableSelfTest tests fixes (one is still failing)


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

Branch: refs/heads/ignite-3477-master
Commit: be93b91d31c888d6f088f451732660baeee14a76
Parents: 9ef380e
Author: Sergey Chugunov <se...@gmail.com>
Authored: Wed Mar 29 15:01:26 2017 +0300
Committer: Sergey Chugunov <se...@gmail.com>
Committed: Wed Mar 29 15:01:26 2017 +0300

----------------------------------------------------------------------
 .../processors/query/h2/opt/GridH2Table.java        | 16 ++++++++--------
 .../processors/query/h2/opt/GridH2TreeIndex.java    | 16 +++++++++-------
 .../query/h2/opt/GridH2TableSelfTest.java           |  3 ++-
 3 files changed, 19 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/be93b91d/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java
index 60eecd8..12f799a 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java
@@ -396,11 +396,11 @@ public class GridH2Table extends TableBase {
         assert snapshotEnabled;
 
         if (snapshots == null) // Nothing to reuse, create new snapshots.
-            snapshots = new Object[idxs.size() - 1];
+            snapshots = new Object[idxs.size() - 2];
 
-        // Take snapshots on all except first which is scan.
-        for (int i = 1, len = idxs.size(); i < len; i++) {
-            Object s = snapshots[i - 1];
+        // Take snapshots on all except first which is scan and second which is hash.
+        for (int i = 2, len = idxs.size(); i < len; i++) {
+            Object s = snapshots[i - 2];
 
             boolean reuseExisting = s != null;
 
@@ -411,7 +411,7 @@ public class GridH2Table extends TableBase {
                 if (qctx != null)
                     qctx.clearSnapshots();
 
-                for (int j = 1; j < i; j++)
+                for (int j = 2; j < i; j++)
                     index(j).releaseSnapshot();
 
                 // Drop invalidated snapshot.
@@ -420,7 +420,7 @@ public class GridH2Table extends TableBase {
                 return null;
             }
 
-            snapshots[i - 1] = s;
+            snapshots[i - 2] = s;
         }
 
         return snapshots;
@@ -480,8 +480,8 @@ public class GridH2Table extends TableBase {
      * @param idxs Indexes.
      */
     private void releaseSnapshots0(ArrayList<Index> idxs) {
-        // Release snapshots on all except first which is scan.
-        for (int i = 1, len = idxs.size(); i < len; i++)
+        // Release snapshots on all except first which is scan and second which is hash.
+        for (int i = 2, len = idxs.size(); i < len; i++)
             ((GridH2IndexBase)idxs.get(i)).releaseSnapshot();
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/be93b91d/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TreeIndex.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TreeIndex.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TreeIndex.java
index 9180b89..d28b99e 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TreeIndex.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TreeIndex.java
@@ -17,18 +17,20 @@
 
 package org.apache.ignite.internal.processors.query.h2.opt;
 
-import java.util.*;
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.List;
+import java.util.NavigableMap;
 import java.util.concurrent.ConcurrentSkipListMap;
-
-import org.apache.ignite.*;
-import org.apache.ignite.internal.processors.query.h2.*;
-import org.apache.ignite.internal.util.*;
-import org.apache.ignite.internal.util.lang.*;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.internal.processors.query.h2.H2Cursor;
+import org.apache.ignite.internal.util.GridCursorIteratorWrapper;
+import org.apache.ignite.internal.util.IgniteTree;
+import org.apache.ignite.internal.util.lang.GridCursor;
 import org.apache.ignite.internal.util.offheap.unsafe.GridOffHeapSnapTreeMap;
 import org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeGuard;
 import org.apache.ignite.internal.util.snaptree.SnapTreeMap;
 import org.apache.ignite.internal.util.typedef.internal.SB;
-import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.spi.indexing.IndexingQueryFilter;
 import org.h2.engine.Session;
 import org.h2.index.Cursor;

http://git-wip-us.apache.org/repos/asf/ignite/blob/be93b91d/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TableSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TableSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TableSelfTest.java
index f64b91b..f9388ef 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TableSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TableSelfTest.java
@@ -33,6 +33,7 @@ import java.util.UUID;
 import java.util.concurrent.Callable;
 import java.util.concurrent.atomic.AtomicInteger;
 import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.internal.processors.query.h2.database.H2PkHashIndex;
 import org.apache.ignite.internal.processors.query.h2.database.H2RowFactory;
 import org.apache.ignite.internal.util.lang.GridCursor;
 import org.apache.ignite.internal.util.typedef.F;
@@ -104,8 +105,8 @@ public class GridH2TableSelfTest extends GridCommonAbstractTest {
                 IndexColumn str = tbl.indexColumn(2, SortOrder.DESCENDING);
                 IndexColumn x = tbl.indexColumn(3, SortOrder.DESCENDING);
 
+                idxs.add(new H2PkHashIndex(null, tbl, HASH, F.asList(id)));
                 idxs.add(new GridH2TreeIndex(PK_NAME, tbl, true, F.asList(id)));
-                idxs.add(new GridH2TreeIndex(HASH, tbl, true, F.asList(id)));
                 idxs.add(new GridH2TreeIndex(NON_UNIQUE_IDX_NAME, tbl, false, F.asList(x, t, id)));
                 idxs.add(new GridH2TreeIndex(STR_IDX_NAME, tbl, false, F.asList(str, id)));
 


[24/34] ignite git commit: Grids were not stopped in two tests leading to errors in other tests

Posted by ag...@apache.org.
Grids were not stopped in two tests leading to errors in other tests


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

Branch: refs/heads/ignite-3477-master
Commit: 3fcab0df64184871d2238e09e127c1816402cb2d
Parents: 9f40516
Author: Sergey Chugunov <se...@gmail.com>
Authored: Thu Mar 30 12:31:04 2017 +0300
Committer: Sergey Chugunov <se...@gmail.com>
Committed: Thu Mar 30 12:31:04 2017 +0300

----------------------------------------------------------------------
 .../processors/cache/IncorrectCacheTypeMetadataTest.java     | 8 ++++++--
 .../internal/processors/cache/IncorrectQueryEntityTest.java  | 8 ++++++--
 2 files changed, 12 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/3fcab0df/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IncorrectCacheTypeMetadataTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IncorrectCacheTypeMetadataTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IncorrectCacheTypeMetadataTest.java
index 9695ffb..e994fb3 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IncorrectCacheTypeMetadataTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IncorrectCacheTypeMetadataTest.java
@@ -64,9 +64,13 @@ public class IncorrectCacheTypeMetadataTest extends GridCommonAbstractTest {
         catch (Exception exception) {
             if (!exception.getMessage().contains(
                 QueryUtils.propertyInitializationExceptionMessage(
-                    Object.class, Object.class, "exceptionOid", Object.class))) {
+                    Object.class, Object.class, "exceptionOid", Object.class)))
                 fail("property initialization exception must be thrown, but got " + exception.getMessage());
-            }
         }
     }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        stopAllGrids();
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/3fcab0df/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IncorrectQueryEntityTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IncorrectQueryEntityTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IncorrectQueryEntityTest.java
index 9bdadc6..e71a77e 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IncorrectQueryEntityTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IncorrectQueryEntityTest.java
@@ -67,9 +67,13 @@ public class IncorrectQueryEntityTest extends GridCommonAbstractTest {
         catch (Exception exception) {
             if (!exception.getMessage().contains(
                 QueryUtils.propertyInitializationExceptionMessage(
-                    Object.class, Object.class, "exceptionOid", Object.class))) {
+                    Object.class, Object.class, "exceptionOid", Object.class)))
                 fail("property initialization exception must be thrown, but got " + exception.getMessage());
-            }
         }
     }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        stopAllGrids();
+    }
 }


[26/34] ignite git commit: ignite-3477-master fix MarshallerContextSelfTest.testOnUpdated

Posted by ag...@apache.org.
ignite-3477-master fix MarshallerContextSelfTest.testOnUpdated


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

Branch: refs/heads/ignite-3477-master
Commit: c48e3d6288226737b1b0e9ad698481dce9dbdbf8
Parents: 3fcab0d
Author: Dmitriy Govorukhin <dg...@gridgain.com>
Authored: Thu Mar 30 15:23:38 2017 +0300
Committer: Dmitriy Govorukhin <dg...@gridgain.com>
Committed: Thu Mar 30 15:23:38 2017 +0300

----------------------------------------------------------------------
 .../ignite/marshaller/MarshallerContextSelfTest.java   | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/c48e3d62/modules/core/src/test/java/org/apache/ignite/marshaller/MarshallerContextSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/marshaller/MarshallerContextSelfTest.java b/modules/core/src/test/java/org/apache/ignite/marshaller/MarshallerContextSelfTest.java
index 5883898..48d971e 100644
--- a/modules/core/src/test/java/org/apache/ignite/marshaller/MarshallerContextSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/marshaller/MarshallerContextSelfTest.java
@@ -31,12 +31,15 @@ import org.apache.ignite.internal.MarshallerContextImpl;
 import org.apache.ignite.internal.processors.closure.GridClosureProcessor;
 import org.apache.ignite.internal.processors.marshaller.MarshallerMappingItem;
 import org.apache.ignite.internal.processors.pool.PoolProcessor;
+import org.apache.ignite.internal.util.typedef.PA;
 import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.testframework.GridTestUtils;
 import org.apache.ignite.testframework.junits.GridTestKernalContext;
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 
 import static java.nio.file.Files.readAllBytes;
 import static org.apache.ignite.internal.MarshallerPlatformIds.JAVA_ID;
+import static org.apache.ignite.testframework.GridTestUtils.waitForCondition;
 
 /**
  * Test marshaller context.
@@ -95,6 +98,9 @@ public class MarshallerContextSelfTest extends GridCommonAbstractTest {
 
         ctx.onMappingAccepted(item1);
 
+        // Wait until marshaller context write class to file.
+        U.sleep(2_000);
+
         checkFileName("java.lang.String", Paths.get(workDir + "/1.classname0"));
 
         MarshallerMappingItem item2 = new MarshallerMappingItem((byte) 2, 2, "Random.Class.Name");
@@ -103,6 +109,7 @@ public class MarshallerContextSelfTest extends GridCommonAbstractTest {
         ctx.onMappingAccepted(item2);
 
         execSvc.shutdown();
+
         if (execSvc.awaitTermination(1000, TimeUnit.MILLISECONDS))
             checkFileName("Random.Class.Name", Paths.get(workDir + "/2.classname2"));
         else
@@ -181,6 +188,10 @@ public class MarshallerContextSelfTest extends GridCommonAbstractTest {
      * @param pathToReal Path to real.
      */
     private void checkFileName(String expected, Path pathToReal) throws IOException {
-        assertEquals(expected, new String(readAllBytes(pathToReal)));
+        byte[] fileContent = readAllBytes(pathToReal);
+
+        assert fileContent != null && fileContent.length > 0;
+
+        assertEquals(expected, new String(fileContent));
     }
 }


[23/34] ignite git commit: IGNITE-3477 - Fixing exceptions test

Posted by ag...@apache.org.
IGNITE-3477 - Fixing exceptions test


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

Branch: refs/heads/ignite-3477-master
Commit: 9f40516e5ec29f1ead4eff6dbc9d3784f5555e52
Parents: 95b48a9
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Wed Mar 29 19:25:26 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Wed Mar 29 19:29:38 2017 +0300

----------------------------------------------------------------------
 .../internal/processors/cache/IgniteCacheOffheapManagerImpl.java  | 3 +--
 .../internal/processors/cache/query/GridCacheQueryManager.java    | 3 ++-
 2 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/9f40516e/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 88cb708..8b8de19 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
@@ -1109,8 +1109,7 @@ public class IgniteCacheOffheapManagerImpl extends GridCacheManagerAdapter imple
             try {
                 CacheDataRow oldRow = dataTree.remove(new SearchRow(key));
 
-                if (oldRow != null)
-                    finishRemove(key, oldRow);
+                finishRemove(key, oldRow);
             }
             finally {
                 busyLock.leaveBusy();

http://git-wip-us.apache.org/repos/asf/ignite/blob/9f40516e/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
index 00a4b2e..e1ed3c5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
@@ -506,7 +506,8 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
                 cctx.kernalContext().indexing().remove(space, key0);
             }
 
-            if(qryProcEnabled)
+            // val may be null if we have no previous value. We should not call processor in this case.
+            if(qryProcEnabled && val != null)
                 qryProc.remove(space, key, partId, val, ver);
         }
         finally {


[02/34] ignite git commit: ignite-3477-master fix IgniteDaemonNodeMarshallerCacheTest.testMarshalOnDaemonNode1

Posted by ag...@apache.org.
ignite-3477-master fix IgniteDaemonNodeMarshallerCacheTest.testMarshalOnDaemonNode1


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

Branch: refs/heads/ignite-3477-master
Commit: 5626f1c0736a1fe6b4ee0435ee642289885236d7
Parents: 6d7eb44
Author: Dmitriy Govorukhin <dg...@gridgain.com>
Authored: Mon Mar 27 18:13:20 2017 +0300
Committer: Dmitriy Govorukhin <dg...@gridgain.com>
Committed: Mon Mar 27 18:13:20 2017 +0300

----------------------------------------------------------------------
 .../internal/processors/cluster/GridClusterStateProcessor.java  | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/5626f1c0/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/GridClusterStateProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/GridClusterStateProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/GridClusterStateProcessor.java
index e5919e0..1286ba9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/GridClusterStateProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/GridClusterStateProcessor.java
@@ -219,7 +219,10 @@ public class GridClusterStateProcessor extends GridProcessorAdapter {
 
     /** {@inheritDoc} */
     @Override public void onGridDataReceived(DiscoveryDataBag.GridDiscoveryData data) {
-        globalState = (ClusterState)data.commonData();
+        ClusterState state = (ClusterState)data.commonData();
+
+        if (state != null)
+            globalState = state;
     }
 
     /**


[29/34] ignite git commit: ignite-3477-master fix MemoryPolicyConfigValidationTest.testMissingUserDefinedDefault

Posted by ag...@apache.org.
ignite-3477-master fix MemoryPolicyConfigValidationTest.testMissingUserDefinedDefault


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

Branch: refs/heads/ignite-3477-master
Commit: fd8ea27daf91a74642d5939e1ab8f2c7861a46fb
Parents: 50acffa
Author: Dmitriy Govorukhin <dg...@gridgain.com>
Authored: Thu Mar 30 16:25:47 2017 +0300
Committer: Dmitriy Govorukhin <dg...@gridgain.com>
Committed: Thu Mar 30 16:25:47 2017 +0300

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


http://git-wip-us.apache.org/repos/asf/ignite/blob/fd8ea27d/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 6b93936..c0f74d0 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
@@ -226,7 +226,7 @@ public class MemoryPolicyConfigValidationTest extends GridCommonAbstractTest {
         NULL_NAME_ON_USER_DEFINED_POLICY("User-defined MemoryPolicyConfiguration must have non-null and non-empty name."),
 
         /** */
-        MISSING_USER_DEFINED_DEFAULT("User-defined default MemoryPolicy name is not presented among configured MemoryPolicies: ");
+        MISSING_USER_DEFINED_DEFAULT("User-defined default MemoryPolicy name must be presented among configured MemoryPolices: ");
 
         /**
          * @param violationMsg Violation message.


[14/34] ignite git commit: Use PRIMARY atomicWriteOrderMode for test.

Posted by ag...@apache.org.
Use PRIMARY atomicWriteOrderMode for test.


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

Branch: refs/heads/ignite-3477-master
Commit: 594cd3e93538b7ad0b548a42547e0ea4f535418c
Parents: ec5923a
Author: sboikov <sb...@gridgain.com>
Authored: Tue Mar 21 18:11:02 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Wed Mar 29 19:29:36 2017 +0300

----------------------------------------------------------------------
 .../cache/GridAbstractCacheInterceptorRebalanceTest.java          | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/594cd3e9/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridAbstractCacheInterceptorRebalanceTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridAbstractCacheInterceptorRebalanceTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridAbstractCacheInterceptorRebalanceTest.java
index b7d7170..0812fcc 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridAbstractCacheInterceptorRebalanceTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridAbstractCacheInterceptorRebalanceTest.java
@@ -23,7 +23,6 @@ import javax.cache.Cache;
 import javax.cache.processor.EntryProcessor;
 import javax.cache.processor.EntryProcessorException;
 import javax.cache.processor.MutableEntry;
-
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.cache.CacheAtomicityMode;
 import org.apache.ignite.cache.CacheInterceptor;
@@ -43,6 +42,7 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 import org.apache.ignite.transactions.Transaction;
 import org.jetbrains.annotations.Nullable;
 
+import static org.apache.ignite.cache.CacheAtomicWriteOrderMode.PRIMARY;
 import static org.apache.ignite.cache.CacheRebalanceMode.SYNC;
 import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
 import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
@@ -85,6 +85,7 @@ public abstract class GridAbstractCacheInterceptorRebalanceTest extends GridComm
 
         ccfg.setInterceptor(interceptor);
         ccfg.setAtomicityMode(atomicityMode());
+        ccfg.setAtomicWriteOrderMode(PRIMARY);
         ccfg.setWriteSynchronizationMode(FULL_SYNC);
         ccfg.setRebalanceMode(SYNC);
         ccfg.setBackups(2);


[06/34] ignite git commit: Merge branch 'ignite-3477-master' of https://github.com/gridgain/apache-ignite into ignite-3477-master

Posted by ag...@apache.org.
Merge branch 'ignite-3477-master' of https://github.com/gridgain/apache-ignite into ignite-3477-master


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

Branch: refs/heads/ignite-3477-master
Commit: b3f953a73d8ee746f742a9e8b90706e63b68617a
Parents: be93b91 75d0e7d
Author: Sergey Chugunov <se...@gmail.com>
Authored: Wed Mar 29 15:02:04 2017 +0300
Committer: Sergey Chugunov <se...@gmail.com>
Committed: Wed Mar 29 15:02:04 2017 +0300

----------------------------------------------------------------------
 .../processors/rest/JettyRestProcessorAbstractSelfTest.java       | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------



[16/34] ignite git commit: ignite-4712 Memory leaks in PageMemory

Posted by ag...@apache.org.
ignite-4712 Memory leaks in PageMemory


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

Branch: refs/heads/ignite-3477-master
Commit: 0308e689472801d3e520ebe32220dfc98d4cdd61
Parents: 649c1e4
Author: sboikov <sb...@gridgain.com>
Authored: Thu Mar 16 10:37:02 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Wed Mar 29 19:29:36 2017 +0300

----------------------------------------------------------------------
 .../cache/database/freelist/PagesList.java      | 221 +++++++----
 .../ignite/cache/LargeEntryUpdateTest.java      | 177 +++++++++
 .../database/IgniteDbAbstractTest.java          | 369 +++++++++++++++++++
 .../IgniteDbMemoryLeakAbstractTest.java         | 265 +++++++++++++
 .../IgniteDbMemoryLeakLargeObjectsTest.java     |  56 +++
 .../IgniteDbMemoryLeakLargePagesTest.java       |  33 ++
 .../IgniteDbMemoryLeakNonTransactionalTest.java |  31 ++
 .../database/IgniteDbMemoryLeakTest.java        |  46 +++
 .../IgniteDbMemoryLeakWithExpirationTest.java   |  44 +++
 .../database/IgniteDbPutGetAbstractTest.java    | 331 +----------------
 .../testsuites/IgniteDbMemoryLeakTestSuite.java |  49 +++
 .../database/IgniteDbMemoryLeakIndexedTest.java |  33 ++
 .../IgniteDbMemoryLeakSqlQueryTest.java         |  76 ++++
 ...IgniteDbMemoryLeakWithIndexingTestSuite.java |  40 ++
 14 files changed, 1369 insertions(+), 402 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/0308e689/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/freelist/PagesList.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/freelist/PagesList.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/freelist/PagesList.java
index e5430cf..5c66b10 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/freelist/PagesList.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/freelist/PagesList.java
@@ -22,6 +22,7 @@ import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.atomic.AtomicLong;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteSystemProperties;
 import org.apache.ignite.internal.pagemem.Page;
@@ -51,7 +52,6 @@ import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.jetbrains.annotations.Nullable;
-import org.jsr166.LongAdder8;
 
 import static java.lang.Boolean.FALSE;
 import static java.lang.Boolean.TRUE;
@@ -76,10 +76,7 @@ public abstract class PagesList extends DataStructure {
             Math.min(8, Runtime.getRuntime().availableProcessors() * 2));
 
     /** */
-    private final boolean trackBucketsSize = IgniteSystemProperties.getBoolean("IGNITE_PAGES_LIST_TRACK_SIZE", false);
-
-    /** */
-    protected final LongAdder8[] bucketsSize;
+    protected final AtomicLong[] bucketsSize;
 
     /** Page ID to store list metadata. */
     private final long metaPageId;
@@ -117,7 +114,7 @@ public abstract class PagesList extends DataStructure {
 
             return TRUE;
         }
-    };
+    }
 
     /**
      * @param cacheId Cache ID.
@@ -142,10 +139,10 @@ public abstract class PagesList extends DataStructure {
         this.buckets = buckets;
         this.metaPageId = metaPageId;
 
-        bucketsSize = new LongAdder8[buckets];
+        bucketsSize = new AtomicLong[buckets];
 
         for (int i = 0; i < buckets; i++)
-            bucketsSize[i] = new LongAdder8();
+            bucketsSize[i] = new AtomicLong();
     }
 
     /**
@@ -191,6 +188,7 @@ public abstract class PagesList extends DataStructure {
 
                 for (Map.Entry<Integer, GridLongList> e : bucketsData.entrySet()) {
                     int bucket = e.getKey();
+                    long bucketSize = 0;
 
                     Stripe[] old = getBucket(bucket);
                     assert old == null;
@@ -199,11 +197,43 @@ public abstract class PagesList extends DataStructure {
 
                     Stripe[] tails = new Stripe[upd.length];
 
-                    for (int i = 0; i < upd.length; i++)
-                        tails[i] = new Stripe(upd[i]);
+                    for (int i = 0; i < upd.length; i++) {
+                        long tailId = upd[i];
+
+                        long pageId = tailId;
+                        int cnt = 0;
+
+                        while (pageId != 0L) {
+                            try (Page page = page(pageId)) {
+                                long pageAddr = readLock(page);
+
+                                assert pageAddr != 0L;
+
+                                try {
+                                    PagesListNodeIO io = PagesListNodeIO.VERSIONS.forPage(pageAddr);
+
+                                    cnt += io.getCount(pageAddr);
+                                    pageId = io.getPreviousId(pageAddr);
+
+                                    // In reuse bucket the page itself can be used as a free page.
+                                    if (isReuseBucket(bucket) && pageId != 0L)
+                                        cnt++;
+                                }
+                                finally {
+                                    readUnlock(page, pageAddr);
+                                }
+                            }
+                        }
+
+                        Stripe stripe = new Stripe(tailId, cnt == 0);
+                        tails[i] = stripe;
+                        bucketSize += cnt;
+                    }
 
                     boolean ok = casBucket(bucket, null, tails);
                     assert ok;
+
+                    bucketsSize[bucket].set(bucketSize);
                 }
             }
         }
@@ -363,7 +393,7 @@ public abstract class PagesList extends DataStructure {
             initPage(pageMem, page, this, PagesListNodeIO.VERSIONS.latest(), wal);
         }
 
-        Stripe stripe = new Stripe(pageId);
+        Stripe stripe = new Stripe(pageId, true);
 
         for (;;) {
             Stripe[] old = getBucket(bucket);
@@ -490,25 +520,32 @@ public abstract class PagesList extends DataStructure {
             for (Stripe tail : tails) {
                 long pageId = tail.tailId;
 
-                try (Page page = page(pageId)) {
-                    long pageAddr = readLock(page); // No correctness guaranties.
+                while (pageId != 0L) {
+                    try (Page page = page(pageId)) {
+                        long pageAddr = readLock(page);
 
-                    try {
-                        PagesListNodeIO io = PagesListNodeIO.VERSIONS.forPage(pageAddr);
+                        assert pageAddr != 0L;
 
-                        int cnt = io.getCount(pageAddr);
+                        try {
+                            PagesListNodeIO io = PagesListNodeIO.VERSIONS.forPage(pageAddr);
 
-                        assert cnt >= 0;
+                            res += io.getCount(pageAddr);
+                            pageId = io.getPreviousId(pageAddr);
 
-                        res += cnt;
-                    }
-                    finally {
-                        readUnlock(page, pageAddr);
+                            // In reuse bucket the page itself can be used as a free page.
+                            if (isReuseBucket(bucket) && pageId != 0L)
+                                res++;
+                        }
+                        finally {
+                            readUnlock(page, pageAddr);
+                        }
                     }
                 }
             }
         }
 
+        assert res == bucketsSize[bucket].get() : "Wrong bucket size counter [exp=" + res + ", cntr=" + bucketsSize[bucket].get() + ']';
+
         return res;
     }
 
@@ -600,8 +637,7 @@ public abstract class PagesList extends DataStructure {
         if (idx == -1)
             handlePageFull(pageId, page, pageAddr, io, dataPage, dataPageAddr, bucket);
         else {
-            if (trackBucketsSize)
-                bucketsSize[bucket].increment();
+            bucketsSize[bucket].incrementAndGet();
 
             if (isWalDeltaRecordNeeded(wal, page))
                 wal.log(new PagesListAddPageRecord(cacheId, pageId, dataPageId));
@@ -660,6 +696,9 @@ public abstract class PagesList extends DataStructure {
                     dataPageId,
                     pageId, 0L));
 
+            // In reuse bucket the page itself can be used as a free page.
+            bucketsSize[bucket].incrementAndGet();
+
             updateTail(bucket, pageId, dataPageId);
         }
         else {
@@ -695,14 +734,13 @@ public abstract class PagesList extends DataStructure {
 
                     assert idx != -1;
 
-                    if (trackBucketsSize)
-                        bucketsSize[bucket].increment();
-
                     dataIO.setFreeListPageId(dataPageAddr, nextId);
 
                     if (isWalDeltaRecordNeeded(wal, dataPage))
                         wal.log(new DataPageSetFreeListPageRecord(cacheId, dataPageId, nextId));
 
+                    bucketsSize[bucket].incrementAndGet();
+
                     updateTail(bucket, pageId, nextId);
                 }
                 finally {
@@ -778,6 +816,10 @@ public abstract class PagesList extends DataStructure {
                                 0L
                             ));
 
+                        // In reuse bucket the page itself can be used as a free page.
+                        if (isReuseBucket(bucket))
+                            bucketsSize[bucket].incrementAndGet();
+
                         // Switch to this new page, which is now a part of our list
                         // to add the rest of the bag to the new page.
                         prevPageAddr = nextPageAddr;
@@ -786,12 +828,11 @@ public abstract class PagesList extends DataStructure {
                     }
                 }
                 else {
-                    if (trackBucketsSize)
-                        bucketsSize[bucket].increment();
-
                     // TODO: use single WAL record for bag?
                     if (isWalDeltaRecordNeeded(wal, page))
                         wal.log(new PagesListAddPageRecord(cacheId, prevId, nextId));
+
+                    bucketsSize[bucket].incrementAndGet();
                 }
             }
         }
@@ -816,10 +857,22 @@ public abstract class PagesList extends DataStructure {
     private Stripe getPageForTake(int bucket) {
         Stripe[] tails = getBucket(bucket);
 
-        if (tails == null)
+        if (tails == null || bucketsSize[bucket].get() == 0)
             return null;
 
-        return randomTail(tails);
+        int len = tails.length;
+        int init = randomInt(len);
+        int cur = init;
+
+        while (true) {
+            Stripe stripe = tails[cur];
+
+            if (!stripe.empty)
+                return stripe;
+
+            if ((cur = (cur + 1) % len) == init)
+                return null;
+        }
     }
 
     /**
@@ -873,7 +926,7 @@ public abstract class PagesList extends DataStructure {
         for (int lockAttempt = 0; ;) {
             Stripe stripe = getPageForTake(bucket);
 
-            if (stripe == null || stripe.empty)
+            if (stripe == null)
                 return 0L;
 
             long tailId = stripe.tailId;
@@ -888,24 +941,38 @@ public abstract class PagesList extends DataStructure {
                     continue;
                 }
 
+                if (stripe.empty) {
+                    // Another thread took the last page.
+                    writeUnlock(tail, tailPageAddr, false);
+
+                    if (bucketsSize[bucket].get() > 0) {
+                        lockAttempt--; // Ignore current attempt.
+
+                        continue;
+                    }
+                    else
+                        return 0L;
+                }
+
                 assert PageIO.getPageId(tailPageAddr) == tailId : "tailId = " + tailId + ", tailPageId = " + PageIO.getPageId(tailPageAddr);
                 assert PageIO.getType(tailPageAddr) == PageIO.T_PAGE_LIST_NODE;
 
                 boolean dirty = false;
-                long ret = 0L;
+                long ret;
                 long recycleId = 0L;
 
                 try {
                     PagesListNodeIO io = PagesListNodeIO.VERSIONS.forPage(tailPageAddr);
 
-                    if (io.getNextId(tailPageAddr) != 0)
+                    if (io.getNextId(tailPageAddr) != 0) {
+                        // It is not a tail anymore, retry.
                         continue;
+                    }
 
                     long pageId = io.takeAnyPage(tailPageAddr);
 
                     if (pageId != 0L) {
-                        if (trackBucketsSize)
-                            bucketsSize[bucket].decrement();
+                        bucketsSize[bucket].decrementAndGet();
 
                         if (isWalDeltaRecordNeeded(wal, tail))
                             wal.log(new PagesListRemovePageRecord(cacheId, tailId, pageId));
@@ -914,59 +981,66 @@ public abstract class PagesList extends DataStructure {
 
                         ret = pageId;
 
-                        // If we got an empty page in non-reuse bucket, move it back to reuse list
-                        // to prevent empty page leak to data pages.
-                        if (io.isEmpty(tailPageAddr) && !isReuseBucket(bucket)) {
+                        if (io.isEmpty(tailPageAddr)) {
                             long prevId = io.getPreviousId(tailPageAddr);
 
-                            if (prevId != 0L) {
-                                try (Page prev = page(prevId)) {
-                                    // Lock pages from next to previous.
-                                    Boolean ok = writePage(pageMem, prev, this, cutTail, null, bucket, FALSE);
+                            // If we got an empty page in non-reuse bucket, move it back to reuse list
+                            // to prevent empty page leak to data pages.
+                            if (!isReuseBucket(bucket)) {
+                                if (prevId != 0L) {
+                                    try (Page prev = page(prevId)) {
+                                        // Lock pages from next to previous.
+                                        Boolean ok = writePage(pageMem, prev, this, cutTail, null, bucket, FALSE);
 
-                                    assert ok == TRUE : ok;
-                                }
+                                        assert ok == TRUE : ok;
+                                    }
 
-                                recycleId = recyclePage(tailId, tail, tailPageAddr);
+                                    recycleId = recyclePage(tailId, tail, tailPageAddr);
+                                }
+                                else
+                                    stripe.empty = true;
                             }
+                            else
+                                stripe.empty = prevId == 0L;
                         }
                     }
                     else {
-                        // The tail page is empty. We can unlink and return it if we have a previous page.
-                        long prevId = io.getPreviousId(tailPageAddr);
+                        // The tail page is empty, but stripe is not. It might
+                        // happen only if we are in reuse bucket and it has
+                        // a previous page, so, the current page can be collected
+                        assert isReuseBucket(bucket);
 
-                        if (prevId != 0L) {
-                            // This can only happen if we are in the reuse bucket.
-                            assert isReuseBucket(bucket);
+                        long prevId = io.getPreviousId(tailPageAddr);
 
-                            try (Page prev = page(prevId)) {
-                                // Lock pages from next to previous.
-                                Boolean ok = writePage(pageMem, prev, this, cutTail, null, bucket, FALSE);
+                        assert prevId != 0L;
 
-                                assert ok == TRUE : ok;
-                            }
+                        try (Page prev = page(prevId)) {
+                            // Lock pages from next to previous.
+                            Boolean ok = writePage(pageMem, prev, this, cutTail, null, bucket, FALSE);
 
-                            if (initIoVers != null) {
-                                tailId = PageIdUtils.changeType(tailId, FLAG_DATA);
+                            assert ok == TRUE : ok;
 
-                                PageIO initIo = initIoVers.latest();
+                            bucketsSize[bucket].decrementAndGet();
+                        }
 
-                                initIo.initNewPage(tailPageAddr, tailId, pageSize());
+                        if (initIoVers != null) {
+                            tailId = PageIdUtils.changeType(tailId, FLAG_DATA);
 
-                                if (isWalDeltaRecordNeeded(wal, tail)) {
-                                    wal.log(new InitNewPageRecord(cacheId, tail.id(), initIo.getType(),
-                                        initIo.getVersion(), tailId));
-                                }
-                            }
-                            else
-                                tailId = recyclePage(tailId, tail, tailPageAddr);
+                            PageIO initIo = initIoVers.latest();
 
-                            dirty = true;
+                            initIo.initNewPage(tailPageAddr, tailId, pageSize());
 
-                            ret = tailId;
+                            if (isWalDeltaRecordNeeded(wal, tail)) {
+                                wal.log(new InitNewPageRecord(cacheId, tail.id(), initIo.getType(),
+                                    initIo.getVersion(), tailId));
+                            }
                         }
                         else
-                            stripe.empty = true;
+                            tailId = recyclePage(tailId, tail, tailPageAddr);
+
+                        dirty = true;
+
+                        ret = tailId;
                     }
 
                     // If we do not have a previous page (we are at head), then we still can return
@@ -1026,8 +1100,7 @@ public abstract class PagesList extends DataStructure {
                 if (!rmvd)
                     return false;
 
-                if (trackBucketsSize)
-                    bucketsSize[bucket].decrement();
+                bucketsSize[bucket].decrementAndGet();
 
                 if (isWalDeltaRecordNeeded(wal, page))
                     wal.log(new PagesListRemovePageRecord(cacheId, pageId, dataPageId));
@@ -1312,9 +1385,11 @@ public abstract class PagesList extends DataStructure {
 
         /**
          * @param tailId Tail ID.
+         * @param empty Empty flag.
          */
-        Stripe(long tailId) {
+        Stripe(long tailId, boolean empty) {
             this.tailId = tailId;
+            this.empty = empty;
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/0308e689/modules/core/src/test/java/org/apache/ignite/cache/LargeEntryUpdateTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/cache/LargeEntryUpdateTest.java b/modules/core/src/test/java/org/apache/ignite/cache/LargeEntryUpdateTest.java
new file mode 100644
index 0000000..18a1654
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/cache/LargeEntryUpdateTest.java
@@ -0,0 +1,177 @@
+/*
+ * 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.cache;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicBoolean;
+import javax.cache.processor.MutableEntry;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteCompute;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.MemoryConfiguration;
+import org.apache.ignite.lang.IgniteFuture;
+import org.apache.ignite.lang.IgniteRunnable;
+import org.apache.ignite.resources.IgniteInstanceResource;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ *
+ */
+public class LargeEntryUpdateTest extends GridCommonAbstractTest {
+    /**  */
+    private static final int THREAD_COUNT = 10;
+
+    /**  */
+    private static final int PAGE_SIZE = 1 << 10; // 1 kB.
+
+    /**  */
+    private static final int PAGE_CACHE_SIZE = 30 << 20; // 30 MB.
+
+    /**  */
+    private static final String CACHE_PREFIX = "testCache";
+
+    /**  */
+    private static final int CACHE_COUNT = 10;
+
+    /**  */
+    private static final long WAIT_TIMEOUT = 5 * 60_000L; // 5 min.
+
+    /**  */
+    private static final long TEST_TIMEOUT = 10 * 60_000L; // 10 min.
+
+    /**  */
+    private final AtomicBoolean cacheUpdate = new AtomicBoolean();
+
+    /** {@inheritDoc} */
+    @Override protected long getTestTimeout() {
+        return TEST_TIMEOUT;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        cfg.setPublicThreadPoolSize(THREAD_COUNT);
+
+        MemoryConfiguration mem = new MemoryConfiguration();
+
+        mem.setPageSize(PAGE_SIZE);
+        mem.setPageCacheSize(PAGE_CACHE_SIZE);
+
+        cfg.setMemoryConfiguration(mem);
+
+        CacheConfiguration[] ccfgs = new CacheConfiguration[CACHE_COUNT];
+
+        for (int i = 0; i < CACHE_COUNT; ++i) {
+            CacheConfiguration ccfg = new CacheConfiguration();
+            ccfg.setName(CACHE_PREFIX + i);
+            ccfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
+            ccfg.setCacheMode(CacheMode.PARTITIONED);
+            ccfgs[i] = ccfg;
+        }
+
+        cfg.setCacheConfiguration(ccfgs);
+
+        return cfg;
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testEntryUpdate() throws Exception {
+        try (Ignite ignite = startGrid()) {
+            for (int i = 0; i < CACHE_COUNT; ++i) {
+                IgniteCache<Long, byte[]> cache = ignite.cache(CACHE_PREFIX + i);
+
+                cache.put(0L, new byte[PAGE_SIZE * 2]);
+            }
+
+            IgniteCompute compute = ignite.compute().withAsync();
+
+            long endTime = System.currentTimeMillis() + WAIT_TIMEOUT;
+
+            int iter = 0;
+
+            while (System.currentTimeMillis() < endTime) {
+                log.info("Iteration: " + iter++);
+
+                cacheUpdate.set(true);
+
+                try {
+                    List<IgniteFuture> futs = new ArrayList<>();
+
+                    for (int i = 0; i < THREAD_COUNT; ++i) {
+                        compute.run(new CacheUpdater());
+
+                        futs.add(compute.future());
+                    }
+
+                    Thread.sleep(30_000);
+
+                    cacheUpdate.set(false);
+
+                    for (IgniteFuture fut : futs)
+                        fut.get();
+                }
+                finally {
+                    cacheUpdate.set(false);
+                }
+            }
+        }
+    }
+
+    /**  */
+    public static class EntryUpdater implements CacheEntryProcessor<Long, byte[], Void> {
+        /**  */
+        public static final EntryUpdater INSTANCE = new EntryUpdater();
+
+        /** {@inheritDoc} */
+        @Override public Void process(MutableEntry<Long, byte[]> entry, Object... args) {
+            entry.setValue(new byte[PAGE_SIZE]);
+
+            return null;
+        }
+    }
+
+    /**  */
+    public class CacheUpdater implements IgniteRunnable {
+        /**  */
+        @IgniteInstanceResource
+        public transient Ignite ignite;
+
+        /** {@inheritDoc} */
+        @Override public void run() {
+            try {
+                while (cacheUpdate.get()) {
+                    for (int i = 0; i < CACHE_COUNT; ++i) {
+                        IgniteCache<Long, byte[]> cache = ignite.cache(CACHE_PREFIX + i);
+
+                        cache.invoke(0L, EntryUpdater.INSTANCE);
+                    }
+                }
+            }
+            catch (Throwable ex) {
+                throw new IgniteException(ex);
+            }
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0308e689/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbAbstractTest.java
new file mode 100644
index 0000000..cf26187
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbAbstractTest.java
@@ -0,0 +1,369 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.database;
+
+import java.io.Serializable;
+import java.util.Arrays;
+import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
+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.internal.processors.cache.database.tree.BPlusTree;
+import org.apache.ignite.internal.util.typedef.internal.S;
+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.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
+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;
+
+/**
+ *
+ */
+public abstract class IgniteDbAbstractTest extends GridCommonAbstractTest {
+    /** */
+    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+    /**
+     * @return Node count.
+     */
+    protected abstract int gridCount();
+
+    /**
+     * @return {@code True} if indexing is enabled.
+     */
+    protected abstract boolean indexingEnabled();
+
+    /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        MemoryConfiguration dbCfg = new MemoryConfiguration();
+
+        dbCfg.setConcurrencyLevel(Runtime.getRuntime().availableProcessors() * 4);
+
+        if (isLargePage())
+            dbCfg.setPageSize(16 * 1024);
+        else
+            dbCfg.setPageSize(1024);
+
+        dbCfg.setPageCacheSize(200 * 1024 * 1024);
+
+        configure(dbCfg);
+
+        cfg.setMemoryConfiguration(dbCfg);
+
+        CacheConfiguration ccfg = new CacheConfiguration();
+
+        if (indexingEnabled())
+            ccfg.setIndexedTypes(Integer.class, DbValue.class);
+
+        ccfg.setAtomicityMode(TRANSACTIONAL);
+        ccfg.setWriteSynchronizationMode(FULL_SYNC);
+        ccfg.setRebalanceMode(SYNC);
+        ccfg.setAffinity(new RendezvousAffinityFunction(false, 32));
+
+        CacheConfiguration ccfg2 = new CacheConfiguration("non-primitive");
+
+        if (indexingEnabled())
+            ccfg2.setIndexedTypes(DbKey.class, DbValue.class);
+
+        ccfg2.setAtomicityMode(TRANSACTIONAL);
+        ccfg2.setWriteSynchronizationMode(FULL_SYNC);
+        ccfg2.setRebalanceMode(SYNC);
+        ccfg2.setAffinity(new RendezvousAffinityFunction(false, 32));
+
+        CacheConfiguration ccfg3 = new CacheConfiguration("large");
+
+        if (indexingEnabled())
+            ccfg3.setIndexedTypes(Integer.class, LargeDbValue.class);
+
+        ccfg3.setAtomicityMode(TRANSACTIONAL);
+        ccfg3.setWriteSynchronizationMode(FULL_SYNC);
+        ccfg3.setRebalanceMode(SYNC);
+        ccfg3.setAffinity(new RendezvousAffinityFunction(false, 32));
+
+        CacheConfiguration ccfg4 = new CacheConfiguration("tiny");
+
+        ccfg4.setAtomicityMode(TRANSACTIONAL);
+        ccfg4.setWriteSynchronizationMode(FULL_SYNC);
+        ccfg4.setRebalanceMode(SYNC);
+        ccfg4.setAffinity(new RendezvousAffinityFunction(1, null));
+
+        CacheConfiguration ccfg5 = new CacheConfiguration("atomic");
+
+        if (indexingEnabled())
+            ccfg5.setIndexedTypes(DbKey.class, DbValue.class);
+
+        ccfg5.setAtomicityMode(ATOMIC);
+        ccfg5.setWriteSynchronizationMode(FULL_SYNC);
+        ccfg5.setRebalanceMode(SYNC);
+        ccfg5.setAffinity(new RendezvousAffinityFunction(false, 32));
+
+        cfg.setCacheConfiguration(ccfg, ccfg2, ccfg3, ccfg4, ccfg5);
+
+        TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
+
+        discoSpi.setIpFinder(IP_FINDER);
+
+        cfg.setDiscoverySpi(discoSpi);
+        cfg.setMarshaller(null);
+
+        configure(cfg);
+
+        return cfg;
+    }
+
+    /**
+     * @param cfg IgniteConfiguration.
+     */
+    protected void configure(IgniteConfiguration cfg){
+        // No-op.
+    }
+
+    /**
+     * @param mCfg MemoryConfiguration.
+     */
+    protected void configure(MemoryConfiguration mCfg){
+        // No-op.
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        deleteRecursively(U.resolveWorkDirectory(U.defaultWorkDirectory(), "db", false));
+
+//        long seed = System.currentTimeMillis();
+//
+//        info("Seed: " + seed + "L");
+//
+//        BPlusTree.rnd = new Random(seed);
+
+        startGrids(gridCount());
+
+        awaitPartitionMapExchange();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        BPlusTree.rnd = null;
+
+        stopAllGrids();
+
+        deleteRecursively(U.resolveWorkDirectory(U.defaultWorkDirectory(), "db", false));
+    }
+
+    /**
+     * @return {@code True} if use large page.
+     */
+    protected boolean isLargePage() {
+        return false;
+    }
+
+    /**
+     *
+     */
+    static class DbKey implements Serializable {
+        /** */
+        int val;
+
+        /**
+         * @param val Value.
+         */
+        DbKey(int val) {
+            this.val = val;
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean equals(Object o) {
+            if (this == o)
+                return true;
+
+            if (o == null || !(o instanceof DbKey))
+                return false;
+
+            DbKey key = (DbKey)o;
+
+            return val == key.val;
+        }
+
+        /** {@inheritDoc} */
+        @Override public int hashCode() {
+            return val;
+        }
+    }
+
+    /**
+     *
+     */
+    static class LargeDbKey implements Serializable {
+        /** */
+        int val;
+
+        /** */
+        byte[] data;
+
+        /**
+         * @param val Value.
+         * @param size Key payload size.
+         */
+        LargeDbKey(int val, int size) {
+            this.val = val;
+
+            data = new byte[size];
+
+            Arrays.fill(data, (byte)val);
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean equals(Object o) {
+            if (this == o)
+                return true;
+
+            if (o == null || !(o instanceof LargeDbKey))
+                return false;
+
+            LargeDbKey key = (LargeDbKey)o;
+
+            return val == key.val && Arrays.equals(data, key.data);
+        }
+
+        /** {@inheritDoc} */
+        @Override public int hashCode() {
+            return val + Arrays.hashCode(data);
+        }
+    }
+
+    /**
+     *
+     */
+    static class DbValue implements Serializable {
+        /** */
+        @QuerySqlField(index = true)
+        int iVal;
+
+        /** */
+        @QuerySqlField(index = true)
+        String sVal;
+
+        /** */
+        @QuerySqlField
+        long lVal;
+
+        /**
+         * @param iVal Integer value.
+         * @param sVal String value.
+         * @param lVal Long value.
+         */
+        DbValue(int iVal, String sVal, long lVal) {
+            this.iVal = iVal;
+            this.sVal = sVal;
+            this.lVal = lVal;
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean equals(Object o) {
+            if (this == o)
+                return true;
+
+            if (o == null || getClass() != o.getClass())
+                return false;
+
+            DbValue dbVal = (DbValue)o;
+
+            return iVal == dbVal.iVal && lVal == dbVal.lVal &&
+                    !(sVal != null ? !sVal.equals(dbVal.sVal) : dbVal.sVal != null);
+        }
+
+        /** {@inheritDoc} */
+        @Override public int hashCode() {
+            int res = iVal;
+
+            res = 31 * res + (sVal != null ? sVal.hashCode() : 0);
+            res = 31 * res + (int)(lVal ^ (lVal >>> 32));
+
+            return res;
+        }
+
+        /** {@inheritDoc} */
+        @Override public String toString() {
+            return S.toString(DbValue.class, this);
+        }
+    }
+
+    /**
+     *
+     */
+    static class LargeDbValue {
+        /** */
+        @QuerySqlField(index = true)
+        String str1;
+
+        /** */
+        @QuerySqlField(index = true)
+        String str2;
+
+        /** */
+        int[] arr;
+
+        /**
+         * @param str1 String 1.
+         * @param str2 String 2.
+         * @param arr Big array.
+         */
+        LargeDbValue(final String str1, final String str2, final int[] arr) {
+            this.str1 = str1;
+            this.str2 = str2;
+            this.arr = arr;
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean equals(final Object o) {
+            if (this == o) return true;
+            if (o == null || getClass() != o.getClass()) return false;
+
+            final LargeDbValue that = (LargeDbValue) o;
+
+            if (str1 != null ? !str1.equals(that.str1) : that.str1 != null) return false;
+            if (str2 != null ? !str2.equals(that.str2) : that.str2 != null) return false;
+
+            return Arrays.equals(arr, that.arr);
+
+        }
+
+        /** {@inheritDoc} */
+        @Override public int hashCode() {
+            int res = str1 != null ? str1.hashCode() : 0;
+
+            res = 31 * res + (str2 != null ? str2.hashCode() : 0);
+            res = 31 * res + Arrays.hashCode(arr);
+
+            return res;
+        }
+
+        /** {@inheritDoc} */
+        @Override public String toString() {
+            return S.toString(LargeDbValue.class, this);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0308e689/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMemoryLeakAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMemoryLeakAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMemoryLeakAbstractTest.java
new file mode 100644
index 0000000..2e9d3f9
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMemoryLeakAbstractTest.java
@@ -0,0 +1,265 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.database;
+
+import java.util.concurrent.ThreadLocalRandom;
+import java.util.concurrent.TimeUnit;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.MemoryConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.processors.cache.database.DataStructure;
+
+import static org.apache.ignite.IgniteSystemProperties.getInteger;
+
+/**
+ * Base class for memory leaks tests.
+ */
+public abstract class IgniteDbMemoryLeakAbstractTest extends IgniteDbAbstractTest {
+    /** */
+    private static final int CONCURRENCY_LEVEL = 8;
+
+    /** */
+    private static final int MIN_PAGE_CACHE_SIZE = 1048576 * CONCURRENCY_LEVEL;
+
+    /** */
+    private volatile Exception ex;
+
+    /** */
+    private long warmUpEndTime;
+
+    /** */
+    private long endTime;
+
+    /** */
+    private long loadedPages;
+
+    /** */
+    private long delta;
+
+    /** */
+    private long probeCnt;
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        super.beforeTest();
+
+        DataStructure.rnd = null;
+
+        long startTime = System.nanoTime();
+
+        warmUpEndTime = startTime + TimeUnit.SECONDS.toNanos(warmUp());
+
+        endTime = warmUpEndTime + TimeUnit.SECONDS.toNanos(duration());
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void configure(IgniteConfiguration cfg) {
+        cfg.setMetricsLogFrequency(5000);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void configure(MemoryConfiguration mCfg) {
+        mCfg.setConcurrencyLevel(CONCURRENCY_LEVEL);
+
+        long size = (1024 * (isLargePage() ? 16 : 1) + 24) * pagesMax();
+
+        mCfg.setPageCacheSize(Math.max(size, MIN_PAGE_CACHE_SIZE));
+    }
+
+    /**
+     * @return Test duration in seconds.
+     */
+    protected int duration() {
+        return getInteger("IGNITE_MEMORY_LEAKS_TEST_DURATION", 300);
+    }
+
+    /**
+     * @return Warm up duration in seconds.
+     */
+    @SuppressWarnings("WeakerAccess")
+    protected int warmUp() {
+        return getInteger("IGNITE_MEMORY_LEAKS_TEST_WARM_UP", 450);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected int gridCount() {
+        return 1;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected boolean indexingEnabled() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected long getTestTimeout() {
+        return (warmUp() + duration() + 10) * 1000; // Extra seconds to stop all threads.
+    }
+
+    /**
+     * @param ig Ignite instance.
+     * @return IgniteCache.
+     */
+    protected abstract IgniteCache<Object, Object> cache(IgniteEx ig);
+
+    /**
+     * @return Cache key to perform an operation.
+     */
+    protected abstract Object key();
+
+    /**
+     * @param key Cache key to perform an operation.
+     * @return Cache value to perform an operation.
+     */
+    protected abstract Object value(Object key);
+
+    /**
+     * @param cache IgniteCache.
+     */
+    protected void operation(IgniteCache<Object, Object> cache) {
+        Object key = key();
+        Object val = value(key);
+
+        switch (nextInt(3)) {
+            case 0:
+                cache.getAndPut(key, val);
+
+                break;
+
+            case 1:
+                cache.get(key);
+
+                break;
+
+            case 2:
+                cache.getAndRemove(key);
+        }
+    }
+
+    /**
+     * @param bound Upper bound (exclusive). Must be positive.
+     * @return Random int value.
+     */
+    protected static int nextInt(int bound) {
+        return ThreadLocalRandom.current().nextInt(bound);
+    }
+
+    /**
+     * @return Random int value.
+     */
+    protected static int nextInt() {
+        return ThreadLocalRandom.current().nextInt();
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testMemoryLeak() throws Exception {
+        final IgniteEx ignite = grid(0);
+
+        final IgniteCache<Object, Object> cache = cache(ignite);
+
+        Runnable target = new Runnable() {
+            @Override public void run() {
+                while (ex == null && System.nanoTime() < endTime) {
+                    try {
+                        operation(cache);
+                    }
+                    catch (Exception e) {
+                        ex = e;
+
+                        break;
+                    }
+                }
+            }
+        };
+
+        Thread[] threads = new Thread[CONCURRENCY_LEVEL];
+
+        info("Warming up is started.");
+
+        for (int i = 0; i < threads.length; i++) {
+            threads[i] = new Thread(target);
+            threads[i].start();
+        }
+
+        while (ex == null && System.nanoTime() < warmUpEndTime)
+            Thread.sleep(100);
+
+        if (ex != null)
+            throw ex;
+
+        info("Warming up is ended.");
+
+        while (ex == null && System.nanoTime() < endTime) {
+            try {
+                check(ignite);
+            }
+            catch (Exception e) {
+                ex = e;
+
+                break;
+            }
+
+            Thread.sleep(TimeUnit.SECONDS.toMillis(5));
+        }
+
+        if (ex != null)
+            throw ex;
+    }
+
+    /**
+     * Callback to check the current state.
+     *
+     * @param ig Ignite instance.
+     * @throws Exception If failed.
+     */
+    protected void check(IgniteEx ig) throws Exception {
+        long pagesActual = ig.context().cache().context().database().pageMemory().loadedPages();
+
+        if (loadedPages > 0) {
+            delta += pagesActual - loadedPages;
+
+            int allowedDelta = pagesDelta();
+
+            if (probeCnt++ > 12) { // We need some statistic first. Minimal statistic is taken for a minute.
+                long actualDelta = delta / probeCnt;
+
+                assertTrue(
+                    "Average growth pages in the number is more than expected [allowed=" + allowedDelta + ", actual=" + actualDelta + "]",
+                    actualDelta <= allowedDelta);
+            }
+        }
+
+        loadedPages = pagesActual;
+    }
+
+    /**
+     * @return Maximal allowed pages number.
+     */
+    protected abstract long pagesMax();
+
+    /**
+     * @return Expected average number of pages, on which their total number can grow per 5 seconds.
+     */
+    @SuppressWarnings("WeakerAccess")
+    protected int pagesDelta() {
+        return 3;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0308e689/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMemoryLeakLargeObjectsTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMemoryLeakLargeObjectsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMemoryLeakLargeObjectsTest.java
new file mode 100644
index 0000000..077a1e1
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMemoryLeakLargeObjectsTest.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.database;
+
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.internal.IgniteEx;
+
+/**
+ *
+ */
+public class IgniteDbMemoryLeakLargeObjectsTest extends IgniteDbMemoryLeakAbstractTest {
+    /** */
+    private final static int[] ARRAY;
+
+    static {
+        ARRAY = new int[1024];
+
+        for (int i = 0; i < ARRAY.length; i++)
+            ARRAY[i] = nextInt();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected IgniteCache<Object, Object> cache(IgniteEx ig) {
+        return ig.cache("large");
+    }
+
+    /** {@inheritDoc} */
+    @Override protected Object key() {
+        return new LargeDbKey(nextInt(10_000), 1024);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected Object value(Object key) {
+        return new LargeDbValue("test-value-1-" + nextInt(200), "test-value-2-" + nextInt(200), ARRAY);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected long pagesMax() {
+        return 35_000;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0308e689/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMemoryLeakLargePagesTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMemoryLeakLargePagesTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMemoryLeakLargePagesTest.java
new file mode 100644
index 0000000..540681d
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMemoryLeakLargePagesTest.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.database;
+
+/**
+ *
+ */
+public class IgniteDbMemoryLeakLargePagesTest extends IgniteDbMemoryLeakTest {
+    /** {@inheritDoc} */
+    @Override protected boolean isLargePage() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected long pagesMax() {
+        return 4000;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0308e689/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMemoryLeakNonTransactionalTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMemoryLeakNonTransactionalTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMemoryLeakNonTransactionalTest.java
new file mode 100644
index 0000000..2a6293d
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMemoryLeakNonTransactionalTest.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.database;
+
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.internal.IgniteEx;
+
+/**
+ *
+ */
+public class IgniteDbMemoryLeakNonTransactionalTest extends IgniteDbMemoryLeakTest {
+    /** {@inheritDoc} */
+    @Override protected IgniteCache<Object, Object> cache(IgniteEx ig) {
+        return ig.cache("atomic");
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0308e689/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMemoryLeakTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMemoryLeakTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMemoryLeakTest.java
new file mode 100644
index 0000000..b8ac8f0
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMemoryLeakTest.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.database;
+
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.internal.IgniteEx;
+
+/**
+ *
+ */
+public class IgniteDbMemoryLeakTest extends IgniteDbMemoryLeakAbstractTest {
+    /** {@inheritDoc} */
+    @Override protected IgniteCache<Object, Object> cache(IgniteEx ig) {
+        return ig.cache("non-primitive");
+    }
+
+    /** {@inheritDoc} */
+    @Override protected Object key() {
+        return new DbKey(nextInt(200_000));
+    }
+
+    /** {@inheritDoc} */
+    @Override protected Object value(Object key) {
+        return new DbValue(((DbKey)key).val, "test-value-" + nextInt(200), nextInt(500));
+    }
+
+    /** {@inheritDoc} */
+    @Override protected long pagesMax() {
+        return 20_000;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0308e689/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMemoryLeakWithExpirationTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMemoryLeakWithExpirationTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMemoryLeakWithExpirationTest.java
new file mode 100644
index 0000000..6e0abaf
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMemoryLeakWithExpirationTest.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.database;
+
+import javax.cache.expiry.CreatedExpiryPolicy;
+import javax.cache.expiry.Duration;
+import javax.cache.expiry.ExpiryPolicy;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.internal.IgniteEx;
+
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+
+/**
+ *
+ */
+public class IgniteDbMemoryLeakWithExpirationTest extends IgniteDbMemoryLeakTest {
+    /** */
+    private static final ExpiryPolicy EXPIRY = new CreatedExpiryPolicy(new Duration(MILLISECONDS, 10L));
+
+    /** {@inheritDoc} */
+    @Override protected IgniteCache<Object, Object> cache(IgniteEx ig) {
+        return ig.cache("non-primitive").withExpiryPolicy(EXPIRY);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected long pagesMax() {
+        return 7000;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0308e689/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbPutGetAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbPutGetAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbPutGetAbstractTest.java
index c7a07e3..12b0126 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbPutGetAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbPutGetAbstractTest.java
@@ -17,8 +17,6 @@
 
 package org.apache.ignite.internal.processors.database;
 
-import java.io.Serializable;
-import java.util.Arrays;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.LinkedHashMap;
@@ -32,160 +30,24 @@ import javax.cache.Cache;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.IgniteDataStreamer;
-import org.apache.ignite.cache.CacheAtomicityMode;
 import org.apache.ignite.cache.CachePeekMode;
-import org.apache.ignite.cache.CacheRebalanceMode;
-import org.apache.ignite.cache.CacheWriteSynchronizationMode;
 import org.apache.ignite.cache.affinity.Affinity;
-import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
-import org.apache.ignite.cache.affinity.AffinityFunction;
 import org.apache.ignite.cache.query.QueryCursor;
 import org.apache.ignite.cache.query.ScanQuery;
 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.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.MemoryConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.internal.IgniteEx;
 import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
-import org.apache.ignite.internal.processors.cache.database.tree.BPlusTree;
 import org.apache.ignite.internal.util.GridRandom;
 import org.apache.ignite.internal.util.typedef.PA;
 import org.apache.ignite.internal.util.typedef.X;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
 import org.apache.ignite.testframework.GridTestUtils;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 import org.junit.Assert;
 
 /**
  *
  */
-public abstract class IgniteDbPutGetAbstractTest extends GridCommonAbstractTest {
-    /** */
-    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
-
-    /**
-     * @return Node count.
-     */
-    protected abstract int gridCount();
-
-    /**
-     * @return {@code True} if indexing is enabled.
-     */
-    protected abstract boolean indexingEnabled();
-
-    /** {@inheritDoc} */
-    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
-        IgniteConfiguration cfg = super.getConfiguration(gridName);
-
-        MemoryConfiguration dbCfg = new MemoryConfiguration();
-
-        if (isLargePage()) {
-            dbCfg.setConcurrencyLevel(Runtime.getRuntime().availableProcessors() * 4);
-
-            dbCfg.setPageSize(16 * 1024);
-
-            dbCfg.setPageCacheSize(200 * 1024 * 1024);
-        }
-        else {
-            dbCfg.setConcurrencyLevel(Runtime.getRuntime().availableProcessors() * 4);
-
-            dbCfg.setPageSize(1024);
-
-            dbCfg.setPageCacheSize(200 * 1024 * 1024);
-        }
-
-        cfg.setMemoryConfiguration(dbCfg);
-
-        CacheConfiguration ccfg = new CacheConfiguration();
-
-        if (indexingEnabled())
-            ccfg.setIndexedTypes(Integer.class, DbValue.class);
-
-        ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
-        ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
-        ccfg.setRebalanceMode(CacheRebalanceMode.SYNC);
-        ccfg.setAffinity(new RendezvousAffinityFunction(false, 32));
-
-        CacheConfiguration ccfg2 = new CacheConfiguration("non-primitive");
-
-        if (indexingEnabled())
-            ccfg2.setIndexedTypes(DbKey.class, DbValue.class);
-
-        ccfg2.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
-        ccfg2.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
-        ccfg2.setRebalanceMode(CacheRebalanceMode.SYNC);
-        ccfg2.setAffinity(new RendezvousAffinityFunction(false, 32));
-
-        CacheConfiguration ccfg3 = new CacheConfiguration("large");
-
-        if (indexingEnabled())
-            ccfg3.setIndexedTypes(Integer.class, LargeDbValue.class);
-
-        ccfg3.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
-        ccfg3.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
-        ccfg3.setRebalanceMode(CacheRebalanceMode.SYNC);
-        ccfg3.setAffinity(new RendezvousAffinityFunction(false, 32));
-
-        CacheConfiguration ccfg4 = new CacheConfiguration("tiny");
-
-        ccfg4.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
-        ccfg4.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
-        ccfg4.setRebalanceMode(CacheRebalanceMode.SYNC);
-        ccfg4.setAffinity(new RendezvousAffinityFunction(false, 32));
-
-        final AffinityFunction aff = new RendezvousAffinityFunction(1, null);
-
-        ccfg4.setAffinity(aff);
-
-        cfg.setCacheConfiguration(ccfg, ccfg2, ccfg3, ccfg4);
-
-        TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
-
-        discoSpi.setIpFinder(IP_FINDER);
-
-        cfg.setDiscoverySpi(discoSpi);
-        cfg.setMarshaller(null);
-
-        return cfg;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void beforeTest() throws Exception {
-        deleteRecursively(U.resolveWorkDirectory(U.defaultWorkDirectory(), "db", false));
-
-        long seed = 1464583813940L; // System.currentTimeMillis();
-
-        info("Seed: " + seed + "L");
-
-        BPlusTree.rnd = new Random(seed);
-
-        startGrids(gridCount());
-
-        awaitPartitionMapExchange();
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void afterTest() throws Exception {
-        BPlusTree.rnd = null;
-
-        stopAllGrids();
-
-        deleteRecursively(U.resolveWorkDirectory(U.defaultWorkDirectory(), "db", false));
-    }
-
-    /**
-     * @return {@code True} if use large page.
-     */
-    protected boolean isLargePage() {
-        return false;
-    };
-
+public abstract class IgniteDbPutGetAbstractTest extends IgniteDbAbstractTest {
     /**
      *
      */
@@ -196,9 +58,7 @@ public abstract class IgniteDbPutGetAbstractTest extends GridCommonAbstractTest
 
         final int cnt = 100_000;
 
-        Random rnd = BPlusTree.rnd;
-
-        assert rnd != null;
+        Random rnd = new Random();
 
         Map<Integer, DbValue> map = new HashMap<>();
 
@@ -1349,191 +1209,4 @@ public abstract class IgniteDbPutGetAbstractTest extends GridCommonAbstractTest
 
         assertNull(internalCache.peekEx(key));
     }
-
-    /**
-     *
-     */
-    private static class DbKey implements Serializable {
-        /** */
-        private int val;
-
-        /**
-         * @param val Value.
-         */
-        private DbKey(int val) {
-            this.val = val;
-        }
-
-        /** {@inheritDoc} */
-        @Override public boolean equals(Object o) {
-            if (this == o)
-                return true;
-
-            if (o == null || !(o instanceof DbKey))
-                return false;
-
-            DbKey key = (DbKey)o;
-
-            return val == key.val;
-        }
-
-        /** {@inheritDoc} */
-        @Override public int hashCode() {
-            return val;
-        }
-    }
-
-    /**
-     *
-     */
-    private static class LargeDbKey implements Serializable {
-        /** */
-        private int val;
-
-        /** */
-        private byte[] data;
-
-        /**
-         * @param val Value.
-         * @param size Key payload size.
-         */
-        private LargeDbKey(int val, int size) {
-            this.val = val;
-
-            data = new byte[size];
-
-            Arrays.fill(data, (byte)val);
-        }
-
-        /** {@inheritDoc} */
-        @Override public boolean equals(Object o) {
-            if (this == o)
-                return true;
-
-            if (o == null || !(o instanceof LargeDbKey))
-                return false;
-
-            LargeDbKey key = (LargeDbKey)o;
-
-            return val == key.val && Arrays.equals(data, key.data);
-        }
-
-        /** {@inheritDoc} */
-        @Override public int hashCode() {
-            return val + Arrays.hashCode(data);
-        }
-    }
-
-    /**
-     *
-     */
-    private static class DbValue implements Serializable {
-        /** */
-        @QuerySqlField(index = true)
-        private int iVal;
-
-        /** */
-        @QuerySqlField(index = true)
-        private String sVal;
-
-        /** */
-        @QuerySqlField
-        private long lVal;
-
-        /**
-         * @param iVal Integer value.
-         * @param sVal String value.
-         * @param lVal Long value.
-         */
-        public DbValue(int iVal, String sVal, long lVal) {
-            this.iVal = iVal;
-            this.sVal = sVal;
-            this.lVal = lVal;
-        }
-
-        /** {@inheritDoc} */
-        @Override public boolean equals(Object o) {
-            if (this == o)
-                return true;
-
-            if (o == null || getClass() != o.getClass())
-                return false;
-
-            DbValue dbVal = (DbValue)o;
-
-            return iVal == dbVal.iVal && lVal == dbVal.lVal &&
-                !(sVal != null ? !sVal.equals(dbVal.sVal) : dbVal.sVal != null);
-        }
-
-        /** {@inheritDoc} */
-        @Override public int hashCode() {
-            int res = iVal;
-
-            res = 31 * res + (sVal != null ? sVal.hashCode() : 0);
-            res = 31 * res + (int)(lVal ^ (lVal >>> 32));
-
-            return res;
-        }
-
-        /** {@inheritDoc} */
-        @Override public String toString() {
-            return S.toString(DbValue.class, this);
-        }
-    }
-
-    /**
-     *
-     */
-    private static class LargeDbValue {
-        /** */
-        @QuerySqlField(index = true)
-        private String str1;
-
-        /** */
-        @QuerySqlField(index = true)
-        private String str2;
-
-        /** */
-        private int[] arr;
-
-        /**
-         * @param str1 String 1.
-         * @param str2 String 2.
-         * @param arr Big array.
-         */
-        public LargeDbValue(final String str1, final String str2, final int[] arr) {
-            this.str1 = str1;
-            this.str2 = str2;
-            this.arr = arr;
-        }
-
-        /** {@inheritDoc} */
-        @Override public boolean equals(final Object o) {
-            if (this == o) return true;
-            if (o == null || getClass() != o.getClass()) return false;
-
-            final LargeDbValue that = (LargeDbValue) o;
-
-            if (str1 != null ? !str1.equals(that.str1) : that.str1 != null) return false;
-            if (str2 != null ? !str2.equals(that.str2) : that.str2 != null) return false;
-
-            return Arrays.equals(arr, that.arr);
-
-        }
-
-        /** {@inheritDoc} */
-        @Override public int hashCode() {
-            int res = str1 != null ? str1.hashCode() : 0;
-
-            res = 31 * res + (str2 != null ? str2.hashCode() : 0);
-            res = 31 * res + Arrays.hashCode(arr);
-
-            return res;
-        }
-
-        /** {@inheritDoc} */
-        @Override public String toString() {
-            return S.toString(LargeDbValue.class, this);
-        }
-    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/0308e689/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteDbMemoryLeakTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteDbMemoryLeakTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteDbMemoryLeakTestSuite.java
new file mode 100644
index 0000000..f271bd8
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteDbMemoryLeakTestSuite.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.testsuites;
+
+import junit.framework.TestSuite;
+import org.apache.ignite.cache.LargeEntryUpdateTest;
+import org.apache.ignite.internal.processors.database.IgniteDbMemoryLeakLargeObjectsTest;
+import org.apache.ignite.internal.processors.database.IgniteDbMemoryLeakLargePagesTest;
+import org.apache.ignite.internal.processors.database.IgniteDbMemoryLeakNonTransactionalTest;
+import org.apache.ignite.internal.processors.database.IgniteDbMemoryLeakTest;
+import org.apache.ignite.internal.processors.database.IgniteDbMemoryLeakWithExpirationTest;
+
+/**
+ * Page memory leaks tests.
+ */
+public class IgniteDbMemoryLeakTestSuite extends TestSuite {
+    /**
+     * @return Test suite.
+     * @throws Exception Thrown in case of the failure.
+     */
+    public static TestSuite suite() throws Exception {
+        TestSuite suite = new TestSuite("Ignite Db Memory Leaks Test Suite");
+
+        suite.addTestSuite(IgniteDbMemoryLeakTest.class);
+        suite.addTestSuite(IgniteDbMemoryLeakWithExpirationTest.class);
+        suite.addTestSuite(IgniteDbMemoryLeakLargePagesTest.class);
+        suite.addTestSuite(IgniteDbMemoryLeakLargeObjectsTest.class);
+        suite.addTestSuite(IgniteDbMemoryLeakNonTransactionalTest.class);
+
+        suite.addTestSuite(LargeEntryUpdateTest.class);
+
+        return suite;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0308e689/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMemoryLeakIndexedTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMemoryLeakIndexedTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMemoryLeakIndexedTest.java
new file mode 100644
index 0000000..f6a06c9
--- /dev/null
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMemoryLeakIndexedTest.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.database;
+
+/**
+ *
+ */
+public class IgniteDbMemoryLeakIndexedTest extends IgniteDbMemoryLeakTest {
+    /** {@inheritDoc} */
+    @Override protected boolean indexingEnabled() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected long pagesMax() {
+        return 24_000;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0308e689/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMemoryLeakSqlQueryTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMemoryLeakSqlQueryTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMemoryLeakSqlQueryTest.java
new file mode 100644
index 0000000..57f9fb5
--- /dev/null
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMemoryLeakSqlQueryTest.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.database;
+
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ *
+ */
+public class IgniteDbMemoryLeakSqlQueryTest extends IgniteDbMemoryLeakTest {
+    /** {@inheritDoc} */
+    @Override protected boolean indexingEnabled() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected long pagesMax() {
+        return 24_000;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void operation(IgniteCache<Object, Object> cache) {
+        Object key = key();
+        Object val = value(key);
+
+        switch (nextInt(4)) {
+            case 0:
+                cache.getAndPut(key, val);
+
+                break;
+
+            case 1:
+                cache.get(key);
+
+                break;
+
+            case 2:
+                cache.getAndRemove(key);
+
+                break;
+
+            case 3:
+                cache.query(sqlQuery(cache)).getAll();
+        }
+    }
+
+    /**
+     * @param cache IgniteCache.
+     * @return SqlFieldsQuery.
+     */
+    @NotNull private SqlFieldsQuery sqlQuery(IgniteCache<Object, Object> cache) {
+        String qry = String.format("select _key from \"%s\".DbValue where iVal=?", cache.getName());
+
+        SqlFieldsQuery sqlQry = new SqlFieldsQuery(qry);
+        sqlQry.setArgs(nextInt(200_000));
+
+        return sqlQry;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0308e689/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteDbMemoryLeakWithIndexingTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteDbMemoryLeakWithIndexingTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteDbMemoryLeakWithIndexingTestSuite.java
new file mode 100644
index 0000000..36cd101
--- /dev/null
+++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteDbMemoryLeakWithIndexingTestSuite.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.testsuites;
+
+import junit.framework.TestSuite;
+import org.apache.ignite.internal.processors.database.IgniteDbMemoryLeakIndexedTest;
+import org.apache.ignite.internal.processors.database.IgniteDbMemoryLeakSqlQueryTest;
+
+/**
+ * Page memory leaks tests using indexing.
+ */
+public class IgniteDbMemoryLeakWithIndexingTestSuite extends TestSuite {
+    /**
+     * @return Test suite.
+     * @throws Exception Thrown in case of the failure.
+     */
+    public static TestSuite suite() throws Exception {
+        TestSuite suite = new TestSuite("Ignite Db Memory Leaks With Indexing Test Suite");
+
+        suite.addTestSuite(IgniteDbMemoryLeakSqlQueryTest.class);
+        suite.addTestSuite(IgniteDbMemoryLeakIndexedTest.class);
+
+        return suite;
+    }
+}


[17/34] ignite git commit: Fix for failed assert in GridH2Table.destroy: need wait for local message handlers.

Posted by ag...@apache.org.
Fix for failed assert in GridH2Table.destroy:  need wait for local message handlers.


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

Branch: refs/heads/ignite-3477-master
Commit: ec5923a39520ed6b14f5e4d71e8f743badd0e6ab
Parents: 5d9323c
Author: sboikov <sb...@gridgain.com>
Authored: Tue Mar 21 15:51:30 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Wed Mar 29 19:29:36 2017 +0300

----------------------------------------------------------------------
 .../internal/processors/query/h2/IgniteH2Indexing.java    | 10 +++++++++-
 .../internal/processors/query/h2/opt/GridH2Table.java     |  9 +--------
 .../query/h2/twostep/GridReduceQueryExecutor.java         |  1 -
 3 files changed, 10 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/ec5923a3/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 e663768..19e5fb4 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
@@ -2173,7 +2173,15 @@ public class IgniteH2Indexing implements GridQueryIndexing {
                     // We prefer runLocal to runLocalSafe, because the latter can produce deadlock here.
                     ctx.closure().runLocal(new GridPlainRunnable() {
                         @Override public void run() {
-                            locNodeHnd.apply(finalLocNode, finalMsg);
+                            if (!busyLock.enterBusy())
+                                return;
+
+                            try {
+                                locNodeHnd.apply(finalLocNode, finalMsg);
+                            }
+                            finally {
+                                busyLock.leaveBusy();
+                            }
                         }
                     }, plc).listen(logger);
                 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/ec5923a3/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java
index 12f799a..89a010d 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java
@@ -438,14 +438,7 @@ public class GridH2Table extends TableBase {
         Lock l = lock(true, Long.MAX_VALUE);
 
         try {
-           /* assert sessions.isEmpty() : sessions;*/
-
-            //todo only for investigation
-            if (!sessions.isEmpty()){
-                U.dumpThreads(null);
-
-                assert sessions.isEmpty() : sessions;
-            }
+            assert sessions.isEmpty() : sessions;
 
             destroyed = true;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/ec5923a3/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 0f62b4b..fad3de8 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
@@ -84,7 +84,6 @@ 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.IgniteProductVersion;
 import org.apache.ignite.plugin.extensions.communication.Message;
 import org.h2.command.ddl.CreateTableData;
 import org.h2.engine.Session;


[21/34] ignite git commit: IGNITE-4758 - Introduced multiple memory policies. Fixes #1595

Posted by ag...@apache.org.
IGNITE-4758 - Introduced multiple memory policies. Fixes #1595


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

Branch: refs/heads/ignite-3477-master
Commit: 7ac0fd0c9a6a7c89951f04489269556475bafdd2
Parents: 96286f2
Author: Sergey Chugunov <se...@gmail.com>
Authored: Wed Mar 29 15:27:05 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Wed Mar 29 19:29:38 2017 +0300

----------------------------------------------------------------------
 .../configuration/CacheConfiguration.java       |  25 ++
 .../configuration/MemoryConfiguration.java      | 104 ++++--
 .../MemoryPolicyConfiguration.java              |  80 +++++
 .../apache/ignite/internal/IgniteKernal.java    |  50 ++-
 .../processors/cache/GridCacheContext.java      |  43 +++
 .../processors/cache/GridCacheProcessor.java    |  21 +-
 .../cache/IgniteCacheOffheapManagerImpl.java    |  34 +-
 .../cache/database/CacheDataRowAdapter.java     |   4 +-
 .../IgniteCacheDatabaseSharedManager.java       | 354 ++++++++++++++++---
 .../processors/cache/database/MemoryPolicy.java |  53 +++
 .../processors/cache/database/RowStore.java     |   2 +-
 .../cache/distributed/near/GridNearTxLocal.java |   1 -
 .../visor/node/VisorGridConfiguration.java      |   2 +-
 .../visor/node/VisorMemoryConfiguration.java    |  55 ++-
 .../node/VisorMemoryPolicyConfiguration.java    |  72 ++++
 .../resources/META-INF/classnames.properties    |   1 +
 .../ignite/cache/LargeEntryUpdateTest.java      |   1 -
 .../cache/CacheConfigurationLeakTest.java       |   7 +-
 .../CacheMemoryPolicyConfigurationTest.java     | 164 +++++++++
 .../cache/MemoryPolicyConfigValidationTest.java | 241 +++++++++++++
 .../database/IgniteDbAbstractTest.java          |   2 -
 .../database/IgniteDbDynamicCacheSelfTest.java  |   9 +-
 .../IgniteDbMemoryLeakAbstractTest.java         |  10 +-
 .../loadtests/hashmap/GridCacheTestContext.java |   3 +
 .../testsuites/IgniteCacheTestSuite2.java       |   4 +
 .../query/h2/database/H2TreeIndex.java          |   5 +-
 .../h2/GridIndexingSpiAbstractSelfTest.java     | 196 +++++-----
 .../cpp/core-test/config/cache-query-32.xml     |  50 +++
 .../config/cache-query-continuous-32.xml        |  46 +++
 .../config/cache-query-continuous-default.xml   |  87 +++++
 .../core-test/config/cache-query-continuous.xml |  61 +---
 .../core-test/config/cache-query-default.xml    | 131 +++++++
 .../cpp/core-test/config/cache-query.xml        | 114 +-----
 .../cpp/core-test/config/cache-test-32.xml      |  50 +++
 .../cpp/core-test/config/cache-test-default.xml | 135 +++++++
 .../cpp/core-test/config/cache-test.xml         | 105 +-----
 .../cpp/core-test/project/vs/core-test.vcxproj  |   7 +
 .../project/vs/core-test.vcxproj.filters        |  21 ++
 .../cpp/core-test/src/cache_query_test.cpp      |   4 +
 .../platforms/cpp/core-test/src/cache_test.cpp  |   5 +
 .../cpp/core-test/src/continuous_query_test.cpp |   4 +
 .../cpp/core-test/src/ignition_test.cpp         |   4 +
 .../cpp/core-test/src/interop_test.cpp          |   4 +
 .../cpp/core-test/src/transactions_test.cpp     |   4 +
 .../cpp/odbc-test/config/queries-test-32.xml    |  47 +++
 .../odbc-test/config/queries-test-default.xml   |  38 ++
 .../odbc-test/config/queries-test-noodbc-32.xml |  47 +++
 .../cpp/odbc-test/config/queries-test.xml       |  11 +-
 .../cpp/odbc-test/project/vs/odbc-test.vcxproj  |   3 +
 .../project/vs/odbc-test.vcxproj.filters        |   6 +
 .../cpp/odbc-test/src/api_robustness_test.cpp   |  20 +-
 .../cpp/odbc-test/src/queries_test.cpp          |   8 +
 .../odbc-test/src/sql_test_suite_fixture.cpp    |   6 +-
 53 files changed, 2057 insertions(+), 504 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/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 25398ca..84e1b01 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
@@ -223,6 +223,9 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
     /** Cache name. */
     private String name;
 
+    /** Name of {@link MemoryPolicyConfiguration} for this cache */
+    private String memPlcName;
+
     /** Threshold for concurrent loading of keys from {@link CacheStore}. */
     private int storeConcurrentLoadAllThreshold = DFLT_CONCURRENT_LOAD_ALL_THRESHOLD;
 
@@ -467,6 +470,7 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
         longQryWarnTimeout = cc.getLongQueryWarningTimeout();
         offHeapMaxMem = cc.getOffHeapMaxMemory();
         maxConcurrentAsyncOps = cc.getMaxConcurrentAsyncOperations();
+        memPlcName = cc.getMemoryPolicyName();
         sqlIndexMaxInlineSize = cc.getSqlIndexMaxInlineSize();
         name = cc.getName();
         nearCfg = cc.getNearConfiguration();
@@ -528,6 +532,27 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
     }
 
     /**
+     * @return {@link MemoryPolicyConfiguration} name.
+     */
+    public String getMemoryPolicyName() {
+        return memPlcName;
+    }
+
+    /**
+     * Sets name of {@link MemoryPolicyConfiguration} for this cache.
+     *
+     * @param memPlcName MemoryPolicyConfiguration name. Can be null (default MemoryPolicyConfiguration will be used) but should not be empty.
+     * @return {@code this} for chaining.
+     */
+    public CacheConfiguration<K, V> setMemoryPolicyName(String memPlcName) {
+        A.ensure(name == null || !name.isEmpty(), "Name cannot be empty.");
+
+        this.memPlcName = memPlcName;
+
+        return this;
+    }
+
+    /**
      * Gets cache eviction policy. By default, returns {@code null}
      * which means that evictions are disabled for cache.
      *

http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/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 242354e..1722781 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
@@ -22,30 +22,74 @@ import org.apache.ignite.internal.util.typedef.internal.A;
 import org.apache.ignite.internal.util.typedef.internal.U;
 
 /**
- * Database configuration used to configure database.
+ * Database configuration used to configure database and manage offheap memory of Ignite Node.
+ *
+ * <p>It may be configured under {@link IgniteConfiguration XML configuration} as follows:</p>
+ * <pre>
+ *     {@code
+ *     <property name="memoryConfiguration">
+ *         <bean class="org.apache.ignite.configuration.MemoryConfiguration">
+ *             <property name="systemCacheMemorySize" value="103833600"/>
+ *             <property name="defaultMemoryPolicyName" value="default_mem_plc"/>
+ *
+ *             <property name="memoryPolicies">
+ *                 <list>
+ *                     <bean class="org.apache.ignite.configuration.MemoryPolicyConfiguration">
+ *                         <property name="name" value="default_mem_plc"/>
+ *                         <property name="size" value="103833600"/>
+ *                     </bean>
+ *                     <bean class="org.apache.ignite.configuration.MemoryPolicyConfiguration">
+ *                         ...
+ *                     </bean>
+ *                 </list>
+ *             </property>
+ *         </bean>
+ *     </property>
+ *     }
+ * </pre>
  */
 public class MemoryConfiguration implements Serializable {
     /** */
     private static final long serialVersionUID = 0L;
 
-    /** Default cache size is 1Gb. */
-    public static final long DFLT_PAGE_CACHE_SIZE = 1024 * 1024 * 1024;
+    /** Default MemoryPolicy size is 1GB. */
+    public static final long DFLT_MEMORY_POLICY_SIZE = 1024 * 1024 * 1024;
+
+    /** Default size of memory chunk for system cache is 100MB. */
+    public static final long DFLT_SYS_CACHE_MEM_SIZE = 100 * 1024 * 1024;
 
     /** Default page size. */
     public static final int DFLT_PAGE_SIZE = 2 * 1024;
 
+    /** Size of memory for system cache. */
+    private long sysCacheMemSize = DFLT_SYS_CACHE_MEM_SIZE;
+
     /** Page size. */
     private int pageSize = DFLT_PAGE_SIZE;
 
-    /** File cache allocation path. */
-    private String fileCacheAllocationPath;
-
-    /** Amount of memory allocated for the page cache. */
-    private long pageCacheSize = DFLT_PAGE_CACHE_SIZE;
-
     /** Concurrency level. */
     private int concLvl;
 
+    /** Name of MemoryPolicy to be used as default. */
+    private String dfltMemPlcName;
+
+    /** Memory policies. */
+    private MemoryPolicyConfiguration[] memPlcs;
+
+    /**
+     * @return memory size for system cache.
+     */
+    public long getSystemCacheMemorySize() {
+        return sysCacheMemSize;
+    }
+
+    /**
+     * @param sysCacheMemSize Memory size for system cache.
+     */
+    public void setSystemCacheMemorySize(long sysCacheMemSize) {
+        this.sysCacheMemSize = sysCacheMemSize;
+    }
+
     /**
      * @return Page size.
      */
@@ -64,31 +108,29 @@ public class MemoryConfiguration implements Serializable {
     }
 
     /**
-     * @return File allocation path.
+     * @return Array of MemoryPolicyConfiguration objects.
      */
-    public String getFileCacheAllocationPath() {
-        return fileCacheAllocationPath;
+    public MemoryPolicyConfiguration[] getMemoryPolicies() {
+        return memPlcs;
     }
 
     /**
-     * @param fileCacheAllocationPath File allocation path.
+     * @param memPlcs MemoryPolicyConfiguration instances.
      */
-    public void setFileCacheAllocationPath(String fileCacheAllocationPath) {
-        this.fileCacheAllocationPath = fileCacheAllocationPath;
+    public void setMemoryPolicies(MemoryPolicyConfiguration... memPlcs) {
+        this.memPlcs = memPlcs;
     }
 
     /**
-     * @return Page cache size, in bytes.
+     * @return default {@link MemoryPolicyConfiguration} instance.
      */
-    public long getPageCacheSize() {
-        return pageCacheSize;
-    }
+    public MemoryPolicyConfiguration createDefaultPolicyConfig() {
+        MemoryPolicyConfiguration memPlc = new MemoryPolicyConfiguration();
 
-    /**
-     * @param pageCacheSize Page cache size, in bytes.
-     */
-    public void setPageCacheSize(long pageCacheSize) {
-        this.pageCacheSize = pageCacheSize;
+        memPlc.setName(null);
+        memPlc.setSize(DFLT_MEMORY_POLICY_SIZE);
+
+        return memPlc;
     }
 
     /**
@@ -104,4 +146,18 @@ public class MemoryConfiguration implements Serializable {
     public void setConcurrencyLevel(int concLvl) {
         this.concLvl = concLvl;
     }
+
+    /**
+     * @return Name of MemoryPolicy to be used as default.
+     */
+    public String getDefaultMemoryPolicyName() {
+        return dfltMemPlcName;
+    }
+
+    /**
+     * @param dfltMemPlcName Name of MemoryPolicy to be used as default.
+     */
+    public void setDefaultMemoryPolicyName(String dfltMemPlcName) {
+        this.dfltMemPlcName = dfltMemPlcName;
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/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
new file mode 100644
index 0000000..3bf1706
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/MemoryPolicyConfiguration.java
@@ -0,0 +1,80 @@
+/*
+ * 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.configuration;
+
+import java.io.Serializable;
+import org.apache.ignite.internal.pagemem.PageMemory;
+import org.apache.ignite.internal.processors.cache.database.MemoryPolicy;
+
+/**
+ * Configuration bean used for creating {@link MemoryPolicy} instances.
+ */
+public final class MemoryPolicyConfiguration implements Serializable {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** Unique name of MemoryPolicy. */
+    private String name;
+
+    /** Size in bytes of {@link PageMemory} in bytes that will be created for this configuration. */
+    private long size;
+
+    /** Path for memory mapped file (won't be created if not configured). */
+    private String swapFilePath;
+
+    /**
+     * Unique name of MemoryPolicy.
+     */
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * @param name Unique name of MemoryPolicy.
+     */
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    /**
+     * Size in bytes of {@link PageMemory} in bytes that will be created for this configuration.
+     */
+    public long getSize() {
+        return size;
+    }
+
+    /**
+     * Size in bytes of {@link PageMemory} in bytes that will be created for this configuration.
+     */
+    public void setSize(long size) {
+        this.size = size;
+    }
+
+    /**
+     * @return Path for memory mapped file (won't be created if not configured).
+     */
+    public String getSwapFilePath() {
+        return swapFilePath;
+    }
+
+    /**
+     * @param swapFilePath Path for memory mapped file (won't be created if not configured)..
+     */
+    public void setSwapFilePath(String swapFilePath) {
+        this.swapFilePath = swapFilePath;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
index 6252182..9a924a1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
@@ -36,6 +36,7 @@ import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
 import java.util.ListIterator;
 import java.util.Map;
@@ -81,6 +82,7 @@ import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.CollectionConfiguration;
 import org.apache.ignite.configuration.ConnectorConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.MemoryConfiguration;
 import org.apache.ignite.configuration.NearCacheConfiguration;
 import org.apache.ignite.internal.binary.BinaryEnumCache;
 import org.apache.ignite.internal.binary.BinaryMarshaller;
@@ -107,6 +109,7 @@ import org.apache.ignite.internal.processors.cache.GridCacheUtilityKey;
 import org.apache.ignite.internal.processors.cache.IgniteCacheProxy;
 import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
 import org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl;
+import org.apache.ignite.internal.processors.cache.database.MemoryPolicy;
 import org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor;
 import org.apache.ignite.internal.processors.clock.GridClockSyncProcessor;
 import org.apache.ignite.internal.processors.closure.GridClosureProcessor;
@@ -775,6 +778,7 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
         ackClassPaths(rtBean);
         ackSystemProperties();
         ackEnvironmentVariables();
+        ackMemoryConfiguration();
         ackCacheConfiguration();
         ackP2pConfiguration();
         ackRebalanceConfiguration();
@@ -1185,7 +1189,13 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
                                 sysPoolQSize = exec.getQueue().size();
                             }
 
-                            PageMemory pageMem = ctx.cache().context().database().pageMemory();
+                            int loadedPages = 0;
+
+                            for (GridCacheContext cctx : ctx.cache().context().cacheContexts()) {
+                                MemoryPolicy memPlc = cctx.memoryPolicy();
+
+                                loadedPages += memPlc != null ? memPlc.pageMemory().loadedPages() : 0;
+                            }
 
                             String id = U.id8(localNode().id());
 
@@ -1195,7 +1205,7 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
                                 "    ^-- H/N/C [hosts=" + hosts + ", nodes=" + nodes + ", CPUs=" + cpus + "]" + NL +
                                 "    ^-- CPU [cur=" + dblFmt.format(cpuLoadPct) + "%, avg=" +
                                 dblFmt.format(avgCpuLoadPct) + "%, GC=" + dblFmt.format(gcPct) + "%]" + NL +
-                                "    ^-- PageMemory [pages=" + (pageMem != null ? pageMem.loadedPages() : 0) + "]" + NL +
+                                "    ^-- PageMemory [pages=" + loadedPages + "]" + NL +
                                 "    ^-- Heap [used=" + dblFmt.format(heapUsedInMBytes) + "MB, free=" +
                                 dblFmt.format(freeHeapPct) + "%, comm=" + dblFmt.format(heapCommInMBytes) + "MB]" + NL +
                                 "    ^-- Non heap [used=" + dblFmt.format(nonHeapUsedInMBytes) + "MB, free=" +
@@ -2415,6 +2425,18 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
     /**
      *
      */
+    private void ackMemoryConfiguration() {
+        MemoryConfiguration memCfg = cfg.getMemoryConfiguration();
+
+        U.log(log, "System cache MemoryPolicy size is configured to " +
+                (memCfg.getSystemCacheMemorySize() / (1024 * 1024)) +
+        "MB size. " +
+                "Use MemoryConfiguration.systemCacheMemorySize property to change it.");
+    }
+
+    /**
+     *
+     */
     private void ackCacheConfiguration() {
         CacheConfiguration[] cacheCfgs = cfg.getCacheConfiguration();
 
@@ -2423,15 +2445,31 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
         else {
             SB sb = new SB();
 
+            HashMap<String, ArrayList<String>> memPlcNamesMapping = new HashMap<>();
+
             for (CacheConfiguration c : cacheCfgs) {
-                String name = U.maskName(c.getName());
+                String cacheName = U.maskName(c.getName());
+
+                String memPlcName = U.maskName(c.getMemoryPolicyName());
+
+                if (!memPlcNamesMapping.containsKey(memPlcName))
+                    memPlcNamesMapping.put(memPlcName, new ArrayList<String>());
 
-                sb.a("'").a(name).a("', ");
+                ArrayList<String> cacheNames = memPlcNamesMapping.get(memPlcName);
+
+                cacheNames.add(cacheName);
             }
 
-            String names = sb.toString();
+            for (Map.Entry<String, ArrayList<String>> e : memPlcNamesMapping.entrySet()) {
+                sb.a("in '").a(e.getKey()).a("' memoryPolicy: [");
+
+                for (String s : e.getValue())
+                    sb.a("'").a(s).a("', ");
+
+                sb.d(sb.length() - 2, sb.length()).a("]");
+            }
 
-            U.log(log, "Configured caches [" + names.substring(0, names.length() - 2) + ']');
+            U.log(log, "Configured caches [" + sb.toString() + ']');
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
index e8513de..ffc379c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
@@ -54,7 +54,11 @@ import org.apache.ignite.internal.managers.communication.GridIoManager;
 import org.apache.ignite.internal.managers.deployment.GridDeploymentManager;
 import org.apache.ignite.internal.managers.discovery.GridDiscoveryManager;
 import org.apache.ignite.internal.managers.eventstorage.GridEventStorageManager;
+import org.apache.ignite.internal.pagemem.PageMemory;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.internal.processors.cache.database.MemoryPolicy;
+import org.apache.ignite.internal.processors.cache.database.freelist.FreeList;
+import org.apache.ignite.internal.processors.cache.database.tree.reuse.ReuseList;
 import org.apache.ignite.internal.processors.cache.datastructures.CacheDataStructuresManager;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheAdapter;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheEntry;
@@ -133,6 +137,15 @@ public class GridCacheContext<K, V> implements Externalizable {
     /** Cache shared context. */
     private GridCacheSharedContext<K, V> sharedCtx;
 
+    /** Memory policy. */
+    private MemoryPolicy memPlc;
+
+    /** FreeList instance this cache is associated with. */
+    private FreeList freeList;
+
+    /** ReuseList instance this cache is associated with */
+    private ReuseList reuseList;
+
     /** Logger. */
     private IgniteLogger log;
 
@@ -256,6 +269,8 @@ public class GridCacheContext<K, V> implements Externalizable {
      * @param sharedCtx Cache shared context.
      * @param cacheCfg Cache configuration.
      * @param cacheType Cache type.
+     * @param memPlc MemoryPolicy instance.
+     * @param freeList FreeList instance.
      * @param affNode {@code True} if local node is affinity node.
      * @param updatesAllowed Updates allowed flag.
      * @param evtMgr Cache event manager.
@@ -278,6 +293,9 @@ public class GridCacheContext<K, V> implements Externalizable {
         CacheType cacheType,
         boolean affNode,
         boolean updatesAllowed,
+        MemoryPolicy memPlc,
+        FreeList freeList,
+        ReuseList reuseList,
 
         /*
          * Managers in starting order!
@@ -321,6 +339,10 @@ public class GridCacheContext<K, V> implements Externalizable {
         this.updatesAllowed = updatesAllowed;
         this.depEnabled = ctx.deploy().enabled() && !cacheObjects().isBinaryEnabled(cacheCfg);
 
+        this.memPlc = memPlc;
+        this.freeList = freeList;
+        this.reuseList = reuseList;
+
         /*
          * Managers in starting order!
          * ===========================
@@ -681,6 +703,27 @@ public class GridCacheContext<K, V> implements Externalizable {
     }
 
     /**
+     * @return Memory policy.
+     */
+    public MemoryPolicy memoryPolicy() {
+        return memPlc;
+    }
+
+    /**
+     * @return Free List.
+     */
+    public FreeList freeList() {
+        return freeList;
+    }
+
+    /**
+     * @return Reuse List.
+     */
+    public ReuseList reuseList() {
+        return reuseList;
+    }
+
+    /**
      * Gets public name for cache.
      *
      * @return Public name of the cache.

http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/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 9d7b40f..d4f6d87 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
@@ -73,6 +73,7 @@ import org.apache.ignite.internal.binary.BinaryContext;
 import org.apache.ignite.internal.binary.BinaryMarshaller;
 import org.apache.ignite.internal.binary.GridBinaryMarshaller;
 import org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage;
+import org.apache.ignite.internal.pagemem.PageMemory;
 import org.apache.ignite.internal.pagemem.snapshot.StartFullSnapshotAckDiscoveryMessage;
 import org.apache.ignite.internal.pagemem.store.IgnitePageStoreManager;
 import org.apache.ignite.internal.pagemem.wal.IgniteWriteAheadLogManager;
@@ -80,6 +81,9 @@ import org.apache.ignite.internal.processors.GridProcessorAdapter;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
 import org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl;
 import org.apache.ignite.internal.processors.cache.database.IgniteCacheDatabaseSharedManager;
+import org.apache.ignite.internal.processors.cache.database.MemoryPolicy;
+import org.apache.ignite.internal.processors.cache.database.freelist.FreeList;
+import org.apache.ignite.internal.processors.cache.database.tree.reuse.ReuseList;
 import org.apache.ignite.internal.processors.cache.datastructures.CacheDataStructuresManager;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCache;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheAdapter;
@@ -708,6 +712,9 @@ public class GridCacheProcessor extends GridProcessorAdapter {
             else
                 cacheType = CacheType.USER;
 
+        if (cacheType != CacheType.USER)
+            cfg.setMemoryPolicyName(sharedCtx.database().systemMemoryPolicyName());
+
         boolean template = cfg.getName() != null && cfg.getName().endsWith("*");
 
         DynamicCacheDescriptor desc = new DynamicCacheDescriptor(ctx,
@@ -1220,7 +1227,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
         cacheCtx.onStarted();
 
         if (log.isInfoEnabled())
-            log.info("Started cache [name=" + U.maskName(cfg.getName()) + ", mode=" + cfg.getCacheMode() + ']');
+            log.info("Started cache [name=" + U.maskName(cfg.getName()) + ", memoryPolicyName=" + cfg.getMemoryPolicyName() + ", mode=" + cfg.getCacheMode() + ']');
     }
 
     /**
@@ -1455,6 +1462,12 @@ public class GridCacheProcessor extends GridProcessorAdapter {
 
         boolean affNode = cfg.getCacheMode() == LOCAL || CU.affinityNode(ctx.discovery().localNode(), cfg.getNodeFilter());
 
+        String memPlcName = cfg.getMemoryPolicyName();
+
+        MemoryPolicy memPlc = sharedCtx.database().memoryPolicy(memPlcName);
+        FreeList freeList = sharedCtx.database().freeList(memPlcName);
+        ReuseList reuseList = sharedCtx.database().reuseList(memPlcName);
+
         GridCacheContext<?, ?> cacheCtx = new GridCacheContext(
             ctx,
             sharedCtx,
@@ -1462,6 +1475,9 @@ public class GridCacheProcessor extends GridProcessorAdapter {
             cacheType,
             affNode,
             updatesAllowed,
+            memPlc,
+            freeList,
+            reuseList,
 
             /*
              * Managers in starting order!
@@ -1590,6 +1606,9 @@ public class GridCacheProcessor extends GridProcessorAdapter {
                 cacheType,
                 affNode,
                 true,
+                memPlc,
+                freeList,
+                reuseList,
 
                 /*
                  * Managers in starting order!

http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/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 16d3715..88cb708 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
@@ -162,9 +162,9 @@ public class IgniteCacheOffheapManagerImpl extends GridCacheManagerAdapter imple
 
             pendingEntries = new PendingEntriesTree(cctx,
                 name,
-                cctx.shared().database().pageMemory(),
+                cctx.memoryPolicy().pageMemory(),
                 rootPage,
-                cctx.shared().database().globalReuseList(),
+                cctx.reuseList(),
                 true);
         }
     }
@@ -639,12 +639,12 @@ public class IgniteCacheOffheapManagerImpl extends GridCacheManagerAdapter imple
      * @throws IgniteCheckedException If failed.
      */
     private long allocateForTree() throws IgniteCheckedException {
-        ReuseList reuseList = cctx.shared().database().globalReuseList();
+        ReuseList reuseList = cctx.reuseList();
 
         long pageId;
 
         if (reuseList == null || (pageId = reuseList.takeRecycledPage()) == 0L)
-            pageId = cctx.shared().database().pageMemory().allocatePage(cctx.cacheId(), INDEX_PARTITION, FLAG_IDX);
+            pageId = cctx.memoryPolicy().pageMemory().allocatePage(cctx.cacheId(), INDEX_PARTITION, FLAG_IDX);
 
         return pageId;
     }
@@ -663,7 +663,7 @@ public class IgniteCacheOffheapManagerImpl extends GridCacheManagerAdapter imple
 
     /** {@inheritDoc} */
     @Override public ReuseList reuseListForIndex(String idxName) {
-        return cctx.shared().database().globalReuseList();
+        return cctx.reuseList();
     }
 
     /** {@inheritDoc} */
@@ -736,21 +736,16 @@ public class IgniteCacheOffheapManagerImpl extends GridCacheManagerAdapter imple
      */
     protected CacheDataStore createCacheDataStore0(int p)
         throws IgniteCheckedException {
-        IgniteCacheDatabaseSharedManager dbMgr = cctx.shared().database();
-
         final long rootPage = allocateForTree();
 
-        FreeList freeList = cctx.shared().database().globalFreeList();
-
-        CacheDataRowStore rowStore = new CacheDataRowStore(cctx, freeList);
+        CacheDataRowStore rowStore = new CacheDataRowStore(cctx, cctx.freeList());
 
         String idxName = treeName(p);
 
         CacheDataTree dataTree = new CacheDataTree(idxName,
-            cctx.shared().database().globalReuseList(),
+            cctx.reuseList(),
             rowStore,
             cctx,
-            dbMgr.pageMemory(),
             rootPage,
             true);
 
@@ -1408,7 +1403,6 @@ public class IgniteCacheOffheapManagerImpl extends GridCacheManagerAdapter imple
          * @param reuseList Reuse list.
          * @param rowStore Row store.
          * @param cctx Context.
-         * @param pageMem Page memory.
          * @param metaPageId Meta page ID.
          * @param initNew Initialize new index.
          * @throws IgniteCheckedException If failed.
@@ -1418,12 +1412,18 @@ public class IgniteCacheOffheapManagerImpl extends GridCacheManagerAdapter imple
             ReuseList reuseList,
             CacheDataRowStore rowStore,
             GridCacheContext cctx,
-            PageMemory pageMem,
             long metaPageId,
             boolean initNew
         ) throws IgniteCheckedException {
-            super(name, cctx.cacheId(), pageMem, cctx.shared().wal(), cctx.offheap().globalRemoveId(), metaPageId,
-                reuseList, DataInnerIO.VERSIONS, DataLeafIO.VERSIONS);
+            super(name,
+                    cctx.cacheId(),
+                    cctx.memoryPolicy().pageMemory(),
+                    cctx.shared().wal(),
+                    cctx.offheap().globalRemoveId(),
+                    metaPageId,
+                    reuseList,
+                    DataInnerIO.VERSIONS,
+                    DataLeafIO.VERSIONS);
 
             assert rowStore != null;
 
@@ -1472,7 +1472,7 @@ public class IgniteCacheOffheapManagerImpl extends GridCacheManagerAdapter imple
         private int compareKeys(KeyCacheObject key, final long link) throws IgniteCheckedException {
             byte[] bytes = key.valueBytes(cctx.cacheObjectContext());
 
-            PageMemory pageMem = cctx.shared().database().pageMemory();
+            PageMemory pageMem = cctx.memoryPolicy().pageMemory();
 
             try (Page page = page(pageId(link))) {
                 long pageAddr = page.getForReadPointer(); // Non-empty data page must not be recycled.

http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/CacheDataRowAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/CacheDataRowAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/CacheDataRowAdapter.java
index 5a62e75..72b7d02 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/CacheDataRowAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/CacheDataRowAdapter.java
@@ -104,7 +104,7 @@ public class CacheDataRowAdapter implements CacheDataRow {
         boolean first = true;
 
         do {
-            PageMemory pageMem = cctx.shared().database().pageMemory();
+            PageMemory pageMem = cctx.memoryPolicy().pageMemory();
 
             try (Page page = page(pageId(nextLink), cctx)) {
                 long pageAddr = page.getForReadPointer(); // Non-empty data page must not be recycled.
@@ -460,7 +460,7 @@ public class CacheDataRowAdapter implements CacheDataRow {
      * @throws IgniteCheckedException If failed.
      */
     private Page page(final long pageId, final GridCacheContext cctx) throws IgniteCheckedException {
-        return cctx.shared().database().pageMemory().page(cctx.cacheId(), pageId);
+        return cctx.memoryPolicy().pageMemory().page(cctx.cacheId(), pageId);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/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 7fb9d0a..c1c2e67 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
@@ -19,11 +19,15 @@ package org.apache.ignite.internal.processors.cache.database;
 
 import java.io.File;
 import java.util.Collection;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
 import java.util.UUID;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteLogger;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.configuration.MemoryConfiguration;
+import org.apache.ignite.configuration.MemoryPolicyConfiguration;
 import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.mem.DirectMemoryProvider;
@@ -46,11 +50,26 @@ import org.jetbrains.annotations.Nullable;
  *
  */
 public class IgniteCacheDatabaseSharedManager extends GridCacheSharedManagerAdapter implements IgniteChangeGlobalStateSupport {
+    /** MemoryPolicyConfiguration name reserved for internal caches. */
+    private static final String SYSTEM_MEMORY_POLICY_NAME = "sysMemPlc";
+
+    /** Minimum size of memory chunk */
+    private static final long MIN_PAGE_MEMORY_SIZE = 1024 * 1024;
+
+    /** */
+    protected Map<String, MemoryPolicy> memPlcMap;
+
+    /** */
+    protected MemoryPolicy dfltMemPlc;
+
+    /** */
+    private Map<String, FreeListImpl> freeListMap;
+
     /** */
-    protected PageMemory pageMem;
+    private FreeListImpl dfltFreeList;
 
     /** */
-    private FreeListImpl freeList;
+    private int pageSize;
 
     /** {@inheritDoc} */
     @Override protected void start0() throws IgniteCheckedException {
@@ -62,33 +81,203 @@ public class IgniteCacheDatabaseSharedManager extends GridCacheSharedManagerAdap
      * @throws IgniteCheckedException If failed.
      */
     public void init() throws IgniteCheckedException {
-        if (pageMem == null) {
+        if (memPlcMap == null) {
             MemoryConfiguration dbCfg = cctx.kernalContext().config().getMemoryConfiguration();
 
             if (dbCfg == null)
                 dbCfg = new MemoryConfiguration();
 
-            pageMem = initMemory(dbCfg);
+            validateConfiguration(dbCfg);
+
+            pageSize = dbCfg.getPageSize();
+
+            initPageMemoryPolicies(dbCfg);
 
-            pageMem.start();
+            startPageMemoryPools();
 
-            initDataStructures();
+            initPageMemoryDataStructures(dbCfg);
         }
     }
 
     /**
-     * @param log Logger.
+     * @param dbCfg Database config.
      */
-    public void dumpStatistics(IgniteLogger log) {
-        if (freeList != null)
-            freeList.dumpStatistics(log);
+    protected void initPageMemoryDataStructures(MemoryConfiguration dbCfg) throws IgniteCheckedException {
+        freeListMap = U.newHashMap(memPlcMap.size());
+
+        String dfltMemPlcName = dbCfg.getDefaultMemoryPolicyName();
+
+        for (MemoryPolicy memPlc : memPlcMap.values()) {
+            MemoryPolicyConfiguration memPlcCfg = memPlc.config();
+
+            FreeListImpl freeList = new FreeListImpl(0,
+                    cctx.igniteInstanceName(),
+                    memPlc.pageMemory(),
+                    null,
+                    cctx.wal(),
+                    0L,
+                    true);
+
+            freeListMap.put(memPlcCfg.getName(), freeList);
+        }
+
+        dfltFreeList = freeListMap.get(dfltMemPlcName);
     }
 
     /**
-     * @throws IgniteCheckedException If failed.
+     * @return Size of page used for PageMemory regions.
+     */
+    public int pageSize() {
+        return pageSize;
+    }
+
+    /**
+     *
+     */
+    private void startPageMemoryPools() {
+        for (MemoryPolicy memPlc : memPlcMap.values())
+            memPlc.pageMemory().start();
+    }
+
+    /**
+     * @param dbCfg Database config.
+     */
+    protected void initPageMemoryPolicies(MemoryConfiguration dbCfg) {
+        MemoryPolicyConfiguration[] memPlcsCfgs = dbCfg.getMemoryPolicies();
+
+        if (memPlcsCfgs == null) {
+            //reserve place for default and system memory policies
+            memPlcMap = U.newHashMap(2);
+
+            dfltMemPlc = createDefaultMemoryPolicy(dbCfg);
+            memPlcMap.put(null, dfltMemPlc);
+
+            log.warning("No user-defined default MemoryPolicy found; system default of 1GB size will be used.");
+        }
+        else {
+            String dfltMemPlcName = dbCfg.getDefaultMemoryPolicyName();
+
+            if (dfltMemPlcName == null) {
+                //reserve additional place for default and system memory policies
+                memPlcMap = U.newHashMap(memPlcsCfgs.length + 2);
+
+                dfltMemPlc = createDefaultMemoryPolicy(dbCfg);
+                memPlcMap.put(null, dfltMemPlc);
+
+                log.warning("No user-defined default MemoryPolicy found; system default of 1GB size will be used.");
+            }
+            else
+                //reserve additional place for system memory policy only
+                memPlcMap = U.newHashMap(memPlcsCfgs.length + 1);
+
+            for (MemoryPolicyConfiguration memPlcCfg : memPlcsCfgs) {
+                PageMemory pageMem = initMemory(dbCfg, memPlcCfg);
+
+                MemoryPolicy memPlc = new MemoryPolicy(pageMem, memPlcCfg);
+
+                memPlcMap.put(memPlcCfg.getName(), memPlc);
+
+                if (memPlcCfg.getName().equals(dfltMemPlcName))
+                    dfltMemPlc = memPlc;
+            }
+        }
+
+        MemoryPolicyConfiguration sysPlcCfg = createSystemMemoryPolicy(dbCfg.getSystemCacheMemorySize());
+
+        memPlcMap.put(SYSTEM_MEMORY_POLICY_NAME, new MemoryPolicy(initMemory(dbCfg, sysPlcCfg), sysPlcCfg));
+    }
+
+    /**
+     * @param dbCfg Database config.
+     */
+    private MemoryPolicy createDefaultMemoryPolicy(MemoryConfiguration dbCfg) {
+        MemoryPolicyConfiguration dfltPlc = dbCfg.createDefaultPolicyConfig();
+
+        PageMemory pageMem = initMemory(dbCfg, dfltPlc);
+
+        return new MemoryPolicy(pageMem, dfltPlc);
+    }
+
+    /**
+     * @param sysCacheMemSize size of PageMemory to be created for system cache.
+     */
+    private MemoryPolicyConfiguration createSystemMemoryPolicy(long sysCacheMemSize) {
+        MemoryPolicyConfiguration res = new MemoryPolicyConfiguration();
+
+        res.setName(SYSTEM_MEMORY_POLICY_NAME);
+        res.setSize(sysCacheMemSize);
+
+        return res;
+    }
+
+    /**
+     * @param dbCfg configuration to validate.
+     */
+    private void validateConfiguration(MemoryConfiguration dbCfg) throws IgniteCheckedException {
+        MemoryPolicyConfiguration[] plcCfgs = dbCfg.getMemoryPolicies();
+
+        Set<String> plcNames = (plcCfgs != null) ? U.<String>newHashSet(plcCfgs.length) : new HashSet<String>(0);
+
+        if (plcCfgs != null) {
+            for (MemoryPolicyConfiguration plcCfg : plcCfgs) {
+                assert plcCfg != null;
+
+                checkPolicyName(plcCfg.getName(), plcNames);
+
+                checkPolicySize(plcCfg);
+            }
+        }
+
+        checkDefaultPolicyConfiguration(dbCfg.getDefaultMemoryPolicyName(), plcNames);
+    }
+
+    /**
+     * @param dfltPlcName Default MemoryPolicy name.
+     * @param plcNames All MemoryPolicy names.
+     * @throws IgniteCheckedException In case of validation violation.
+     */
+    private static void checkDefaultPolicyConfiguration(String dfltPlcName, Set<String> plcNames) throws IgniteCheckedException {
+        if (dfltPlcName != null) {
+            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);
+        }
+    }
+
+    /**
+     * @param plcCfg MemoryPolicyConfiguration to validate.
      */
-    protected void initDataStructures() throws IgniteCheckedException {
-        freeList = new FreeListImpl(0, cctx.igniteInstanceName(), pageMem, null, cctx.wal(), 0L, true);
+    private static void checkPolicySize(MemoryPolicyConfiguration plcCfg) throws IgniteCheckedException {
+        if (plcCfg.getSize() < MIN_PAGE_MEMORY_SIZE)
+            throw new IgniteCheckedException("MemoryPolicy must have size more than 1MB: " + plcCfg.getName());
+    }
+
+    /**
+     * @param plcName MemoryPolicy name to validate.
+     * @param observedNames Names of MemoryPolicies observed before.
+     */
+    private static void checkPolicyName(String plcName, Set<String> observedNames) throws IgniteCheckedException {
+        if (plcName == null || plcName.isEmpty())
+            throw new IgniteCheckedException("User-defined MemoryPolicyConfiguration must have non-null and non-empty name.");
+
+        if (observedNames.contains(plcName))
+            throw new IgniteCheckedException("Two MemoryPolicies have the same name: " + plcName);
+
+        if (SYSTEM_MEMORY_POLICY_NAME.equals(plcName))
+            throw new IgniteCheckedException("'sysMemPlc' policy name is reserved for internal use.");
+
+        observedNames.add(plcName);
+    }
+
+    /**
+     * @param log Logger.
+     */
+    public void dumpStatistics(IgniteLogger log) {
+        if (freeListMap != null) {
+            for (FreeListImpl freeList : freeListMap.values())
+                freeList.dumpStatistics(log);
+        }
     }
 
     /**
@@ -99,27 +288,60 @@ public class IgniteCacheDatabaseSharedManager extends GridCacheSharedManagerAdap
     }
 
     /**
-     * @return Node-global free list.
+     * @return collection of all configured {@link MemoryPolicy policies}.
      */
-    public FreeList globalFreeList() {
-        assert freeList != null : "Non initialized";
+    public Collection<MemoryPolicy> memoryPolicies() {
+        return memPlcMap != null ? memPlcMap.values() : null;
+    }
+
+    /**
+     * @param memPlcName Memory policy name.
+     * @return {@link MemoryPolicy} instance associated with a given {@link MemoryPolicyConfiguration}.
+     * @throws IgniteCheckedException in case of request for unknown MemoryPolicy.
+     */
+    public MemoryPolicy memoryPolicy(String memPlcName) throws IgniteCheckedException {
+        if (memPlcName == null)
+            return dfltMemPlc;
+
+        if (memPlcMap == null)
+            return null;
 
-        return freeList;
+        MemoryPolicy plc;
+
+        if ((plc = memPlcMap.get(memPlcName)) == null)
+            throw new IgniteCheckedException("Requested MemoryPolicy is not configured: " + memPlcName);
+
+        return plc;
     }
 
     /**
-     * @return Node-global reuse list.
+     * @param memPlcName MemoryPolicyConfiguration name.
+     * @return {@link FreeList} instance associated with a given {@link MemoryPolicyConfiguration}.
      */
-    public ReuseList globalReuseList() {
-        assert freeList != null : "Non initialized";
+    public FreeList freeList(String memPlcName) {
+        if (memPlcName == null)
+            return dfltFreeList;
 
-        return freeList;
+        return freeListMap != null ? freeListMap.get(memPlcName) : null;
+    }
+
+    /**
+     * @param memPlcName MemoryPolicyConfiguration name.
+     * @return {@link ReuseList} instance associated with a given {@link MemoryPolicyConfiguration}.
+     */
+    public ReuseList reuseList(String memPlcName) {
+        if (memPlcName == null)
+            return dfltFreeList;
+
+        return freeListMap != null ? freeListMap.get(memPlcName) : null;
     }
 
     /** {@inheritDoc} */
     @Override protected void stop0(boolean cancel) {
-        if (pageMem != null)
-            pageMem.stop();
+        if (memPlcMap != null) {
+            for (MemoryPolicy memPlc : memPlcMap.values())
+                memPlc.pageMemory().stop();
+        }
     }
 
     /**
@@ -130,13 +352,6 @@ public class IgniteCacheDatabaseSharedManager extends GridCacheSharedManagerAdap
     }
 
     /**
-     * @return Page memory instance.
-     */
-    public PageMemory pageMemory() {
-        return pageMem;
-    }
-
-    /**
      *
      */
     public void lock() throws IgniteCheckedException {
@@ -230,42 +445,76 @@ public class IgniteCacheDatabaseSharedManager extends GridCacheSharedManagerAdap
     }
 
     /**
-     * @param dbCfg Database configuration.
+     * @param dbCfg memory configuration with common parameters.
+     * @param plc memory policy with PageMemory specific parameters.
      * @return Page memory instance.
      */
-    protected PageMemory initMemory(MemoryConfiguration dbCfg) {
-        String path = dbCfg.getFileCacheAllocationPath();
+    private PageMemory initMemory(MemoryConfiguration dbCfg, MemoryPolicyConfiguration plc) {
+        long[] sizes = calculateFragmentSizes(
+                dbCfg.getConcurrencyLevel(),
+                plc.getSize());
 
-        int concLvl = dbCfg.getConcurrencyLevel();
+        File allocPath = buildAllocPath(plc);
 
+        DirectMemoryProvider memProvider = allocPath == null ?
+            new UnsafeMemoryProvider(sizes) :
+            new MappedFileMemoryProvider(
+                log,
+                allocPath,
+                true,
+                sizes);
+
+        return createPageMemory(memProvider, dbCfg.getPageSize());
+    }
+
+    /**
+     * Calculate fragment sizes for a cache with given size and concurrency level.
+     * @param concLvl Concurrency level.
+     * @param cacheSize Cache size.
+     */
+    protected long[] calculateFragmentSizes(int concLvl, long cacheSize) {
         if (concLvl < 1)
             concLvl = Runtime.getRuntime().availableProcessors();
 
-        long fragmentSize = dbCfg.getPageCacheSize() / concLvl;
+        long fragmentSize = cacheSize / concLvl;
 
         if (fragmentSize < 1024 * 1024)
             fragmentSize = 1024 * 1024;
 
-        String consId = String.valueOf(cctx.discovery().consistentId());
-
-        consId = consId.replaceAll("[:,\\.]", "_");
-
-        File allocPath = path == null ? null : buildPath(path, consId);
-
         long[] sizes = new long[concLvl];
 
         for (int i = 0; i < concLvl; i++)
             sizes[i] = fragmentSize;
 
-        DirectMemoryProvider memProvider = path == null ?
-            new UnsafeMemoryProvider(sizes) :
-            new MappedFileMemoryProvider(
-                log,
-                allocPath,
-                true,
-                sizes);
+        return sizes;
+    }
 
-        return new PageMemoryNoStoreImpl(log, memProvider, cctx, dbCfg.getPageSize(), false);
+    /**
+     * Builds allocation path for memory mapped file to be used with PageMemory.
+     *
+     * @param plc MemoryPolicyConfiguration.
+     */
+    @Nullable protected File buildAllocPath(MemoryPolicyConfiguration plc) {
+        String path = plc.getSwapFilePath();
+
+        if (path == null)
+            return null;
+
+        String consId = String.valueOf(cctx.discovery().consistentId());
+
+        consId = consId.replaceAll("[:,\\.]", "_");
+
+        return buildPath(path, consId);
+    }
+
+    /**
+     * Creates PageMemory with given size and memory provider.
+     *
+     * @param memProvider Memory provider.
+     * @param pageSize Page size.
+     */
+    protected PageMemory createPageMemory(DirectMemoryProvider memProvider, int pageSize) {
+        return new PageMemoryNoStoreImpl(log, memProvider, cctx, pageSize, false);
     }
 
     /**
@@ -292,4 +541,11 @@ public class IgniteCacheDatabaseSharedManager extends GridCacheSharedManagerAdap
     @Override public void onDeActivate(GridKernalContext kctx) throws IgniteCheckedException {
 
     }
+
+    /**
+     * @return Name of MemoryPolicyConfiguration for internal caches.
+     */
+    public String systemMemoryPolicyName() {
+        return SYSTEM_MEMORY_POLICY_NAME;
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/MemoryPolicy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/MemoryPolicy.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/MemoryPolicy.java
new file mode 100644
index 0000000..0978d10
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/MemoryPolicy.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ignite.internal.processors.cache.database;
+
+import org.apache.ignite.configuration.MemoryPolicyConfiguration;
+import org.apache.ignite.internal.pagemem.PageMemory;
+
+/**
+ * Memory policy provides access to objects configured with {@link MemoryPolicyConfiguration} configuration.
+ */
+public class MemoryPolicy {
+    /** */
+    private final PageMemory pageMem;
+
+    /** */
+    private final MemoryPolicyConfiguration cfg;
+
+    /**
+     * @param pageMem Page mem.
+     */
+    public MemoryPolicy(PageMemory pageMem, MemoryPolicyConfiguration cfg) {
+        this.pageMem = pageMem;
+        this.cfg = cfg;
+    }
+
+    /**
+     *
+     */
+    public PageMemory pageMemory() {
+        return pageMem;
+    }
+
+    /**
+     * @return Config.
+     */
+    public MemoryPolicyConfiguration config() {
+        return cfg;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/RowStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/RowStore.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/RowStore.java
index 8d54542..6d1fc0e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/RowStore.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/RowStore.java
@@ -52,7 +52,7 @@ public class RowStore {
         this.freeList = freeList;
 
         coctx = cctx.cacheObjectContext();
-        pageMem = cctx.shared().database().pageMemory();
+        pageMem = cctx.memoryPolicy().pageMemory();
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
index 750a99d..c257154 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
@@ -1567,7 +1567,6 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter implements AutoClosea
                 {
                     if (log.isDebugEnabled())
                         log.debug("Acquired transaction lock for remove on keys: " + enlisted);
-                    U.debug(log, "Acquired transaction lock for remove on keys: " + enlisted);
 
                     postLockWrite(cacheCtx,
                         enlisted,

http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorGridConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorGridConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorGridConfiguration.java
index d20e074..0ce13df 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorGridConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorGridConfiguration.java
@@ -112,7 +112,7 @@ public class VisorGridConfiguration implements Serializable, LessNamingBean {
         sysProps = IgniteSystemProperties.snapshot();
         atomic = VisorAtomicConfiguration.from(c.getAtomicConfiguration());
         txCfg = VisorTransactionConfiguration.from(c.getTransactionConfiguration());
-        memCfg = VisorMemoryConfiguration.from(c.getMemoryConfiguration());
+        memCfg = new VisorMemoryConfiguration(c.getMemoryConfiguration());
 
         return this;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorMemoryConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorMemoryConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorMemoryConfiguration.java
index 489aad2..2080105 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorMemoryConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorMemoryConfiguration.java
@@ -18,19 +18,20 @@
 package org.apache.ignite.internal.visor.node;
 
 import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
 import org.apache.ignite.configuration.MemoryConfiguration;
+import org.apache.ignite.configuration.MemoryPolicyConfiguration;
 import org.apache.ignite.internal.LessNamingBean;
+import org.apache.ignite.internal.util.typedef.F;
 
 /**
  * Data transfer object for memory configuration.
  */
-public class VisorMemoryConfiguration implements Serializable, LessNamingBean {
+public class VisorMemoryConfiguration implements Serializable {
     /** */
     private static final long serialVersionUID = 0L;
 
-    /** Concurrency level. */
-    private int concLvl;
-
     /** File cache allocation path. */
     private String fileCacheAllocationPath;
 
@@ -40,27 +41,41 @@ public class VisorMemoryConfiguration implements Serializable, LessNamingBean {
     /** Page size. */
     private int pageSize;
 
+    /** Concurrency level. */
+    private int concLvl;
+
+    /** Name of MemoryPolicy to be used as default. */
+    private String dfltMemPlcName;
+
+    /** Memory policies. */
+    private List<VisorMemoryPolicyConfiguration> memPlcs;
+
     /**
      * Create data transfer object.
      *
      * @param memCfg Memory configuration.
-     * @return Data transfer object.
      */
-    public static VisorMemoryConfiguration from(MemoryConfiguration memCfg) {
-        VisorMemoryConfiguration res = new VisorMemoryConfiguration();
+    public VisorMemoryConfiguration(MemoryConfiguration memCfg) {
+        assert memCfg != null;
+
+        pageSize = memCfg.getPageSize();
+        concLvl = memCfg.getConcurrencyLevel();
+        dfltMemPlcName = memCfg.getDefaultMemoryPolicyName();
 
-        res.concLvl = memCfg.getConcurrencyLevel();
-        res.fileCacheAllocationPath = memCfg.getFileCacheAllocationPath();
-        res.pageCacheSize = memCfg.getPageCacheSize();
-        res.pageSize = memCfg.getPageSize();
+        MemoryPolicyConfiguration[] plcs = memCfg.getMemoryPolicies();
 
-        return res;
+        if (!F.isEmpty(plcs)) {
+            memPlcs = new ArrayList<>(plcs.length);
+
+            for (MemoryPolicyConfiguration plc : plcs)
+                memPlcs.add(new VisorMemoryPolicyConfiguration(plc));
+        }
     }
 
     /**
      * @return Concurrency level.
      */
-    public int concurrencyLevel() {
+    public int getConcurrencyLevel() {
         return concLvl;
     }
 
@@ -84,4 +99,18 @@ public class VisorMemoryConfiguration implements Serializable, LessNamingBean {
     public int getPageSize() {
         return pageSize;
     }
+
+    /**
+     * @return Name of MemoryPolicy to be used as default.
+     */
+    public String getDefaultMemoryPolicyName() {
+        return dfltMemPlcName;
+    }
+
+    /**
+     * @return Collection of MemoryPolicyConfiguration objects.
+     */
+    public List<VisorMemoryPolicyConfiguration> getMemoryPolicies() {
+        return memPlcs;
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorMemoryPolicyConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorMemoryPolicyConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorMemoryPolicyConfiguration.java
new file mode 100644
index 0000000..28eebd2
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorMemoryPolicyConfiguration.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.visor.node;
+
+import java.io.Serializable;
+import org.apache.ignite.configuration.MemoryPolicyConfiguration;
+
+/**
+ * Data transfer object for memory configuration.
+ */
+public class VisorMemoryPolicyConfiguration implements Serializable {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** Unique name of MemoryPolicy. */
+    private String name;
+
+    /** Page memory size in bytes. */
+    private long size;
+
+    /** Path for memory mapped file. */
+    private String swapFilePath;
+
+    /**
+     * Constructor.
+     *
+     * @param plc Memory policy configuration.
+     */
+    public VisorMemoryPolicyConfiguration(MemoryPolicyConfiguration plc) {
+        assert plc != null;
+
+        name = plc.getName();
+        size = plc.getSize();
+        swapFilePath = plc.getSwapFilePath();
+    }
+
+    /**
+     * Unique name of MemoryPolicy.
+     */
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * Page memory size in bytes.
+     */
+    public long getSize() {
+        return size;
+    }
+
+    /**
+     * @return Path for memory mapped file.
+     */
+    public String getSwapFilePath() {
+        return swapFilePath;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/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 3a26c97..988d889 100644
--- a/modules/core/src/main/resources/META-INF/classnames.properties
+++ b/modules/core/src/main/resources/META-INF/classnames.properties
@@ -1800,6 +1800,7 @@ org.apache.ignite.internal.visor.node.VisorGridConfiguration
 org.apache.ignite.internal.visor.node.VisorIgfsConfiguration
 org.apache.ignite.internal.visor.node.VisorLifecycleConfiguration
 org.apache.ignite.internal.visor.node.VisorMemoryConfiguration
+org.apache.ignite.internal.visor.node.VisorMemoryPolicyConfiguration
 org.apache.ignite.internal.visor.node.VisorMetricsConfiguration
 org.apache.ignite.internal.visor.node.VisorNodeConfigurationCollectorJob
 org.apache.ignite.internal.visor.node.VisorNodeConfigurationCollectorTask

http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/modules/core/src/test/java/org/apache/ignite/cache/LargeEntryUpdateTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/cache/LargeEntryUpdateTest.java b/modules/core/src/test/java/org/apache/ignite/cache/LargeEntryUpdateTest.java
index 18a1654..592ba0f 100644
--- a/modules/core/src/test/java/org/apache/ignite/cache/LargeEntryUpdateTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/cache/LargeEntryUpdateTest.java
@@ -74,7 +74,6 @@ public class LargeEntryUpdateTest extends GridCommonAbstractTest {
         MemoryConfiguration mem = new MemoryConfiguration();
 
         mem.setPageSize(PAGE_SIZE);
-        mem.setPageCacheSize(PAGE_CACHE_SIZE);
 
         cfg.setMemoryConfiguration(mem);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationLeakTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationLeakTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationLeakTest.java
index 918a3b0..820cff3 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationLeakTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationLeakTest.java
@@ -23,6 +23,7 @@ import org.apache.ignite.cache.eviction.lru.LruEvictionPolicy;
 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.lang.IgniteInClosure;
 import org.apache.ignite.testframework.GridTestUtils;
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
@@ -44,7 +45,11 @@ public class CacheConfigurationLeakTest extends GridCommonAbstractTest {
 
         MemoryConfiguration memCfg = new MemoryConfiguration();
 
-        memCfg.setPageCacheSize(MemoryConfiguration.DFLT_PAGE_CACHE_SIZE * 10);
+        MemoryPolicyConfiguration plc = new MemoryPolicyConfiguration();
+
+        plc.setSize(MemoryConfiguration.DFLT_MEMORY_POLICY_SIZE * 10);
+
+        memCfg.setMemoryPolicies(plc);
 
         cfg.setMemoryConfiguration(memCfg);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheMemoryPolicyConfigurationTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheMemoryPolicyConfigurationTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheMemoryPolicyConfigurationTest.java
new file mode 100644
index 0000000..630d4be
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheMemoryPolicyConfigurationTest.java
@@ -0,0 +1,164 @@
+/*
+ * 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.IgniteCache;
+import org.apache.ignite.IgniteCheckedException;
+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.mem.OutOfMemoryException;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ *
+ */
+public class CacheMemoryPolicyConfigurationTest extends GridCommonAbstractTest {
+    /** */
+    private volatile CacheConfiguration ccfg;
+
+    /** */
+    private volatile MemoryConfiguration memCfg;
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        if (memCfg != null)
+            cfg.setMemoryConfiguration(memCfg);
+
+        if (ccfg != null)
+            cfg.setCacheConfiguration(ccfg);
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        stopAllGrids();
+    }
+
+    /**
+     * Verifies that proper exception is thrown when MemoryPolicy is misconfigured for cache.
+     */
+    public void testMissingMemoryPolicy() throws Exception {
+        ccfg = new CacheConfiguration();
+
+        ccfg.setMemoryPolicyName("nonExistingMemPlc");
+
+        try {
+            startGrid(0);
+        }
+        catch (IgniteCheckedException e) {
+            String msg = e.getMessage();
+
+            assertTrue("Not expected exception was thrown: " + e, msg.contains("Requested MemoryPolicy is not configured"));
+
+            return;
+        }
+
+        fail("Expected exception was not thrown: missing MemoryPolicy");
+    }
+
+    /**
+     * Verifies that {@link OutOfMemoryException} is thrown when cache is configured with too small MemoryPolicy.
+     */
+    public void testTooSmallMemoryPolicy() throws Exception {
+        memCfg = new MemoryConfiguration();
+
+        MemoryPolicyConfiguration dfltPlcCfg = new MemoryPolicyConfiguration();
+        dfltPlcCfg.setName("dfltPlc");
+        dfltPlcCfg.setSize(1024 * 1024);
+
+        MemoryPolicyConfiguration bigPlcCfg = new MemoryPolicyConfiguration();
+        bigPlcCfg.setName("bigPlc");
+        bigPlcCfg.setSize(1024 * 1024 * 1024);
+
+        memCfg.setMemoryPolicies(dfltPlcCfg, bigPlcCfg);
+        memCfg.setDefaultMemoryPolicyName("dfltPlc");
+
+        ccfg = new CacheConfiguration();
+
+        IgniteEx ignite0 = startGrid(0);
+
+        IgniteCache<Object, Object> cache = ignite0.cache(null);
+
+        boolean oomeThrown = false;
+
+        try {
+            for (int i = 0; i < 500_000; i++)
+                cache.put(i, "abc");
+        }
+        catch (Exception e) {
+            Throwable cause = e;
+
+            do {
+                if (cause instanceof OutOfMemoryException) {
+                    oomeThrown = true;
+                    break;
+                }
+
+                if (cause == null)
+                    break;
+
+                if (cause.getSuppressed() == null || cause.getSuppressed().length == 0)
+                    cause = cause.getCause();
+                else
+                    cause = cause.getSuppressed()[0];
+            }
+            while (true);
+        }
+
+        if (!oomeThrown)
+            fail("OutOfMemoryException hasn't been thrown");
+    }
+
+    /**
+     * Verifies that with enough memory allocated adding values to cache doesn't cause any exceptions.
+     */
+    public void testProperlySizedMemoryPolicy() throws Exception {
+        memCfg = new MemoryConfiguration();
+
+        MemoryPolicyConfiguration dfltPlcCfg = new MemoryPolicyConfiguration();
+        dfltPlcCfg.setName("dfltPlc");
+        dfltPlcCfg.setSize(1024 * 1024);
+
+        MemoryPolicyConfiguration bigPlcCfg = new MemoryPolicyConfiguration();
+        bigPlcCfg.setName("bigPlc");
+        bigPlcCfg.setSize(1024 * 1024 * 1024);
+
+        memCfg.setMemoryPolicies(dfltPlcCfg, bigPlcCfg);
+        memCfg.setDefaultMemoryPolicyName("dfltPlc");
+
+        ccfg = new CacheConfiguration();
+        ccfg.setMemoryPolicyName("bigPlc");
+
+        IgniteEx ignite0 = startGrid(0);
+
+        IgniteCache<Object, Object> cache = ignite0.cache(null);
+
+        try {
+            for (int i = 0; i < 500_000; i++)
+                cache.put(i, "abc");
+        }
+        catch (Exception e) {
+            fail("With properly sized MemoryPolicy no exceptions are expected to be thrown.");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/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
new file mode 100644
index 0000000..6b93936
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MemoryPolicyConfigValidationTest.java
@@ -0,0 +1,241 @@
+/*
+ * 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.IgniteCheckedException;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.MemoryConfiguration;
+import org.apache.ignite.configuration.MemoryPolicyConfiguration;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ *
+ */
+public class MemoryPolicyConfigValidationTest extends GridCommonAbstractTest {
+    /** Configuration violation type to check. */
+    private ValidationViolationType violationType;
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        MemoryConfiguration memCfg = new MemoryConfiguration();
+
+        MemoryPolicyConfiguration[] plcs = null;
+
+        switch (violationType) {
+            case NAMES_CONFLICT:
+                plcs = createPlcsWithNamesConflictCfg();
+
+                break;
+
+            case RESERVED_MEMORY_POLICY_MISUSE:
+                plcs = createPlcWithReservedNameMisuseCfg();
+
+                break;
+
+            case TOO_SMALL_MEMORY_SIZE:
+                plcs = createTooSmallMemoryCfg();
+
+                break;
+
+            case NULL_NAME_ON_USER_DEFINED_POLICY:
+                plcs = createPlcWithNullName();
+
+                break;
+
+            case MISSING_USER_DEFINED_DEFAULT:
+                plcs = createMissingUserDefinedDefault();
+
+                memCfg.setDefaultMemoryPolicyName("missingMemoryPolicyName");
+
+                break;
+        }
+
+        memCfg.setMemoryPolicies(plcs);
+
+        cfg.setMemoryConfiguration(memCfg);
+
+        return cfg;
+    }
+
+    private MemoryPolicyConfiguration[] createMissingUserDefinedDefault() {
+        MemoryPolicyConfiguration[] res = new MemoryPolicyConfiguration[1];
+
+        res[0] = createMemoryPolicy("presentedPolicyCfg", 10 * 1024 * 1024);
+
+        return res;
+    }
+
+    private MemoryPolicyConfiguration[] createPlcWithNullName() {
+        MemoryPolicyConfiguration[] res = new MemoryPolicyConfiguration[1];
+
+        res[0] = createMemoryPolicy(null, 10 * 1024 * 1024);
+
+        return res;
+    }
+
+    /**
+     *
+     */
+    private MemoryPolicyConfiguration[] createTooSmallMemoryCfg() {
+        MemoryPolicyConfiguration[] res = new MemoryPolicyConfiguration[1];
+
+        res[0] = createMemoryPolicy("dflt", 10);
+
+        return res;
+    }
+
+    /**
+     *
+     */
+    private MemoryPolicyConfiguration[] createPlcWithReservedNameMisuseCfg() {
+        MemoryPolicyConfiguration[] res = new MemoryPolicyConfiguration[1];
+
+        res[0] = createMemoryPolicy("sysMemPlc", 1024 * 1024);
+
+        return res;
+    }
+
+    /**
+     *
+     */
+    private MemoryPolicyConfiguration[] createPlcsWithNamesConflictCfg() {
+        MemoryPolicyConfiguration[] res = new MemoryPolicyConfiguration[2];
+
+        res[0] = createMemoryPolicy("cflt0", 1024 * 1024);
+        res[1] = createMemoryPolicy("cflt0", 1024 * 1024);
+
+        return res;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        super.afterTest();
+
+        stopAllGrids();
+    }
+
+    /**
+     * @param name Name of MemoryPolicyConfiguration.
+     * @param size Size of MemoryPolicyConfiguration in bytes.
+     */
+    private MemoryPolicyConfiguration createMemoryPolicy(String name, long size) {
+        MemoryPolicyConfiguration plc = new MemoryPolicyConfiguration();
+
+        plc.setName(name);
+        plc.setSize(size);
+
+        return plc;
+    }
+
+    /**
+     * 'sysMemPlc' name is reserved for MemoryPolicyConfiguration for system caches.
+     */
+    public void testReservedMemoryPolicyMisuse() throws Exception {
+        violationType = ValidationViolationType.RESERVED_MEMORY_POLICY_MISUSE;
+
+        doTest(violationType);
+    }
+
+    /**
+     * If user defines default is must be presented among configured memory policies.
+     */
+    public void testMissingUserDefinedDefault() throws Exception {
+        violationType = ValidationViolationType.MISSING_USER_DEFINED_DEFAULT;
+
+        doTest(violationType);
+    }
+
+    /**
+     * Names of all MemoryPolicies must be distinct.
+     */
+    public void testNamesConflict() throws Exception {
+        violationType = ValidationViolationType.NAMES_CONFLICT;
+
+        doTest(violationType);
+    }
+
+    /**
+     * User-defined policy must have a non-null non-empty name.
+     */
+    public void testNullNameOnUserDefinedPolicy() throws Exception {
+        violationType = ValidationViolationType.NULL_NAME_ON_USER_DEFINED_POLICY;
+
+        doTest(violationType);
+    }
+
+    /**
+     * MemoryPolicy must be configured with size of at least 1MB.
+     */
+    public void testMemoryTooSmall() throws Exception {
+        violationType = ValidationViolationType.TOO_SMALL_MEMORY_SIZE;
+
+        doTest(violationType);
+    }
+
+    /**
+     * Tries to start ignite node with invalid configuration and checks that corresponding exception is thrown.
+     *
+     * @param violationType Configuration violation type.
+     */
+    private void doTest(ValidationViolationType violationType) throws Exception {
+        try {
+            startGrid(0);
+        }
+        catch (IgniteCheckedException e) {
+            Throwable c = e.getCause();
+
+            assertTrue(c != null);
+            assertTrue(c.getMessage().contains(violationType.violationMsg));
+
+            return;
+        }
+
+        fail("Expected exception hasn't been thrown");
+    }
+
+    /**
+     *
+     */
+    private enum ValidationViolationType {
+        /** */
+        NAMES_CONFLICT("Two MemoryPolicies have the same name: "),
+
+        /** */
+        RESERVED_MEMORY_POLICY_MISUSE("'sysMemPlc' policy name is reserved for internal use."),
+
+        /** */
+        TOO_SMALL_MEMORY_SIZE("MemoryPolicy must have size more than 1MB: "),
+
+        /** */
+        NULL_NAME_ON_USER_DEFINED_POLICY("User-defined MemoryPolicyConfiguration must have non-null and non-empty name."),
+
+        /** */
+        MISSING_USER_DEFINED_DEFAULT("User-defined default MemoryPolicy name is not presented among configured MemoryPolicies: ");
+
+        /**
+         * @param violationMsg Violation message.
+         */
+        ValidationViolationType(String violationMsg) {
+            this.violationMsg = violationMsg;
+        }
+
+        /** */
+        String violationMsg;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbAbstractTest.java
index cf26187..f9c63ee 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbAbstractTest.java
@@ -68,8 +68,6 @@ public abstract class IgniteDbAbstractTest extends GridCommonAbstractTest {
         else
             dbCfg.setPageSize(1024);
 
-        dbCfg.setPageCacheSize(200 * 1024 * 1024);
-
         configure(dbCfg);
 
         cfg.setMemoryConfiguration(dbCfg);

http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbDynamicCacheSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbDynamicCacheSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbDynamicCacheSelfTest.java
index a9e0541..b7a8bf3 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbDynamicCacheSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbDynamicCacheSelfTest.java
@@ -27,6 +27,7 @@ import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.MemoryConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.MemoryPolicyConfiguration;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 
@@ -40,7 +41,13 @@ public class IgniteDbDynamicCacheSelfTest extends GridCommonAbstractTest {
 
         MemoryConfiguration dbCfg = new MemoryConfiguration();
 
-        dbCfg.setPageCacheSize(200 * 1024 * 1024);
+        MemoryPolicyConfiguration plc = new MemoryPolicyConfiguration();
+
+        plc.setName("dfltPlc");
+        plc.setSize(200 * 1024 * 1024);
+
+        dbCfg.setDefaultMemoryPolicyName("dfltPlc");
+        dbCfg.setMemoryPolicies(plc);
 
         cfg.setMemoryConfiguration(dbCfg);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMemoryLeakAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMemoryLeakAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMemoryLeakAbstractTest.java
index 2e9d3f9..5228955 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMemoryLeakAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMemoryLeakAbstractTest.java
@@ -22,6 +22,7 @@ import java.util.concurrent.TimeUnit;
 import org.apache.ignite.IgniteCache;
 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.database.DataStructure;
 
@@ -35,9 +36,6 @@ public abstract class IgniteDbMemoryLeakAbstractTest extends IgniteDbAbstractTes
     private static final int CONCURRENCY_LEVEL = 8;
 
     /** */
-    private static final int MIN_PAGE_CACHE_SIZE = 1048576 * CONCURRENCY_LEVEL;
-
-    /** */
     private volatile Exception ex;
 
     /** */
@@ -76,10 +74,6 @@ public abstract class IgniteDbMemoryLeakAbstractTest extends IgniteDbAbstractTes
     /** {@inheritDoc} */
     @Override protected void configure(MemoryConfiguration mCfg) {
         mCfg.setConcurrencyLevel(CONCURRENCY_LEVEL);
-
-        long size = (1024 * (isLargePage() ? 16 : 1) + 24) * pagesMax();
-
-        mCfg.setPageCacheSize(Math.max(size, MIN_PAGE_CACHE_SIZE));
     }
 
     /**
@@ -231,7 +225,7 @@ public abstract class IgniteDbMemoryLeakAbstractTest extends IgniteDbAbstractTes
      * @throws Exception If failed.
      */
     protected void check(IgniteEx ig) throws Exception {
-        long pagesActual = ig.context().cache().context().database().pageMemory().loadedPages();
+        long pagesActual = ig.context().cache().context().database().memoryPolicy(null).pageMemory().loadedPages();
 
         if (loadedPages > 0) {
             delta += pagesActual - loadedPages;

http://git-wip-us.apache.org/repos/asf/ignite/blob/7ac0fd0c/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridCacheTestContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridCacheTestContext.java b/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridCacheTestContext.java
index cec9e30..0f4aa87 100644
--- a/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridCacheTestContext.java
+++ b/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridCacheTestContext.java
@@ -80,6 +80,9 @@ public class GridCacheTestContext<K, V> extends GridCacheContext<K, V> {
             CacheType.USER,
             true,
             true,
+            null,
+            null,
+            null,
             new GridCacheEventManager(),
             new CacheOsStoreManager(null, new CacheConfiguration()),
             new GridCacheEvictionManager(),


[09/34] ignite git commit: ignite-3477-master remove BinaryObjectExceptionSelfTest (unnecessary)

Posted by ag...@apache.org.
ignite-3477-master remove BinaryObjectExceptionSelfTest (unnecessary)


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

Branch: refs/heads/ignite-3477-master
Commit: b30703a94d5a16b4c80cdcfc7b8dceb0d93efe4d
Parents: 9c89b9b
Author: Dmitriy Govorukhin <dg...@gridgain.com>
Authored: Wed Mar 29 15:38:18 2017 +0300
Committer: Dmitriy Govorukhin <dg...@gridgain.com>
Committed: Wed Mar 29 15:38:18 2017 +0300

----------------------------------------------------------------------
 .../binary/BinaryObjectExceptionSelfTest.java   | 209 -------------------
 1 file changed, 209 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/b30703a9/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectExceptionSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectExceptionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectExceptionSelfTest.java
deleted file mode 100644
index e4be824..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectExceptionSelfTest.java
+++ /dev/null
@@ -1,209 +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.binary;
-
-import java.lang.reflect.Field;
-import java.math.BigDecimal;
-import java.sql.Timestamp;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.UUID;
-import javax.cache.Cache;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.binary.BinaryBasicNameMapper;
-import org.apache.ignite.binary.BinaryObjectException;
-import org.apache.ignite.configuration.BinaryConfiguration;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.IgniteEx;
-import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-
-/**
- * BinaryObjectExceptionSelfTest
- */
-public class BinaryObjectExceptionSelfTest extends GridCommonAbstractTest {
-    /** */
-    private static final String TEST_KEY = "test_key";
-
-    /** */
-    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
-
-    /** {@inheritDoc} */
-    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
-        IgniteConfiguration cfg = super.getConfiguration(gridName);
-
-        cfg.setMarshaller(new BinaryMarshaller());
-        cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER));
-
-        cfg.setCacheConfiguration(new CacheConfiguration().setCopyOnRead(true));
-
-        BinaryConfiguration bcfg = new BinaryConfiguration();
-
-        bcfg.setNameMapper(new BinaryBasicNameMapper(false));
-
-        cfg.setBinaryConfiguration(bcfg);
-
-        return cfg;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void beforeTest() throws Exception {
-        startGrids(2);
-
-        awaitPartitionMapExchange();
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void afterTest() throws Exception {
-        stopAllGrids();
-    }
-
-    /**
-     * Test unexpected field type.
-     *
-     * @throws Exception If failed.
-     */
-    @SuppressWarnings("WhileLoopReplaceableByForEach")
-    public void testUnexpectedFieldType() throws Exception {
-        IgniteEx grid = grid(0);
-
-        IgniteCache<String, Value> cache = grid.cache(null);
-
-        cache.put(TEST_KEY, new Value());
-
-        BinaryObjectImpl b = (BinaryObjectImpl)cache.withKeepBinary().get(TEST_KEY);
-
-        b.deserialize(); // deserialize working
-
-        byte[] a = b.array();
-
-        int unexpectedCnt = 0;
-
-        Field[] fields = Value.class.getDeclaredFields();
-
-        StringBuilder sb = new StringBuilder(4 << 10);
-
-        for (int i = b.dataStartOffset(), j = b.footerStartOffset(); i < j; ++i) {
-            byte old = a[i];
-
-            a[i] = -1;
-
-            try {
-                Iterator<Cache.Entry<String, Value>> it = cache.iterator();
-
-                while (it.hasNext())
-                    it.next();
-            }
-            catch (Exception ex) {
-                Throwable root = ex;
-
-                sb.setLength(0);
-
-                sb.append(root.getMessage());
-
-                while (root.getCause() != null) {
-                    root = root.getCause();
-
-                    sb.append(". ").append(root.getMessage());
-                }
-                if (root instanceof BinaryObjectException && root.getMessage().startsWith("Unexpected field type")) {
-                    log().info(sb.toString());
-
-                    Field f = fields[unexpectedCnt];
-
-                    Throwable t = ex;
-
-                    assertTrue(t.getMessage(), t.getMessage().contains(
-                        "object [typeName=org.apache.ignite.internal.binary.BinaryObjectExceptionSelfTest$Value"));
-
-                    t = t.getCause();
-
-                    assertTrue(t.getMessage(), t.getMessage().contains("field [name=" + f.getName()));
-
-                    ++unexpectedCnt;
-                }
-                else
-                    log().info("Ignored exception: " + sb);
-            }
-
-            a[i] = old;
-        }
-
-        assertEquals("Fields count must match \"Unexpected field type\" exception count", fields.length, unexpectedCnt);
-    }
-
-    /** */
-    private enum EnumValues {
-        /** */
-        val1,
-
-        /** */
-        val2,
-
-        /** */
-        val3;
-    }
-
-    /** */
-    @SuppressWarnings("unused")
-    private static class Value {
-        /** */
-        public byte byteVal = 1;
-
-        /** */
-        public boolean booleanVal = true;
-
-        /** */
-        public short shortVal = 2;
-
-        /** */
-        public char charVal = 'Q';
-
-        /** */
-        public int intVal = 3;
-
-        /** */
-        public long longVal = 4;
-
-        /** */
-        public float floatVal = 5;
-
-        /** */
-        public double doubleVal = 6;
-
-        /** */
-        public BigDecimal bigDecimal = new BigDecimal(7);
-
-        /** */
-        public String string = "QWERTY";
-
-        /** */
-        public UUID uuid = UUID.randomUUID();
-
-        /** */
-        public Date date = new Date();
-
-        /** */
-        public Timestamp timestamp = new Timestamp(date.getTime() + 1000L);
-
-        /** */
-        public EnumValues enumVal = EnumValues.val2;
-    }
-}


[07/34] ignite git commit: ignite-3477-master fix failover test (lost partition), and skip exception on node stopping

Posted by ag...@apache.org.
ignite-3477-master fix failover test (lost partition), and skip exception on node stopping


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

Branch: refs/heads/ignite-3477-master
Commit: 6c6a9a3082dc350ce805c2bc9d6eeb48dd93a3f6
Parents: b3f953a
Author: Dmitriy Govorukhin <dg...@gridgain.com>
Authored: Wed Mar 29 15:27:35 2017 +0300
Committer: Dmitriy Govorukhin <dg...@gridgain.com>
Committed: Wed Mar 29 15:27:35 2017 +0300

----------------------------------------------------------------------
 .../cache/distributed/dht/atomic/GridDhtAtomicCache.java        | 5 +++++
 .../processors/cache/GridCacheAbstractFailoverSelfTest.java     | 4 ++++
 2 files changed, 9 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/6c6a9a30/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
index bc1c584..cfeb9d4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
@@ -3201,6 +3201,11 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
                     }
                 }
             }
+            catch (NodeStoppingException e){
+                U.error(log, "Failed to update key:" + key + " on backup, node stopping", e);
+
+                return;
+            }
             catch (GridDhtInvalidPartitionException ignored) {
                 // Ignore.
             }

http://git-wip-us.apache.org/repos/asf/ignite/blob/6c6a9a30/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFailoverSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFailoverSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFailoverSelfTest.java
index 09a0d9a..fa4ffca 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFailoverSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFailoverSelfTest.java
@@ -23,6 +23,7 @@ import javax.cache.CacheException;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.cache.CacheMode;
 import org.apache.ignite.cache.CachePartialUpdateException;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
@@ -97,6 +98,9 @@ public abstract class GridCacheAbstractFailoverSelfTest extends GridCacheAbstrac
 
         cfg.setRebalanceMode(SYNC);
 
+        if (cfg.getCacheMode() == CacheMode.PARTITIONED)
+            cfg.setBackups(TOP_CHANGE_THREAD_CNT);
+
         return cfg;
     }
 


[13/34] ignite git commit: Removed debug code.

Posted by ag...@apache.org.
Removed debug code.


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

Branch: refs/heads/ignite-3477-master
Commit: c4e7b4e4756dcee74d4710ae960c73f0f53d6b66
Parents: 594cd3e
Author: sboikov <sb...@gridgain.com>
Authored: Wed Mar 22 18:05:54 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Wed Mar 29 19:29:36 2017 +0300

----------------------------------------------------------------------
 .../ignite/cache/store/jdbc/CacheAbstractJdbcStore.java | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/c4e7b4e4/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheAbstractJdbcStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheAbstractJdbcStore.java b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheAbstractJdbcStore.java
index 72d73ba..83d7e55 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheAbstractJdbcStore.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheAbstractJdbcStore.java
@@ -438,8 +438,6 @@ public abstract class CacheAbstractJdbcStore<K, V> implements CacheStore<K, V>,
 
                 PreparedStatement stmt = null;
 
-                ResultSet rs = null;
-
                 try {
                     conn = openConnection(true);
 
@@ -461,7 +459,7 @@ public abstract class CacheAbstractJdbcStore<K, V> implements CacheStore<K, V>,
                             for (int j = 0; j < i; j++)
                                 stmt.setObject(idx++, upperBound[j]);
 
-                    rs = stmt.executeQuery();
+                    ResultSet rs = stmt.executeQuery();
 
                     while (rs.next()) {
                         K key = buildObject(em.cacheName, em.keyType(), em.keyKind(), em.keyColumns(), em.keyCols, em.loadColIdxs, rs);
@@ -470,14 +468,6 @@ public abstract class CacheAbstractJdbcStore<K, V> implements CacheStore<K, V>,
                         clo.apply(key, val);
                     }
                 }
-                catch (NullPointerException e){
-                    //todo only for investigation
-                    System.out.println("Got NPE");
-
-                    e.printStackTrace();
-
-                    System.out.println("thread:" + Thread.currentThread().getName() + " conn:" + conn + " stmt:" + stmt + " rs:" + rs);
-                }
                 catch (SQLException e) {
                     throw new IgniteCheckedException("Failed to load cache", e);
                 }