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/08/01 09:25:44 UTC

[01/47] ignite git commit: IGNITE-5829 Linked TODO with ticket.

Repository: ignite
Updated Branches:
  refs/heads/master ece7cf924 -> f575a245c


IGNITE-5829 Linked TODO with ticket.


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

Branch: refs/heads/master
Commit: 00babb4bcb0d432ae614a3cb98dfa7a61dfdbc1c
Parents: 2005eec
Author: Pavel Kovalenko <jo...@gmail.com>
Authored: Tue Jul 25 15:50:43 2017 +0300
Committer: Pavel Kovalenko <jo...@gmail.com>
Committed: Tue Jul 25 15:50:43 2017 +0300

----------------------------------------------------------------------
 .../processors/cache/persistence/freelist/FreeListImpl.java      | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/00babb4b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/FreeListImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/FreeListImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/FreeListImpl.java
index e99a5ee..d50020e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/FreeListImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/FreeListImpl.java
@@ -193,7 +193,7 @@ public class FreeListImpl extends PagesList implements FreeList, ReuseList {
             io.addRow(pageAddr, row, rowSize, pageSize());
 
             if (needWalDeltaRecord(pageId, page, null)) {
-                // TODO This record must contain only a reference to a logical WAL record with the actual data.
+                // TODO IGNITE-5829 This record must contain only a reference to a logical WAL record with the actual data.
                 byte[] payload = new byte[rowSize];
 
                 DataPagePayload data = io.readPayload(pageAddr, PageIdUtils.itemId(row.link()), pageSize());
@@ -239,7 +239,7 @@ public class FreeListImpl extends PagesList implements FreeList, ReuseList {
             assert payloadSize > 0 : payloadSize;
 
             if (needWalDeltaRecord(pageId, page, null)) {
-                // TODO This record must contain only a reference to a logical WAL record with the actual data.
+                // TODO IGNITE-5829 This record must contain only a reference to a logical WAL record with the actual data.
                 byte[] payload = new byte[payloadSize];
 
                 DataPagePayload data = io.readPayload(pageAddr, PageIdUtils.itemId(row.link()), pageSize());


[47/47] ignite git commit: master - Fixed visor compilation after merge

Posted by ag...@apache.org.
master - Fixed visor compilation after merge


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

Branch: refs/heads/master
Commit: f575a245cf9958857e0f51d7f56db43f0d3a2d5c
Parents: 8b576c1
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Tue Aug 1 12:25:25 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Tue Aug 1 12:25:25 2017 +0300

----------------------------------------------------------------------
 .../scala/org/apache/ignite/visor/visor.scala   | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/f575a245/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala
index 6db731b..ffc7a00 100644
--- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala
+++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala
@@ -29,12 +29,10 @@ import org.apache.ignite.internal.util.lang.{GridFunc => F}
 import org.apache.ignite.internal.util.typedef._
 import org.apache.ignite.internal.util.{GridConfigurationFinder, IgniteUtils => U}
 import org.apache.ignite.lang._
-import org.apache.ignite.thread.IgniteThreadPoolExecutor
+import org.apache.ignite.thread.{IgniteThreadFactory, IgniteThreadPoolExecutor}
 import org.apache.ignite.visor.commands.common.VisorTextTable
-
 import jline.console.ConsoleReader
 import org.jetbrains.annotations.Nullable
-
 import java.io._
 import java.lang.{Boolean => JavaBoolean}
 import java.net._
@@ -221,7 +219,13 @@ object visor extends VisorTag {
     @volatile private var logStarted = false
 
     /** Internal thread pool. */
-    @volatile var pool: ExecutorService = new IgniteThreadPoolExecutor()
+    @volatile var pool: ExecutorService = new IgniteThreadPoolExecutor(
+        Runtime.getRuntime().availableProcessors(),
+        Runtime.getRuntime().availableProcessors(),
+        0L,
+        new LinkedBlockingQueue[Runnable](),
+        new IgniteThreadFactory("visorInstance", "visor")
+    )
 
     /** Configuration file path, if any. */
     @volatile var cfgPath: String = _
@@ -2173,7 +2177,13 @@ object visor extends VisorTag {
                         Thread.currentThread.interrupt()
                 }
 
-                pool = new IgniteThreadPoolExecutor()
+                pool = new IgniteThreadPoolExecutor(
+                    Runtime.getRuntime().availableProcessors(),
+                    Runtime.getRuntime().availableProcessors(),
+                    0L,
+                    new LinkedBlockingQueue[Runnable](),
+                    new IgniteThreadFactory("visorInstance", "visor")
+                )
             }
 
             // Call all close callbacks.


[21/47] ignite git commit: GG-12544 Removed limitation for stacktrace showing.

Posted by ag...@apache.org.
GG-12544 Removed limitation for stacktrace showing.


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

Branch: refs/heads/master
Commit: 6031ed85aa0242e8a56dee43c14c73bcafa7fab7
Parents: 98a5240
Author: vsisko <vs...@gridgain.com>
Authored: Fri Jul 28 09:54:07 2017 +0700
Committer: vsisko <vs...@gridgain.com>
Committed: Fri Jul 28 09:54:07 2017 +0700

----------------------------------------------------------------------
 .../ignite/internal/visor/debug/VisorThreadInfo.java      | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/6031ed85/modules/core/src/main/java/org/apache/ignite/internal/visor/debug/VisorThreadInfo.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/debug/VisorThreadInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/debug/VisorThreadInfo.java
index f48e6c1..9b0dd89 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/debug/VisorThreadInfo.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/debug/VisorThreadInfo.java
@@ -35,9 +35,6 @@ public class VisorThreadInfo extends VisorDataTransferObject {
     /** */
     private static final long serialVersionUID = 0L;
 
-    /** */
-    private static final int MAX_FRAMES = 8;
-
     /** Thread name. */
     private String name;
 
@@ -308,9 +305,7 @@ public class VisorThreadInfo extends VisorDataTransferObject {
 
         sb.append('\n');
 
-        int maxFrames = Math.min(stackTrace.size(), MAX_FRAMES);
-
-        for (int i = 0; i < maxFrames; i++) {
+        for (int i = 0; i < stackTrace.size(); i++) {
             StackTraceElement ste = stackTrace.get(i);
 
             sb.append("\tat ").append(ste).append('\n');
@@ -339,9 +334,6 @@ public class VisorThreadInfo extends VisorDataTransferObject {
             }
         }
 
-        if (maxFrames < stackTrace.size())
-            sb.append("\t...").append('\n');
-
         if (!F.isEmpty(locks)) {
             sb.append("\n\tNumber of locked synchronizers = ").append(locks.size()).append('\n');
 


[41/47] ignite git commit: IGNITE-5877 Fixed execution SQL and Scan queries from Web Console.

Posted by ag...@apache.org.
IGNITE-5877 Fixed execution SQL and Scan queries from Web Console.


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

Branch: refs/heads/master
Commit: 09aba54ddc34bae45882942d2e3d8238442cccfc
Parents: 355e8e8
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Mon Jul 31 14:48:56 2017 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Mon Jul 31 14:48:56 2017 +0700

----------------------------------------------------------------------
 .../ignite/internal/visor/query/VisorQueryTask.java      |  2 +-
 .../ignite/internal/visor/query/VisorScanQueryTask.java  |  2 +-
 .../apache/ignite/cache/store/jdbc/model/BinaryTest.java |  1 -
 .../frontend/app/modules/sql/sql.controller.js           | 11 +++++++++--
 .../frontend/app/services/Messages.service.js            |  7 +++++++
 5 files changed, 18 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/09aba54d/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryTask.java
index 20471e5..9198d5e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryTask.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryTask.java
@@ -70,7 +70,7 @@ public class VisorQueryTask extends VisorOneNodeTask<VisorQueryTaskArg, VisorEit
         /** {@inheritDoc} */
         @Override protected VisorEither<VisorQueryResult> run(final VisorQueryTaskArg arg) {
             try {
-                IgniteCache<Object, Object> c = ignite.context().cache().jcache(arg.getCacheName());
+                IgniteCache<Object, Object> c = ignite.cache(arg.getCacheName());
                 UUID nid = ignite.localNode().id();
 
                 SqlFieldsQuery qry = new SqlFieldsQuery(arg.getQueryText());

http://git-wip-us.apache.org/repos/asf/ignite/blob/09aba54d/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorScanQueryTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorScanQueryTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorScanQueryTask.java
index d200211..0c1c418 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorScanQueryTask.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorScanQueryTask.java
@@ -100,7 +100,7 @@ public class VisorScanQueryTask extends VisorOneNodeTask<VisorScanQueryTaskArg,
         /** {@inheritDoc} */
         @Override protected VisorEither<VisorQueryResult> run(final VisorScanQueryTaskArg arg) {
             try {
-                IgniteCache<Object, Object> c = ignite.context().cache().jcache(arg.getCacheName());
+                IgniteCache<Object, Object> c = ignite.cache(arg.getCacheName());
                 UUID nid = ignite.localNode().id();
 
                 String filterText = arg.getFilter();

http://git-wip-us.apache.org/repos/asf/ignite/blob/09aba54d/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/model/BinaryTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/model/BinaryTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/model/BinaryTest.java
index 6cb551b..c753910 100644
--- a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/model/BinaryTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/model/BinaryTest.java
@@ -18,7 +18,6 @@
 package org.apache.ignite.cache.store.jdbc.model;
 
 import java.io.Serializable;
-import java.sql.Date;
 import java.util.Arrays;
 
 /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/09aba54d/modules/web-console/frontend/app/modules/sql/sql.controller.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/sql/sql.controller.js b/modules/web-console/frontend/app/modules/sql/sql.controller.js
index 3d38634..30f53b7 100644
--- a/modules/web-console/frontend/app/modules/sql/sql.controller.js
+++ b/modules/web-console/frontend/app/modules/sql/sql.controller.js
@@ -130,13 +130,20 @@ class Paragraph {
             while (_.nonNil(cause)) {
                 if (_.nonEmpty(cause.className) &&
                     _.includes(['SQLException', 'JdbcSQLException', 'QueryCancelledException'], JavaTypes.shortClassName(cause.className))) {
-                    this.error.message = cause.message;
+                    this.error.message = cause.message || cause.className;
 
                     break;
                 }
 
                 cause = cause.cause;
             }
+
+            if (_.isEmpty(this.error.message) && _.nonEmpty(err.className)) {
+                this.error.message = 'Internal cluster error';
+
+                if (_.nonEmpty(err.className))
+                    this.error.message += ': ' + err.className;
+            }
         };
     }
 
@@ -1761,7 +1768,7 @@ export default ['$rootScope', '$scope', '$http', '$q', '$timeout', '$interval',
                     if (_.nonNil(item)) {
                         const clsName = _.isEmpty(item.className) ? '' : '[' + JavaTypes.shortClassName(item.className) + '] ';
 
-                        scope.content.push((scope.content.length > 0 ? tab : '') + clsName + item.message);
+                        scope.content.push((scope.content.length > 0 ? tab : '') + clsName + (item.message || ''));
 
                         addToTrace(item.cause);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/09aba54d/modules/web-console/frontend/app/services/Messages.service.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/services/Messages.service.js b/modules/web-console/frontend/app/services/Messages.service.js
index 5e691bc..854cf0b 100644
--- a/modules/web-console/frontend/app/services/Messages.service.js
+++ b/modules/web-console/frontend/app/services/Messages.service.js
@@ -30,6 +30,13 @@ export default ['IgniteMessages', ['$alert', ($alert) => {
             if (err.hasOwnProperty('message'))
                 return prefix + err.message;
 
+            if (_.nonEmpty(err.className)) {
+                if (_.isEmpty(prefix))
+                    prefix = 'Internal cluster error: ';
+
+                return prefix + err.className;
+            }
+
             return prefix + err;
         }
 


[16/47] ignite git commit: IGNITE-5761 - Fixed header license

Posted by ag...@apache.org.
IGNITE-5761 - Fixed header license


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

Branch: refs/heads/master
Commit: 9825eaa35c5c95485f7d7c3b60de7d0ca47dad23
Parents: 5172541
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Thu Jul 27 10:42:30 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Thu Jul 27 10:42:30 2017 +0300

----------------------------------------------------------------------
 .../dht/NotMappedPartitionInTxTest.java            | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/9825eaa3/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/NotMappedPartitionInTxTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/NotMappedPartitionInTxTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/NotMappedPartitionInTxTest.java
index 4059660..e09cf53 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/NotMappedPartitionInTxTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/NotMappedPartitionInTxTest.java
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.apache.ignite.internal.processors.cache.distributed.dht;
 
 import java.util.Collection;


[11/47] ignite git commit: IGNITE-5761 Add correct message when entries are not mapped to at least one node and avoid hang on rollback

Posted by ag...@apache.org.
IGNITE-5761 Add correct message when entries are not mapped to at least one node and avoid hang on rollback


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

Branch: refs/heads/master
Commit: bcbb10d4ed72c3ac2cd8149bb5cd148f63e95725
Parents: 995258f
Author: Igor Seliverstov <gv...@gmail.com>
Authored: Thu Jul 27 09:44:34 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Thu Jul 27 09:44:34 2017 +0300

----------------------------------------------------------------------
 ...arOptimisticSerializableTxPrepareFuture.java |   9 +
 .../near/GridNearOptimisticTxPrepareFuture.java |  15 ++
 .../GridNearPessimisticTxPrepareFuture.java     |   9 +-
 .../dht/NotMappedPartitionInTxTest.java         | 247 +++++++++++++++++++
 .../testsuites/IgniteCacheTestSuite5.java       |   2 +
 5 files changed, 281 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/bcbb10d4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticSerializableTxPrepareFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticSerializableTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticSerializableTxPrepareFuture.java
index 72ddc67..561c4f7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticSerializableTxPrepareFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticSerializableTxPrepareFuture.java
@@ -29,6 +29,7 @@ import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.cluster.ClusterTopologyException;
 import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
+import org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
 import org.apache.ignite.internal.processors.cache.GridCacheContext;
 import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
@@ -611,6 +612,14 @@ public class GridNearOptimisticSerializableTxPrepareFuture extends GridNearOptim
             cacheCtx.affinity().nodesByKey(entry.key(), topVer) :
             cacheCtx.topology().nodes(cacheCtx.affinity().partition(entry.key()), topVer);
 
+        if (F.isEmpty(nodes)) {
+            onDone(new ClusterTopologyServerNotFoundException("Failed to map keys to nodes " +
+                "(partition is not mapped to any node) [key=" + entry.key() +
+                ", partition=" + cacheCtx.affinity().partition(entry.key()) + ", topVer=" + topVer + ']'));
+
+            return;
+        }
+
         txMapping.addMapping(nodes);
 
         ClusterNode primary = F.first(nodes);

http://git-wip-us.apache.org/repos/asf/ignite/blob/bcbb10d4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java
index edddf7d..1e7a567 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java
@@ -32,6 +32,7 @@ import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.cluster.ClusterTopologyException;
 import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
+import org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
 import org.apache.ignite.internal.processors.cache.GridCacheContext;
 import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
@@ -430,6 +431,10 @@ public class GridNearOptimisticTxPrepareFuture extends GridNearOptimisticTxPrepa
 
             GridDistributedTxMapping updated = map(write, topVer, cur, topLocked, remap);
 
+            if(updated == null)
+                // an exception occurred while transaction mapping, stop further processing
+                break;
+
             if (write.context().isNear())
                 hasNearCache = true;
 
@@ -640,6 +645,16 @@ public class GridNearOptimisticTxPrepareFuture extends GridNearOptimisticTxPrepa
                 cacheCtx.affinity().nodesByKey(entry.key(), topVer) :
                 cacheCtx.topology().nodes(cacheCtx.affinity().partition(entry.key()), topVer);
 
+        if (F.isEmpty(nodes)) {
+            ClusterTopologyServerNotFoundException e = new ClusterTopologyServerNotFoundException("Failed to map " +
+                "keys to nodes (partition is not mapped to any node) [key=" + entry.key() +
+                ", partition=" + cacheCtx.affinity().partition(entry.key()) + ", topVer=" + topVer + ']');
+
+            onDone(e);
+
+            return null;
+        }
+
         txMapping.addMapping(nodes);
 
         ClusterNode primary = F.first(nodes);

http://git-wip-us.apache.org/repos/asf/ignite/blob/bcbb10d4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java
index e934319..11cd9f9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java
@@ -27,6 +27,7 @@ import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
+import org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
 import org.apache.ignite.internal.processors.cache.GridCacheContext;
 import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
@@ -282,7 +283,13 @@ public class GridNearPessimisticTxPrepareFuture extends GridNearTxPrepareFutureA
             else
                 nodes = cacheCtx.affinity().nodesByKey(txEntry.key(), topVer);
 
-            assert !nodes.isEmpty();
+            if (F.isEmpty(nodes)) {
+                onDone(new ClusterTopologyServerNotFoundException("Failed to map keys to nodes (partition " +
+                    "is not mapped to any node) [key=" + txEntry.key() +
+                    ", partition=" + cacheCtx.affinity().partition(txEntry.key()) + ", topVer=" + topVer + ']'));
+
+                return;
+            }
 
             ClusterNode primary = nodes.get(0);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/bcbb10d4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/NotMappedPartitionInTxTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/NotMappedPartitionInTxTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/NotMappedPartitionInTxTest.java
new file mode 100644
index 0000000..4059660
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/NotMappedPartitionInTxTest.java
@@ -0,0 +1,247 @@
+package org.apache.ignite.internal.processors.cache.distributed.dht;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.UUID;
+import java.util.concurrent.Callable;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.ignite.transactions.Transaction;
+import org.apache.ignite.transactions.TransactionConcurrency;
+import org.apache.ignite.transactions.TransactionIsolation;
+import org.jetbrains.annotations.Nullable;
+
+import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC;
+import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
+import static org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED;
+import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
+import static org.apache.ignite.transactions.TransactionIsolation.SERIALIZABLE;
+
+/**
+ */
+@SuppressWarnings({"unchecked", "ThrowableNotThrown"})
+public class NotMappedPartitionInTxTest extends GridCommonAbstractTest {
+    /** Cache. */
+    private static final String CACHE = "testCache";
+
+    /** Cache 2. */
+    public static final String CACHE2 = CACHE + 1;
+
+    /** Test key. */
+    private static final String TEST_KEY = "key";
+
+    /** Is client. */
+    private boolean isClient;
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        return super.getConfiguration(gridName)
+            .setClientMode(isClient)
+            .setCacheConfiguration(
+                new CacheConfiguration(CACHE)
+                    .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL)
+                    .setCacheMode(CacheMode.REPLICATED)
+                    .setAffinity(new TestAffinity()),
+                new CacheConfiguration(CACHE2)
+                    .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL));
+    }
+
+    /**
+     *
+     */
+    public void testOneServerOptimistic() throws Exception {
+        try {
+            isClient = false;
+            startGrid(0);
+
+            isClient = true;
+            final IgniteEx client = startGrid(1);
+
+            GridTestUtils.assertThrowsAnyCause(log, new Callable<Void>() {
+                @Override public Void call() throws Exception {
+                    testNotMapped(client, OPTIMISTIC, REPEATABLE_READ);
+
+                    return null;
+                }
+            }, ClusterTopologyServerNotFoundException.class, "Failed to map keys to nodes (partition is not mapped to any node)");
+        }
+        finally {
+            stopAllGrids();
+        }
+    }
+
+    /**
+     *
+     */
+    public void testOneServerOptimisticSerializable() throws Exception {
+        try {
+            isClient = false;
+            startGrid(0);
+
+            isClient = true;
+            final IgniteEx client = startGrid(1);
+
+            GridTestUtils.assertThrowsAnyCause(log, new Callable<Void>() {
+                @Override public Void call() throws Exception {
+                    testNotMapped(client, OPTIMISTIC, SERIALIZABLE);
+
+                    return null;
+                }
+            }, ClusterTopologyServerNotFoundException.class, "Failed to map keys to nodes (partition is not mapped to any node)");
+        }
+        finally {
+            stopAllGrids();
+        }
+    }
+
+    /**
+     *
+     */
+    public void testOneServerPessimistic() throws Exception {
+        try {
+            isClient = false;
+            startGrid(0);
+
+            isClient = true;
+            final IgniteEx client = startGrid(1);
+
+            GridTestUtils.assertThrowsAnyCause(log, new Callable<Void>() {
+                @Override public Void call() throws Exception {
+                    testNotMapped(client, PESSIMISTIC, READ_COMMITTED);
+
+                    return null;
+                }
+            }, ClusterTopologyServerNotFoundException.class, "Failed to lock keys (all partition nodes left the grid)");
+        }
+        finally {
+            stopAllGrids();
+        }
+    }
+
+    /**
+     *
+     */
+    public void testFourServersOptimistic() throws Exception {
+        try {
+            isClient = false;
+            startGrids(4);
+
+            isClient = true;
+            final IgniteEx client = startGrid(4);
+
+            GridTestUtils.assertThrowsAnyCause(log, new Callable<Void>() {
+                @Override public Void call() throws Exception {
+                    testNotMapped(client, OPTIMISTIC, REPEATABLE_READ);
+
+                    return null;
+                }
+            }, ClusterTopologyServerNotFoundException.class, "Failed to map keys to nodes (partition is not mapped to any node)");
+        }
+        finally {
+            stopAllGrids();
+        }
+    }
+
+    /**
+     *
+     */
+    public void testFourServersOptimisticSerializable() throws Exception {
+        try {
+            isClient = false;
+            startGrids(4);
+
+            isClient = true;
+            final IgniteEx client = startGrid(4);
+
+            GridTestUtils.assertThrowsAnyCause(log, new Callable<Void>() {
+                @Override public Void call() throws Exception {
+                    testNotMapped(client, OPTIMISTIC, SERIALIZABLE);
+
+                    return null;
+                }
+            }, ClusterTopologyServerNotFoundException.class, "Failed to map keys to nodes (partition is not mapped to any node)");
+        }
+        finally {
+            stopAllGrids();
+        }
+    }
+
+    /**
+     *
+     */
+    public void testFourServersPessimistic() throws Exception {
+        try {
+            isClient = false;
+            startGrids(4);
+
+            isClient = true;
+            final IgniteEx client = startGrid(4);
+
+            GridTestUtils.assertThrowsAnyCause(log, new Callable<Void>() {
+                @Override public Void call() throws Exception {
+                    testNotMapped(client, PESSIMISTIC, READ_COMMITTED);
+
+                    return null;
+                }
+            }, ClusterTopologyServerNotFoundException.class, "Failed to lock keys (all partition nodes left the grid)");
+        }
+        finally {
+            stopAllGrids();
+        }
+    }
+
+    /**
+     * @param client Ignite client.
+     */
+    private void testNotMapped(IgniteEx client, TransactionConcurrency concurrency, TransactionIsolation isolation) {
+        IgniteCache cache2 = client.cache(CACHE2);
+        IgniteCache cache1 = client.cache(CACHE).withKeepBinary();
+
+        try(Transaction tx = client.transactions().txStart(concurrency, isolation)) {
+
+            Map<String, Integer> param = new TreeMap<>();
+            param.put(TEST_KEY + 1, 1);
+            param.put(TEST_KEY + 1, 3);
+            param.put(TEST_KEY, 3);
+
+            cache1.put(TEST_KEY, 3);
+
+            cache1.putAll(param);
+            cache2.putAll(param);
+
+            tx.commit();
+        }
+    }
+
+    /** */
+    private static class TestAffinity extends RendezvousAffinityFunction {
+        /** {@inheritDoc} */
+        @Override public int partition(Object key) {
+            if (TEST_KEY.equals(key))
+                return 1;
+
+            return super.partition(key);
+        }
+
+        /** {@inheritDoc} */
+        @Override public List<ClusterNode> assignPartition(int part, List<ClusterNode> nodes, int backups,
+            @Nullable Map<UUID, Collection<ClusterNode>> neighborhoodCache) {
+            if (part == 1)
+                return Collections.emptyList();
+
+            return super.assignPartition(part, nodes, backups, neighborhoodCache);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/bcbb10d4/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java
index 1395b95..dab2b19 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java
@@ -41,6 +41,7 @@ import org.apache.ignite.internal.processors.cache.distributed.GridCachePartitio
 import org.apache.ignite.internal.processors.cache.distributed.IgniteCacheGroupsPartitionLossPolicySelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.IgniteCachePartitionLossPolicySelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.IgniteCacheTxIteratorSelfTest;
+import org.apache.ignite.internal.processors.cache.distributed.dht.NotMappedPartitionInTxTest;
 import org.apache.ignite.internal.processors.cache.distributed.dht.atomic.IgniteCacheAtomicProtocolTest;
 import org.apache.ignite.internal.processors.cache.distributed.rebalancing.CacheManualRebalancingTest;
 import org.apache.ignite.internal.processors.cache.distributed.replicated.IgniteCacheSyncRebalanceModeSelfTest;
@@ -94,6 +95,7 @@ public class IgniteCacheTestSuite5 extends TestSuite {
         suite.addTestSuite(GridCachePartitionExchangeManagerHistSizeTest.class);
 
         suite.addTestSuite(GridCachePartitionEvictionDuringReadThroughSelfTest.class);
+        suite.addTestSuite(NotMappedPartitionInTxTest.class);
 
         return suite;
     }


[09/47] ignite git commit: IGNITE-5835 Web Console: Highlight active element in select input.

Posted by ag...@apache.org.
IGNITE-5835 Web Console: Highlight active element in select input.


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

Branch: refs/heads/master
Commit: b49469f469e3ad9f64d009a474b6e09686ec9203
Parents: 586a96e
Author: Dmitriy Shabalin <ds...@gridgain.com>
Authored: Thu Jul 27 10:39:54 2017 +0700
Committer: Andrey Novikov <an...@gridgain.com>
Committed: Thu Jul 27 10:39:54 2017 +0700

----------------------------------------------------------------------
 modules/web-console/frontend/app/app.config.js  |  3 +-
 .../app/components/bs-select-menu/style.scss    | 16 +++++
 .../app/components/bs-select-menu/template.pug  |  2 +
 .../frontend/app/primitives/dropdown/index.scss | 68 --------------------
 4 files changed, 20 insertions(+), 69 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/b49469f4/modules/web-console/frontend/app/app.config.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/app.config.js b/modules/web-console/frontend/app/app.config.js
index b9741d1..6ba1d98 100644
--- a/modules/web-console/frontend/app/app.config.js
+++ b/modules/web-console/frontend/app/app.config.js
@@ -78,7 +78,8 @@ igniteConsoleCfg.config(['$selectProvider', ($selectProvider) => {
         noneText: 'Clear All',
         template: '<bs-select-menu></bs-select-menu>',
         iconCheckmark: 'fa fa-check',
-        caretHtml: ''
+        caretHtml: '',
+        animation: ''
     });
 }]);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/b49469f4/modules/web-console/frontend/app/components/bs-select-menu/style.scss
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/components/bs-select-menu/style.scss b/modules/web-console/frontend/app/components/bs-select-menu/style.scss
index faddd3c..870b1bf 100644
--- a/modules/web-console/frontend/app/components/bs-select-menu/style.scss
+++ b/modules/web-console/frontend/app/components/bs-select-menu/style.scss
@@ -75,4 +75,20 @@
             padding-bottom: 10px;
         }
     }
+
+    &.bssm-multiple {
+        .bssm-active-indicator {
+            display: initial;
+        }
+    }
+
+    &:not(.bssm-multiple) {
+        .bssm-active-indicator {
+            display: none;
+        }
+
+        & > li > .bssm-item-button__active {
+            background-color: #eeeeee;
+        }
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/b49469f4/modules/web-console/frontend/app/components/bs-select-menu/template.pug
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/components/bs-select-menu/template.pug b/modules/web-console/frontend/app/components/bs-select-menu/template.pug
index 91f3d8e..a9c1c28 100644
--- a/modules/web-console/frontend/app/components/bs-select-menu/template.pug
+++ b/modules/web-console/frontend/app/components/bs-select-menu/template.pug
@@ -17,6 +17,7 @@
 ul.bs-select-menu(
     tabindex='-1'
     ng-show='$isVisible()'
+    ng-class=`{ 'bssm-multiple': $isMultiple }`
     role='select'
 )
     li(ng-if='$showAllNoneButtons || ($isMultiple && $matches.length > 2)')
@@ -37,6 +38,7 @@ ul.bs-select-menu(
             role='menuitem'
             tabindex='-1'
             ng-click='$select($index, $event)'
+            ng-class=`{ 'bssm-item-button__active': $isActive($index) }`
             data-placement='right auto'
             title='{{ ::match.label }}'
         )

http://git-wip-us.apache.org/repos/asf/ignite/blob/b49469f4/modules/web-console/frontend/app/primitives/dropdown/index.scss
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/primitives/dropdown/index.scss b/modules/web-console/frontend/app/primitives/dropdown/index.scss
index 47a7e90..4695d21 100644
--- a/modules/web-console/frontend/app/primitives/dropdown/index.scss
+++ b/modules/web-console/frontend/app/primitives/dropdown/index.scss
@@ -53,74 +53,6 @@
             border-bottom: 1px solid $table-border-color;
         }
     }
-
-    ul.select.dropdown-menu {
-        li {
-            hr {
-                display: none;
-            }
-
-            a {
-                &:before {
-                    content: '';
-
-                    position: relative;
-                    top: 1px;
-                    left: -3px;
-
-                    display: inline-block;
-                    width: 12px;
-                    height: 12px;
-
-                    margin-left: 0;
-                    margin-right: 7px;
-
-                    border: 1px solid #afafaf;
-                    border-radius: 2px;
-                    background-color: #FFF;
-
-                    box-shadow: inset 0 1px 1px $input-border;
-                }
-
-                &.active {
-                    color: $text-color;
-                }
-
-                &.active:before {
-                    border-color: $brand-info;
-                    background-color: $brand-info;
-
-                    box-shadow: none;
-                }
-
-                & > i {
-                    position: relative;
-                    top: -2px;
-                    left: -18px;
-
-                    float: none;
-
-                    width: 0;
-                    margin: 0;
-
-                    background: none;
-
-                    &.fa-check:before {
-                        content: '';
-
-                        display: block;
-                        width: 4px;
-                        height: 8px;
-
-                        border: solid #FFF;
-                        border-width: 0 2px 2px 0;
-
-                        transform: rotate(35deg);
-                    }
-                }
-            }
-        }
-    }
 }
 
 .dropdown--ignite {


[38/47] ignite git commit: IGNITE-5621: Support BINARY and VARBINARY SQL types for C++

Posted by ag...@apache.org.
IGNITE-5621: Support BINARY and VARBINARY SQL types for C++

(cherry picked from commit 96b43e5)


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

Branch: refs/heads/master
Commit: 97813a8280d54c9b4ce08dca954e05fa62393cbe
Parents: 3085b20
Author: Igor Sapego <is...@gridgain.com>
Authored: Fri Jul 28 19:30:35 2017 +0300
Committer: Igor Sapego <is...@gridgain.com>
Committed: Fri Jul 28 19:32:43 2017 +0300

----------------------------------------------------------------------
 .../core-test/config/cache-query-default.xml    |  29 +++
 .../cpp/core-test/src/cache_query_test.cpp      | 215 ++++++++++++++++++-
 .../ignite/cache/query/query_fields_row.h       |  28 +++
 .../ignite/cache/query/query_sql_fields.h       |  13 +-
 .../ignite/impl/cache/query/query_argument.h    |  63 ++++++
 .../impl/cache/query/query_fields_row_impl.h    |  29 +++
 6 files changed, 373 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/97813a82/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
index 16f601d..42ac80f 100644
--- a/modules/platforms/cpp/core-test/config/cache-query-default.xml
+++ b/modules/platforms/cpp/core-test/config/cache-query-default.xml
@@ -160,6 +160,35 @@
                         </list>
                     </property>
                 </bean>
+
+                <bean class="org.apache.ignite.configuration.CacheConfiguration">
+                    <property name="name" value="ByteArrayCache"/>
+                    <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="ByteArrayType"/>
+                                <property name="fields">
+                                    <map>
+                                        <entry key="intVal" value="java.lang.Integer"/>
+                                        <entry key="arrayVal" value="[B"/>
+                                    </map>
+                                </property>
+                            </bean>
+                        </list>
+                    </property>
+                </bean>
             </list>
         </property>
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/97813a82/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 e763e08..4993279 100644
--- a/modules/platforms/cpp/core-test/src/cache_query_test.cpp
+++ b/modules/platforms/cpp/core-test/src/cache_query_test.cpp
@@ -47,7 +47,7 @@ using ignite::impl::binary::BinaryUtils;
 /**
  * Person class for query tests.
  */
-class IGNITE_IMPORT_EXPORT QueryPerson
+class QueryPerson
 {
 public:
     /**
@@ -203,7 +203,7 @@ private:
 /**
  * Relation class for query tests.
  */
-class IGNITE_IMPORT_EXPORT QueryRelation
+class QueryRelation
 {
 public:
     /**
@@ -257,6 +257,40 @@ private:
     int32_t someVal;
 };
 
+/**
+ * Byte array test type.
+ */
+struct ByteArrayType
+{
+    /**
+     * Test constructor.
+     *
+     * @param val Init value.
+     */
+    ByteArrayType(int32_t val) :
+        intVal(val),
+        arrayVal(val + 1, val + 1)
+    {
+        // No-op.
+    }
+
+    /**
+     * Default constructor.
+     */
+    ByteArrayType() :
+        intVal(0),
+        arrayVal()
+    {
+        // No-op.
+    }
+
+    /** Int field. */
+    int32_t intVal;
+
+    /** Array field. */
+    std::vector<int8_t> arrayVal;
+};
+
 namespace ignite
 {
     namespace binary
@@ -300,7 +334,7 @@ namespace ignite
             IGNITE_BINARY_IS_NULL_FALSE(QueryRelation)
             IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(QueryRelation)
 
-            static void Write(BinaryWriter& writer, QueryRelation obj)
+            static void Write(BinaryWriter& writer, const QueryRelation& obj)
             {
                 writer.WriteInt32("personId", obj.GetPersonId());
                 writer.WriteInt32("someVal", obj.GetHobbyId());
@@ -314,6 +348,32 @@ namespace ignite
                 dst = QueryRelation(personId, someVal);
             }
         IGNITE_BINARY_TYPE_END
+
+        /**
+         * Binary type definition for ByteArrayType.
+         */
+        IGNITE_BINARY_TYPE_START(ByteArrayType)
+            IGNITE_BINARY_GET_TYPE_ID_AS_HASH(ByteArrayType)
+            IGNITE_BINARY_GET_TYPE_NAME_AS_IS(ByteArrayType)
+            IGNITE_BINARY_GET_FIELD_ID_AS_HASH
+            IGNITE_BINARY_IS_NULL_FALSE(ByteArrayType)
+            IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(ByteArrayType)
+
+            static void Write(BinaryWriter& writer, const ByteArrayType& obj)
+            {
+                writer.WriteInt32("intVal", obj.intVal);
+                writer.WriteInt8Array("arrayVal", &obj.arrayVal[0], static_cast<int32_t>(obj.arrayVal.size()));
+            }
+
+            static void Read(BinaryReader& reader, ByteArrayType& dst)
+            {
+                dst.intVal = reader.ReadInt32("intVal");
+                int32_t arrayValSize = reader.ReadInt8Array("arrayVal", 0, 0);
+
+                dst.arrayVal.resize(static_cast<size_t>(arrayValSize));
+                reader.ReadInt8Array("arrayVal", &dst.arrayVal[0], arrayValSize);
+            }
+        IGNITE_BINARY_TYPE_END
     }
 }
 
@@ -1956,4 +2016,153 @@ BOOST_AUTO_TEST_CASE(TestFieldsQuerySetSchema)
     CheckEmpty(cursor);
 }
 
+/**
+ * Test query for byte arrays.
+ */
+BOOST_AUTO_TEST_CASE(TestFieldsQueryByteArraySelect)
+{
+    Cache<int32_t, ByteArrayType> byteArrayCache = grid.GetCache<int32_t, ByteArrayType>("ByteArrayCache");
+
+    int32_t entryCnt = 100; // Number of entries.
+
+    for (int32_t i = 0; i < entryCnt; i++)
+        byteArrayCache.Put(i, ByteArrayType(i));
+
+    SqlFieldsQuery qry("select intVal, arrayVal, intVal + 1 from ByteArrayType where _key=42");
+
+    QueryFieldsCursor cursor = byteArrayCache.Query(qry);
+
+    BOOST_REQUIRE(cursor.HasNext());
+
+    QueryFieldsRow row = cursor.GetNext();
+
+    BOOST_REQUIRE(row.HasNext());
+
+    int32_t intVal1 = row.GetNext<int32_t>();
+
+    BOOST_CHECK_EQUAL(intVal1, 42);
+
+    BOOST_REQUIRE(row.HasNext());
+
+    std::vector<int8_t> arrayVal;
+    int32_t arrayValSize = row.GetNextInt8Array(0, 0);
+
+    arrayVal.resize(static_cast<size_t>(arrayValSize));
+    row.GetNextInt8Array(&arrayVal[0], arrayValSize);
+
+    BOOST_CHECK_EQUAL(arrayValSize, 43);
+
+    for (int32_t i = 0; i < arrayValSize; ++i)
+        BOOST_CHECK_EQUAL(arrayVal[i], 43);
+
+    BOOST_REQUIRE(row.HasNext());
+
+    int32_t intVal2 = row.GetNext<int32_t>();
+
+    BOOST_CHECK_EQUAL(intVal2, 43);
+
+    BOOST_REQUIRE(!row.HasNext());
+
+    CheckEmpty(cursor);
+}
+
+/**
+ * Test query for byte arrays.
+ */
+BOOST_AUTO_TEST_CASE(TestFieldsQueryByteArrayInsert)
+{
+    Cache<int32_t, ByteArrayType> byteArrayCache = grid.GetCache<int32_t, ByteArrayType>("ByteArrayCache");
+
+    SqlFieldsQuery qry("insert into ByteArrayType(_key, intVal, arrayVal) values (?, ?, ?)");
+
+    int32_t entryCnt = 100; // Number of entries.
+
+    for (int32_t i = 0; i < entryCnt; i++)
+    {
+        int32_t key = i;
+        int32_t intVal = i;
+        std::vector<int8_t> arrayVal(i + 1, i + 1);
+
+        qry.AddArgument(key);
+        qry.AddArgument(intVal);
+        qry.AddInt8ArrayArgument(&arrayVal[0], i + 1);
+
+        byteArrayCache.Query(qry);
+
+        qry.ClearArguments();
+    }
+
+    ByteArrayType val = byteArrayCache.Get(42);
+
+    BOOST_CHECK_EQUAL(val.intVal, 42);
+    BOOST_CHECK_EQUAL(val.arrayVal.size(), 43);
+
+    for (int32_t i = 0; i < 43; ++i)
+        BOOST_CHECK_EQUAL(val.arrayVal[i], 43);
+}
+
+/**
+ * Test query for byte arrays.
+ */
+BOOST_AUTO_TEST_CASE(TestFieldsQueryByteArrayInsertSelect)
+{
+    Cache<int32_t, ByteArrayType> byteArrayCache = grid.GetCache<int32_t, ByteArrayType>("ByteArrayCache");
+
+    SqlFieldsQuery qry("insert into ByteArrayType(_key, intVal, arrayVal) values (?, ?, ?)");
+
+    int32_t entryCnt = 100; // Number of entries.
+
+    for (int32_t i = 0; i < entryCnt; i++)
+    {
+        int32_t key = i;
+        int32_t intVal = i;
+        std::vector<int8_t> arrayVal(i + 1, i + 1);
+
+        qry.AddArgument(key);
+        qry.AddArgument(intVal);
+        qry.AddInt8ArrayArgument(&arrayVal[0], i + 1);
+
+        byteArrayCache.Query(qry);
+
+        qry.ClearArguments();
+    }
+
+    qry = SqlFieldsQuery("select intVal, arrayVal, intVal + 1 from ByteArrayType where _key=42");
+
+    QueryFieldsCursor cursor = byteArrayCache.Query(qry);
+
+    BOOST_REQUIRE(cursor.HasNext());
+
+    QueryFieldsRow row = cursor.GetNext();
+
+    BOOST_REQUIRE(row.HasNext());
+
+    int32_t intVal1 = row.GetNext<int32_t>();
+
+    BOOST_CHECK_EQUAL(intVal1, 42);
+
+    BOOST_REQUIRE(row.HasNext());
+
+    std::vector<int8_t> arrayVal;
+    int32_t arrayValSize = row.GetNextInt8Array(0, 0);
+
+    arrayVal.resize(static_cast<size_t>(arrayValSize));
+    row.GetNextInt8Array(&arrayVal[0], arrayValSize);
+
+    BOOST_CHECK_EQUAL(arrayValSize, 43);
+
+    for (int32_t i = 0; i < arrayValSize; ++i)
+        BOOST_CHECK_EQUAL(arrayVal[i], 43);
+
+    BOOST_REQUIRE(row.HasNext());
+
+    int32_t intVal2 = row.GetNext<int32_t>();
+
+    BOOST_CHECK_EQUAL(intVal2, 43);
+
+    BOOST_REQUIRE(!row.HasNext());
+
+    CheckEmpty(cursor);
+}
+
 BOOST_AUTO_TEST_SUITE_END()

http://git-wip-us.apache.org/repos/asf/ignite/blob/97813a82/modules/platforms/cpp/core/include/ignite/cache/query/query_fields_row.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/cache/query/query_fields_row.h b/modules/platforms/cpp/core/include/ignite/cache/query/query_fields_row.h
index d3ac2de..8ed587c 100644
--- a/modules/platforms/cpp/core/include/ignite/cache/query/query_fields_row.h
+++ b/modules/platforms/cpp/core/include/ignite/cache/query/query_fields_row.h
@@ -172,6 +172,34 @@ namespace ignite
                 }
 
                 /**
+                 * Get next entry assuming it's an array of 8-byte signed
+                 * integers. Maps to "byte[]" type in Java.
+                 *
+                 * This method should only be used on the valid instance.
+                 *
+                 * @param dst Array to store data to.
+                 * @param len Expected length of array.
+                 * @return Actual amount of elements read. If "len" argument is less than actual
+                 *     array size or resulting array is set to null, nothing will be written
+                 *     to resulting array and returned value will contain required array length.
+                 *     -1 will be returned in case array in stream was null.
+                 *
+                 * @throw IgniteError class instance in case of failure.
+                 */
+                int32_t GetNextInt8Array(int8_t* dst, int32_t len)
+                {
+                    impl::cache::query::QueryFieldsRowImpl* impl0 = impl.Get();
+
+                    if (impl0)
+                        return impl0->GetNextInt8Array(dst, len);
+                    else
+                    {
+                        throw IgniteError(IgniteError::IGNITE_ERR_GENERIC,
+                            "Instance is not usable (did you check for error?).");
+                    }
+                }
+
+                /**
                  * Check if the instance is valid.
                  *
                  * Invalid instance can be returned if some of the previous

http://git-wip-us.apache.org/repos/asf/ignite/blob/97813a82/modules/platforms/cpp/core/include/ignite/cache/query/query_sql_fields.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/cache/query/query_sql_fields.h b/modules/platforms/cpp/core/include/ignite/cache/query/query_sql_fields.h
index bf8d7ac..96d794d 100644
--- a/modules/platforms/cpp/core/include/ignite/cache/query/query_sql_fields.h
+++ b/modules/platforms/cpp/core/include/ignite/cache/query/query_sql_fields.h
@@ -139,7 +139,7 @@ namespace ignite
                         using std::swap;
 
                         swap(sql, other.sql);
-                        swap(sql, other.schema);
+                        swap(schema, other.schema);
                         swap(pageSize, other.pageSize);
                         swap(loc, other.loc);
                         swap(distributedJoins, other.distributedJoins);
@@ -274,6 +274,17 @@ namespace ignite
                 }
 
                 /**
+                 * Add array of bytes as an argument.
+                 *
+                 * @param src Array pointer.
+                 * @param len Array length in bytes.
+                 */
+                void AddInt8ArrayArgument(const int8_t* src, int32_t len)
+                {
+                    args.push_back(new impl::cache::query::QueryInt8ArrayArgument(src, len));
+                }
+
+                /**
                  * Remove all added arguments.
                  */
                 void ClearArguments()

http://git-wip-us.apache.org/repos/asf/ignite/blob/97813a82/modules/platforms/cpp/core/include/ignite/impl/cache/query/query_argument.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/impl/cache/query/query_argument.h b/modules/platforms/cpp/core/include/ignite/impl/cache/query/query_argument.h
index f2f55bc..e9e7e51 100644
--- a/modules/platforms/cpp/core/include/ignite/impl/cache/query/query_argument.h
+++ b/modules/platforms/cpp/core/include/ignite/impl/cache/query/query_argument.h
@@ -129,6 +129,69 @@ namespace ignite
                     /** Value. */
                     T val;
                 };
+
+                /**
+                 * Query bytes array argument class.
+                 */
+                class QueryInt8ArrayArgument : public QueryArgumentBase
+                {
+                public:
+                    /**
+                     * Constructor.
+                     *
+                     * @param src Array.
+                     * @param len Array length.
+                     */
+                    QueryInt8ArrayArgument(const int8_t* src, int32_t len) :
+                        val(src, src + len)
+                    {
+                        // No-op.
+                    }
+
+                    /**
+                     * Copy constructor.
+                     *
+                     * @param other Other instance.
+                     */
+                    QueryInt8ArrayArgument(const QueryInt8ArrayArgument& other) :
+                        val(other.val)
+                    {
+                        // No-op.
+                    }
+
+                    /**
+                     * Assignment operator.
+                     *
+                     * @param other Other instance.
+                     * @return *this.
+                     */
+                    QueryInt8ArrayArgument& operator=(const QueryInt8ArrayArgument& other)
+                    {
+                        if (this != &other)
+                            val = other.val;
+
+                        return *this;
+                    }
+
+                    virtual ~QueryInt8ArrayArgument()
+                    {
+                        // No-op.
+                    }
+
+                    virtual QueryArgumentBase* Copy() const
+                    {
+                        return new QueryInt8ArrayArgument(*this);
+                    }
+
+                    virtual void Write(ignite::binary::BinaryRawWriter& writer)
+                    {
+                        writer.WriteInt8Array(&val[0], static_cast<int32_t>(val.size()));
+                    }
+
+                private:
+                    /** Value. */
+                    std::vector<int8_t> val;
+                };
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/97813a82/modules/platforms/cpp/core/include/ignite/impl/cache/query/query_fields_row_impl.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/impl/cache/query/query_fields_row_impl.h b/modules/platforms/cpp/core/include/ignite/impl/cache/query/query_fields_row_impl.h
index 82cebd5..63e0523 100644
--- a/modules/platforms/cpp/core/include/ignite/impl/cache/query/query_fields_row_impl.h
+++ b/modules/platforms/cpp/core/include/ignite/impl/cache/query/query_fields_row_impl.h
@@ -127,6 +127,35 @@ namespace ignite
                     }
 
                     /**
+                     * Get next entry assuming it's an array of 8-byte signed
+                     * integers. Maps to "byte[]" type in Java.
+                     *
+                     * @param dst Array to store data to.
+                     * @param len Expected length of array.
+                     * @return Actual amount of elements read. If "len" argument is less than actual
+                     *     array size or resulting array is set to null, nothing will be written
+                     *     to resulting array and returned value will contain required array length.
+                     *     -1 will be returned in case array in stream was null.
+                     */
+                    int32_t GetNextInt8Array(int8_t* dst, int32_t len)
+                    {
+                        if (IsValid()) {
+
+                            int32_t actualLen = reader.ReadInt8Array(dst, len);
+
+                            if (actualLen == 0 || dst && len >= actualLen)
+                                ++processed;
+
+                            return actualLen;
+                        }
+                        else
+                        {
+                            throw IgniteError(IgniteError::IGNITE_ERR_GENERIC,
+                                "Instance is not usable (did you check for error?).");
+                        }
+                    }
+
+                    /**
                      * Check if the instance is valid.
                      *
                      * Invalid instance can be returned if some of the previous


[10/47] ignite git commit: IGNITE-5767 Web Console: Changed mapping for BINARY SQL type to byte[].

Posted by ag...@apache.org.
IGNITE-5767 Web Console: Changed mapping for BINARY SQL type to byte[].


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

Branch: refs/heads/master
Commit: 995258f9a326bb5a08b1e004d92e2760c25f20c0
Parents: b49469f
Author: Vasiliy Sisko <vs...@gridgain.com>
Authored: Thu Jul 27 11:06:52 2017 +0700
Committer: Andrey Novikov <an...@gridgain.com>
Committed: Thu Jul 27 11:06:52 2017 +0700

----------------------------------------------------------------------
 .../store/jdbc/CacheJdbcPojoStoreTest.java      |  55 ++++++++-
 .../cache/store/jdbc/model/BinaryTest.java      | 122 +++++++++++++++++++
 .../cache/store/jdbc/model/BinaryTestKey.java   |  87 +++++++++++++
 .../frontend/app/data/jdbc-types.json           |   6 +-
 4 files changed, 264 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/995258f9/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreTest.java
index bb85cab..ea2808f 100644
--- a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreTest.java
@@ -17,6 +17,7 @@
 
 package org.apache.ignite.cache.store.jdbc;
 
+import java.io.ByteArrayInputStream;
 import java.lang.reflect.Field;
 import java.sql.Connection;
 import java.sql.PreparedStatement;
@@ -25,6 +26,7 @@ import java.sql.Statement;
 import java.sql.Timestamp;
 import java.sql.Types;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.UUID;
 import java.util.concurrent.ConcurrentLinkedQueue;
@@ -33,6 +35,8 @@ import org.apache.ignite.Ignite;
 import org.apache.ignite.binary.BinaryObject;
 import org.apache.ignite.binary.BinaryObjectBuilder;
 import org.apache.ignite.cache.store.jdbc.dialect.H2Dialect;
+import org.apache.ignite.cache.store.jdbc.model.BinaryTest;
+import org.apache.ignite.cache.store.jdbc.model.BinaryTestKey;
 import org.apache.ignite.cache.store.jdbc.model.Organization;
 import org.apache.ignite.cache.store.jdbc.model.OrganizationKey;
 import org.apache.ignite.cache.store.jdbc.model.Person;
@@ -44,7 +48,6 @@ import org.apache.ignite.internal.util.typedef.CI2;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteBiInClosure;
 import org.apache.ignite.testframework.GridTestUtils;
-import org.apache.ignite.testframework.config.GridTestProperties;
 import org.apache.ignite.testframework.junits.cache.GridAbstractCacheStoreSelfTest;
 import org.h2.jdbcx.JdbcConnectionPool;
 
@@ -78,7 +81,7 @@ public class CacheJdbcPojoStoreTest extends GridAbstractCacheStoreSelfTest<Cache
     @Override protected CacheJdbcPojoStore<Object, Object> store() {
         CacheJdbcPojoStoreFactory<Object, Object> storeFactory = new CacheJdbcPojoStoreFactory<>();
 
-        JdbcType[] storeTypes = new JdbcType[6];
+        JdbcType[] storeTypes = new JdbcType[7];
 
         storeTypes[0] = new JdbcType();
         storeTypes[0].setDatabaseSchema("PUBLIC");
@@ -147,6 +150,15 @@ public class CacheJdbcPojoStoreTest extends GridAbstractCacheStoreSelfTest<Cache
         storeTypes[5].setValueType("java.util.UUID");
         storeTypes[5].setValueFields(new JdbcTypeField(Types.BINARY, "VAL", UUID.class, null));
 
+        storeTypes[6] = new JdbcType();
+        storeTypes[6].setDatabaseSchema("PUBLIC");
+        storeTypes[6].setDatabaseTable("BINARY_ENTRIES");
+        storeTypes[6].setKeyType("org.apache.ignite.cache.store.jdbc.model.BinaryTestKey");
+        storeTypes[6].setKeyFields(new JdbcTypeField(Types.BINARY, "KEY", Integer.class, "id"));
+
+        storeTypes[6].setValueType("org.apache.ignite.cache.store.jdbc.model.BinaryTest");
+        storeTypes[6].setValueFields(new JdbcTypeField(Types.BINARY, "VAL", byte[].class, "bytes"));
+
         storeFactory.setTypes(storeTypes);
 
         storeFactory.setDialect(new H2Dialect());
@@ -210,6 +222,13 @@ public class CacheJdbcPojoStoreTest extends GridAbstractCacheStoreSelfTest<Cache
             // No-op.
         }
 
+        try {
+            stmt.executeUpdate("delete from Binary_Entries");
+        }
+        catch (SQLException ignore) {
+            // No-op.
+        }
+
         stmt.executeUpdate("CREATE TABLE IF NOT EXISTS " +
             "String_Entries (key varchar(100) not null, val varchar(100), PRIMARY KEY(key))");
 
@@ -217,6 +236,9 @@ public class CacheJdbcPojoStoreTest extends GridAbstractCacheStoreSelfTest<Cache
             "UUID_Entries (key binary(16) not null, val binary(16), PRIMARY KEY(key))");
 
         stmt.executeUpdate("CREATE TABLE IF NOT EXISTS " +
+            "Binary_Entries (key binary(16) not null, val binary(16), PRIMARY KEY(key))");
+
+        stmt.executeUpdate("CREATE TABLE IF NOT EXISTS " +
             "Timestamp_Entries (key timestamp not null, val integer, PRIMARY KEY(key))");
 
         stmt.executeUpdate("CREATE TABLE IF NOT EXISTS " +
@@ -304,11 +326,31 @@ public class CacheJdbcPojoStoreTest extends GridAbstractCacheStoreSelfTest<Cache
 
         conn.commit();
 
+        U.closeQuiet(prnStmt);
+
+        PreparedStatement binaryStmt = conn.prepareStatement("INSERT INTO Binary_Entries(key, val) VALUES (?, ?)");
+
+        byte[] bytes = new byte[16];
+
+        for (byte i = 0; i < 16; i++)
+            bytes[i] = i;
+
+        binaryStmt.setInt(1, 1);
+        binaryStmt.setBinaryStream(2, new ByteArrayInputStream(bytes));
+
+        binaryStmt.addBatch();
+        binaryStmt.executeBatch();
+
+        U.closeQuiet(binaryStmt);
+
+        conn.commit();
+
         U.closeQuiet(conn);
 
         final Collection<Object> orgKeys = new ConcurrentLinkedQueue<>();
         final Collection<Object> prnKeys = new ConcurrentLinkedQueue<>();
         final Collection<Object> prnComplexKeys = new ConcurrentLinkedQueue<>();
+        final Collection<Object> binaryTestVals = new ConcurrentLinkedQueue<>();
 
         IgniteBiInClosure<Object, Object> c = new CI2<Object, Object>() {
             @Override public void apply(Object k, Object v) {
@@ -331,12 +373,18 @@ public class CacheJdbcPojoStoreTest extends GridAbstractCacheStoreSelfTest<Cache
                         if (PersonComplexKey.class.getName().equals(keyType)
                             && Person.class.getName().equals(valType))
                             prnComplexKeys.add(key);
+
+                        if (BinaryTestKey.class.getName().equals(keyType)
+                            && BinaryTest.class.getName().equals(valType))
+                            binaryTestVals.add(val.field("bytes"));
                     }
                 }else {
                     if (k instanceof OrganizationKey && v instanceof Organization)
                         orgKeys.add(k);
                     else if (k instanceof PersonKey && v instanceof Person)
                         prnKeys.add(k);
+                    else if (k instanceof BinaryTestKey && v instanceof BinaryTest)
+                        binaryTestVals.add(((BinaryTest)v).getBytes());
                     else if (k instanceof PersonComplexKey && v instanceof Person) {
                         PersonComplexKey key = (PersonComplexKey)k;
 
@@ -357,6 +405,8 @@ public class CacheJdbcPojoStoreTest extends GridAbstractCacheStoreSelfTest<Cache
         assertEquals(ORGANIZATION_CNT, orgKeys.size());
         assertEquals(PERSON_CNT, prnKeys.size());
         assertEquals(PERSON_CNT, prnComplexKeys.size());
+        assertEquals(1, binaryTestVals.size());
+        assertTrue(Arrays.equals(bytes, (byte[])binaryTestVals.iterator().next()));
 
         Collection<Object> tmpOrgKeys = new ArrayList<>(orgKeys);
         Collection<Object> tmpPrnKeys = new ArrayList<>(prnKeys);
@@ -545,5 +595,4 @@ public class CacheJdbcPojoStoreTest extends GridAbstractCacheStoreSelfTest<Cache
 
         return obj;
     }
-
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/995258f9/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/model/BinaryTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/model/BinaryTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/model/BinaryTest.java
new file mode 100644
index 0000000..6cb551b
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/model/BinaryTest.java
@@ -0,0 +1,122 @@
+/*
+ * 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.store.jdbc.model;
+
+import java.io.Serializable;
+import java.sql.Date;
+import java.util.Arrays;
+
+/**
+ * BinaryTest definition.
+ */
+public class BinaryTest implements Serializable {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** Value for id. */
+    private Integer id;
+
+    /** Value for bytes. */
+    private byte[] bytes;
+
+    /**
+     * Empty constructor.
+     */
+    public BinaryTest() {
+        // No-op.
+    }
+
+    /**
+     * Full constructor.
+     */
+    public BinaryTest(
+        Integer id,
+        byte[] bytes
+    ) {
+        this.id = id;
+        this.bytes = bytes;
+    }
+
+    /**
+     * Gets id.
+     *
+     * @return Value for id.
+     */
+    public Integer getId() {
+        return id;
+    }
+
+    /**
+     * Sets id.
+     *
+     * @param id New value for id.
+     */
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    /**
+     * Gets bytes.
+     *
+     * @return Value for bytes.
+     */
+    public byte[] getBytes() {
+        return bytes;
+    }
+
+    /**
+     * Sets bytes.
+     *
+     * @param bytes New value for bytes.
+     */
+    public void setBytes(byte[] bytes) {
+        this.bytes = bytes;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object o) {
+        if (this == o)
+            return true;
+
+        if (!(o instanceof BinaryTest))
+            return false;
+
+        BinaryTest that = (BinaryTest)o;
+
+        if (id != null ? !id.equals(that.id) : that.id != null)
+            return false;
+
+        return bytes != null ? Arrays.equals(bytes, that.bytes) : that.bytes == null;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int hashCode() {
+        int res = id != null ? id.hashCode() : 0;
+
+        res = 31 * res + (bytes != null ? Arrays.hashCode(bytes) : 0);
+
+        return res;
+    }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return "Person [id=" + id +
+            ", bytes=" + Arrays.toString(bytes) +
+            "]";
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/995258f9/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/model/BinaryTestKey.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/model/BinaryTestKey.java b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/model/BinaryTestKey.java
new file mode 100644
index 0000000..b710fad
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/model/BinaryTestKey.java
@@ -0,0 +1,87 @@
+/*
+ * 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.store.jdbc.model;
+
+import java.io.Serializable;
+
+/**
+ * BinaryTestKey definition.
+ */
+public class BinaryTestKey implements Serializable {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** Value for id. */
+    private Integer id;
+
+    /**
+     * Empty constructor.
+     */
+    public BinaryTestKey() {
+        // No-op.
+    }
+
+    /**
+     * Full constructor.
+     */
+    public BinaryTestKey(Integer id) {
+        this.id = id;
+    }
+
+    /**
+     * Gets id.
+     *
+     * @return Value for id.
+     */
+    public Integer getId() {
+        return id;
+    }
+
+    /**
+     * Sets id.
+     *
+     * @param id New value for id.
+     */
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object o) {
+        if (this == o)
+            return true;
+
+        if (!(o instanceof BinaryTestKey))
+            return false;
+
+        BinaryTestKey that = (BinaryTestKey)o;
+
+        return id != null ? id.equals(that.id) : that.id == null;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int hashCode() {
+        return id != null ? id.hashCode() : 0;
+    }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return "PersonKey [id=" + id +
+            "]";
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/995258f9/modules/web-console/frontend/app/data/jdbc-types.json
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/data/jdbc-types.json b/modules/web-console/frontend/app/data/jdbc-types.json
index 07abbaf..c743e31 100644
--- a/modules/web-console/frontend/app/data/jdbc-types.json
+++ b/modules/web-console/frontend/app/data/jdbc-types.json
@@ -21,9 +21,9 @@
     {"dbName": "DATE", "dbType": 91, "signed": {"javaType": "Date"}},
     {"dbName": "TIME", "dbType": 92, "signed": {"javaType": "Time"}},
     {"dbName": "TIMESTAMP", "dbType": 93, "signed": {"javaType": "Timestamp"}},
-    {"dbName": "BINARY", "dbType": -2, "signed": {"javaType": "Object"}},
-    {"dbName": "VARBINARY", "dbType": -3, "signed": {"javaType": "Object"}},
-    {"dbName": "LONGVARBINARY", "dbType": -4, "signed": {"javaType": "Object"}},
+    {"dbName": "BINARY", "dbType": -2, "signed": {"javaType": "byte[]"}},
+    {"dbName": "VARBINARY", "dbType": -3, "signed": {"javaType": "byte[]"}},
+    {"dbName": "LONGVARBINARY", "dbType": -4, "signed": {"javaType": "byte[]"}},
     {"dbName": "NULL", "dbType": 0, "signed": {"javaType": "Object"}},
     {"dbName": "OTHER", "dbType": 1111, "signed": {"javaType": "Object"}},
     {"dbName": "JAVA_OBJECT", "dbType": 2000, "signed": {"javaType": "Object"}},


[13/47] ignite git commit: IGNITE-5729 - IgniteCacheProxy instances from with() methods are not reusable after cache restart

Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/5172541f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyImpl.java
new file mode 100644
index 0000000..b94afa1
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyImpl.java
@@ -0,0 +1,1810 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.Set;
+import java.util.UUID;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.concurrent.locks.Lock;
+import javax.cache.Cache;
+import javax.cache.CacheException;
+import javax.cache.configuration.CacheEntryListenerConfiguration;
+import javax.cache.configuration.Configuration;
+import javax.cache.expiry.ExpiryPolicy;
+import javax.cache.integration.CompletionListener;
+import javax.cache.processor.EntryProcessor;
+import javax.cache.processor.EntryProcessorException;
+import javax.cache.processor.EntryProcessorResult;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteCacheRestartingException;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.cache.CacheEntry;
+import org.apache.ignite.cache.CacheEntryProcessor;
+import org.apache.ignite.cache.CacheManager;
+import org.apache.ignite.cache.CacheMetrics;
+import org.apache.ignite.cache.CachePeekMode;
+import org.apache.ignite.cache.query.ContinuousQuery;
+import org.apache.ignite.cache.query.FieldsQueryCursor;
+import org.apache.ignite.cache.query.Query;
+import org.apache.ignite.cache.query.QueryCursor;
+import org.apache.ignite.cache.query.QueryDetailMetrics;
+import org.apache.ignite.cache.query.QueryMetrics;
+import org.apache.ignite.cache.query.ScanQuery;
+import org.apache.ignite.cache.query.SpiQuery;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.cache.query.SqlQuery;
+import org.apache.ignite.cache.query.TextQuery;
+import org.apache.ignite.cluster.ClusterGroup;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.internal.AsyncSupportAdapter;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.internal.processors.cache.query.CacheQuery;
+import org.apache.ignite.internal.processors.cache.query.CacheQueryFuture;
+import org.apache.ignite.internal.processors.cache.query.GridCacheQueryType;
+import org.apache.ignite.internal.processors.query.QueryUtils;
+import org.apache.ignite.internal.util.GridCloseableIteratorAdapter;
+import org.apache.ignite.internal.util.GridEmptyIterator;
+import org.apache.ignite.internal.util.future.GridFutureAdapter;
+import org.apache.ignite.internal.util.future.IgniteFinishedFutureImpl;
+import org.apache.ignite.internal.util.future.IgniteFutureImpl;
+import org.apache.ignite.internal.util.lang.GridCloseableIterator;
+import org.apache.ignite.internal.util.lang.GridClosureException;
+import org.apache.ignite.internal.util.lang.IgniteOutClosureX;
+import org.apache.ignite.internal.util.tostring.GridToStringExclude;
+import org.apache.ignite.internal.util.tostring.GridToStringInclude;
+import org.apache.ignite.internal.util.typedef.CI1;
+import org.apache.ignite.internal.util.typedef.CX1;
+import org.apache.ignite.internal.util.typedef.X;
+import org.apache.ignite.internal.util.typedef.internal.A;
+import org.apache.ignite.internal.util.typedef.internal.CU;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteBiPredicate;
+import org.apache.ignite.lang.IgniteClosure;
+import org.apache.ignite.lang.IgniteFuture;
+import org.apache.ignite.lang.IgniteInClosure;
+import org.apache.ignite.mxbean.CacheMetricsMXBean;
+import org.apache.ignite.plugin.security.SecurityPermission;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Cache proxy implementation.
+ */
+@SuppressWarnings("unchecked")
+public class IgniteCacheProxyImpl<K, V> extends AsyncSupportAdapter<IgniteCache<K, V>>
+    implements IgniteCacheProxy<K, V> {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** Context. */
+    private volatile GridCacheContext<K, V> ctx;
+
+    /** Delegate. */
+    @GridToStringInclude
+    private volatile IgniteInternalCache<K, V> delegate;
+
+    /** */
+    @GridToStringExclude
+    private CacheManager cacheMgr;
+
+    /** Future indicates that cache is under restarting. */
+    private final AtomicReference<GridFutureAdapter<Void>> restartFut;
+
+    /** Flag indicates that proxy is closed. */
+    private volatile boolean closed;
+
+    /**
+     * Empty constructor required for {@link Externalizable}.
+     */
+    public IgniteCacheProxyImpl() {
+        restartFut = new AtomicReference<GridFutureAdapter<Void>>(null);
+    }
+
+    /**
+     * @param ctx Context.
+     * @param delegate Delegate.
+     * @param async Async support flag.
+     */
+    public IgniteCacheProxyImpl(
+            @NotNull GridCacheContext<K, V> ctx,
+            @NotNull IgniteInternalCache<K, V> delegate,
+            boolean async
+    ) {
+        this(ctx, delegate, new AtomicReference<GridFutureAdapter<Void>>(null), async);
+    }
+
+    /**
+     * @param ctx Context.
+     * @param delegate Delegate.
+     * @param async Async support flag.
+     */
+    private IgniteCacheProxyImpl(
+        @NotNull GridCacheContext<K, V> ctx,
+        @NotNull IgniteInternalCache<K, V> delegate,
+        @NotNull AtomicReference<GridFutureAdapter<Void>> restartFut,
+        boolean async
+    ) {
+        super(async);
+
+        assert ctx != null;
+        assert delegate != null;
+
+        this.ctx = ctx;
+        this.delegate = delegate;
+
+        this.restartFut = restartFut;
+    }
+
+    /**
+     * @return Context.
+     */
+    @Override
+    public GridCacheContext<K, V> context() {
+        return ctx;
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteCacheProxy<K, V> cacheNoGate() {
+        return new GatewayProtectedCacheProxy<>(this, new CacheOperationContext(), false);
+    }
+
+    /** {@inheritDoc} */
+    @Override public CacheMetrics metrics() {
+        return ctx.cache().clusterMetrics();
+    }
+
+    /** {@inheritDoc} */
+    @Override public CacheMetrics metrics(ClusterGroup grp) {
+        return ctx.cache().clusterMetrics(grp);
+    }
+
+    /** {@inheritDoc} */
+    @Override public CacheMetrics localMetrics() {
+        return ctx.cache().localMetrics();
+    }
+
+    /** {@inheritDoc} */
+    @Override public CacheMetricsMXBean mxBean() {
+        return ctx.cache().clusterMxBean();
+    }
+
+    /** {@inheritDoc} */
+    @Override public CacheMetricsMXBean localMxBean() {
+        return ctx.cache().localMxBean();
+    }
+
+    /** {@inheritDoc} */
+    @Override public <C extends Configuration<K, V>> C getConfiguration(Class<C> clazz) {
+        CacheConfiguration cfg = ctx.config();
+
+        if (!clazz.isAssignableFrom(cfg.getClass()))
+            throw new IllegalArgumentException();
+
+        return clazz.cast(cfg);
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteCache<K, V> withExpiryPolicy(ExpiryPolicy plc) {
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteCache<K, V> withSkipStore() {
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public <K1, V1> IgniteCache<K1, V1> withKeepBinary() {
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteCache<K, V> withNoRetries() {
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteCache<K, V> withPartitionRecover() {
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public void loadCache(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args) {
+        try {
+            if (isAsync()) {
+                if (ctx.cache().isLocal())
+                    setFuture(ctx.cache().localLoadCacheAsync(p, args));
+                else
+                    setFuture(ctx.cache().globalLoadCacheAsync(p, args));
+            }
+            else {
+                if (ctx.cache().isLocal())
+                    ctx.cache().localLoadCache(p, args);
+                else
+                    ctx.cache().globalLoadCache(p, args);
+            }
+        }
+        catch (IgniteCheckedException | IgniteException e) {
+            throw cacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<Void> loadCacheAsync(@Nullable IgniteBiPredicate<K, V> p,
+        @Nullable Object... args) throws CacheException {
+        try {
+            if (ctx.cache().isLocal())
+                return (IgniteFuture<Void>)createFuture(ctx.cache().localLoadCacheAsync(p, args));
+            else
+                return (IgniteFuture<Void>)createFuture(ctx.cache().globalLoadCacheAsync(p, args));
+        }
+        catch (IgniteCheckedException | IgniteException e) {
+            throw cacheException(e);
+        }
+   }
+
+    /** {@inheritDoc} */
+    @Override public void localLoadCache(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args) {
+        try {
+            if (isAsync())
+                setFuture(delegate.localLoadCacheAsync(p, args));
+            else
+                delegate.localLoadCache(p, args);
+        }
+        catch (IgniteCheckedException | IgniteException e) {
+            throw cacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<Void> localLoadCacheAsync(@Nullable IgniteBiPredicate<K, V> p,
+        @Nullable Object... args) throws CacheException {
+        return (IgniteFuture<Void>)createFuture(delegate.localLoadCacheAsync(p, args));
+    }
+
+    /** {@inheritDoc} */
+    @Nullable @Override public V getAndPutIfAbsent(K key, V val) throws CacheException {
+        try {
+            if (isAsync()) {
+                setFuture(delegate.getAndPutIfAbsentAsync(key, val));
+
+                return null;
+            }
+            else
+                return delegate.getAndPutIfAbsent(key, val);
+        }
+        catch (IgniteCheckedException | IgniteException e) {
+            throw cacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<V> getAndPutIfAbsentAsync(K key, V val) throws CacheException {
+        return createFuture(delegate.getAndPutIfAbsentAsync(key, val));
+    }
+
+    /** {@inheritDoc} */
+    @Override public Lock lock(K key) throws CacheException {
+        return lockAll(Collections.singleton(key));
+    }
+
+    /** {@inheritDoc} */
+    @Override public Lock lockAll(final Collection<? extends K> keys) {
+        return new CacheLockImpl<>(ctx.gate(), delegate, new CacheOperationContext(), keys);
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isLocalLocked(K key, boolean byCurrThread) {
+        return byCurrThread ? delegate.isLockedByThread(key) : delegate.isLocked(key);
+    }
+
+    /**
+     * @param scanQry ScanQry.
+     * @param transformer Transformer
+     * @param grp Optional cluster group.
+     * @return Cursor.
+     * @throws IgniteCheckedException If failed.
+     */
+    @SuppressWarnings("unchecked")
+    private <T, R> QueryCursor<R> query(
+        final ScanQuery scanQry,
+        @Nullable final IgniteClosure<T, R> transformer,
+        @Nullable ClusterGroup grp)
+        throws IgniteCheckedException {
+
+        final CacheQuery<R> qry;
+
+        CacheOperationContext opCtxCall = ctx.operationContextPerCall();
+
+        boolean isKeepBinary = opCtxCall != null && opCtxCall.isKeepBinary();
+
+        IgniteBiPredicate<K, V> p = scanQry.getFilter();
+
+        qry = ctx.queries().createScanQuery(p, transformer, scanQry.getPartition(), isKeepBinary);
+
+        if (scanQry.getPageSize() > 0)
+            qry.pageSize(scanQry.getPageSize());
+
+        if (grp != null)
+            qry.projection(grp);
+
+        final GridCloseableIterator<R> iter = ctx.kernalContext().query().executeQuery(GridCacheQueryType.SCAN,
+            ctx.name(), ctx, new IgniteOutClosureX<GridCloseableIterator<R>>() {
+                @Override public GridCloseableIterator<R> applyx() throws IgniteCheckedException {
+                    final GridCloseableIterator iter0 = qry.executeScanQuery();
+
+                    final boolean needToConvert = transformer == null;
+
+                    return new GridCloseableIteratorAdapter<R>() {
+                        @Override protected R onNext() throws IgniteCheckedException {
+                            Object next = iter0.nextX();
+
+                            if (needToConvert) {
+                                Map.Entry<K, V> entry = (Map.Entry<K, V>)next;
+
+                                return (R)new CacheEntryImpl<>(entry.getKey(), entry.getValue());
+                            }
+
+                            return (R)next;
+                        }
+
+                        @Override protected boolean onHasNext() throws IgniteCheckedException {
+                            return iter0.hasNextX();
+                        }
+
+                        @Override protected void onClose() throws IgniteCheckedException {
+                            iter0.close();
+                        }
+                    };
+                }
+            }, true);
+
+        return new QueryCursorImpl<>(iter);
+    }
+
+    /**
+     * @param filter Filter.
+     * @param grp Optional cluster group.
+     * @return Cursor.
+     * @throws IgniteCheckedException If failed.
+     */
+    @SuppressWarnings("unchecked")
+    private QueryCursor<Cache.Entry<K, V>> query(final Query filter, @Nullable ClusterGroup grp)
+        throws IgniteCheckedException {
+        final CacheQuery qry;
+
+        CacheOperationContext opCtxCall = ctx.operationContextPerCall();
+
+        boolean isKeepBinary = opCtxCall != null && opCtxCall.isKeepBinary();
+
+        final CacheQueryFuture fut;
+
+        if (filter instanceof TextQuery) {
+            TextQuery p = (TextQuery)filter;
+
+            qry = ctx.queries().createFullTextQuery(p.getType(), p.getText(), isKeepBinary);
+
+            if (grp != null)
+                qry.projection(grp);
+
+            fut = ctx.kernalContext().query().executeQuery(GridCacheQueryType.TEXT, p.getText(), ctx,
+                new IgniteOutClosureX<CacheQueryFuture<Map.Entry<K, V>>>() {
+                    @Override public CacheQueryFuture<Map.Entry<K, V>> applyx() {
+                        return qry.execute();
+                    }
+                }, false);
+        }
+        else if (filter instanceof SpiQuery) {
+            qry = ctx.queries().createSpiQuery(isKeepBinary);
+
+            if (grp != null)
+                qry.projection(grp);
+
+            fut = ctx.kernalContext().query().executeQuery(GridCacheQueryType.SPI, filter.getClass().getSimpleName(),
+                ctx, new IgniteOutClosureX<CacheQueryFuture<Map.Entry<K, V>>>() {
+                    @Override public CacheQueryFuture<Map.Entry<K, V>> applyx() {
+                        return qry.execute(((SpiQuery)filter).getArgs());
+                    }
+                }, false);
+        }
+        else {
+            if (filter instanceof SqlFieldsQuery)
+                throw new CacheException("Use methods 'queryFields' and 'localQueryFields' for " +
+                    SqlFieldsQuery.class.getSimpleName() + ".");
+
+            throw new CacheException("Unsupported query type: " + filter);
+        }
+
+        return new QueryCursorImpl<>(new GridCloseableIteratorAdapter<Entry<K, V>>() {
+            /** */
+            private Cache.Entry<K, V> cur;
+
+            @Override protected Entry<K, V> onNext() throws IgniteCheckedException {
+                if (!onHasNext())
+                    throw new NoSuchElementException();
+
+                Cache.Entry<K, V> e = cur;
+
+                cur = null;
+
+                return e;
+            }
+
+            @Override protected boolean onHasNext() throws IgniteCheckedException {
+                if (cur != null)
+                    return true;
+
+                Object next = fut.next();
+
+                // Workaround a bug: if IndexingSpi is configured future represents Iterator<Cache.Entry>
+                // instead of Iterator<Map.Entry> due to IndexingSpi interface.
+                if (next == null)
+                    return false;
+
+                if (next instanceof Cache.Entry)
+                    cur = (Cache.Entry)next;
+                else {
+                    Map.Entry e = (Map.Entry)next;
+
+                    cur = new CacheEntryImpl(e.getKey(), e.getValue());
+                }
+
+                return true;
+            }
+
+            @Override protected void onClose() throws IgniteCheckedException {
+                fut.cancel();
+            }
+        });
+    }
+
+    /**
+     * @param loc Enforce local.
+     * @return Local node cluster group.
+     */
+    private ClusterGroup projection(boolean loc) {
+        if (loc || ctx.isLocal() || ctx.isReplicatedAffinityNode())
+            return ctx.kernalContext().grid().cluster().forLocal();
+
+        if (ctx.isReplicated())
+            return ctx.kernalContext().grid().cluster().forDataNodes(ctx.name()).forRandom();
+
+        return null;
+    }
+
+    /**
+     * Executes continuous query.
+     *
+     * @param qry Query.
+     * @param loc Local flag.
+     * @param keepBinary Keep binary flag.
+     * @return Initial iteration cursor.
+     */
+    @SuppressWarnings("unchecked")
+    private QueryCursor<Cache.Entry<K, V>> queryContinuous(ContinuousQuery qry, boolean loc, boolean keepBinary) {
+        if (qry.getInitialQuery() instanceof ContinuousQuery)
+            throw new IgniteException("Initial predicate for continuous query can't be an instance of another " +
+                "continuous query. Use SCAN or SQL query for initial iteration.");
+
+        if (qry.getLocalListener() == null)
+            throw new IgniteException("Mandatory local listener is not set for the query: " + qry);
+
+        if (qry.getRemoteFilter() != null && qry.getRemoteFilterFactory() != null)
+            throw new IgniteException("Should be used either RemoterFilter or RemoteFilterFactory.");
+
+        try {
+            final UUID routineId = ctx.continuousQueries().executeQuery(
+                qry.getLocalListener(),
+                qry.getRemoteFilter(),
+                qry.getRemoteFilterFactory(),
+                qry.getPageSize(),
+                qry.getTimeInterval(),
+                qry.isAutoUnsubscribe(),
+                loc,
+                keepBinary,
+                qry.isIncludeExpired());
+
+            final QueryCursor<Cache.Entry<K, V>> cur =
+                qry.getInitialQuery() != null ? query(qry.getInitialQuery()) : null;
+
+            return new QueryCursor<Cache.Entry<K, V>>() {
+                @Override public Iterator<Cache.Entry<K, V>> iterator() {
+                    return cur != null ? cur.iterator() : new GridEmptyIterator<Cache.Entry<K, V>>();
+                }
+
+                @Override public List<Cache.Entry<K, V>> getAll() {
+                    return cur != null ? cur.getAll() : Collections.<Cache.Entry<K, V>>emptyList();
+                }
+
+                @Override public void close() {
+                    if (cur != null)
+                        cur.close();
+
+                    try {
+                        ctx.kernalContext().continuous().stopRoutine(routineId).get();
+                    }
+                    catch (IgniteCheckedException e) {
+                        throw U.convertException(e);
+                    }
+                }
+            };
+        }
+        catch (IgniteCheckedException e) {
+            throw U.convertException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
+    @Override public FieldsQueryCursor<List<?>> query(SqlFieldsQuery qry) {
+        return (FieldsQueryCursor<List<?>>)query((Query)qry);
+    }
+
+    /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
+    @Override public <R> QueryCursor<R> query(Query<R> qry) {
+        A.notNull(qry, "qry");
+        try {
+            ctx.checkSecurity(SecurityPermission.CACHE_READ);
+
+            validate(qry);
+
+            convertToBinary(qry);
+
+            CacheOperationContext opCtxCall = ctx.operationContextPerCall();
+
+            boolean keepBinary = opCtxCall != null && opCtxCall.isKeepBinary();
+
+            if (qry instanceof ContinuousQuery)
+                return (QueryCursor<R>)queryContinuous((ContinuousQuery<K, V>)qry, qry.isLocal(), keepBinary);
+
+            if (qry instanceof SqlQuery)
+                return (QueryCursor<R>)ctx.kernalContext().query().querySql(ctx, (SqlQuery)qry, keepBinary);
+
+            if (qry instanceof SqlFieldsQuery)
+                return (FieldsQueryCursor<R>)ctx.kernalContext().query().querySqlFields(ctx, (SqlFieldsQuery)qry,
+                    keepBinary);
+
+            if (qry instanceof ScanQuery)
+                return query((ScanQuery)qry, null, projection(qry.isLocal()));
+
+            return (QueryCursor<R>)query(qry, projection(qry.isLocal()));
+        }
+        catch (Exception e) {
+            if (e instanceof CacheException)
+                throw (CacheException)e;
+
+            throw new CacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public <T, R> QueryCursor<R> query(Query<T> qry, IgniteClosure<T, R> transformer) {
+        A.notNull(qry, "qry");
+        A.notNull(transformer, "transformer");
+
+        if (!(qry instanceof ScanQuery))
+            throw new UnsupportedOperationException("Transformers are supported only for SCAN queries.");
+
+        try {
+            ctx.checkSecurity(SecurityPermission.CACHE_READ);
+
+            validate(qry);
+
+            return query((ScanQuery<K, V>)qry, transformer, projection(qry.isLocal()));
+        }
+        catch (Exception e) {
+            if (e instanceof CacheException)
+                throw (CacheException)e;
+
+            throw new CacheException(e);
+        }
+    }
+
+    /**
+     * Convert query arguments to BinaryObjects if binary marshaller used.
+     *
+     * @param qry Query.
+     */
+    private void convertToBinary(final Query qry) {
+        if (ctx.binaryMarshaller()) {
+            if (qry instanceof SqlQuery) {
+                final SqlQuery sqlQry = (SqlQuery) qry;
+
+                convertToBinary(sqlQry.getArgs());
+            }
+            else if (qry instanceof SpiQuery) {
+                final SpiQuery spiQry = (SpiQuery) qry;
+
+                convertToBinary(spiQry.getArgs());
+            }
+            else if (qry instanceof SqlFieldsQuery) {
+                final SqlFieldsQuery fieldsQry = (SqlFieldsQuery) qry;
+
+                convertToBinary(fieldsQry.getArgs());
+            }
+        }
+    }
+
+    /**
+     * Converts query arguments to BinaryObjects if binary marshaller used.
+     *
+     * @param args Arguments.
+     */
+    private void convertToBinary(final Object[] args) {
+        if (args == null)
+            return;
+
+        for (int i = 0; i < args.length; i++)
+            args[i] = ctx.cacheObjects().binary().toBinary(args[i]);
+    }
+
+    /**
+     * Checks query.
+     *
+     * @param qry Query
+     * @throws CacheException If query indexing disabled for sql query.
+     */
+    private void validate(Query qry) {
+        if (!QueryUtils.isEnabled(ctx.config()) && !(qry instanceof ScanQuery) &&
+            !(qry instanceof ContinuousQuery) && !(qry instanceof SpiQuery))
+            throw new CacheException("Indexing is disabled for cache: " + ctx.cache().name() +
+                ". Use setIndexedTypes or setTypeMetadata methods on CacheConfiguration to enable.");
+
+        if (!ctx.kernalContext().query().moduleEnabled() &&
+            (qry instanceof SqlQuery || qry instanceof SqlFieldsQuery || qry instanceof TextQuery))
+            throw new CacheException("Failed to execute query. Add module 'ignite-indexing' to the classpath " +
+                "of all Ignite nodes.");
+    }
+
+    /** {@inheritDoc} */
+    @Override public Iterable<Cache.Entry<K, V>> localEntries(CachePeekMode... peekModes) throws CacheException {
+        try {
+            return delegate.localEntries(peekModes);
+        }
+        catch (IgniteCheckedException | IgniteException e) {
+            throw cacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public QueryMetrics queryMetrics() {
+        return delegate.context().queries().metrics();
+    }
+
+    /** {@inheritDoc} */
+    @Override public void resetQueryMetrics() {
+        delegate.context().queries().resetMetrics();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Collection<? extends QueryDetailMetrics> queryDetailMetrics() {
+        return delegate.context().queries().detailMetrics();
+    }
+
+    /** {@inheritDoc} */
+    @Override public void resetQueryDetailMetrics() {
+        delegate.context().queries().resetDetailMetrics();
+    }
+
+    /** {@inheritDoc} */
+    @Override public void localEvict(Collection<? extends K> keys) {
+        delegate.evictAll(keys);
+    }
+
+    /** {@inheritDoc} */
+    @Nullable @Override public V localPeek(K key, CachePeekMode... peekModes) {
+        try {
+            return delegate.localPeek(key, peekModes, null);
+        }
+        catch (IgniteException | IgniteCheckedException e) {
+            throw cacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public int size(CachePeekMode... peekModes) throws CacheException {
+        try {
+            if (isAsync()) {
+                setFuture(delegate.sizeAsync(peekModes));
+
+                return 0;
+            }
+            else
+                return delegate.size(peekModes);
+        }
+        catch (IgniteCheckedException | IgniteException e) {
+            throw cacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<Integer> sizeAsync(CachePeekMode... peekModes) throws CacheException {
+        return createFuture(delegate.sizeAsync(peekModes));
+    }
+
+    /** {@inheritDoc} */
+    @Override public long sizeLong(CachePeekMode... peekModes) throws CacheException {
+        try {
+            if (isAsync()) {
+                setFuture(delegate.sizeLongAsync(peekModes));
+
+                return 0;
+            }
+            else
+                return delegate.sizeLong(peekModes);
+        }
+        catch (IgniteCheckedException | IgniteException e) {
+            throw cacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<Long> sizeLongAsync(CachePeekMode... peekModes) throws CacheException {
+        return createFuture(delegate.sizeLongAsync(peekModes));
+    }
+
+    /** {@inheritDoc} */
+    @Override public long sizeLong(int part, CachePeekMode... peekModes) throws CacheException {
+        try {
+            if (isAsync()) {
+                setFuture(delegate.sizeLongAsync(part, peekModes));
+
+                return 0;
+            }
+            else
+                return delegate.sizeLong(part, peekModes);
+        }
+        catch (IgniteCheckedException | IgniteException e) {
+            throw cacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<Long> sizeLongAsync(int part, CachePeekMode... peekModes) throws CacheException {
+        return createFuture(delegate.sizeLongAsync(part, peekModes));
+    }
+
+    /** {@inheritDoc} */
+    @Override public int localSize(CachePeekMode... peekModes) {
+        try {
+            return delegate.localSize(peekModes);
+        }
+        catch (IgniteCheckedException | IgniteException e) {
+            throw cacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public long localSizeLong(CachePeekMode... peekModes) {
+        try {
+            return delegate.localSizeLong(peekModes);
+        }
+        catch (IgniteCheckedException | IgniteException e) {
+            throw cacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public long localSizeLong(int part, CachePeekMode... peekModes) {
+        try {
+            return delegate.localSizeLong(part, peekModes);
+        }
+        catch (IgniteCheckedException | IgniteException e) {
+            throw cacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public V get(K key) {
+        try {
+            if (isAsync()) {
+                setFuture(delegate.getAsync(key));
+
+                return null;
+            }
+            else
+                return delegate.get(key);
+        }
+        catch (IgniteCheckedException | IgniteException e) {
+            throw cacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<V> getAsync(K key) {
+        return createFuture(delegate.getAsync(key));
+    }
+
+    /** {@inheritDoc} */
+    @Override public CacheEntry<K, V> getEntry(K key) {
+        try {
+            if (isAsync()) {
+                setFuture(delegate.getEntryAsync(key));
+
+                return null;
+            }
+            else
+                return delegate.getEntry(key);
+        }
+        catch (IgniteCheckedException | IgniteException e) {
+            throw cacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<CacheEntry<K, V>> getEntryAsync(K key) {
+        return createFuture(delegate.getEntryAsync(key));
+    }
+
+    /** {@inheritDoc} */
+    @Override public Map<K, V> getAll(Set<? extends K> keys) {
+        try {
+            if (isAsync()) {
+                setFuture(delegate.getAllAsync(keys));
+
+                return null;
+            }
+            else
+                return delegate.getAll(keys);
+        }
+        catch (IgniteCheckedException | IgniteException e) {
+            throw cacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<Map<K, V>> getAllAsync(Set<? extends K> keys) {
+        return createFuture(delegate.getAllAsync(keys));
+    }
+
+    /** {@inheritDoc} */
+    @Override public Collection<CacheEntry<K, V>> getEntries(Set<? extends K> keys) {
+        try {
+            if (isAsync()) {
+                setFuture(delegate.getEntriesAsync(keys));
+
+                return null;
+            }
+            else
+                return delegate.getEntries(keys);
+        }
+        catch (IgniteCheckedException | IgniteException e) {
+            throw cacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<Collection<CacheEntry<K, V>>> getEntriesAsync(Set<? extends K> keys) {
+        return createFuture(delegate.getEntriesAsync(keys));
+    }
+
+    /** {@inheritDoc} */
+    @Override public Map<K, V> getAllOutTx(Set<? extends K> keys) {
+        try {
+            if (isAsync()) {
+                setFuture(delegate.getAllOutTxAsync(keys));
+
+                return null;
+            }
+            else
+                return delegate.getAllOutTx(keys);
+        }
+        catch (IgniteCheckedException | IgniteException e) {
+            throw cacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<Map<K, V>> getAllOutTxAsync(Set<? extends K> keys) {
+        return createFuture(delegate.getAllOutTxAsync(keys));
+    }
+
+    /**
+     * @param keys Keys.
+     * @return Values map.
+     */
+    public Map<K, V> getAll(Collection<? extends K> keys) {
+        try {
+            if (isAsync()) {
+                setFuture(delegate.getAllAsync(keys));
+
+                return null;
+            }
+            else
+                return delegate.getAll(keys);
+        }
+        catch (IgniteCheckedException | IgniteException e) {
+            throw cacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean containsKey(K key) {
+        if (isAsync()) {
+            setFuture(delegate.containsKeyAsync(key));
+
+            return false;
+        }
+        else
+            return delegate.containsKey(key);
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<Boolean> containsKeyAsync(K key) {
+        return createFuture(delegate.containsKeyAsync(key));
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean containsKeys(Set<? extends K> keys) {
+        if (isAsync()) {
+            setFuture(delegate.containsKeysAsync(keys));
+
+            return false;
+        }
+        else
+            return delegate.containsKeys(keys);
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<Boolean> containsKeysAsync(Set<? extends K> keys) {
+        return createFuture(delegate.containsKeysAsync(keys));
+    }
+
+    /** {@inheritDoc} */
+    @Override public void loadAll(
+        Set<? extends K> keys,
+        boolean replaceExisting,
+        @Nullable final CompletionListener completionLsnr
+    ) {
+        IgniteInternalFuture<?> fut = ctx.cache().loadAll(keys, replaceExisting);
+
+        if (completionLsnr != null) {
+            fut.listen(new CI1<IgniteInternalFuture<?>>() {
+                @Override public void apply(IgniteInternalFuture<?> fut) {
+                    try {
+                        fut.get();
+
+                        completionLsnr.onCompletion();
+                    }
+                    catch (IgniteCheckedException e) {
+                        completionLsnr.onException(cacheException(e));
+                    }
+                }
+            });
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public void put(K key, V val) {
+        try {
+            if (isAsync())
+                setFuture(putAsync0(key, val));
+            else
+                delegate.put(key, val);
+        }
+        catch (IgniteCheckedException | IgniteException e) {
+            throw cacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<Void> putAsync(K key, V val) {
+        return createFuture(putAsync0(key, val));
+    }
+
+    /**
+     * Put async internal operation implementation.
+     *
+     * @param key Key.
+     * @param val Value.
+     * @return Internal future.
+     */
+    private IgniteInternalFuture<Void> putAsync0(K key, V val) {
+        IgniteInternalFuture<Boolean> fut = delegate.putAsync(key, val);
+
+        return fut.chain(new CX1<IgniteInternalFuture<Boolean>, Void>() {
+            @Override public Void applyx(IgniteInternalFuture<Boolean> fut1) throws IgniteCheckedException {
+                try {
+                    fut1.get();
+                }
+                catch (RuntimeException e) {
+                    throw new GridClosureException(e);
+                }
+
+                return null;
+            }
+        });
+    }
+
+    /** {@inheritDoc} */
+    @Override public V getAndPut(K key, V val) {
+        try {
+            if (isAsync()) {
+                setFuture(delegate.getAndPutAsync(key, val));
+
+                return null;
+            }
+            else
+                return delegate.getAndPut(key, val);
+        }
+        catch (IgniteCheckedException | IgniteException e) {
+            throw cacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<V> getAndPutAsync(K key, V val) {
+        return createFuture(delegate.getAndPutAsync(key, val));
+    }
+
+    /** {@inheritDoc} */
+    @Override public void putAll(Map<? extends K, ? extends V> map) {
+        try {
+            if (isAsync())
+                setFuture(delegate.putAllAsync(map));
+            else
+                delegate.putAll(map);
+        }
+        catch (IgniteCheckedException | IgniteException e) {
+            throw cacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<Void> putAllAsync(Map<? extends K, ? extends V> map) {
+        return (IgniteFuture<Void>)createFuture(delegate.putAllAsync(map));
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean putIfAbsent(K key, V val) {
+        try {
+            if (isAsync()) {
+                setFuture(delegate.putIfAbsentAsync(key, val));
+
+                return false;
+            }
+            else
+                return delegate.putIfAbsent(key, val);
+        }
+        catch (IgniteCheckedException | IgniteException e) {
+            throw cacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<Boolean> putIfAbsentAsync(K key, V val) {
+        return createFuture(delegate.putIfAbsentAsync(key, val));
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean remove(K key) {
+        try {
+            if (isAsync()) {
+                setFuture(delegate.removeAsync(key));
+
+                return false;
+            }
+            else
+                return delegate.remove(key);
+        }
+        catch (IgniteCheckedException | IgniteException e) {
+            throw cacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<Boolean> removeAsync(K key) {
+        return createFuture(delegate.removeAsync(key));
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean remove(K key, V oldVal) {
+        try {
+            if (isAsync()) {
+                setFuture(delegate.removeAsync(key, oldVal));
+
+                return false;
+            }
+            else
+                return delegate.remove(key, oldVal);
+        }
+        catch (IgniteCheckedException | IgniteException e) {
+            throw cacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<Boolean> removeAsync(K key, V oldVal) {
+        return createFuture(delegate.removeAsync(key, oldVal));
+    }
+
+    /** {@inheritDoc} */
+    @Override public V getAndRemove(K key) {
+        try {
+            if (isAsync()) {
+                setFuture(delegate.getAndRemoveAsync(key));
+
+                return null;
+            }
+            else
+                return delegate.getAndRemove(key);
+        }
+        catch (IgniteCheckedException | IgniteException e) {
+            throw cacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<V> getAndRemoveAsync(K key) {
+        return createFuture(delegate.getAndRemoveAsync(key));
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean replace(K key, V oldVal, V newVal) {
+        try {
+            if (isAsync()) {
+                setFuture(delegate.replaceAsync(key, oldVal, newVal));
+
+                return false;
+            }
+            else
+                return delegate.replace(key, oldVal, newVal);
+        }
+        catch (IgniteCheckedException | IgniteException e) {
+            throw cacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<Boolean> replaceAsync(K key, V oldVal, V newVal) {
+        return createFuture(delegate.replaceAsync(key, oldVal, newVal));
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean replace(K key, V val) {
+        try {
+            if (isAsync()) {
+                setFuture(delegate.replaceAsync(key, val));
+
+                return false;
+            }
+            else
+                return delegate.replace(key, val);
+        }
+        catch (IgniteCheckedException | IgniteException e) {
+            throw cacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<Boolean> replaceAsync(K key, V val) {
+        return createFuture(delegate.replaceAsync(key, val));
+    }
+
+    /** {@inheritDoc} */
+    @Override public V getAndReplace(K key, V val) {
+        try {
+            if (isAsync()) {
+                setFuture(delegate.getAndReplaceAsync(key, val));
+
+                return null;
+            }
+            else
+                return delegate.getAndReplace(key, val);
+        }
+        catch (IgniteCheckedException | IgniteException e) {
+            throw cacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<V> getAndReplaceAsync(K key, V val) {
+        return createFuture(delegate.getAndReplaceAsync(key, val));
+    }
+
+    /** {@inheritDoc} */
+    @Override public void removeAll(Set<? extends K> keys) {
+        try {
+            if (isAsync())
+                setFuture(delegate.removeAllAsync(keys));
+            else
+                delegate.removeAll(keys);
+        }
+        catch (IgniteCheckedException | IgniteException e) {
+            throw cacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<Void> removeAllAsync(Set<? extends K> keys) {
+        return (IgniteFuture<Void>)createFuture(delegate.removeAllAsync(keys));
+    }
+
+    /** {@inheritDoc} */
+    @Override public void removeAll() {
+        try {
+            if (isAsync())
+                setFuture(delegate.removeAllAsync());
+            else
+                delegate.removeAll();
+        }
+        catch (IgniteCheckedException | IgniteException e) {
+            throw cacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<Void> removeAllAsync() {
+        return (IgniteFuture<Void>)createFuture(delegate.removeAllAsync());
+    }
+
+    /** {@inheritDoc} */
+    @Override public void clear(K key) {
+        try {
+            if (isAsync())
+                setFuture(delegate.clearAsync(key));
+            else
+                delegate.clear(key);
+        }
+        catch (IgniteCheckedException | IgniteException e) {
+            throw cacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<Void> clearAsync(K key) {
+        return (IgniteFuture<Void>)createFuture(delegate.clearAsync(key));
+    }
+
+    /** {@inheritDoc} */
+    @Override public void clearAll(Set<? extends K> keys) {
+        try {
+            if (isAsync())
+                setFuture(delegate.clearAllAsync(keys));
+            else
+                delegate.clearAll(keys);
+        }
+        catch (IgniteCheckedException | IgniteException e) {
+            throw cacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<Void> clearAllAsync(Set<? extends K> keys) {
+        return (IgniteFuture<Void>)createFuture(delegate.clearAllAsync(keys));
+    }
+
+    /** {@inheritDoc} */
+    @Override public void clear() {
+        try {
+            if (isAsync())
+                setFuture(delegate.clearAsync());
+            else
+                delegate.clear();
+        }
+        catch (IgniteCheckedException | IgniteException e) {
+            throw cacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<Void> clearAsync() {
+        return (IgniteFuture<Void>)createFuture(delegate.clearAsync());
+    }
+
+    /** {@inheritDoc} */
+    @Override public void localClear(K key) {
+        delegate.clearLocally(key);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void localClearAll(Set<? extends K> keys) {
+        for (K key : keys)
+            delegate.clearLocally(key);
+    }
+
+    /** {@inheritDoc} */
+    @Override public <T> T invoke(K key, EntryProcessor<K, V, T> entryProcessor, Object... args)
+        throws EntryProcessorException {
+        try {
+            if (isAsync()) {
+                setFuture(invokeAsync0(key, entryProcessor, args));
+
+                return null;
+            }
+            else {
+                EntryProcessorResult<T> res = delegate.invoke(key, entryProcessor, args);
+
+                return res != null ? res.get() : null;
+            }
+        }
+        catch (IgniteCheckedException | IgniteException e) {
+            throw cacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public <T> IgniteFuture<T> invokeAsync(K key, EntryProcessor<K, V, T> entryProcessor,
+        Object... args) {
+        return createFuture(invokeAsync0(key, entryProcessor, args));
+    }
+
+    /**
+     * Invoke async operation internal implementation.
+     *
+     * @param key Key.
+     * @param entryProcessor Processor.
+     * @param args Arguments.
+     * @return Internal future.
+     */
+    private <T> IgniteInternalFuture<T> invokeAsync0(K key, EntryProcessor<K, V, T> entryProcessor, Object[] args) {
+        IgniteInternalFuture<EntryProcessorResult<T>> fut = delegate.invokeAsync(key, entryProcessor, args);
+
+        return fut.chain(new CX1<IgniteInternalFuture<EntryProcessorResult<T>>, T>() {
+            @Override public T applyx(IgniteInternalFuture<EntryProcessorResult<T>> fut1)
+                throws IgniteCheckedException {
+                try {
+                    EntryProcessorResult<T> res = fut1.get();
+
+                    return res != null ? res.get() : null;
+                }
+                catch (RuntimeException e) {
+                    throw new GridClosureException(e);
+                }
+            }
+        });
+    }
+
+
+    /** {@inheritDoc} */
+    @Override public <T> T invoke(K key, CacheEntryProcessor<K, V, T> entryProcessor, Object... args)
+        throws EntryProcessorException {
+        return invoke(key, (EntryProcessor<K, V, T>)entryProcessor, args);
+    }
+
+    /** {@inheritDoc} */
+    @Override public <T> IgniteFuture<T> invokeAsync(K key, CacheEntryProcessor<K, V, T> entryProcessor,
+        Object... args) {
+        return invokeAsync(key, (EntryProcessor<K, V, T>)entryProcessor, args);
+    }
+
+    /**
+     * @param topVer Locked topology version.
+     * @param key Key.
+     * @param entryProcessor Entry processor.
+     * @param args Arguments.
+     * @return Invoke result.
+     */
+    public <T> T invoke(@Nullable AffinityTopologyVersion topVer,
+        K key,
+        EntryProcessor<K, V, T> entryProcessor,
+        Object... args) {
+        try {
+            if (isAsync())
+                throw new UnsupportedOperationException();
+            else {
+                EntryProcessorResult<T> res = delegate.invoke(topVer, key, entryProcessor, args);
+
+                return res != null ? res.get() : null;
+            }
+        }
+        catch (IgniteCheckedException | IgniteException e) {
+            throw cacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public <T> Map<K, EntryProcessorResult<T>> invokeAll(Set<? extends K> keys,
+        EntryProcessor<K, V, T> entryProcessor,
+        Object... args) {
+        try {
+            if (isAsync()) {
+                setFuture(delegate.invokeAllAsync(keys, entryProcessor, args));
+
+                return null;
+            }
+            else
+                return delegate.invokeAll(keys, entryProcessor, args);
+        }
+        catch (IgniteCheckedException | IgniteException e) {
+            throw cacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public <T> IgniteFuture<Map<K, EntryProcessorResult<T>>> invokeAllAsync(Set<? extends K> keys,
+        EntryProcessor<K, V, T> entryProcessor, Object... args) {
+        return createFuture(delegate.invokeAllAsync(keys, entryProcessor, args));
+    }
+
+    /** {@inheritDoc} */
+    @Override public <T> Map<K, EntryProcessorResult<T>> invokeAll(Set<? extends K> keys,
+        CacheEntryProcessor<K, V, T> entryProcessor,
+        Object... args) {
+        try {
+            if (isAsync()) {
+                setFuture(delegate.invokeAllAsync(keys, entryProcessor, args));
+
+                return null;
+            }
+            else
+                return delegate.invokeAll(keys, entryProcessor, args);
+        }
+        catch (IgniteCheckedException | IgniteException e) {
+            throw cacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public <T> IgniteFuture<Map<K, EntryProcessorResult<T>>> invokeAllAsync(Set<? extends K> keys,
+        CacheEntryProcessor<K, V, T> entryProcessor, Object... args) {
+        return createFuture(delegate.invokeAllAsync(keys, entryProcessor, args));
+    }
+
+    /** {@inheritDoc} */
+    @Override public <T> Map<K, EntryProcessorResult<T>> invokeAll(
+        Map<? extends K, ? extends EntryProcessor<K, V, T>> map,
+        Object... args) {
+        try {
+            if (isAsync()) {
+                setFuture(delegate.invokeAllAsync(map, args));
+
+                return null;
+            }
+            else
+                return delegate.invokeAll(map, args);
+        }
+        catch (IgniteCheckedException | IgniteException e) {
+            throw cacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public <T> IgniteFuture<Map<K, EntryProcessorResult<T>>> invokeAllAsync(
+        Map<? extends K, ? extends EntryProcessor<K, V, T>> map, Object... args) {
+        return createFuture(delegate.invokeAllAsync(map, args));
+    }
+
+    /** {@inheritDoc} */
+    @Override public String getName() {
+        return delegate.name();
+    }
+
+    /** {@inheritDoc} */
+    @Override public CacheManager getCacheManager() {
+        return cacheMgr;
+    }
+
+    /**
+     * @param cacheMgr Cache manager.
+     */
+    public void setCacheManager(CacheManager cacheMgr) {
+        this.cacheMgr = cacheMgr;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void destroy() {
+        destroyAsync().get();
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<?> destroyAsync() {
+        return new IgniteFutureImpl<>(ctx.kernalContext().cache().dynamicDestroyCache(ctx.name(), false, true, false));
+    }
+
+    /** {@inheritDoc} */
+    @Override public void close() {
+        closeAsync().get();
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<?> closeAsync() {
+        return new IgniteFutureImpl<>(ctx.kernalContext().cache().dynamicCloseCache(ctx.name()));
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isClosed() {
+        return ctx.kernalContext().cache().context().closed(ctx);
+    }
+
+    /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
+    @Override public <T> T unwrap(Class<T> clazz) {
+        if (clazz.isAssignableFrom(getClass()))
+            return (T)this;
+        else if (clazz.isAssignableFrom(IgniteEx.class))
+            return (T)ctx.grid();
+
+        throw new IllegalArgumentException("Unwrapping to class is not supported: " + clazz);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void registerCacheEntryListener(CacheEntryListenerConfiguration<K, V> lsnrCfg) {
+        try {
+            CacheOperationContext opCtx = ctx.operationContextPerCall();
+
+            ctx.continuousQueries().executeJCacheQuery(lsnrCfg, false, opCtx != null && opCtx.isKeepBinary());
+        }
+        catch (IgniteCheckedException | IgniteException e) {
+            throw cacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public void deregisterCacheEntryListener(CacheEntryListenerConfiguration<K, V> lsnrCfg) {
+        try {
+            ctx.continuousQueries().cancelJCacheQuery(lsnrCfg);
+        }
+        catch (IgniteCheckedException | IgniteException e) {
+            throw cacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public Iterator<Cache.Entry<K, V>> iterator() {
+        try {
+            return ctx.cache().igniteIterator();
+        }
+        catch (IgniteCheckedException | IgniteException e) {
+            throw cacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override protected IgniteCache<K, V> createAsyncInstance() {
+        return new IgniteCacheProxyImpl<K, V>(
+                ctx,
+                delegate,
+                true
+        );
+    }
+
+    /**
+     * Creates projection that will operate with binary objects. <p> Projection returned by this method will force
+     * cache not to deserialize binary objects, so keys and values will be returned from cache API methods without
+     * changes. Therefore, signature of the projection can contain only following types: <ul> <li>{@code BinaryObject}
+     * for binary classes</li> <li>All primitives (byte, int, ...) and there boxed versions (Byte, Integer, ...)</li>
+     * <li>Arrays of primitives (byte[], int[], ...)</li> <li>{@link String} and array of {@link String}s</li>
+     * <li>{@link UUID} and array of {@link UUID}s</li> <li>{@link Date} and array of {@link Date}s</li> <li>{@link
+     * java.sql.Timestamp} and array of {@link java.sql.Timestamp}s</li> <li>Enums and array of enums</li> <li> Maps,
+     * collections and array of objects (but objects inside them will still be converted if they are binary) </li>
+     * </ul> <p> For example, if you use {@link Integer} as a key and {@code Value} class as a value (which will be
+     * stored in binary format), you should acquire following projection to avoid deserialization:
+     * <pre>
+     * IgniteInternalCache<Integer, GridBinaryObject> prj = cache.keepBinary();
+     *
+     * // Value is not deserialized and returned in binary format.
+     * GridBinaryObject po = prj.get(1);
+     * </pre>
+     * <p> Note that this method makes sense only if cache is working in binary mode ({@code
+     * CacheConfiguration#isBinaryEnabled()} returns {@code true}. If not, this method is no-op and will return
+     * current projection.
+     *
+     * @return Projection for binary objects.
+     */
+    @Override
+    @SuppressWarnings("unchecked")
+    public <K1, V1> IgniteCache<K1, V1> keepBinary() {
+        throw new UnsupportedOperationException();
+    }
+
+    /**
+     * @param dataCenterId Data center ID.
+     * @return Projection for data center id.
+     */
+    @Override
+    @SuppressWarnings("unchecked")
+    public IgniteCache<K, V> withDataCenterId(byte dataCenterId) {
+        throw new UnsupportedOperationException();
+    }
+
+    /**
+     * @return Cache with skip store enabled.
+     */
+    @Override
+    public IgniteCache<K, V> skipStore() {
+        throw new UnsupportedOperationException();
+    }
+
+    /**
+     * Method converts exception to IgniteCacheRestartingException in case of cache restarting
+     * or to CacheException in other cases.
+     *
+     * @param e {@code IgniteCheckedException} or {@code IgniteException}.
+     * @return Cache exception.
+     */
+    private RuntimeException cacheException(Exception e) {
+        GridFutureAdapter<Void> restartFut = this.restartFut.get();
+
+        if (restartFut != null && !restartFut.isDone()) {
+            if (X.hasCause(e, CacheStoppedException.class) || X.hasSuppressed(e, CacheStoppedException.class))
+                throw new IgniteCacheRestartingException(new IgniteFutureImpl<>(restartFut), "Cache is restarting: " +
+                        ctx.name());
+        }
+
+        if (e instanceof IgniteCheckedException)
+            return CU.convertToCacheException((IgniteCheckedException) e);
+
+        if (e instanceof RuntimeException)
+            return (RuntimeException) e;
+
+        throw new IllegalStateException("Unknown exception", e);
+    }
+
+    /**
+     * @param fut Future for async operation.
+     */
+    private <R> void setFuture(IgniteInternalFuture<R> fut) {
+        curFut.set(createFuture(fut));
+    }
+
+    /** {@inheritDoc} */
+    @Override protected <R> IgniteFuture<R> createFuture(IgniteInternalFuture<R> fut) {
+        return new IgniteCacheFutureImpl<>(fut);
+    }
+
+    /**
+     * @return Internal proxy.
+     */
+    @Override
+    public GridCacheProxyImpl<K, V> internalProxy() {
+        return new GridCacheProxyImpl<>(ctx, delegate, ctx.operationContextPerCall());
+    }
+
+    /**
+     * @return {@code True} if proxy was closed.
+     */
+    @Override public boolean isProxyClosed() {
+        return closed;
+    }
+
+    /**
+     * Closes this proxy instance.
+     */
+    @Override public void closeProxy() {
+        closed = true;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Collection<Integer> lostPartitions() {
+        return delegate.lostPartitions();
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeExternal(ObjectOutput out) throws IOException {
+        out.writeObject(ctx);
+
+        out.writeObject(delegate);
+    }
+
+    /** {@inheritDoc} */
+    @SuppressWarnings({"unchecked"})
+    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        ctx = (GridCacheContext<K, V>)in.readObject();
+
+        delegate = (IgniteInternalCache<K, V>)in.readObject();
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<?> rebalance() {
+        return new IgniteFutureImpl<>(ctx.preloader().forceRebalance());
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<?> indexReadyFuture() {
+        IgniteInternalFuture fut = ctx.shared().database().indexRebuildFuture(ctx.cacheId());
+
+        if (fut == null)
+            return new IgniteFinishedFutureImpl<>();
+
+        return new IgniteFutureImpl<>(fut);
+    }
+
+    /**
+     * Gets value without waiting for toplogy changes.
+     *
+     * @param key Key.
+     * @return Value.
+     */
+    @Override
+    public V getTopologySafe(K key) {
+        try {
+            return delegate.getTopologySafe(key);
+        }
+        catch (IgniteCheckedException | IgniteException e) {
+            throw cacheException(e);
+        }
+    }
+
+    /**
+     * Throws {@code IgniteCacheRestartingException} if proxy is restarting.
+     */
+    public void checkRestart() {
+        if (isRestarting())
+            throw new IgniteCacheRestartingException(new IgniteFutureImpl<>(restartFut.get()), "Cache is restarting: " +
+                    context().name());
+    }
+
+    /**
+     * @return True if proxy is restarting, false in other case.
+     */
+    public boolean isRestarting() {
+        return restartFut != null && restartFut.get() != null;
+    }
+
+    /**
+     * Restarts this cache proxy.
+     */
+    public void restart() {
+        GridFutureAdapter<Void> restartFut = new GridFutureAdapter<>();
+
+        final GridFutureAdapter<Void> currentFut = this.restartFut.get();
+
+        boolean changed = this.restartFut.compareAndSet(currentFut, restartFut);
+
+        if (changed && currentFut != null)
+            restartFut.listen(new IgniteInClosure<IgniteInternalFuture<Void>>() {
+                @Override public void apply(IgniteInternalFuture<Void> future) {
+                    if (future.error() != null)
+                        currentFut.onDone(future.error());
+                    else
+                        currentFut.onDone();
+                }
+            });
+    }
+
+    /**
+     * Mark this proxy as restarted.
+     *
+     * @param ctx New cache context.
+     * @param delegate New delegate.
+     */
+    public void onRestarted(GridCacheContext ctx, IgniteInternalCache delegate) {
+        GridFutureAdapter<Void> restartFut = this.restartFut.get();
+
+        assert restartFut != null;
+
+        this.ctx = ctx;
+        this.delegate = delegate;
+
+        restartFut.onDone();
+
+        this.restartFut.compareAndSet(restartFut, null);
+    }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return S.toString(IgniteCacheProxyImpl.class, this);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/5172541f/modules/core/src/main/java/org/apache/ignite/internal/processors/dr/IgniteDrDataStreamerCacheUpdater.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/dr/IgniteDrDataStreamerCacheUpdater.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/dr/IgniteDrDataStreamerCacheUpdater.java
index 0cec1fe..61ab122 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/dr/IgniteDrDataStreamerCacheUpdater.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/dr/IgniteDrDataStreamerCacheUpdater.java
@@ -62,7 +62,7 @@ public class IgniteDrDataStreamerCacheUpdater implements StreamReceiver<KeyCache
             IgniteLogger log = ctx.log(IgniteDrDataStreamerCacheUpdater.class);
             GridCacheAdapter internalCache = ctx.cache().internalCache(cacheName);
 
-            CacheOperationContext opCtx = ((IgniteCacheProxy)cache0).operationContext();
+            CacheOperationContext opCtx = ((IgniteCacheProxy)cache0).context().operationContextPerCall();
 
             IgniteInternalCache cache =
                 opCtx != null ? new GridCacheProxyImpl(internalCache.context(), internalCache, opCtx) : internalCache;

http://git-wip-us.apache.org/repos/asf/ignite/blob/5172541f/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java
index 6207995..ef914a9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java
@@ -17,6 +17,18 @@
 
 package org.apache.ignite.internal.processors.platform.cache;
 
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.concurrent.locks.Lock;
+import javax.cache.Cache;
+import javax.cache.integration.CompletionListener;
+import javax.cache.processor.EntryProcessorException;
+import javax.cache.processor.EntryProcessorResult;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
@@ -41,8 +53,8 @@ import org.apache.ignite.internal.processors.cache.query.QueryCursorEx;
 import org.apache.ignite.internal.processors.platform.PlatformAbstractTarget;
 import org.apache.ignite.internal.processors.platform.PlatformContext;
 import org.apache.ignite.internal.processors.platform.PlatformNativeException;
-import org.apache.ignite.internal.processors.platform.cache.expiry.PlatformExpiryPolicy;
 import org.apache.ignite.internal.processors.platform.PlatformTarget;
+import org.apache.ignite.internal.processors.platform.cache.expiry.PlatformExpiryPolicy;
 import org.apache.ignite.internal.processors.platform.cache.query.PlatformContinuousQuery;
 import org.apache.ignite.internal.processors.platform.cache.query.PlatformContinuousQueryProxy;
 import org.apache.ignite.internal.processors.platform.cache.query.PlatformFieldsQueryCursor;
@@ -63,19 +75,6 @@ import org.apache.ignite.transactions.TransactionDeadlockException;
 import org.apache.ignite.transactions.TransactionTimeoutException;
 import org.jetbrains.annotations.Nullable;
 
-import javax.cache.Cache;
-import javax.cache.integration.CompletionListener;
-import javax.cache.processor.EntryProcessorException;
-import javax.cache.processor.EntryProcessorResult;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicLong;
-import java.util.concurrent.locks.Lock;
-
 /**
  * Native cache wrapper implementation.
  */
@@ -1009,7 +1008,7 @@ public class PlatformCache extends PlatformAbstractTarget {
             }
 
             case OP_WITH_NO_RETRIES: {
-                CacheOperationContext opCtx = cache.operationContext();
+                CacheOperationContext opCtx = cache.context().operationContextPerCall();
 
                 if (opCtx != null && opCtx.noRetries())
                     return this;
@@ -1018,7 +1017,9 @@ public class PlatformCache extends PlatformAbstractTarget {
             }
 
             case OP_WITH_SKIP_STORE: {
-                if (cache.delegate().skipStore())
+                CacheOperationContext opCtx = cache.context().operationContextPerCall();
+
+                if (opCtx != null && opCtx.skipStore())
                     return this;
 
                 return copy(rawCache.withSkipStore(), keepBinary);

http://git-wip-us.apache.org/repos/asf/ignite/blob/5172541f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheEntryProcessorCopySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheEntryProcessorCopySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheEntryProcessorCopySelfTest.java
index 7affa8c..7005e14 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheEntryProcessorCopySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheEntryProcessorCopySelfTest.java
@@ -31,6 +31,7 @@ import org.apache.ignite.cache.CacheEntryProcessor;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.internal.binary.BinaryMarshaller;
+import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
 import org.apache.ignite.internal.util.typedef.internal.CU;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
@@ -149,7 +150,15 @@ public class CacheEntryProcessorCopySelfTest extends GridCommonAbstractTest {
                 }
             });
 
-            CacheObject obj = ((GridCacheAdapter)((IgniteCacheProxy)cache).delegate()).peekEx(0).peekVisibleValue();
+            GridCacheAdapter ca = (GridCacheAdapter)((IgniteCacheProxy)cache).internalProxy().delegate();
+
+            GridCacheEntryEx entry = ca.entryEx(0);
+
+            entry.unswap();
+
+            CacheObject obj = entry.peekVisibleValue();
+
+            ca.context().evicts().touch(entry, AffinityTopologyVersion.NONE);
 
             int actCnt = cnt.get();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/5172541f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStopAndDestroySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStopAndDestroySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStopAndDestroySelfTest.java
index f67e247..c53bc4b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStopAndDestroySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStopAndDestroySelfTest.java
@@ -768,6 +768,7 @@ public class CacheStopAndDestroySelfTest extends GridCommonAbstractTest {
 
         cache.close();
 
+        // Check second close succeeds without exception.
         cache.close();
 
         try {

http://git-wip-us.apache.org/repos/asf/ignite/blob/5172541f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java
index 822537c..9376971 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java
@@ -34,6 +34,7 @@ import org.apache.ignite.cache.CacheAtomicityMode;
 import org.apache.ignite.cache.CacheMode;
 import org.apache.ignite.cache.CachePeekMode;
 import org.apache.ignite.cache.CacheWriteSynchronizationMode;
+import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
 import org.apache.ignite.cache.store.CacheStore;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
@@ -246,6 +247,7 @@ public abstract class GridCacheAbstractSelfTest extends GridCommonAbstractTest {
             }
         }
 
+        cfg.setAffinity(new RendezvousAffinityFunction(false, 4096));
         cfg.setCacheMode(cacheMode());
         cfg.setAtomicityMode(atomicityMode());
         cfg.setWriteSynchronizationMode(writeSynchronization());

http://git-wip-us.apache.org/repos/asf/ignite/blob/5172541f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOnCopyFlagAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOnCopyFlagAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOnCopyFlagAbstractSelfTest.java
index 80404ce..2a90bf6 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOnCopyFlagAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOnCopyFlagAbstractSelfTest.java
@@ -178,7 +178,7 @@ public abstract class GridCacheOnCopyFlagAbstractSelfTest extends GridCommonAbst
                 cache.put(key, val);
 
                 CacheObject obj =
-                    ((GridCacheAdapter)((IgniteCacheProxy)cache).delegate()).peekEx(key).peekVisibleValue();
+                    ((GridCacheAdapter)((IgniteCacheProxy)cache).internalProxy().delegate()).peekEx(key).peekVisibleValue();
 
                 // Check thar internal entry wasn't changed.
                 assertEquals(i, getValue(obj, cache));
@@ -211,7 +211,7 @@ public abstract class GridCacheOnCopyFlagAbstractSelfTest extends GridCommonAbst
 
                 cache.put(key, newTestVal);
 
-                obj = ((GridCacheAdapter)((IgniteCacheProxy)cache).delegate()).peekEx(key).peekVisibleValue();
+                obj = ((GridCacheAdapter)((IgniteCacheProxy)cache).internalProxy().delegate()).peekEx(key).peekVisibleValue();
 
                 // Check thar internal entry wasn't changed.
                 assertEquals(-i, getValue(obj, cache));
@@ -290,7 +290,7 @@ public abstract class GridCacheOnCopyFlagAbstractSelfTest extends GridCommonAbst
                 });
 
                 CacheObject obj =
-                    ((GridCacheAdapter)((IgniteCacheProxy)cache).delegate()).peekEx(key).peekVisibleValue();
+                    ((GridCacheAdapter)((IgniteCacheProxy)cache).internalProxy().delegate()).peekEx(key).peekVisibleValue();
 
                 assertNotEquals(WRONG_VALUE, getValue(obj, cache));
             }

http://git-wip-us.apache.org/repos/asf/ignite/blob/5172541f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheValueConsistencyAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheValueConsistencyAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheValueConsistencyAbstractSelfTest.java
index 3c5fe0e..e068252 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheValueConsistencyAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheValueConsistencyAbstractSelfTest.java
@@ -124,7 +124,7 @@ public abstract class GridCacheValueConsistencyAbstractSelfTest extends GridCach
                     info("Node is reported as NOT affinity node for key [key=" + key +
                         ", nodeId=" + locNode.id() + ']');
 
-                    if (nearEnabled() && cache == cache0)
+                    if (nearEnabled() && cache.equals(cache0))
                         assertEquals((Integer)i, cache0.localPeek(key));
                     else
                         assertNull(cache0.localPeek(key));
@@ -184,7 +184,7 @@ public abstract class GridCacheValueConsistencyAbstractSelfTest extends GridCach
                     info("Node is reported as NOT affinity node for key [key=" + key +
                         ", nodeId=" + locNode.id() + ']');
 
-                    if (nearEnabled() && cache == cache0)
+                    if (nearEnabled() && cache.equals(cache0))
                         assertEquals((Integer)i, cache0.localPeek(key));
                     else
                         assertNull(cache0.localPeek(key));

http://git-wip-us.apache.org/repos/asf/ignite/blob/5172541f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigVariationsFullApiTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigVariationsFullApiTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigVariationsFullApiTest.java
index dcba92f..8d5462d 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigVariationsFullApiTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigVariationsFullApiTest.java
@@ -17,8 +17,6 @@
 
 package org.apache.ignite.internal.processors.cache;
 
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Sets;
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -49,12 +47,13 @@ import javax.cache.processor.EntryProcessor;
 import javax.cache.processor.EntryProcessorException;
 import javax.cache.processor.EntryProcessorResult;
 import javax.cache.processor.MutableEntry;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Sets;
 import junit.framework.AssertionFailedError;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
-import org.apache.ignite.IgniteLogger;
 import org.apache.ignite.IgniteTransactions;
 import org.apache.ignite.cache.CacheEntry;
 import org.apache.ignite.cache.CacheEntryEventSerializableFilter;
@@ -83,7 +82,6 @@ import org.apache.ignite.lang.IgniteBiPredicate;
 import org.apache.ignite.lang.IgniteClosure;
 import org.apache.ignite.lang.IgniteFuture;
 import org.apache.ignite.lang.IgnitePredicate;
-import org.apache.ignite.resources.LoggerResource;
 import org.apache.ignite.testframework.GridTestUtils;
 import org.apache.ignite.testframework.junits.IgniteCacheConfigVariationsAbstractTest;
 import org.apache.ignite.transactions.Transaction;

http://git-wip-us.apache.org/repos/asf/ignite/blob/5172541f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerAbstractTest.java
index bcf46fd..e473d52 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerAbstractTest.java
@@ -65,7 +65,6 @@ import org.apache.ignite.internal.processors.continuous.GridContinuousProcessor;
 import org.apache.ignite.internal.util.lang.GridAbsPredicate;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
 import org.apache.ignite.spi.eventstorage.memory.MemoryEventStorageSpi;
 import org.apache.ignite.testframework.GridTestUtils;
 import org.jetbrains.annotations.Nullable;

http://git-wip-us.apache.org/repos/asf/ignite/blob/5172541f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheGroupsTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheGroupsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheGroupsTest.java
index d3269c3..b55e3d0 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheGroupsTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheGroupsTest.java
@@ -17,7 +17,6 @@
 
 package org.apache.ignite.internal.processors.cache;
 
-import com.google.common.collect.Sets;
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -50,6 +49,7 @@ import javax.cache.integration.CacheLoaderException;
 import javax.cache.integration.CacheWriterException;
 import javax.cache.processor.EntryProcessorException;
 import javax.cache.processor.MutableEntry;
+import com.google.common.collect.Sets;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.IgniteCheckedException;
@@ -78,8 +78,8 @@ import org.apache.ignite.configuration.NearCacheConfiguration;
 import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.IgniteKernal;
 import org.apache.ignite.internal.binary.BinaryMarshaller;
-import org.apache.ignite.internal.processors.cache.persistence.CacheDataRow;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLocalPartition;
+import org.apache.ignite.internal.processors.cache.persistence.CacheDataRow;
 import org.apache.ignite.internal.processors.platform.cache.expiry.PlatformExpiryPolicyFactory;
 import org.apache.ignite.internal.util.lang.GridAbsPredicate;
 import org.apache.ignite.internal.util.lang.GridIterator;
@@ -87,6 +87,7 @@ import org.apache.ignite.internal.util.lang.GridPlainCallable;
 import org.apache.ignite.internal.util.lang.gridfunc.ContainsPredicate;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.PA;
+import org.apache.ignite.internal.util.typedef.X;
 import org.apache.ignite.internal.util.typedef.internal.CU;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteBiInClosure;
@@ -2892,10 +2893,10 @@ public class IgniteCacheGroupsTest extends GridCommonAbstractTest {
 
         IgniteInternalFuture cacheFut = GridTestUtils.runAsync(new Runnable() {
             @Override public void run() {
-                try {
-                    int cntr = 0;
+                int cntr = 0;
 
-                    while (!stop.get()) {
+                while (!stop.get()) {
+                    try {
                         ThreadLocalRandom rnd = ThreadLocalRandom.current();
 
                         String grp;
@@ -2927,13 +2928,20 @@ public class IgniteCacheGroupsTest extends GridCommonAbstractTest {
 
                         node.destroyCache(cache.getName());
                     }
-                }
-                catch (Exception e) {
-                    err.set(true);
+                    catch (Exception e) {
+                        if (X.hasCause(e, CacheStoppedException.class)) {
+                            // Cache operation can be blocked on
+                            // awaiting new topology version and cancelled with CacheStoppedException cause.
 
-                    log.error("Unexpected error(2): " + e, e);
+                            continue;
+                        }
 
-                    stop.set(true);
+                        err.set(true);
+
+                        log.error("Unexpected error(2): " + e, e);
+
+                        stop.set(true);
+                    }
                 }
             }
         }, "cache-destroy-thread");
@@ -3706,7 +3714,7 @@ public class IgniteCacheGroupsTest extends GridCommonAbstractTest {
 
         final AtomicReferenceArray<IgniteCache> caches = new AtomicReferenceArray<>(CACHES);
 
-        for (int i = 0; i < 10; i++) {
+        for (int i = 0; i < CACHES; i++) {
             CacheAtomicityMode atomicityMode = i % 2 == 0 ? ATOMIC : TRANSACTIONAL;
 
             caches.set(i,
@@ -3799,28 +3807,41 @@ public class IgniteCacheGroupsTest extends GridCommonAbstractTest {
 
                 IgniteInternalFuture opFut = GridTestUtils.runMultiThreadedAsync(new Runnable() {
                     @Override public void run() {
-                        try {
-                            ThreadLocalRandom rnd = ThreadLocalRandom.current();
+                        ThreadLocalRandom rnd = ThreadLocalRandom.current();
 
-                            while (!stop.get()) {
+                        while (!stop.get()) {
+                            try {
                                 int idx = rnd.nextInt(CACHES);
 
                                 IgniteCache cache = caches.get(idx);
 
                                 if (cache != null && caches.compareAndSet(idx, cache, null)) {
-                                    for (int i = 0; i < 10; i++)
-                                        cacheOperation(rnd, cache);
-
-                                    caches.set(idx, cache);
+                                    try {
+                                        for (int i = 0; i < 10; i++)
+                                            cacheOperation(rnd, cache);
+                                    }
+                                    catch (Exception e) {
+                                        if (X.hasCause(e, CacheStoppedException.class)) {
+                                            // Cache operation can be blocked on
+                                            // awaiting new topology version and cancelled with CacheStoppedException cause.
+
+                                            continue;
+                                        }
+
+                                        throw e;
+                                    }
+                                    finally {
+                                        caches.set(idx, cache);
+                                    }
                                 }
                             }
-                        }
-                        catch (Exception e) {
-                            err.set(e);
+                            catch (Exception e) {
+                                err.set(e);
 
-                            log.error("Unexpected error: " + e, e);
+                                log.error("Unexpected error: " + e, e);
 
-                            stop.set(true);
+                                stop.set(true);
+                            }
                         }
                     }
                 }, 8, "op-thread");

http://git-wip-us.apache.org/repos/asf/ignite/blob/5172541f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStartStopLoadTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStartStopLoadTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStartStopLoadTest.java
index 7cb9861..25b90c4 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStartStopLoadTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStartStopLoadTest.java
@@ -113,7 +113,6 @@ public class IgniteCacheStartStopLoadTest extends GridCommonAbstractTest {
 
                 cache.put(1, obj);
 
-                weakMap.put(((IgniteCacheProxy)cache).delegate(), Boolean.TRUE);
                 weakMap.put(obj, Boolean.TRUE);
             }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/5172541f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/MemoryPolicyInitializationTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/MemoryPolicyInitializationTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/MemoryPolicyInitializationTest.java
index 9a49b6c..6493f88 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/MemoryPolicyInitializationTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/MemoryPolicyInitializationTest.java
@@ -24,6 +24,7 @@ import org.apache.ignite.configuration.MemoryConfiguration;
 import org.apache.ignite.configuration.MemoryPolicyConfiguration;
 import org.apache.ignite.internal.IgniteEx;
 import org.apache.ignite.internal.processors.cache.GridCacheContext;
+import org.apache.ignite.internal.processors.cache.IgniteCacheProxy;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 
@@ -217,7 +218,7 @@ public class MemoryPolicyInitializationTest extends GridCommonAbstractTest {
      * @param plcName Policy name.
      */
     private void verifyCacheMemoryPolicy(IgniteCache cache, String plcName) {
-        GridCacheContext ctx = U.field(cache, "ctx");
+        GridCacheContext ctx = ((IgniteCacheProxy) cache).context();
 
         assertEquals(plcName, ctx.memoryPolicy().config().getName());
     }


[26/47] ignite git commit: Fixed log info calls without isInfoEnabled checks

Posted by ag...@apache.org.
Fixed log info calls without isInfoEnabled checks


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

Branch: refs/heads/master
Commit: 96e7bb1daccd64ea72ed043f1ebbe2792e5a0e92
Parents: 99584fe
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Fri Jul 28 15:11:41 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Fri Jul 28 15:11:41 2017 +0300

----------------------------------------------------------------------
 .../IgniteDiagnosticPrepareContext.java         |  3 +-
 .../apache/ignite/internal/IgniteKernal.java    |  3 +-
 .../mem/file/MappedFileMemoryProvider.java      |  3 +-
 .../GridCachePartitionExchangeManager.java      |  2 +-
 .../GridDhtPartitionsExchangeFuture.java        | 20 ++++++-----
 .../GridCacheDatabaseSharedManager.java         |  7 ++--
 .../persistence/freelist/FreeListImpl.java      | 18 +++++-----
 .../reader/StandaloneWalRecordsIterator.java    |  4 ++-
 .../cluster/GridClusterStateProcessor.java      |  3 +-
 .../datastructures/GridCacheLockImpl.java       | 13 ++++---
 .../processors/odbc/SqlListenerProcessor.java   |  3 +-
 .../ignite/internal/util/nio/GridNioServer.java |  7 ++--
 .../ignite/spi/discovery/tcp/ServerImpl.java    | 38 ++++++++++----------
 .../ignite/tests/p2p/JobStealingTask.java       | 12 ++++---
 .../hadoop/jobtracker/HadoopJobTracker.java     | 24 +++++++------
 .../hadoop/shuffle/HadoopShuffleJob.java        |  5 +--
 .../apache/ignite/stream/mqtt/MqttStreamer.java |  6 ++--
 .../spi/deployment/uri/UriDeploymentSpi.java    |  3 +-
 18 files changed, 101 insertions(+), 73 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/96e7bb1d/modules/core/src/main/java/org/apache/ignite/internal/IgniteDiagnosticPrepareContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteDiagnosticPrepareContext.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteDiagnosticPrepareContext.java
index 416ef29..378dc74 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteDiagnosticPrepareContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteDiagnosticPrepareContext.java
@@ -146,7 +146,8 @@ public class IgniteDiagnosticPrepareContext {
             @Override public void apply(IgniteInternalFuture<String> fut) {
                 synchronized (IgniteDiagnosticPrepareContext.class) {
                     try {
-                        log.info(fut.get());
+                        if (log.isInfoEnabled())
+                            log.info(fut.get());
                     }
                     catch (Exception e) {
                         U.error(log, "Failed to dump diagnostic info: " + e, e);

http://git-wip-us.apache.org/repos/asf/ignite/blob/96e7bb1d/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 00c1d73..ae6722c 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
@@ -1253,7 +1253,8 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
                                 sysPoolIdleThreads + ", qSize=" + sysPoolQSize + "]" + NL +
                                 "    ^-- Outbound messages queue [size=" + m.getOutboundMessagesQueueSize() + "]";
 
-                            log.info(msg);
+                            if (log.isInfoEnabled())
+                                log.info(msg);
 
                             ctx.cache().context().database().dumpStatistics(log);
                         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/96e7bb1d/modules/core/src/main/java/org/apache/ignite/internal/mem/file/MappedFileMemoryProvider.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/mem/file/MappedFileMemoryProvider.java b/modules/core/src/main/java/org/apache/ignite/internal/mem/file/MappedFileMemoryProvider.java
index b0d8d9a..3800214 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/mem/file/MappedFileMemoryProvider.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/mem/file/MappedFileMemoryProvider.java
@@ -81,7 +81,8 @@ public class MappedFileMemoryProvider implements DirectMemoryProvider {
         File[] files = allocationPath.listFiles(ALLOCATOR_FILTER);
 
         if (files.length != 0) {
-            log.info("Will clean up the following files upon start: " + Arrays.asList(files));
+            if (log.isInfoEnabled())
+                log.info("Will clean up the following files upon start: " + Arrays.asList(files));
 
             for (File file : files) {
                 if (!file.delete())

http://git-wip-us.apache.org/repos/asf/ignite/blob/96e7bb1d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
index d4fe93f..71572f1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
@@ -1491,7 +1491,7 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
 
         cctx.io().dumpPendingMessages(pendingMsgs);
 
-        if (pendingMsgs.length() > 0)
+        if (pendingMsgs.length() > 0 && diagnosticLog.isInfoEnabled())
             diagnosticLog.info(pendingMsgs.toString());
 
         if (IgniteSystemProperties.getBoolean(IGNITE_IO_DUMP_ON_TIMEOUT, false))

http://git-wip-us.apache.org/repos/asf/ignite/blob/96e7bb1d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
index c4a4f83..ad17666 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
@@ -442,13 +442,14 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
 
             boolean crdNode = crd != null && crd.isLocal();
 
-            exchLog.info("Started exchange init [topVer=" + topVer +
-                ", crd=" + crdNode +
-                ", evt=" + discoEvt.type() +
-                ", node=" + discoEvt.node() +
-                ", evtNode=" + discoEvt.node() +
-                ", customEvt=" + (discoEvt.type() == EVT_DISCOVERY_CUSTOM_EVT ? ((DiscoveryCustomEvent)discoEvt).customMessage() : null) +
-                ']');
+            if (exchLog.isInfoEnabled())
+                exchLog.info("Started exchange init [topVer=" + topVer +
+                    ", crd=" + crdNode +
+                    ", evt=" + discoEvt.type() +
+                    ", node=" + discoEvt.node() +
+                    ", evtNode=" + discoEvt.node() +
+                    ", customEvt=" + (discoEvt.type() == EVT_DISCOVERY_CUSTOM_EVT ? ((DiscoveryCustomEvent)discoEvt).customMessage() : null) +
+                    ']');
 
             ExchangeType exchange;
 
@@ -967,8 +968,9 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
             String futInfo = RELEASE_FUTURE_DUMP_THRESHOLD > 0 && waitTime > RELEASE_FUTURE_DUMP_THRESHOLD ?
                 partReleaseFut.toString() : "NA";
 
-            log.info("Finished waiting for partition release future [topVer=" + exchangeId().topologyVersion() +
-                ", waitTime=" + (waitEnd - waitStart) + "ms, futInfo=" + futInfo + "]");
+            if (log.isInfoEnabled())
+                log.info("Finished waiting for partition release future [topVer=" + exchangeId().topologyVersion() +
+                    ", waitTime=" + (waitEnd - waitStart) + "ms, futInfo=" + futInfo + "]");
         }
 
         IgniteInternalFuture<?> locksFut = cctx.mvcc().finishLocks(exchId.topologyVersion());

http://git-wip-us.apache.org/repos/asf/ignite/blob/96e7bb1d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheDatabaseSharedManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheDatabaseSharedManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheDatabaseSharedManager.java
index 39038ba..a1eb4af 100755
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheDatabaseSharedManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheDatabaseSharedManager.java
@@ -1229,7 +1229,8 @@ public class GridCacheDatabaseSharedManager extends IgniteCacheDatabaseSharedMan
             if (Files.exists(dir.toPath()))
                 log.warning("Read checkpoint status: cpDir.exists() is false, Files.exists(cpDir) is true.");
 
-            log.info("Read checkpoint status: checkpoint directory is not found.");
+            if (log.isInfoEnabled())
+                log.info("Read checkpoint status: checkpoint directory is not found.");
 
             return new CheckpointStatus(0, startId, startPtr, endId, endPtr);
         }
@@ -1266,8 +1267,8 @@ public class GridCacheDatabaseSharedManager extends IgniteCacheDatabaseSharedMan
         if (endFile != null)
             endPtr = readPointer(endFile, buf);
 
-        // TODO: remove excessive logging after GG-12116 fix.
-        log.info("Read checkpoint status: start marker = " + startFile + ", end marker = " + endFile);
+        if (log.isInfoEnabled())
+            log.info("Read checkpoint status [startMarker=" + startFile + ", endMarker=" + endFile + ']');
 
         return new CheckpointStatus(lastStartTs, startId, startPtr, endId, endPtr);
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/96e7bb1d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/FreeListImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/FreeListImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/FreeListImpl.java
index d50020e..53a33c1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/FreeListImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/FreeListImpl.java
@@ -406,18 +406,20 @@ public class FreeListImpl extends PagesList implements FreeList, ReuseList {
                     }
                 }
 
-                log.info("Bucket [b=" + b +
-                    ", size=" + size +
-                    ", stripes=" + (stripes != null ? stripes.length : 0) +
-                    ", stripesEmpty=" + empty + ']');
+                if (log.isInfoEnabled())
+                    log.info("Bucket [b=" + b +
+                        ", size=" + size +
+                        ", stripes=" + (stripes != null ? stripes.length : 0) +
+                        ", stripesEmpty=" + empty + ']');
             }
         }
 
         if (dataPages > 0) {
-            log.info("FreeList [name=" + name +
-                ", buckets=" + BUCKETS +
-                ", dataPages=" + dataPages +
-                ", reusePages=" + bucketsSize[REUSE_BUCKET].longValue() + "]");
+            if (log.isInfoEnabled())
+                log.info("FreeList [name=" + name +
+                    ", buckets=" + BUCKETS +
+                    ", dataPages=" + dataPages +
+                    ", reusePages=" + bucketsSize[REUSE_BUCKET].longValue() + "]");
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/96e7bb1d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneWalRecordsIterator.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneWalRecordsIterator.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneWalRecordsIterator.java
index ecad70a..85022ad 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneWalRecordsIterator.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneWalRecordsIterator.java
@@ -234,7 +234,9 @@ class StandaloneWalRecordsIterator extends AbstractWalRecordsIterator {
             return initReadHandle(fd, null);
         }
         catch (FileNotFoundException e) {
-            log.info("Missing WAL segment in the archive: " + e.getMessage());
+            if (log.isInfoEnabled())
+                log.info("Missing WAL segment in the archive: " + e.getMessage());
+
             return null;
         }
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/96e7bb1d/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 6e94669..283a58f 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
@@ -273,7 +273,8 @@ public class GridClusterStateProcessor extends GridProcessorAdapter {
                 if (fut != null)
                     fut.setRemaining(nodeIds, topVer.nextMinorVersion());
 
-                log.info("Start state transition: " + msg.activate());
+                if (log.isInfoEnabled())
+                    log.info("Started state transition: " + msg.activate());
 
                 globalState = DiscoveryDataClusterState.createTransitionState(msg.activate(),
                     msg.requestId(),

http://git-wip-us.apache.org/repos/asf/ignite/blob/96e7bb1d/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheLockImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheLockImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheLockImpl.java
index b798670..fac7eaf 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheLockImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheLockImpl.java
@@ -567,15 +567,17 @@ public final class GridCacheLockImpl implements GridCacheLockEx, IgniteChangeGlo
                             }
                             catch (Exception e) {
                                 if (interruptAll) {
-                                    log.info("Node is stopped (or lock is broken in non-failover safe mode)," +
-                                        " aborting transaction.");
+                                    if (log.isInfoEnabled())
+                                        log.info("Node is stopped (or lock is broken in non-failover safe mode)," +
+                                            " aborting transaction.");
 
                                     // Return immediately, exception will be thrown later.
                                     return true;
                                 }
                                 else {
                                     if (Thread.currentThread().isInterrupted()) {
-                                        log.info("Thread is interrupted while attempting to acquire lock.");
+                                        if (log.isInfoEnabled())
+                                            log.info("Thread is interrupted while attempting to acquire lock.");
 
                                         // Delegate the decision to throw InterruptedException to the AQS.
                                         sync.release(0);
@@ -803,8 +805,9 @@ public final class GridCacheLockImpl implements GridCacheLockEx, IgniteChangeGlo
                             }
                             catch (Exception e) {
                                 if (interruptAll) {
-                                    log.info("Node is stopped (or lock is broken in non-failover safe mode)," +
-                                        " aborting transaction.");
+                                    if (log.isInfoEnabled())
+                                        log.info("Node is stopped (or lock is broken in non-failover safe mode)," +
+                                            " aborting transaction.");
 
                                     return true;
                                 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/96e7bb1d/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerProcessor.java
index a7061ff..1b364b1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerProcessor.java
@@ -144,7 +144,8 @@ public class SqlListenerProcessor extends GridProcessorAdapter {
 
                         ctx.ports().registerPort(port, IgnitePortProtocol.TCP, getClass());
 
-                        log.info("SQL connector processor has started on TCP port " + port);
+                        if (log.isInfoEnabled())
+                            log.info("SQL connector processor has started on TCP port " + port);
 
                         lastErr = null;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/96e7bb1d/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java
index ce7e7f3..2f591f7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java
@@ -3878,9 +3878,10 @@ public class GridNioServer<T> {
             GridNioSession ses = randomSession(clientWorkers.get(w1));
 
             if (ses != null) {
-                log.info("Move session [from=" + w1 +
-                    ", to=" + w2 +
-                    ", ses=" + ses + ']');
+                if (log.isInfoEnabled())
+                    log.info("Move session [from=" + w1 +
+                        ", to=" + w2 +
+                        ", ses=" + ses + ']');
 
                 moveSession(ses, w1, w2);
             }

http://git-wip-us.apache.org/repos/asf/ignite/blob/96e7bb1d/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
index d621fb3..f673f3f 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
@@ -1510,21 +1510,22 @@ class ServerImpl extends TcpDiscoveryImpl {
 
             TcpDiscoveryNode coord = resolveCoordinator();
 
-            log.info("Discovery SPI statistics [statistics=" + spi.stats + ", spiState=" + spiStateCopy() +
-                ", coord=" + coord +
-                ", next=" + (msgWorker != null ? msgWorker.next : "N/A") +
-                ", intOrder=" + (locNode != null ? locNode.internalOrder() : "N/A") +
-                ", topSize=" + ring.allNodes().size() +
-                ", leavingNodesSize=" + leavingNodesSize +
-                ", failedNodesSize=" + failedNodesSize +
-                ", joiningNodesSize=" + joiningNodesSize +
-                ", pendingCustomMsgs=" + pendingCustomMsgsSize +
-                ", msgWorker.queue.size=" + (msgWorker != null ? msgWorker.queueSize() : "N/A") +
-                ", clients=" + ring.clientNodes().size() +
-                ", clientWorkers=" + clientMsgWorkers.size() +
-                ", lastUpdate=" + (locNode != null ? U.format(locNode.lastUpdateTime()) : "N/A") +
-                ", heapFree=" + runtime.freeMemory() / (1024 * 1024) +
-                "M, heapTotal=" + runtime.maxMemory() / (1024 * 1024) + "M]");
+            if (log.isInfoEnabled())
+                log.info("Discovery SPI statistics [statistics=" + spi.stats + ", spiState=" + spiStateCopy() +
+                    ", coord=" + coord +
+                    ", next=" + (msgWorker != null ? msgWorker.next : "N/A") +
+                    ", intOrder=" + (locNode != null ? locNode.internalOrder() : "N/A") +
+                    ", topSize=" + ring.allNodes().size() +
+                    ", leavingNodesSize=" + leavingNodesSize +
+                    ", failedNodesSize=" + failedNodesSize +
+                    ", joiningNodesSize=" + joiningNodesSize +
+                    ", pendingCustomMsgs=" + pendingCustomMsgsSize +
+                    ", msgWorker.queue.size=" + (msgWorker != null ? msgWorker.queueSize() : "N/A") +
+                    ", clients=" + ring.clientNodes().size() +
+                    ", clientWorkers=" + clientMsgWorkers.size() +
+                    ", lastUpdate=" + (locNode != null ? U.format(locNode.lastUpdateTime()) : "N/A") +
+                    ", heapFree=" + runtime.freeMemory() / (1024 * 1024) +
+                    "M, heapTotal=" + runtime.maxMemory() / (1024 * 1024) + "M]");
         }
     }
 
@@ -5506,9 +5507,10 @@ class ServerImpl extends TcpDiscoveryImpl {
                 spiStateCopy() == CONNECTED &&
                 (hasRemoteSrvNodes = ring.hasRemoteServerNodes())) {
 
-                log.info("Local node seems to be disconnected from topology (failure detection timeout " +
-                    "is reached) [failureDetectionTimeout=" + spi.failureDetectionTimeout() +
-                    ", connCheckFreq=" + connCheckFreq + ']');
+                if (log.isInfoEnabled())
+                    log.info("Local node seems to be disconnected from topology (failure detection timeout " +
+                        "is reached) [failureDetectionTimeout=" + spi.failureDetectionTimeout() +
+                        ", connCheckFreq=" + connCheckFreq + ']');
 
                 failureThresholdReached = true;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/96e7bb1d/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/JobStealingTask.java
----------------------------------------------------------------------
diff --git a/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/JobStealingTask.java b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/JobStealingTask.java
index 2e81694..b43f4cd 100644
--- a/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/JobStealingTask.java
+++ b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/JobStealingTask.java
@@ -70,7 +70,8 @@ public class JobStealingTask extends ComputeTaskAdapter<Object, Map<UUID, Intege
         Map<UUID, Integer> ret = U.newHashMap(results.size());
 
         for (ComputeJobResult res : results) {
-            log.info("Job result: " + res.getData());
+            if (log.isInfoEnabled())
+                log.info("Job result: " + res.getData());
 
             UUID resUuid = (UUID)res.getData();
 
@@ -102,7 +103,8 @@ public class JobStealingTask extends ComputeTaskAdapter<Object, Map<UUID, Intege
 
         /** {@inheritDoc} */
         @Override public Serializable execute() {
-            log.info("Started job on node: " + ignite.cluster().localNode().id());
+            if (log.isInfoEnabled())
+                log.info("Started job on node: " + ignite.cluster().localNode().id());
 
             try {
                 Long sleep = argument(0);
@@ -112,12 +114,14 @@ public class JobStealingTask extends ComputeTaskAdapter<Object, Map<UUID, Intege
                 Thread.sleep(sleep);
             }
             catch (InterruptedException e) {
-                log.info("Job got interrupted on node: " + ignite.cluster().localNode().id());
+                if (log.isInfoEnabled())
+                    log.info("Job got interrupted on node: " + ignite.cluster().localNode().id());
 
                 throw new IgniteException("Job got interrupted.", e);
             }
             finally {
-                log.info("Job finished on node: " + ignite.cluster().localNode().id());
+                if (log.isInfoEnabled())
+                    log.info("Job finished on node: " + ignite.cluster().localNode().id());
             }
 
             return ignite.cluster().localNode().id();

http://git-wip-us.apache.org/repos/asf/ignite/blob/96e7bb1d/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/jobtracker/HadoopJobTracker.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/jobtracker/HadoopJobTracker.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/jobtracker/HadoopJobTracker.java
index 39f909e..cf40497 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/jobtracker/HadoopJobTracker.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/jobtracker/HadoopJobTracker.java
@@ -803,25 +803,27 @@ public class HadoopJobTracker extends HadoopComponent {
      */
     @SuppressWarnings({"unused", "ConstantConditions" })
     private void printPlan(HadoopJobId jobId, HadoopMapReducePlan plan) {
-        log.info("Plan for " + jobId);
+        if (log.isInfoEnabled()) {
+            log.info("Plan for " + jobId);
 
-        SB b = new SB();
+            SB b = new SB();
 
-        b.a("   Map: ");
+            b.a("   Map: ");
 
-        for (UUID nodeId : plan.mapperNodeIds())
-            b.a(nodeId).a("=").a(plan.mappers(nodeId).size()).a(' ');
+            for (UUID nodeId : plan.mapperNodeIds())
+                b.a(nodeId).a("=").a(plan.mappers(nodeId).size()).a(' ');
 
-        log.info(b.toString());
+            log.info(b.toString());
 
-        b = new SB();
+            b = new SB();
 
-        b.a("   Reduce: ");
+            b.a("   Reduce: ");
 
-        for (UUID nodeId : plan.reducerNodeIds())
-            b.a(nodeId).a("=").a(Arrays.toString(plan.reducers(nodeId))).a(' ');
+            for (UUID nodeId : plan.reducerNodeIds())
+                b.a(nodeId).a("=").a(Arrays.toString(plan.reducers(nodeId))).a(' ');
 
-        log.info(b.toString());
+            log.info(b.toString());
+        }
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/96e7bb1d/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/shuffle/HadoopShuffleJob.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/shuffle/HadoopShuffleJob.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/shuffle/HadoopShuffleJob.java
index 226d3e3..346362b 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/shuffle/HadoopShuffleJob.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/shuffle/HadoopShuffleJob.java
@@ -182,8 +182,9 @@ public class HadoopShuffleJob<T> implements AutoCloseable {
 
         if (stripeMappers0) {
             if (!embedded) {
-                log.info("Striped mapper output is disabled becuase it cannot be used in external mode [jobId=" +
-                    job.id() + ']');
+                if (log.isInfoEnabled())
+                    log.info("Striped mapper output is disabled becuase it cannot be used in external mode [jobId=" +
+                        job.id() + ']');
 
                 stripeMappers0 = false;
             }

http://git-wip-us.apache.org/repos/asf/ignite/blob/96e7bb1d/modules/mqtt/src/main/java/org/apache/ignite/stream/mqtt/MqttStreamer.java
----------------------------------------------------------------------
diff --git a/modules/mqtt/src/main/java/org/apache/ignite/stream/mqtt/MqttStreamer.java b/modules/mqtt/src/main/java/org/apache/ignite/stream/mqtt/MqttStreamer.java
index e546da2..1ae59be 100644
--- a/modules/mqtt/src/main/java/org/apache/ignite/stream/mqtt/MqttStreamer.java
+++ b/modules/mqtt/src/main/java/org/apache/ignite/stream/mqtt/MqttStreamer.java
@@ -242,7 +242,8 @@ public class MqttStreamer<K, V> extends StreamAdapter<MqttMessage, K, V> impleme
             // Create the connection retrier.
             connectionRetrier = new MqttConnectionRetrier(retrier);
 
-            log.info("Starting MQTT Streamer " + cachedLogValues);
+            if (log.isInfoEnabled())
+                log.info("Starting MQTT Streamer " + cachedLogValues);
 
             // Connect.
             connectionRetrier.connect();
@@ -679,7 +680,8 @@ public class MqttStreamer<K, V> extends StreamAdapter<MqttMessage, K, V> impleme
                         client.subscribe(topics.toArray(new String[0]), qoses);
                     }
 
-                    log.info("MQTT Streamer (re-)connected and subscribed " + cachedLogValues);
+                    if (log.isInfoEnabled())
+                        log.info("MQTT Streamer (re-)connected and subscribed " + cachedLogValues);
 
                     return null;
                 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/96e7bb1d/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/UriDeploymentSpi.java
----------------------------------------------------------------------
diff --git a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/UriDeploymentSpi.java b/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/UriDeploymentSpi.java
index 68ed0d9..f149804 100644
--- a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/UriDeploymentSpi.java
+++ b/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/UriDeploymentSpi.java
@@ -604,7 +604,8 @@ public class UriDeploymentSpi extends IgniteSpiAdapter implements DeploymentSpi
                             uriList.add(U.hidePassword(uri));
                     }
 
-                    log.info("Found deleted GAR units [uris=" + uriList + ']');
+                    if (log.isInfoEnabled())
+                        log.info("Found deleted GAR units [uris=" + uriList + ']');
                 }
 
                 processDeletedFiles(uris);


[06/47] ignite git commit: new utility methods for working with files

Posted by ag...@apache.org.
new utility methods for working with files


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

Branch: refs/heads/master
Commit: e001a063a9c2260c4732093e54c332cb8af33b0b
Parents: a790dfa
Author: EdShangGG <es...@gridgain.com>
Authored: Wed Jul 26 16:37:45 2017 +0300
Committer: EdShangGG <es...@gridgain.com>
Committed: Wed Jul 26 16:37:45 2017 +0300

----------------------------------------------------------------------
 .../ignite/internal/util/IgniteUtils.java       | 65 ++++++++++++++++++++
 1 file changed, 65 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/e001a063/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
index 6a3be55..abdab69 100755
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
@@ -73,9 +73,13 @@ import java.nio.channels.FileLock;
 import java.nio.channels.SelectionKey;
 import java.nio.channels.Selector;
 import java.nio.charset.Charset;
+import java.nio.file.DirectoryStream;
+import java.nio.file.FileVisitResult;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
+import java.nio.file.SimpleFileVisitor;
+import java.nio.file.attribute.BasicFileAttributes;
 import java.security.AccessController;
 import java.security.KeyManagementException;
 import java.security.MessageDigest;
@@ -9979,6 +9983,67 @@ public abstract class IgniteUtils {
     }
 
     /**
+     * Return count of regular file in the directory (including in sub-directories)
+     *
+     * @param dir path to directory
+     * @return count of regular file
+     * @throws IOException sometimes
+     */
+    public static int fileCount(Path dir) throws IOException {
+        int cnt = 0;
+
+        try (DirectoryStream<Path> ds = Files.newDirectoryStream(dir)){
+            for (Path d : ds) {
+                if (Files.isDirectory(d))
+                    cnt += fileCount(d);
+
+                else if (Files.isRegularFile(d))
+                    cnt++;
+            }
+        }
+
+        return cnt;
+    }
+
+    /**
+     * Will calculate the size of a directory.
+     *
+     * If there is concurrent activity in the directory, than returned value may be wrong.
+     */
+    public static long dirSize(Path path) throws IgniteCheckedException {
+        final AtomicLong s = new AtomicLong(0);
+
+        try {
+            Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
+                @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
+                    s.addAndGet(attrs.size());
+
+                    return FileVisitResult.CONTINUE;
+                }
+
+                @Override public FileVisitResult visitFileFailed(Path file, IOException exc) {
+                    U.error(null, "file skipped - " + file, exc);
+
+                    // Skip directory or file
+                    return FileVisitResult.CONTINUE;
+                }
+
+                @Override public FileVisitResult postVisitDirectory(Path dir, IOException exc) {
+                    if (exc != null)
+                        U.error(null, "error during size calculation of directory - " + dir, exc);
+
+                    // Ignoring
+                    return FileVisitResult.CONTINUE;
+                }
+            });
+        } catch (IOException e) {
+            throw new IgniteCheckedException("walkFileTree will not throw IOException if the FileVisitor does not");
+        }
+
+        return s.get();
+    }
+
+    /**
      * Returns {@link GridIntIterator} for range of primitive integers.
      * @param start Start.
      * @param cnt Count.


[36/47] ignite git commit: IGNITE-5816 - Fixed race in WAL segment close leading to ClosedChannelException

Posted by ag...@apache.org.
IGNITE-5816 - Fixed race in WAL segment close leading to ClosedChannelException


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

Branch: refs/heads/master
Commit: 770efe23ce58a62461c698b42b4d58c5791bceb2
Parents: c685e39
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Fri Jul 28 17:26:19 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Fri Jul 28 17:26:52 2017 +0300

----------------------------------------------------------------------
 .../wal/FileWriteAheadLogManager.java           | 32 +++++++++++++++-----
 1 file changed, 24 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/770efe23/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java
index b655ddf..85eb480 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java
@@ -1800,6 +1800,13 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl
 
             if (flush(ptr, stop))
                 return;
+            else if (stop) {
+                FakeRecord fr = (FakeRecord)head.get();
+
+                assert fr.stop : "Invalid fake record on top of the queue: " + fr;
+
+                expWritten = recordOffset(fr);
+            }
 
             // Spin-wait for a while before acquiring the lock.
             for (int i = 0; i < 64; i++) {
@@ -2049,14 +2056,11 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl
          * @throws StorageException If failed.
          */
         private boolean close(boolean rollOver) throws IgniteCheckedException, StorageException {
-            if (mode == WALMode.DEFAULT)
-                fsync(null, true);
-            else
+            if (stop.compareAndSet(false, true)) {
                 flushOrWait(null, true);
 
-            assert stopped() : "Segment is not closed after close flush: " + head.get();
+                assert stopped() : "Segment is not closed after close flush: " + head.get();
 
-            if (stop.compareAndSet(false, true)) {
                 try {
                     int switchSegmentRecSize = RecordV1Serializer.REC_TYPE_SIZE + RecordV1Serializer.FILE_WAL_POINTER_SIZE;
 
@@ -2070,10 +2074,22 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl
 
                         buf.rewind();
 
-                        fileIO.write(buf, written);
+                        int rem = buf.remaining();
+
+                        while (rem > 0) {
+                            int written0 = fileIO.write(buf, written);
+
+                            written += written0;
+
+                            rem -= written0;
+                        }
+                    }
+
+                    // Do the final fsync.
+                    if (mode == WALMode.DEFAULT) {
+                        fileIO.force();
 
-                        if (mode == WALMode.DEFAULT)
-                            fileIO.force();
+                        lastFsyncPos = written;
                     }
 
                     fileIO.close();


[07/47] ignite git commit: small improvements in abstract tests -checking "checkTopology" flag in startGridsMultiThreaded -auto cluster activation in startGridsMultiThreaded

Posted by ag...@apache.org.
small improvements in abstract tests
-checking "checkTopology" flag in startGridsMultiThreaded
-auto cluster activation in startGridsMultiThreaded


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

Branch: refs/heads/master
Commit: 50c5b1dfc1cf182f42bd36dc5d5757f61180ff36
Parents: e001a06
Author: EdShangGG <es...@gridgain.com>
Authored: Wed Jul 26 16:38:08 2017 +0300
Committer: EdShangGG <es...@gridgain.com>
Committed: Wed Jul 26 16:38:08 2017 +0300

----------------------------------------------------------------------
 .../org/apache/ignite/testframework/junits/GridAbstractTest.java | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/50c5b1df/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
index d6d241c..9b99e01 100755
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
@@ -698,7 +698,9 @@ public abstract class GridAbstractTest extends TestCase {
 
         if (cnt > 1) {
             startGridsMultiThreaded(1, cnt - 1);
-            checkTopology(cnt);
+
+            if (checkTopology())
+                checkTopology(cnt);
         }
 
         return ignite;


[08/47] ignite git commit: IGNITE-5174: list only server nodes for specified topology version

Posted by ag...@apache.org.
IGNITE-5174: list only server nodes for specified topology version

Fixes #2312


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

Branch: refs/heads/master
Commit: 586a96eaf4570f4f2020041cfef07550025421d8
Parents: 50c5b1d
Author: Evgeny Stanilovskiy <es...@gridgain.com>
Authored: Wed Jul 26 18:49:41 2017 +0300
Committer: dpavlov <dp...@gridgain.com>
Committed: Wed Jul 26 18:49:41 2017 +0300

----------------------------------------------------------------------
 .../internal/managers/discovery/GridDiscoveryManager.java | 10 ++++++++++
 1 file changed, 10 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/586a96ea/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
index 9f5bd3f..7ad058d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
@@ -1974,6 +1974,16 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
         return snapshots.get(topVer);
     }
 
+    /**
+     * Gets server nodes topology by specified version from snapshots history storage.
+     *
+     * @param topVer Topology version.
+     * @return Server topology nodes or {@code null} if there are no nodes for passed in version.
+     */
+    @Nullable public Collection<ClusterNode> serverTopologyNodes(long topVer) {
+        return F.view(topology(topVer), F.not(FILTER_CLI));
+    }
+
     /** @return All daemon nodes in topology. */
     public Collection<ClusterNode> daemonNodes() {
         return discoCache().daemonNodes();


[43/47] ignite git commit: IGNITE-4944 Added hover for table.

Posted by ag...@apache.org.
IGNITE-4944 Added hover for table.


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

Branch: refs/heads/master
Commit: d4a70a8f27b73acbe2d1a9f622c71cf9e6aa283a
Parents: e3701f0
Author: Andrey Novikov <an...@gridgain.com>
Authored: Mon Jul 31 15:13:03 2017 +0700
Committer: Andrey Novikov <an...@gridgain.com>
Committed: Mon Jul 31 15:13:03 2017 +0700

----------------------------------------------------------------------
 modules/web-console/frontend/app/app.js         |  2 +
 .../list-of-registered-users.tpl.pug            |  2 +-
 .../app/components/ui-grid-hovering/cell.js     | 48 ++++++++++++++++++++
 .../app/components/ui-grid-hovering/hovering.js | 31 +++++++++++++
 .../app/components/ui-grid-hovering/index.js    | 30 ++++++++++++
 .../app/components/ui-grid-hovering/style.scss  | 22 +++++++++
 .../app/components/ui-grid-hovering/viewport.js | 42 +++++++++++++++++
 7 files changed, 176 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/d4a70a8f/modules/web-console/frontend/app/app.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/app.js b/modules/web-console/frontend/app/app.js
index 0925254..8599eb7 100644
--- a/modules/web-console/frontend/app/app.js
+++ b/modules/web-console/frontend/app/app.js
@@ -127,6 +127,7 @@ import gridColumnSelector from './components/grid-column-selector';
 import gridItemSelected from './components/grid-item-selected';
 import bsSelectMenu from './components/bs-select-menu';
 import protectFromBsSelectRender from './components/protect-from-bs-select-render';
+import uiGridHovering from './components/ui-grid-hovering';
 
 // Inject external modules.
 import IgniteModules from 'IgniteModules/index';
@@ -195,6 +196,7 @@ angular.module('ignite-console', [
     gridColumnSelector.name,
     gridItemSelected.name,
     bsSelectMenu.name,
+    uiGridHovering.name,
     protectFromBsSelectRender.name,
     AngularStrapTooltip.name,
     AngularStrapSelect.name,

http://git-wip-us.apache.org/repos/asf/ignite/blob/d4a70a8f/modules/web-console/frontend/app/components/list-of-registered-users/list-of-registered-users.tpl.pug
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/components/list-of-registered-users/list-of-registered-users.tpl.pug b/modules/web-console/frontend/app/components/list-of-registered-users/list-of-registered-users.tpl.pug
index 68530a5..e311246 100644
--- a/modules/web-console/frontend/app/components/list-of-registered-users/list-of-registered-users.tpl.pug
+++ b/modules/web-console/frontend/app/components/list-of-registered-users/list-of-registered-users.tpl.pug
@@ -64,4 +64,4 @@ include /app/helpers/jade/mixins
                     grid-item-selected(grid-api='$ctrl.gridApi')
 
         .panel-collapse
-            .grid.ui-grid--ignite.ui-grid-disabled-group-selection(ui-grid='$ctrl.gridOptions' ui-grid-resize-columns ui-grid-selection ui-grid-exporter ui-grid-pinning ui-grid-grouping)
+            .grid.ui-grid--ignite.ui-grid-disabled-group-selection(ui-grid='$ctrl.gridOptions' ui-grid-resize-columns ui-grid-selection ui-grid-exporter ui-grid-pinning ui-grid-grouping ui-grid-hovering)

http://git-wip-us.apache.org/repos/asf/ignite/blob/d4a70a8f/modules/web-console/frontend/app/components/ui-grid-hovering/cell.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/components/ui-grid-hovering/cell.js b/modules/web-console/frontend/app/components/ui-grid-hovering/cell.js
new file mode 100644
index 0000000..f64df2c
--- /dev/null
+++ b/modules/web-console/frontend/app/components/ui-grid-hovering/cell.js
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ */
+
+export default function() {
+    return {
+        priority: -200,
+        restrict: 'A',
+        require: '?^uiGrid',
+        link($scope, $element) {
+            if (!$scope.grid.options.enableHovering)
+                return;
+
+            // Apply hover when mousing in.
+            $element.on('mouseover', () => {
+                // Empty all isHovered because scroll breaks it.
+                $scope.row.grid.api.core.getVisibleRows().forEach((row) => {
+                    row.isHovered = false;
+                });
+
+                // Now set proper hover
+                $scope.row.isHovered = true;
+
+                $scope.$apply();
+            });
+
+            // Remove hover when mousing out.
+            $element.on('mouseout', () => {
+                $scope.row.isHovered = false;
+
+                $scope.$apply();
+            });
+        }
+    };
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/d4a70a8f/modules/web-console/frontend/app/components/ui-grid-hovering/hovering.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/components/ui-grid-hovering/hovering.js b/modules/web-console/frontend/app/components/ui-grid-hovering/hovering.js
new file mode 100644
index 0000000..17202a4
--- /dev/null
+++ b/modules/web-console/frontend/app/components/ui-grid-hovering/hovering.js
@@ -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.
+ */
+
+export default function() {
+    return {
+        priority: 0,
+        require: '^uiGrid',
+        compile() {
+            return {
+                pre($scope, $element, attrs, uiGridCtrl) {
+                    uiGridCtrl.grid.options.enableHovering = true;
+                },
+                post() { }
+            };
+        }
+    };
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/d4a70a8f/modules/web-console/frontend/app/components/ui-grid-hovering/index.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/components/ui-grid-hovering/index.js b/modules/web-console/frontend/app/components/ui-grid-hovering/index.js
new file mode 100644
index 0000000..eaa8207
--- /dev/null
+++ b/modules/web-console/frontend/app/components/ui-grid-hovering/index.js
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+import angular from 'angular';
+
+import uiGridCell from './cell';
+import uiGridHovering from './hovering';
+import uiGridViewport from './viewport';
+
+import './style.scss';
+
+export default angular
+    .module('ignite-console.ui-grid-hovering', [])
+    .directive('uiGridCell', uiGridCell)
+    .directive('uiGridHovering', uiGridHovering)
+    .directive('uiGridViewport', uiGridViewport);

http://git-wip-us.apache.org/repos/asf/ignite/blob/d4a70a8f/modules/web-console/frontend/app/components/ui-grid-hovering/style.scss
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/components/ui-grid-hovering/style.scss b/modules/web-console/frontend/app/components/ui-grid-hovering/style.scss
new file mode 100644
index 0000000..6c7597a
--- /dev/null
+++ b/modules/web-console/frontend/app/components/ui-grid-hovering/style.scss
@@ -0,0 +1,22 @@
+/*
+ * 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.
+ */
+
+.ui-grid.ui-grid--ignite {
+    .ui-grid-row.ui-grid-row-hovered > [ui-grid-row] > .ui-grid-cell {
+        background: #ededed;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/d4a70a8f/modules/web-console/frontend/app/components/ui-grid-hovering/viewport.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/components/ui-grid-hovering/viewport.js b/modules/web-console/frontend/app/components/ui-grid-hovering/viewport.js
new file mode 100644
index 0000000..7ef433a
--- /dev/null
+++ b/modules/web-console/frontend/app/components/ui-grid-hovering/viewport.js
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ */
+
+import angular from 'angular';
+
+export default function() {
+    return {
+        priority: -200,
+        compile($el) {
+            let newNgClass = '';
+
+            const rowRepeatDiv = angular.element($el.children().children()[0]);
+            const existingNgClass = rowRepeatDiv.attr('ng-class');
+
+            if (existingNgClass)
+                newNgClass = existingNgClass.slice(0, -1) + ', "ui-grid-row-hovered": row.isHovered }';
+            else
+                newNgClass = '{ "ui-grid-row-hovered": row.isHovered }';
+
+            rowRepeatDiv.attr('ng-class', newNgClass);
+
+            return {
+                pre() { },
+                post() { }
+            };
+        }
+    };
+}


[24/47] ignite git commit: IGNITE-5792 test muted with reference to IGNITE-5302 ticket

Posted by ag...@apache.org.
IGNITE-5792 test muted with reference to IGNITE-5302 ticket


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

Branch: refs/heads/master
Commit: 1ea2da9a98fe353a2e3b892fb34122f3db27ca91
Parents: 2cbc049
Author: Sergey Chugunov <se...@gmail.com>
Authored: Fri Jul 28 14:16:43 2017 +0300
Committer: Sergey Chugunov <se...@gmail.com>
Committed: Fri Jul 28 14:16:56 2017 +0300

----------------------------------------------------------------------
 .../cache/persistence/IgnitePdsCacheRebalancingAbstractTest.java   | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/1ea2da9a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsCacheRebalancingAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsCacheRebalancingAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsCacheRebalancingAbstractTest.java
index 588b3ac..c463871 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsCacheRebalancingAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsCacheRebalancingAbstractTest.java
@@ -215,6 +215,8 @@ public abstract class IgnitePdsCacheRebalancingAbstractTest extends GridCommonAb
      * @throws Exception If fails.
      */
     public void testRebalancingOnRestartAfterCheckpoint() throws Exception {
+        fail("IGNITE-5302");
+
         IgniteEx ignite0 = startGrid(0);
 
         IgniteEx ignite1 = startGrid(1);


[20/47] ignite git commit: IGNITE-5771: Added Ignite::SetActive() for C++

Posted by ag...@apache.org.
IGNITE-5771: Added Ignite::SetActive() for C++

(cherry picked from commit 47fea40)


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

Branch: refs/heads/master
Commit: 98a524067b2d2349c558256ee38efdf81e0ba7ff
Parents: a07d7b9
Author: Igor Sapego <is...@gridgain.com>
Authored: Thu Jul 27 19:39:51 2017 +0300
Committer: Igor Sapego <is...@gridgain.com>
Committed: Thu Jul 27 20:02:16 2017 +0300

----------------------------------------------------------------------
 .../cpp/core-test/src/cluster_test.cpp          | 13 ++++++++++
 .../platforms/cpp/core/include/ignite/ignite.h  | 15 +++++++++++
 .../ignite/impl/cluster/cluster_group_impl.h    | 15 +++++++++++
 .../cpp/core/include/ignite/impl/ignite_impl.h  | 23 ++++++++++++++++-
 modules/platforms/cpp/core/src/ignite.cpp       | 10 ++++++++
 .../src/impl/cluster/cluster_group_impl.cpp     | 26 +++++++++++++++++++-
 6 files changed, 100 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/98a52406/modules/platforms/cpp/core-test/src/cluster_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/cluster_test.cpp b/modules/platforms/cpp/core-test/src/cluster_test.cpp
index e9d6728..4ee3f39 100644
--- a/modules/platforms/cpp/core-test/src/cluster_test.cpp
+++ b/modules/platforms/cpp/core-test/src/cluster_test.cpp
@@ -83,4 +83,17 @@ BOOST_AUTO_TEST_CASE(IgniteImplForServers)
     BOOST_REQUIRE(clusterGroup.Get()->ForServers().IsValid());
 }
 
+BOOST_AUTO_TEST_CASE(IgniteSetActive)
+{
+    BOOST_REQUIRE(node.IsActive());
+
+    node.SetActive(false);
+
+    BOOST_REQUIRE(!node.IsActive());
+
+    node.SetActive(true);
+
+    BOOST_REQUIRE(node.IsActive());
+}
+
 BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/98a52406/modules/platforms/cpp/core/include/ignite/ignite.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/ignite.h b/modules/platforms/cpp/core/include/ignite/ignite.h
index b3b06f0..135f215 100644
--- a/modules/platforms/cpp/core/include/ignite/ignite.h
+++ b/modules/platforms/cpp/core/include/ignite/ignite.h
@@ -182,6 +182,21 @@ namespace ignite
         }
 
         /**
+         * Check if the Ignite grid is active.
+         *
+         * @return True if grid is active and false otherwise.
+         */
+        bool IsActive();
+
+        /**
+         * Change Ignite grid state to active or inactive.
+         *
+         * @param active If true start activation process. If false start
+         *    deactivation process.
+         */
+        void SetActive(bool active);
+
+        /**
          * Get transactions.
          *
          * This method should only be used on the valid instance.

http://git-wip-us.apache.org/repos/asf/ignite/blob/98a52406/modules/platforms/cpp/core/include/ignite/impl/cluster/cluster_group_impl.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/impl/cluster/cluster_group_impl.h b/modules/platforms/cpp/core/include/ignite/impl/cluster/cluster_group_impl.h
index 3cfd700..d81e899 100644
--- a/modules/platforms/cpp/core/include/ignite/impl/cluster/cluster_group_impl.h
+++ b/modules/platforms/cpp/core/include/ignite/impl/cluster/cluster_group_impl.h
@@ -71,6 +71,21 @@ namespace ignite
                  */
                 SP_ComputeImpl GetCompute();
 
+                /**
+                 * Check if the Ignite grid is active.
+                 *
+                 * @return True if grid is active and false otherwise.
+                 */
+                bool IsActive();
+
+                /**
+                 * Change Ignite grid state to active or inactive.
+                 *
+                 * @param active If true start activation process. If false start
+                 *    deactivation process.
+                 */
+                void SetActive(bool active);
+
             private:
                 IGNITE_NO_COPY_ASSIGNMENT(ClusterGroupImpl);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/98a52406/modules/platforms/cpp/core/include/ignite/impl/ignite_impl.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/impl/ignite_impl.h b/modules/platforms/cpp/core/include/ignite/impl/ignite_impl.h
index baddec4..ea192e2 100644
--- a/modules/platforms/cpp/core/include/ignite/impl/ignite_impl.h
+++ b/modules/platforms/cpp/core/include/ignite/impl/ignite_impl.h
@@ -82,7 +82,7 @@ namespace ignite
              * @param name Cache name.
              * @param err Error.
              */
-            template<typename K, typename V> 
+            template<typename K, typename V>
             cache::CacheImpl* GetCache(const char* name, IgniteError& err)
             {
                 ignite::jni::java::JniErrorInfo jniErr;
@@ -209,6 +209,27 @@ namespace ignite
              */
             SP_ComputeImpl GetCompute();
 
+            /**
+             * Check if the Ignite grid is active.
+             *
+             * @return True if grid is active and false otherwise.
+             */
+            bool IsActive()
+            {
+                return prjImpl.Get()->IsActive();
+            }
+
+            /**
+             * Change Ignite grid state to active or inactive.
+             *
+             * @param active If true start activation process. If false start
+             *    deactivation process.
+             */
+            void SetActive(bool active)
+            {
+                prjImpl.Get()->SetActive(active);
+            }
+
         private:
             /**
              * Get transactions internal call.

http://git-wip-us.apache.org/repos/asf/ignite/blob/98a52406/modules/platforms/cpp/core/src/ignite.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/ignite.cpp b/modules/platforms/cpp/core/src/ignite.cpp
index 9c42f1d..6eaae01 100644
--- a/modules/platforms/cpp/core/src/ignite.cpp
+++ b/modules/platforms/cpp/core/src/ignite.cpp
@@ -45,6 +45,16 @@ namespace ignite
         return impl.Get()->GetConfiguration();
     }
 
+    bool Ignite::IsActive()
+    {
+        return impl.Get()->IsActive();
+    }
+
+    void Ignite::SetActive(bool active)
+    {
+        impl.Get()->SetActive(active);
+    }
+
     transactions::Transactions Ignite::GetTransactions()
     {
         using ignite::common::concurrent::SharedPointer;

http://git-wip-us.apache.org/repos/asf/ignite/blob/98a52406/modules/platforms/cpp/core/src/impl/cluster/cluster_group_impl.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/impl/cluster/cluster_group_impl.cpp b/modules/platforms/cpp/core/src/impl/cluster/cluster_group_impl.cpp
index c34e828..91f9d30 100644
--- a/modules/platforms/cpp/core/src/impl/cluster/cluster_group_impl.cpp
+++ b/modules/platforms/cpp/core/src/impl/cluster/cluster_group_impl.cpp
@@ -30,7 +30,11 @@ namespace ignite
             {
                 enum Type
                 {
-                    FOR_SERVERS = 23
+                    FOR_SERVERS = 23,
+
+                    SET_ACTIVE = 28,
+
+                    IS_ACTIVE = 29
                 };
             };
 
@@ -61,6 +65,26 @@ namespace ignite
                 return computeImpl;
             }
 
+            bool ClusterGroupImpl::IsActive()
+            {
+                IgniteError err;
+
+                int64_t res = OutInOpLong(Command::IS_ACTIVE, 0, err);
+
+                IgniteError::ThrowIfNeeded(err);
+
+                return res == 1;
+            }
+
+            void ClusterGroupImpl::SetActive(bool active)
+            {
+                IgniteError err;
+
+                int64_t res = OutInOpLong(Command::SET_ACTIVE, active ? 1 : 0, err);
+
+                IgniteError::ThrowIfNeeded(err);
+            }
+
             SP_ClusterGroupImpl ClusterGroupImpl::FromTarget(jobject javaRef)
             {
                 return SP_ClusterGroupImpl(new ClusterGroupImpl(GetEnvironmentPointer(), javaRef));


[31/47] ignite git commit: IGNITE-5729 Added query validations to proxy. Fixed .NET test.

Posted by ag...@apache.org.
IGNITE-5729 Added query validations to proxy. Fixed .NET test.


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

Branch: refs/heads/master
Commit: 591566e9d8323ca2f3e28b43c421e35909ef9cb7
Parents: ff7ba72
Author: Pavel Kovalenko <jo...@gmail.com>
Authored: Fri Jul 28 16:42:31 2017 +0300
Committer: Pavel Kovalenko <jo...@gmail.com>
Committed: Fri Jul 28 16:43:11 2017 +0300

----------------------------------------------------------------------
 .../internal/processors/cache/IgniteCacheProxyImpl.java       | 7 ++++---
 .../Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs  | 3 +--
 2 files changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/591566e9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyImpl.java
index b94afa1..0bc3ba2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyImpl.java
@@ -677,14 +677,15 @@ public class IgniteCacheProxyImpl<K, V> extends AsyncSupportAdapter<IgniteCache<
      */
     private void validate(Query qry) {
         if (!QueryUtils.isEnabled(ctx.config()) && !(qry instanceof ScanQuery) &&
-            !(qry instanceof ContinuousQuery) && !(qry instanceof SpiQuery))
+            !(qry instanceof ContinuousQuery) && !(qry instanceof SpiQuery) && !(qry instanceof SqlQuery) &&
+            !(qry instanceof SqlFieldsQuery))
             throw new CacheException("Indexing is disabled for cache: " + ctx.cache().name() +
-                ". Use setIndexedTypes or setTypeMetadata methods on CacheConfiguration to enable.");
+                    ". Use setIndexedTypes or setTypeMetadata methods on CacheConfiguration to enable.");
 
         if (!ctx.kernalContext().query().moduleEnabled() &&
             (qry instanceof SqlQuery || qry instanceof SqlFieldsQuery || qry instanceof TextQuery))
             throw new CacheException("Failed to execute query. Add module 'ignite-indexing' to the classpath " +
-                "of all Ignite nodes.");
+                    "of all Ignite nodes.");
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/591566e9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
index 500c3fb..ae2fe8f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
@@ -489,8 +489,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
             // SQL query.
             err = Assert.Throws<IgniteException>(() => cache.Query(new SqlQuery(typeof(QueryPerson), "age < 50")));
 
-            Assert.AreEqual("Indexing is disabled for cache: nonindexed_cache. " +
-                "Use setIndexedTypes or setTypeMetadata methods on CacheConfiguration to enable.", err.Message);
+            Assert.AreEqual("Failed to find SQL table for type: QueryPerson", err.Message);
         }
 
         /// <summary>


[30/47] ignite git commit: IGNITE-5734 Web Console: Fixed bugs after ui-router upgrade.

Posted by ag...@apache.org.
IGNITE-5734 Web Console: Fixed bugs after ui-router upgrade.


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

Branch: refs/heads/master
Commit: ff7ba72251c18269a43a9dd0c57527124bbb307a
Parents: 430bf06
Author: Andrey Novikov <an...@gridgain.com>
Authored: Fri Jul 28 20:23:28 2017 +0700
Committer: Andrey Novikov <an...@gridgain.com>
Committed: Fri Jul 28 20:23:28 2017 +0700

----------------------------------------------------------------------
 modules/web-console/backend/index.js            |  6 +++
 modules/web-console/frontend/app/app.js         |  6 ---
 .../frontend/app/controllers/auth.controller.js |  9 ++--
 .../app/modules/agent/AgentManager.service.js   | 24 ++--------
 .../app/modules/agent/AgentModal.service.js     |  8 ++--
 .../frontend/app/modules/demo/Demo.module.js    | 22 +++++----
 .../configuration/summary/summary.worker.js     |  4 +-
 .../frontend/app/modules/states/errors.state.js |  2 +-
 .../app/modules/states/password.state.js        |  2 +
 .../app/modules/states/profile.state.js         |  2 +-
 .../frontend/app/modules/states/signin.state.js |  6 ++-
 .../app/modules/user/AclRoute.provider.js       | 50 --------------------
 .../frontend/app/modules/user/user.module.js    | 35 +++++---------
 .../web-console/frontend/views/signin.tpl.pug   |  2 +-
 .../views/templates/agent-download.tpl.pug      |  2 -
 15 files changed, 55 insertions(+), 125 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/ff7ba722/modules/web-console/backend/index.js
----------------------------------------------------------------------
diff --git a/modules/web-console/backend/index.js b/modules/web-console/backend/index.js
index 85e137c..18bb24d 100644
--- a/modules/web-console/backend/index.js
+++ b/modules/web-console/backend/index.js
@@ -88,6 +88,12 @@ const init = ([settings, apiSrv, agentsHnd, browsersHnd]) => {
     srv.on('error', _onError.bind(null, settings.server.port));
     srv.on('listening', _onListening.bind(null, srv.address()));
 
+    process.on('unhandledRejection', (error) => {
+        // Will print "unhandledRejection err is not defined"
+        console.log('unhandledRejection', error);
+    });
+
+
     apiSrv.attach(srv);
 
     agentsHnd.attach(srv, browsersHnd);

http://git-wip-us.apache.org/repos/asf/ignite/blob/ff7ba722/modules/web-console/frontend/app/app.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/app.js b/modules/web-console/frontend/app/app.js
index a322ff7..0925254 100644
--- a/modules/web-console/frontend/app/app.js
+++ b/modules/web-console/frontend/app/app.js
@@ -108,7 +108,6 @@ import id8 from './filters/id8.filter';
 
 // Controllers
 import profile from 'Controllers/profile-controller';
-import auth from './controllers/auth.controller';
 import resetPassword from './controllers/reset-password.controller';
 
 // Components
@@ -249,7 +248,6 @@ angular.module('ignite-console', [
 .service('Clusters', Clusters)
 .service('Caches', Caches)
 // Controllers.
-.controller(...auth)
 .controller(...resetPassword)
 .controller(...profile)
 // Filters.
@@ -289,10 +287,6 @@ angular.module('ignite-console', [
     $root.$on('user', () => agentMgr.connect());
 }])
 .run(['$transitions', ($transitions) => {
-    $transitions.onStart({ }, () => {
-        _.forEach(angular.element('.modal'), (m) => angular.element(m).scope().$hide());
-    });
-
     $transitions.onSuccess({ }, (trans) => {
         try {
             const {name, params, unsaved} = trans.$to();

http://git-wip-us.apache.org/repos/asf/ignite/blob/ff7ba722/modules/web-console/frontend/app/controllers/auth.controller.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/controllers/auth.controller.js b/modules/web-console/frontend/app/controllers/auth.controller.js
index 21ffeb8..caa74dc 100644
--- a/modules/web-console/frontend/app/controllers/auth.controller.js
+++ b/modules/web-console/frontend/app/controllers/auth.controller.js
@@ -16,10 +16,9 @@
  */
 
 // Sign in controller.
-// TODO IGNITE-1936 Refactor this controller.
-export default ['auth', [
-    '$scope', 'IgniteFocus', 'IgniteCountries', 'Auth',
-    ($scope, Focus, Countries, Auth) => {
+export default [
+    '$scope', '$uiRouterGlobals', 'IgniteFocus', 'IgniteCountries', 'Auth',
+    ($scope, $uiRouterGlobals, Focus, Countries, Auth) => {
         $scope.auth = Auth.auth;
         $scope.forgotPassword = Auth.forgotPassword;
         $scope.action = 'signin';
@@ -27,4 +26,4 @@ export default ['auth', [
 
         Focus.move('user_email');
     }
-]];
+];

http://git-wip-us.apache.org/repos/asf/ignite/blob/ff7ba722/modules/web-console/frontend/app/modules/agent/AgentManager.service.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/agent/AgentManager.service.js b/modules/web-console/frontend/app/modules/agent/AgentManager.service.js
index bdd1fda..6bc31a0 100644
--- a/modules/web-console/frontend/app/modules/agent/AgentManager.service.js
+++ b/modules/web-console/frontend/app/modules/agent/AgentManager.service.js
@@ -73,27 +73,13 @@ class ConnectionState {
 }
 
 export default class IgniteAgentManager {
-    static $inject = ['$rootScope', '$q', 'igniteSocketFactory', 'AgentModal', 'UserNotifications'];
+    static $inject = ['$rootScope', '$q', '$transitions', 'igniteSocketFactory', 'AgentModal', 'UserNotifications'];
 
-    constructor($root, $q, socketFactory, AgentModal, UserNotifications) {
-        this.$root = $root;
-        this.$q = $q;
-        this.socketFactory = socketFactory;
-
-        /**
-         * @type {AgentModal}
-         */
-        this.AgentModal = AgentModal;
-
-        /**
-         * @type {UserNotifications}
-         */
-        this.UserNotifications = UserNotifications;
+    constructor($root, $q, $transitions, socketFactory, AgentModal, UserNotifications) {
+        Object.assign(this, {$root, $q, $transitions, socketFactory, AgentModal, UserNotifications});
 
         this.promises = new Set();
 
-        $root.$on('$stateChangeSuccess', () => this.stopWatch());
-
         /**
          * Connection to backend.
          * @type {Socket}
@@ -282,14 +268,14 @@ export default class IgniteAgentManager {
             }
         });
 
+        self.$transitions.onExit({}, () => self.stopWatch());
+
         return self.awaitCluster();
     }
 
     stopWatch() {
         this.modalSubscription && this.modalSubscription.unsubscribe();
 
-        this.AgentModal.hide();
-
         this.promises.forEach((promise) => promise.reject('Agent watch stopped.'));
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/ff7ba722/modules/web-console/frontend/app/modules/agent/AgentModal.service.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/agent/AgentModal.service.js b/modules/web-console/frontend/app/modules/agent/AgentModal.service.js
index 54f8e52..52abf6d 100644
--- a/modules/web-console/frontend/app/modules/agent/AgentModal.service.js
+++ b/modules/web-console/frontend/app/modules/agent/AgentModal.service.js
@@ -36,10 +36,6 @@ export default class AgentModal {
             controllerAs: 'ctrl'
         });
 
-        self.modal.$scope.$on('modal.hide.before', () => {
-            Messages.hideAlert();
-        });
-
         $root.$on('user', (event, user) => self.user = user);
     }
 
@@ -51,8 +47,12 @@ export default class AgentModal {
      * Close dialog and go by specified link.
      */
     back() {
+        this.Messages.hideAlert();
+
         this.hide();
 
+        _.forEach(angular.element('.modal'), (m) => angular.element(m).scope().$hide());
+
         if (this.backState)
             this.$state.go(this.backState);
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/ff7ba722/modules/web-console/frontend/app/modules/demo/Demo.module.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/demo/Demo.module.js b/modules/web-console/frontend/app/modules/demo/Demo.module.js
index 2445461..bf602f8 100644
--- a/modules/web-console/frontend/app/modules/demo/Demo.module.js
+++ b/modules/web-console/frontend/app/modules/demo/Demo.module.js
@@ -34,9 +34,8 @@ angular
         .state('demo.resume', {
             url: '/resume',
             permission: 'demo',
-            controller: ['$state', ($state) => {
-                $state.go('base.configuration.tabs.advanced.clusters');
-            }],
+            redirectTo: 'base.configuration.tabs',
+            unsaved: true,
             tfMetaTags: {
                 title: 'Demo resume'
             }
@@ -44,15 +43,18 @@ angular
         .state('demo.reset', {
             url: '/reset',
             permission: 'demo',
-            controller: ['$state', '$http', 'IgniteMessages', ($state, $http, Messages) => {
-                $http.post('/api/v1/demo/reset')
-                    .then(() => $state.go('base.configuration.tabs.advanced.clusters'))
-                    .catch((res) => {
-                        $state.go('base.configuration.tabs.advanced.clusters');
+            redirectTo: (trans) => {
+                const $http = trans.injector().get('$http');
 
-                        Messages.showError(res);
+                return $http.post('/api/v1/demo/reset')
+                    .then(() => 'base.configuration.tabs')
+                    .catch((err) => {
+                        trans.injector().get('IgniteMessages').showError(err);
+
+                        return 'base.configuration.tabs';
                     });
-            }],
+            },
+            unsaved: true,
             tfMetaTags: {
                 title: 'Demo reset'
             }

http://git-wip-us.apache.org/repos/asf/ignite/blob/ff7ba722/modules/web-console/frontend/app/modules/states/configuration/summary/summary.worker.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/states/configuration/summary/summary.worker.js b/modules/web-console/frontend/app/modules/states/configuration/summary/summary.worker.js
index 91c2afa..11f19ee 100644
--- a/modules/web-console/frontend/app/modules/states/configuration/summary/summary.worker.js
+++ b/modules/web-console/frontend/app/modules/states/configuration/summary/summary.worker.js
@@ -69,8 +69,8 @@ onmessage = function(e) {
     zip.file('Dockerfile', data.docker);
     zip.file('.dockerignore', docker.ignoreFile());
 
-    const cfg = generator.igniteConfiguration(cluster, targetVer.ignite, false);
-    const clientCfg = generator.igniteConfiguration(cluster, targetVer.ignite, true);
+    const cfg = generator.igniteConfiguration(cluster, targetVer, false);
+    const clientCfg = generator.igniteConfiguration(cluster, targetVer, true);
     const clientNearCaches = _.filter(cluster.caches, (cache) =>
         cache.cacheMode === 'PARTITIONED' && _.get(cache, 'clientNearConfiguration.enabled'));
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/ff7ba722/modules/web-console/frontend/app/modules/states/errors.state.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/states/errors.state.js b/modules/web-console/frontend/app/modules/states/errors.state.js
index 3cc03be..fcc6a5b 100644
--- a/modules/web-console/frontend/app/modules/states/errors.state.js
+++ b/modules/web-console/frontend/app/modules/states/errors.state.js
@@ -23,7 +23,7 @@ angular
     .module('ignite-console.states.errors', [
         'ui.router'
     ])
-    .config(['$stateProvider', 'AclRouteProvider', function($stateProvider) {
+    .config(['$stateProvider', function($stateProvider) {
         // set up the states
         $stateProvider
             .state('404', {

http://git-wip-us.apache.org/repos/asf/ignite/blob/ff7ba722/modules/web-console/frontend/app/modules/states/password.state.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/states/password.state.js b/modules/web-console/frontend/app/modules/states/password.state.js
index 8e326bf..60d82b4 100644
--- a/modules/web-console/frontend/app/modules/states/password.state.js
+++ b/modules/web-console/frontend/app/modules/states/password.state.js
@@ -34,6 +34,7 @@ angular
     .state('password.reset', {
         url: '/reset?{token}',
         templateUrl,
+        unsaved: true,
         tfMetaTags: {
             title: 'Reset password'
         }
@@ -41,6 +42,7 @@ angular
     .state('password.send', {
         url: '/send',
         templateUrl,
+        unsaved: true,
         tfMetaTags: {
             title: 'Password Send'
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/ff7ba722/modules/web-console/frontend/app/modules/states/profile.state.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/states/profile.state.js b/modules/web-console/frontend/app/modules/states/profile.state.js
index 87d1d02..35e0ae6 100644
--- a/modules/web-console/frontend/app/modules/states/profile.state.js
+++ b/modules/web-console/frontend/app/modules/states/profile.state.js
@@ -23,7 +23,7 @@ angular
 .module('ignite-console.states.profile', [
     'ui.router'
 ])
-.config(['$stateProvider', 'AclRouteProvider', function($stateProvider) {
+.config(['$stateProvider', function($stateProvider) {
     // set up the states
     $stateProvider.state('base.settings.profile', {
         url: '/profile',

http://git-wip-us.apache.org/repos/asf/ignite/blob/ff7ba722/modules/web-console/frontend/app/modules/states/signin.state.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/states/signin.state.js b/modules/web-console/frontend/app/modules/states/signin.state.js
index f5a4964..8afcaa3 100644
--- a/modules/web-console/frontend/app/modules/states/signin.state.js
+++ b/modules/web-console/frontend/app/modules/states/signin.state.js
@@ -17,6 +17,7 @@
 
 import angular from 'angular';
 import templateUrl from 'views/signin.tpl.pug';
+import controller from 'app/controllers/auth.controller';
 
 angular
 .module('ignite-console.states.login', [
@@ -44,6 +45,9 @@ angular
                     }
                 })
                 .catch(() => true);
-        }
+        },
+        controller,
+        controllerAs: '$ctrl',
+        unsaved: true
     });
 }]);

http://git-wip-us.apache.org/repos/asf/ignite/blob/ff7ba722/modules/web-console/frontend/app/modules/user/AclRoute.provider.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/user/AclRoute.provider.js b/modules/web-console/frontend/app/modules/user/AclRoute.provider.js
deleted file mode 100644
index f5556ff..0000000
--- a/modules/web-console/frontend/app/modules/user/AclRoute.provider.js
+++ /dev/null
@@ -1,50 +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.
- */
-
-export default [() => {
-    class AclRoute {
-        static checkAccess(permissions, failState = '403') {
-            return ['$q', '$state', 'AclService', 'User', 'IgniteActivitiesData', function($q, $state, AclService, User, Activities) {
-                const action = '';
-
-                return User.read()
-                    .catch(() => {
-                        User.clean();
-
-                        if ($state.current.name !== 'signin')
-                            $state.go('signin');
-
-                        return $q.reject('Failed to detect user');
-                    })
-                    .then(() => {
-                        if (AclService.can(permissions))
-                            return Activities.post({ action });
-
-                        $state.go(failState);
-
-                        return $q.reject('User are not authorized');
-                    });
-            }];
-        }
-
-        static $get() {
-            return AclRoute;
-        }
-    }
-
-    return AclRoute;
-}];

http://git-wip-us.apache.org/repos/asf/ignite/blob/ff7ba722/modules/web-console/frontend/app/modules/user/user.module.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/user/user.module.js b/modules/web-console/frontend/app/modules/user/user.module.js
index 721d07f..cac8943 100644
--- a/modules/web-console/frontend/app/modules/user/user.module.js
+++ b/modules/web-console/frontend/app/modules/user/user.module.js
@@ -20,7 +20,6 @@ import aclData from './permissions';
 
 import Auth from './Auth.service';
 import User from './User.service';
-import AclRouteProvider from './AclRoute.provider';
 
 angular.module('ignite-console.user', [
     'mm.acl',
@@ -34,10 +33,10 @@ angular.module('ignite-console.user', [
             if (response.status === 401) {
                 $injector.get('User').clean();
 
-                const $state = $injector.get('$state');
+                const stateName = $injector.get('$uiRouterGlobals').current.name;
 
-                if ($state.current.name !== 'signin')
-                    $state.go('signin');
+                if (stateName !== 'signin')
+                    $injector.get('$state').go('signin');
             }
 
             return $q.reject(response);
@@ -49,7 +48,6 @@ angular.module('ignite-console.user', [
 }])
 .service(...Auth)
 .service(...User)
-.provider('AclRoute', AclRouteProvider)
 .run(['$rootScope', '$transitions', 'AclService', 'User', 'IgniteActivitiesData', ($root, $transitions, AclService, User, Activities) => {
     AclService.setAbilities(aclData);
     AclService.attachRole('guest');
@@ -71,31 +69,22 @@ angular.module('ignite-console.user', [
         AclService.attachRole(role);
     });
 
-    $transitions.onBefore({}, (t) => {
-        const $state = t.router.stateService;
-        const {name, permission} = t.to();
+    $transitions.onEnter({}, (trans) => {
+        const $state = trans.router.stateService;
+        const {name, permission} = trans.to();
 
-        return User.read()
-            .catch(() => {
-                User.clean();
-
-                if (name !== 'signin')
-                    return $state.target('signin');
+        if (_.isEmpty(permission))
+            return;
 
-                return true;
-            })
+        trans.injector().get('User').read()
             .then(() => {
-                if (_.isEmpty(permission))
-                    return true;
-
                 if (AclService.can(permission)) {
-                    Activities.post({action: $state.href(name, t.params('to'))});
+                    Activities.post({action: $state.href(name, trans.params('to'))});
 
-                    return true;
+                    return;
                 }
 
-                return $state.target(t.to().failState || '403');
+                return $state.target(trans.to().failState || '403');
             });
-
     });
 }]);

http://git-wip-us.apache.org/repos/asf/ignite/blob/ff7ba722/modules/web-console/frontend/views/signin.tpl.pug
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/views/signin.tpl.pug b/modules/web-console/frontend/views/signin.tpl.pug
index c7e2027..fcd19e5 100644
--- a/modules/web-console/frontend/views/signin.tpl.pug
+++ b/modules/web-console/frontend/views/signin.tpl.pug
@@ -22,7 +22,7 @@ web-console-header
         ignite-header-title
 
 .container.body-container
-    .main-content(ng-controller='auth')
+    .main-content
         .row.home
             .signin-greedy
                 .col-xs-12.col-md-6

http://git-wip-us.apache.org/repos/asf/ignite/blob/ff7ba722/modules/web-console/frontend/views/templates/agent-download.tpl.pug
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/views/templates/agent-download.tpl.pug b/modules/web-console/frontend/views/templates/agent-download.tpl.pug
index 7829581..fdb3a05 100644
--- a/modules/web-console/frontend/views/templates/agent-download.tpl.pug
+++ b/modules/web-console/frontend/views/templates/agent-download.tpl.pug
@@ -21,8 +21,6 @@
                 h4.modal-title
                     i.fa.fa-download
                     span Connection to Ignite Web Agent is not established
-                button.close(type='button' aria-label='Close' ng-click='$hide()')
-                     svg(ignite-icon="cross")
             .modal-body.agent-download
                 p Please download and run #[a(href='/api/v1/downloads/agent' target='_self') ignite-web-agent] to use this functionality:
                     ul


[17/47] ignite git commit: IGNITE-5729 - Removed RendezvousAffinityFunction with extra partitions in GridCacheAbstractSelfTest

Posted by ag...@apache.org.
IGNITE-5729 - Removed RendezvousAffinityFunction with extra partitions in GridCacheAbstractSelfTest


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

Branch: refs/heads/master
Commit: 004e5aa7df72a16efb02e7500b56475916515ba7
Parents: 9825eaa
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Thu Jul 27 11:42:09 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Thu Jul 27 11:42:09 2017 +0300

----------------------------------------------------------------------
 .../ignite/internal/processors/cache/GridCacheAbstractSelfTest.java | 1 -
 1 file changed, 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/004e5aa7/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java
index 9376971..81aadb9 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java
@@ -247,7 +247,6 @@ public abstract class GridCacheAbstractSelfTest extends GridCommonAbstractTest {
             }
         }
 
-        cfg.setAffinity(new RendezvousAffinityFunction(false, 4096));
         cfg.setCacheMode(cacheMode());
         cfg.setAtomicityMode(atomicityMode());
         cfg.setWriteSynchronizationMode(writeSynchronization());


[46/47] ignite git commit: Merge branch ignite-2.1.3 into master

Posted by ag...@apache.org.
Merge branch ignite-2.1.3 into master


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

Branch: refs/heads/master
Commit: 8b576c14b7f017ff7fcb098673ec20ccf4bf0491
Parents: ece7cf9 4d323f3
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Tue Aug 1 11:20:54 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Tue Aug 1 11:20:54 2017 +0300

----------------------------------------------------------------------
 .../JettyRestProcessorAbstractSelfTest.java     |   18 +-
 .../apache/ignite/IgniteSystemProperties.java   |    6 +
 .../org/apache/ignite/cache/CacheManager.java   |    4 +-
 .../IgniteDiagnosticPrepareContext.java         |    3 +-
 .../apache/ignite/internal/IgniteKernal.java    |    3 +-
 .../discovery/GridDiscoveryManager.java         |   10 +
 .../mem/file/MappedFileMemoryProvider.java      |    3 +-
 .../cache/CacheAffinitySharedManager.java       |   23 +-
 .../processors/cache/CacheOperationContext.java |   15 +
 .../processors/cache/ClusterCachesInfo.java     |  135 +-
 .../processors/cache/ExchangeActions.java       |    4 +-
 .../cache/GatewayProtectedCacheProxy.java       | 1754 +++++++++++
 .../processors/cache/GridCacheAdapter.java      |   16 +-
 .../GridCachePartitionExchangeManager.java      |    2 +-
 .../processors/cache/GridCacheProcessor.java    |   82 +-
 .../processors/cache/GridCacheUtils.java        |    7 +-
 .../cache/IgniteCacheOffheapManagerImpl.java    |   26 +-
 .../processors/cache/IgniteCacheProxy.java      | 2818 +-----------------
 .../processors/cache/IgniteCacheProxyImpl.java  | 1828 ++++++++++++
 .../dht/GridDhtTransactionalCacheAdapter.java   |    7 +-
 .../distributed/dht/GridDhtTxPrepareFuture.java |   24 +-
 .../GridDhtPartitionsExchangeFuture.java        |   20 +-
 ...arOptimisticSerializableTxPrepareFuture.java |    9 +
 .../near/GridNearOptimisticTxPrepareFuture.java |   15 +
 .../GridNearPessimisticTxPrepareFuture.java     |    9 +-
 .../GridCacheDatabaseSharedManager.java         |    7 +-
 .../persistence/freelist/FreeListImpl.java      |   22 +-
 .../wal/FileWriteAheadLogManager.java           |   37 +-
 .../reader/StandaloneWalRecordsIterator.java    |    4 +-
 .../cache/transactions/IgniteTxHandler.java     |   51 +-
 .../cache/transactions/IgniteTxManager.java     |    7 +-
 .../cluster/GridClusterStateProcessor.java      |    3 +-
 .../datastructures/GridCacheLockImpl.java       |   13 +-
 .../dr/IgniteDrDataStreamerCacheUpdater.java    |    2 +-
 .../processors/odbc/SqlListenerProcessor.java   |    3 +-
 .../platform/cache/PlatformCache.java           |   33 +-
 .../ignite/internal/util/IgniteUtils.java       |   65 +
 .../ignite/internal/util/nio/GridNioServer.java |    7 +-
 .../internal/visor/debug/VisorThreadInfo.java   |   10 +-
 .../internal/visor/query/VisorQueryTask.java    |    2 +-
 .../visor/query/VisorScanQueryTask.java         |    2 +-
 .../ignite/spi/discovery/tcp/ServerImpl.java    |   38 +-
 .../store/jdbc/CacheJdbcPojoStoreTest.java      |   55 +-
 .../cache/store/jdbc/model/BinaryTest.java      |  121 +
 .../cache/store/jdbc/model/BinaryTestKey.java   |   87 +
 .../cache/CacheEntryProcessorCopySelfTest.java  |   11 +-
 .../cache/CacheStopAndDestroySelfTest.java      |    1 +
 .../cache/GridCacheAbstractSelfTest.java        |    1 +
 .../GridCacheOnCopyFlagAbstractSelfTest.java    |    6 +-
 ...idCacheValueConsistencyAbstractSelfTest.java |    4 +-
 .../IgniteCacheConfigVariationsFullApiTest.java |    6 +-
 .../IgniteCacheEntryListenerAbstractTest.java   |    1 -
 .../processors/cache/IgniteCacheGroupsTest.java |   89 +-
 .../cache/IgniteCacheStartStopLoadTest.java     |    1 -
 .../dht/NotMappedPartitionInTxTest.java         |  264 ++
 .../IgnitePdsCacheRebalancingAbstractTest.java  |    2 +
 .../MemoryPolicyInitializationTest.java         |    3 +-
 .../db/IgnitePdsWholeClusterRestartTest.java    |    2 +
 .../TxOptimisticDeadlockDetectionTest.java      |    2 +
 .../marshaller/GridMarshallerAbstractTest.java  |   10 +-
 .../testframework/junits/GridAbstractTest.java  |    4 +-
 .../junits/common/GridCommonAbstractTest.java   |    6 +-
 .../testsuites/IgniteCacheTestSuite5.java       |    2 +
 .../ignite/tests/p2p/JobStealingTask.java       |   12 +-
 .../org/apache/ignite/tests/p2p/NodeFilter.java |   30 +
 .../apache/ignite/stream/flume/IgniteSink.java  |    7 +-
 .../hadoop/jobtracker/HadoopJobTracker.java     |   24 +-
 .../hadoop/shuffle/HadoopShuffleJob.java        |    5 +-
 .../processors/query/h2/IgniteH2Indexing.java   |   21 +-
 .../cache/index/H2DynamicTableSelfTest.java     |   32 +
 ...eDbSingleNodeWithIndexingWalRestoreTest.java |  197 ++
 .../IgnitePdsWithIndexingTestSuite.java         |    2 +
 .../apache/ignite/stream/mqtt/MqttStreamer.java |    6 +-
 .../cpp/core/include/ignite/impl/ignite_impl.h  |    2 +-
 .../spi/deployment/uri/UriDeploymentSpi.java    |    3 +-
 modules/web-console/backend/app/settings.js     |    3 +-
 modules/web-console/backend/index.js            |   16 +-
 modules/web-console/backend/middlewares/api.js  |   38 +-
 modules/web-console/frontend/app/app.config.js  |    3 +-
 modules/web-console/frontend/app/app.js         |   10 +-
 .../app/components/bs-select-menu/style.scss    |   16 +
 .../app/components/bs-select-menu/template.pug  |    2 +
 .../components/grid-item-selected/component.js  |   28 +
 .../components/grid-item-selected/controller.js |   38 +
 .../app/components/grid-item-selected/index.js  |   24 +
 .../components/grid-item-selected/template.pug  |   17 +
 .../list-of-registered-users.tpl.pug            |    4 +-
 .../app/components/ui-grid-hovering/cell.js     |   48 +
 .../app/components/ui-grid-hovering/hovering.js |   31 +
 .../app/components/ui-grid-hovering/index.js    |   30 +
 .../app/components/ui-grid-hovering/style.scss  |   22 +
 .../app/components/ui-grid-hovering/viewport.js |   42 +
 .../frontend/app/controllers/auth.controller.js |    9 +-
 .../frontend/app/data/jdbc-types.json           |    6 +-
 .../app/modules/agent/AgentManager.service.js   |   24 +-
 .../app/modules/agent/AgentModal.service.js     |    8 +-
 .../frontend/app/modules/demo/Demo.module.js    |   22 +-
 .../frontend/app/modules/sql/sql.controller.js  |   11 +-
 .../states/configuration/clusters/hadoop.pug    |    2 +-
 .../configuration/summary/summary.worker.js     |    4 +-
 .../frontend/app/modules/states/errors.state.js |    2 +-
 .../app/modules/states/password.state.js        |    2 +
 .../app/modules/states/profile.state.js         |    2 +-
 .../frontend/app/modules/states/signin.state.js |    6 +-
 .../app/modules/user/AclRoute.provider.js       |   50 -
 .../frontend/app/modules/user/user.module.js    |   35 +-
 .../frontend/app/primitives/dropdown/index.scss |   68 -
 .../frontend/app/services/Messages.service.js   |    7 +
 .../web-console/frontend/views/signin.tpl.pug   |    2 +-
 .../views/templates/agent-download.tpl.pug      |    2 -
 110 files changed, 5459 insertions(+), 3341 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/8b576c14/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/ignite/blob/8b576c14/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/ignite/blob/8b576c14/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/ignite/blob/8b576c14/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/ignite/blob/8b576c14/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/ignite/blob/8b576c14/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/ignite/blob/8b576c14/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticSerializableTxPrepareFuture.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/ignite/blob/8b576c14/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/ignite/blob/8b576c14/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/ignite/blob/8b576c14/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheDatabaseSharedManager.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/ignite/blob/8b576c14/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
----------------------------------------------------------------------

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

http://git-wip-us.apache.org/repos/asf/ignite/blob/8b576c14/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/ignite/blob/8b576c14/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/ignite/blob/8b576c14/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/ignite/blob/8b576c14/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/ignite/blob/8b576c14/modules/platforms/cpp/core/include/ignite/impl/ignite_impl.h
----------------------------------------------------------------------
diff --cc modules/platforms/cpp/core/include/ignite/impl/ignite_impl.h
index 8dddf43,6d98ec0..34b3749
--- a/modules/platforms/cpp/core/include/ignite/impl/ignite_impl.h
+++ b/modules/platforms/cpp/core/include/ignite/impl/ignite_impl.h
@@@ -62,8 -47,13 +62,8 @@@ namespace ignit
               *
               * @param env Environment.
               */
 -            IgniteImpl(SP_IgniteEnvironment env, jobject javaRef);
 -            
 -            /**
 -             * Destructor.
 -             */
 -            ~IgniteImpl();
 +            IgniteImpl(SP_IgniteEnvironment env);
-             
+ 
              /**
               * Get name of the Ignite.
               *


[37/47] ignite git commit: Minor - added P2P node filter for tests

Posted by ag...@apache.org.
Minor - added P2P node filter for tests


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

Branch: refs/heads/master
Commit: 3085b20ba75ebb983c35fd094c8864fb8920790a
Parents: 770efe2
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Fri Jul 28 17:56:47 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Fri Jul 28 17:56:47 2017 +0300

----------------------------------------------------------------------
 .../org/apache/ignite/tests/p2p/NodeFilter.java | 30 ++++++++++++++++++++
 1 file changed, 30 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/3085b20b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/NodeFilter.java
----------------------------------------------------------------------
diff --git a/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/NodeFilter.java b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/NodeFilter.java
new file mode 100644
index 0000000..39eb8a8
--- /dev/null
+++ b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/NodeFilter.java
@@ -0,0 +1,30 @@
+/*
+ * 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.tests.p2p;
+
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.lang.IgnitePredicate;
+
+/**
+ *
+ */
+public class NodeFilter implements IgnitePredicate<ClusterNode> {
+    @Override public boolean apply(ClusterNode node) {
+        return true;
+    }
+}


[02/47] ignite git commit: IGNITE-5747 GridCommonAbstractTest.startGridsMultiThreaded works very slowly if persistence is enabled - Fixes #2294.

Posted by ag...@apache.org.
IGNITE-5747 GridCommonAbstractTest.startGridsMultiThreaded works very slowly if persistence is enabled - Fixes #2294.

Signed-off-by: Alexey Goncharuk <al...@gmail.com>


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

Branch: refs/heads/master
Commit: 243913ee24fbc09d0ae5469bb1d99926b1a8e8d5
Parents: 00babb4
Author: EdShangGG <es...@gridgain.com>
Authored: Tue Jul 25 16:50:35 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Tue Jul 25 16:50:35 2017 +0300

----------------------------------------------------------------------
 .../testframework/junits/common/GridCommonAbstractTest.java    | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/243913ee/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
index dc7e89d..014103d 100755
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
@@ -503,8 +503,12 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest {
     protected final Ignite startGridsMultiThreaded(int cnt, boolean awaitPartMapExchange) throws Exception {
         Ignite g = super.startGridsMultiThreaded(cnt);
 
-        if (awaitPartMapExchange)
+        if (awaitPartMapExchange) {
+            if (!g.active())
+                g.active(true);
+
             awaitPartitionMapExchange();
+        }
 
         return g;
     }


[03/47] ignite git commit: IGNITE-5781 Visor throws ClassCastException if cache store implementation is other than CacheJdbcPojoStore Signed-off-by: Konstantin Boudnik (cherry picked from commit 02e2507)

Posted by ag...@apache.org.
IGNITE-5781 Visor throws ClassCastException if cache store implementation is other than CacheJdbcPojoStore
Signed-off-by: Konstantin Boudnik <co...@apache.org>
(cherry picked from commit 02e2507)


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

Branch: refs/heads/master
Commit: 85f17027d0ca7cfa6dfaa3711ad8b4a7a6eb1e79
Parents: 243913e
Author: Aleksandr_Meterko <al...@epam.com>
Authored: Wed Jul 19 19:55:15 2017 +0700
Committer: vsisko <vs...@gridgain.com>
Committed: Wed Jul 26 15:31:54 2017 +0700

----------------------------------------------------------------------
 .../org/apache/ignite/internal/visor/cache/VisorCacheJdbcType.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/85f17027/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheJdbcType.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheJdbcType.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheJdbcType.java
old mode 100644
new mode 100755
index e50402c..a03096f
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheJdbcType.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheJdbcType.java
@@ -64,7 +64,7 @@ public class VisorCacheJdbcType extends VisorDataTransferObject {
     public static List<VisorCacheJdbcType> list(Factory factory) {
         List<VisorCacheJdbcType> res = new ArrayList<>();
 
-        if (factory != null || factory instanceof CacheJdbcPojoStoreFactory) {
+        if (factory instanceof CacheJdbcPojoStoreFactory) {
             CacheJdbcPojoStoreFactory jdbcFactory = (CacheJdbcPojoStoreFactory) factory;
 
             JdbcType[] jdbcTypes = jdbcFactory.getTypes();


[18/47] ignite git commit: GG-12485 added test to verify issue on 8.1.x version

Posted by ag...@apache.org.
GG-12485 added test to verify issue on 8.1.x version


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

Branch: refs/heads/master
Commit: be5a9eaf77877b02a46f30730cd6d8e1e3919f41
Parents: 004e5aa
Author: Sergey Chugunov <se...@gmail.com>
Authored: Thu Jul 27 13:02:59 2017 +0300
Committer: Sergey Chugunov <se...@gmail.com>
Committed: Thu Jul 27 13:45:29 2017 +0300

----------------------------------------------------------------------
 ...eDbSingleNodeWithIndexingWalRestoreTest.java | 197 +++++++++++++++++++
 .../IgnitePdsWithIndexingTestSuite.java         |   2 +
 2 files changed, 199 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/be5a9eaf/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbSingleNodeWithIndexingWalRestoreTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbSingleNodeWithIndexingWalRestoreTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbSingleNodeWithIndexingWalRestoreTest.java
new file mode 100644
index 0000000..385cf19
--- /dev/null
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbSingleNodeWithIndexingWalRestoreTest.java
@@ -0,0 +1,197 @@
+/*
+ * 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.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import org.apache.ignite.IgniteBinary;
+import org.apache.ignite.IgniteCache;
+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.configuration.BinaryConfiguration;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.PersistentStoreConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.binary.BinaryMarshaller;
+import org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ * Test verifies that binary metadata of values stored in cache and indexes upon these values
+ * is handled correctly on cluster restart when persistent store is enabled and compact footer is turned on.
+ */
+public class IgniteDbSingleNodeWithIndexingWalRestoreTest extends GridCommonAbstractTest {
+    /** */
+    private static final String BINARY_TYPE_NAME = "BinaryPerson";
+
+    /** */
+    private static final String BINARY_TYPE_FIELD_NAME = "binaryName";
+
+    /** */
+    private static int ENTRIES_COUNT = 500;
+
+    /** */
+    private static class RegularPerson {
+        /** */
+        private String regName;
+
+        /** */
+        public RegularPerson(String regName) {
+            this.regName = regName;
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        BinaryConfiguration binCfg = new BinaryConfiguration();
+        binCfg.setCompactFooter(true);
+
+        cfg.setBinaryConfiguration(binCfg);
+
+        CacheConfiguration indexedCacheCfg = new CacheConfiguration();
+
+        indexedCacheCfg.setName("indexedCache");
+
+        List<QueryEntity> qryEntities = new ArrayList<>();
+
+        {
+            QueryEntity qryEntity = new QueryEntity();
+            qryEntity.setKeyType(Integer.class.getName());
+            qryEntity.setValueType(BINARY_TYPE_NAME);
+
+            LinkedHashMap<String, String> fields = new LinkedHashMap<>();
+            fields.put(BINARY_TYPE_FIELD_NAME, String.class.getName());
+
+            qryEntity.setFields(fields);
+
+            qryEntity.setIndexes(F.asList(new QueryIndex(BINARY_TYPE_FIELD_NAME)));
+
+            qryEntities.add(qryEntity);
+        }
+
+        {
+            QueryEntity qryEntity = new QueryEntity();
+            qryEntity.setKeyType(Integer.class.getName());
+            qryEntity.setValueType(RegularPerson.class.getName());
+
+            LinkedHashMap<String, String> fields = new LinkedHashMap<>();
+            fields.put("regName", String.class.getName());
+
+            qryEntity.setFields(fields);
+
+            qryEntity.setIndexes(F.asList(new QueryIndex("regName")));
+
+            qryEntities.add(qryEntity);
+        }
+
+        indexedCacheCfg.setQueryEntities(qryEntities);
+
+        cfg.setCacheConfiguration(indexedCacheCfg);
+
+        cfg.setPersistentStoreConfiguration(new PersistentStoreConfiguration());
+
+        cfg.setConsistentId(gridName);
+
+        return cfg;
+    }
+
+    /**
+     * Test for values without class created with BinaryObjectBuilder.
+     */
+    public void testClasslessBinaryValuesRestored() throws Exception {
+        IgniteEx ig = startGrid(0);
+
+        ig.active(true);
+
+        GridCacheDatabaseSharedManager dbMgr = (GridCacheDatabaseSharedManager) ig.context().cache().context().database();
+
+        dbMgr.enableCheckpoints(false).get();
+
+        IgniteCache<Object, Object> cache = ig.cache("indexedCache").withKeepBinary();
+
+        IgniteBinary bin = ig.binary();
+
+        for (int i = 0; i < ENTRIES_COUNT; i++) {
+            BinaryObjectBuilder bldr = bin.builder(BINARY_TYPE_NAME);
+
+            bldr.setField(BINARY_TYPE_FIELD_NAME, "Peter" + i);
+
+            cache.put(i, bldr.build());
+        }
+
+        stopGrid(0, true);
+
+        ig = startGrid(0);
+
+        ig.active(true);
+
+        cache = ig.cache("indexedCache").withKeepBinary();
+
+        for (int i = 0; i < ENTRIES_COUNT; i++)
+            assertEquals("Peter" + i, (((BinaryObject)cache.get(i)).field(BINARY_TYPE_FIELD_NAME)));
+    }
+
+    /**
+     * Test for regular objects stored in cache with compactFooter=true setting
+     * (no metainformation to deserialize values is stored with values themselves).
+     */
+    public void testRegularClassesRestored() throws Exception {
+        IgniteEx ig = startGrid(0);
+
+        ig.active(true);
+
+        GridCacheDatabaseSharedManager dbMgr = (GridCacheDatabaseSharedManager) ig.context().cache().context().database();
+
+        dbMgr.enableCheckpoints(false).get();
+
+        IgniteCache<Object, Object> cache = ig.cache("indexedCache");
+
+        for (int i = 0; i < ENTRIES_COUNT; i++)
+            cache.put(i, new RegularPerson("RegularPeter" + i));
+
+        stopGrid(0, true);
+
+        ig = startGrid(0);
+
+        ig.active(true);
+
+        cache = ig.cache("indexedCache");
+
+        for (int i = 0; i < ENTRIES_COUNT; i++)
+            assertEquals("RegularPeter" + i, ((RegularPerson)cache.get(i)).regName);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        deleteRecursively(U.resolveWorkDirectory(U.defaultWorkDirectory(), "db", false));
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        stopAllGrids();
+
+        deleteRecursively(U.resolveWorkDirectory(U.defaultWorkDirectory(), "db", false));
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/be5a9eaf/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgnitePdsWithIndexingTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgnitePdsWithIndexingTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgnitePdsWithIndexingTestSuite.java
index 15ea594..033e5a9 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgnitePdsWithIndexingTestSuite.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgnitePdsWithIndexingTestSuite.java
@@ -22,6 +22,7 @@ import org.apache.ignite.internal.processors.cache.IgnitePdsSingleNodeWithIndexi
 import org.apache.ignite.internal.processors.cache.IgnitePdsSingleNodeWithIndexingPutGetPersistenceTest;
 import org.apache.ignite.internal.processors.database.IgniteDbMultiNodeWithIndexingPutGetTest;
 import org.apache.ignite.internal.processors.database.IgniteDbSingleNodeWithIndexingPutGetTest;
+import org.apache.ignite.internal.processors.database.IgniteDbSingleNodeWithIndexingWalRestoreTest;
 import org.apache.ignite.internal.processors.database.IgnitePersistentStoreQueryWithMultipleClassesPerCacheTest;
 import org.apache.ignite.internal.processors.database.IgnitePersistentStoreSchemaLoadTest;
 
@@ -36,6 +37,7 @@ public class IgnitePdsWithIndexingTestSuite extends TestSuite {
     public static TestSuite suite() throws Exception {
         TestSuite suite = new TestSuite("Ignite Db Memory Leaks With Indexing Test Suite");
 
+        suite.addTestSuite(IgniteDbSingleNodeWithIndexingWalRestoreTest.class);
         suite.addTestSuite(IgniteDbSingleNodeWithIndexingPutGetTest.class);
         suite.addTestSuite(IgniteDbMultiNodeWithIndexingPutGetTest.class);
         suite.addTestSuite(IgnitePdsSingleNodeWithIndexingPutGetPersistenceTest.class);


[23/47] ignite git commit: IGNITE-5863 Web Console: Implemented component for showing table totals.

Posted by ag...@apache.org.
IGNITE-5863 Web Console: Implemented component for showing table totals.


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

Branch: refs/heads/master
Commit: 2cbc049172c47a77e2b9dcdbda09161ef54ad102
Parents: a57a851
Author: Dmitriy Shabalin <ds...@gridgain.com>
Authored: Fri Jul 28 18:05:16 2017 +0700
Committer: Andrey Novikov <an...@gridgain.com>
Committed: Fri Jul 28 18:05:16 2017 +0700

----------------------------------------------------------------------
 modules/web-console/frontend/app/app.js         |  2 ++
 .../components/grid-item-selected/component.js  | 28 +++++++++++++++
 .../components/grid-item-selected/controller.js | 38 ++++++++++++++++++++
 .../app/components/grid-item-selected/index.js  | 24 +++++++++++++
 .../components/grid-item-selected/template.pug  | 17 +++++++++
 .../list-of-registered-users.tpl.pug            |  2 +-
 6 files changed, 110 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/2cbc0491/modules/web-console/frontend/app/app.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/app.js b/modules/web-console/frontend/app/app.js
index e2d609a..a322ff7 100644
--- a/modules/web-console/frontend/app/app.js
+++ b/modules/web-console/frontend/app/app.js
@@ -125,6 +125,7 @@ import pageConfigure from './components/page-configure';
 import pageConfigureBasic from './components/page-configure-basic';
 import pageConfigureAdvanced from './components/page-configure-advanced';
 import gridColumnSelector from './components/grid-column-selector';
+import gridItemSelected from './components/grid-item-selected';
 import bsSelectMenu from './components/bs-select-menu';
 import protectFromBsSelectRender from './components/protect-from-bs-select-render';
 
@@ -193,6 +194,7 @@ angular.module('ignite-console', [
     pageConfigureBasic.name,
     pageConfigureAdvanced.name,
     gridColumnSelector.name,
+    gridItemSelected.name,
     bsSelectMenu.name,
     protectFromBsSelectRender.name,
     AngularStrapTooltip.name,

http://git-wip-us.apache.org/repos/asf/ignite/blob/2cbc0491/modules/web-console/frontend/app/components/grid-item-selected/component.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/components/grid-item-selected/component.js b/modules/web-console/frontend/app/components/grid-item-selected/component.js
new file mode 100644
index 0000000..d25ad74
--- /dev/null
+++ b/modules/web-console/frontend/app/components/grid-item-selected/component.js
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import template from './template.pug';
+import controller from './controller.js';
+
+export default {
+    template,
+    controller,
+    transclude: true,
+    bindings: {
+        gridApi: '<'
+    }
+};

http://git-wip-us.apache.org/repos/asf/ignite/blob/2cbc0491/modules/web-console/frontend/app/components/grid-item-selected/controller.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/components/grid-item-selected/controller.js b/modules/web-console/frontend/app/components/grid-item-selected/controller.js
new file mode 100644
index 0000000..4923924
--- /dev/null
+++ b/modules/web-console/frontend/app/components/grid-item-selected/controller.js
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+
+export default class {
+    static $inject = ['$scope', 'uiGridConstants'];
+
+    constructor($scope, uiGridConstants) {
+        Object.assign(this, {$scope, uiGridConstants});
+    }
+
+    $onChanges(changes) {
+        if (changes && 'gridApi' in changes && changes.gridApi.currentValue) {
+            this.applyValues();
+
+            this.gridApi.grid.registerDataChangeCallback(() => this.applyValues(), [this.uiGridConstants.dataChange.ROW]);
+            this.gridApi.selection.on.rowSelectionChanged(this.$scope, () => this.applyValues());
+        }
+    }
+
+    applyValues() {
+        this.selected = this.gridApi.selection.getSelectedRows().length;
+        this.count = this.gridApi.grid.rows.length;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/2cbc0491/modules/web-console/frontend/app/components/grid-item-selected/index.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/components/grid-item-selected/index.js b/modules/web-console/frontend/app/components/grid-item-selected/index.js
new file mode 100644
index 0000000..583d871
--- /dev/null
+++ b/modules/web-console/frontend/app/components/grid-item-selected/index.js
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+
+import angular from 'angular';
+
+import component from './component';
+
+export default angular
+    .module('ignite-console.grid-item-selected', [])
+    .component('gridItemSelected', component);

http://git-wip-us.apache.org/repos/asf/ignite/blob/2cbc0491/modules/web-console/frontend/app/components/grid-item-selected/template.pug
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/components/grid-item-selected/template.pug b/modules/web-console/frontend/app/components/grid-item-selected/template.pug
new file mode 100644
index 0000000..eca079e
--- /dev/null
+++ b/modules/web-console/frontend/app/components/grid-item-selected/template.pug
@@ -0,0 +1,17 @@
+//-
+    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.
+
+i {{ $ctrl.selected }} of {{ $ctrl.count }} selected

http://git-wip-us.apache.org/repos/asf/ignite/blob/2cbc0491/modules/web-console/frontend/app/components/list-of-registered-users/list-of-registered-users.tpl.pug
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/components/list-of-registered-users/list-of-registered-users.tpl.pug b/modules/web-console/frontend/app/components/list-of-registered-users/list-of-registered-users.tpl.pug
index 3558ab5..68530a5 100644
--- a/modules/web-console/frontend/app/components/list-of-registered-users/list-of-registered-users.tpl.pug
+++ b/modules/web-console/frontend/app/components/list-of-registered-users/list-of-registered-users.tpl.pug
@@ -61,7 +61,7 @@ include /app/helpers/jade/mixins
                     span(ng-if='$ctrl.groupBy === "country"') List of registered countries
                     grid-column-selector(grid-api='$ctrl.gridApi')
                 .panel-selected(ng-show='$ctrl.selected.length')
-                    | {{ $ctrl.selected.length }} item{{ $ctrl.selected.length > 1 ? 's' : '' }} selected            
+                    grid-item-selected(grid-api='$ctrl.gridApi')
 
         .panel-collapse
             .grid.ui-grid--ignite.ui-grid-disabled-group-selection(ui-grid='$ctrl.gridOptions' ui-grid-resize-columns ui-grid-selection ui-grid-exporter ui-grid-pinning ui-grid-grouping)


[33/47] ignite git commit: IGNITE-5729 - Fixed TCK tests

Posted by ag...@apache.org.
IGNITE-5729 - Fixed TCK tests


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

Branch: refs/heads/master
Commit: 39f7c03ea45280bc8d1fbaf461933141b2f03506
Parents: f975110
Author: Pavel Kovalenko <jo...@gmail.com>
Authored: Fri Jul 28 17:06:50 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Fri Jul 28 17:07:02 2017 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheProcessor.java        | 16 +++++++---------
 .../processors/cache/IgniteCacheProxyImpl.java      | 14 ++++++++++++++
 2 files changed, 21 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/39f7c03e/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 bbd7500..3406f48 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
@@ -3215,8 +3215,8 @@ public class GridCacheProcessor extends GridProcessorAdapter {
      */
     public Collection<IgniteCacheProxy<?, ?>> jcaches() {
         return F.viewReadOnly(jCacheProxies.values(), new IgniteClosure<IgniteCacheProxyImpl<?, ?>, IgniteCacheProxy<?, ?>>() {
-            @Override public IgniteCacheProxy<?, ?> apply(IgniteCacheProxyImpl<?, ?> entry) {
-                return new GatewayProtectedCacheProxy<>(entry, new CacheOperationContext(), true);
+            @Override public IgniteCacheProxy<?, ?> apply(IgniteCacheProxyImpl<?, ?> proxy) {
+                return proxy.gatewayWrapper();
             }
         });
     }
@@ -3315,7 +3315,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
         if (desc != null && !desc.cacheType().userCache())
             throw new IllegalStateException("Failed to get cache because it is a system cache: " + cacheName);
 
-        IgniteCacheProxy<?, ?> cache = jCacheProxies.get(cacheName);
+        IgniteCacheProxyImpl<?, ?> cache = jCacheProxies.get(cacheName);
 
         // Try to start cache, there is no guarantee that cache will be instantiated.
         if (cache == null) {
@@ -3324,9 +3324,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
             cache = jCacheProxies.get(cacheName);
         }
 
-        return cache != null ?
-            new GatewayProtectedCacheProxy<>((IgniteCacheProxy<K, V>)cache, new CacheOperationContext(), true) :
-            null;
+        return cache != null ? (IgniteCacheProxy<K, V>) cache.gatewayWrapper() : null;
     }
 
     /**
@@ -3465,9 +3463,9 @@ public class GridCacheProcessor extends GridProcessorAdapter {
     public Collection<IgniteCacheProxy<?, ?>> publicCaches() {
         Collection<IgniteCacheProxy<?, ?>> res = new ArrayList<>(jCacheProxies.size());
 
-        for (Map.Entry<String, IgniteCacheProxyImpl<?, ?>> entry : jCacheProxies.entrySet()) {
-            if (entry.getValue().context().userCache())
-                res.add(new GatewayProtectedCacheProxy(entry.getValue(), new CacheOperationContext(), true));
+        for (IgniteCacheProxyImpl<?, ?> proxy : jCacheProxies.values()) {
+            if (proxy.context().userCache())
+                res.add(proxy.gatewayWrapper());
         }
 
         return res;

http://git-wip-us.apache.org/repos/asf/ignite/blob/39f7c03e/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyImpl.java
index 0bc3ba2..ef351ef 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyImpl.java
@@ -113,6 +113,9 @@ public class IgniteCacheProxyImpl<K, V> extends AsyncSupportAdapter<IgniteCache<
     @GridToStringInclude
     private volatile IgniteInternalCache<K, V> delegate;
 
+    /** Cached proxy wrapper. */
+    private volatile IgniteCacheProxy<K, V> cachedProxy;
+
     /** */
     @GridToStringExclude
     private CacheManager cacheMgr;
@@ -178,6 +181,17 @@ public class IgniteCacheProxyImpl<K, V> extends AsyncSupportAdapter<IgniteCache<
         return new GatewayProtectedCacheProxy<>(this, new CacheOperationContext(), false);
     }
 
+    /**
+     * @return Default cached proxy wrapper {@link GatewayProtectedCacheProxy}.
+     */
+    public IgniteCacheProxy<K, V> gatewayWrapper() {
+        if (cachedProxy != null)
+            return cachedProxy;
+
+        cachedProxy = new GatewayProtectedCacheProxy<>(this, new CacheOperationContext(), true);
+        return cachedProxy;
+    }
+
     /** {@inheritDoc} */
     @Override public CacheMetrics metrics() {
         return ctx.cache().clusterMetrics();


[05/47] ignite git commit: Failing flaky test with link to ticket number

Posted by ag...@apache.org.
Failing flaky test with link to ticket number


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

Branch: refs/heads/master
Commit: a790dface730eae11f98c6b6f74232f0ec32cf6b
Parents: 7915fd8
Author: Ivan Rakov <iv...@gmail.com>
Authored: Wed Jul 26 13:41:33 2017 +0300
Committer: Ivan Rakov <iv...@gmail.com>
Committed: Wed Jul 26 13:41:33 2017 +0300

----------------------------------------------------------------------
 .../cache/persistence/db/IgnitePdsWholeClusterRestartTest.java     | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/a790dfac/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsWholeClusterRestartTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsWholeClusterRestartTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsWholeClusterRestartTest.java
index c8ec304..1cdfaea 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsWholeClusterRestartTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsWholeClusterRestartTest.java
@@ -118,6 +118,8 @@ public class IgnitePdsWholeClusterRestartTest extends GridCommonAbstractTest {
      * @throws Exception if failed.
      */
     public void testRestarts() throws Exception {
+        fail("https://issues.apache.org/jira/browse/IGNITE-5741");
+
         startGrids(GRID_CNT);
 
         ignite(0).active(true);


[22/47] ignite git commit: IGNITE-5865 Fail test with known issue

Posted by ag...@apache.org.
IGNITE-5865 Fail test with known issue


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

Branch: refs/heads/master
Commit: a57a851dd34c296b3b8b919c6f846dfe68192ea1
Parents: 6031ed8
Author: Pavel Kovalenko <jo...@gmail.com>
Authored: Fri Jul 28 13:32:26 2017 +0300
Committer: Pavel Kovalenko <jo...@gmail.com>
Committed: Fri Jul 28 13:32:26 2017 +0300

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


http://git-wip-us.apache.org/repos/asf/ignite/blob/a57a851d/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxOptimisticDeadlockDetectionTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxOptimisticDeadlockDetectionTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxOptimisticDeadlockDetectionTest.java
index 1573576..1ee3faa 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxOptimisticDeadlockDetectionTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxOptimisticDeadlockDetectionTest.java
@@ -148,6 +148,7 @@ public class TxOptimisticDeadlockDetectionTest extends GridCommonAbstractTest {
      * @throws Exception If failed.
      */
     public void testDeadlocksPartitioned() throws Exception {
+        fail("IGNITE-5865");
         for (CacheWriteSynchronizationMode syncMode : CacheWriteSynchronizationMode.values()) {
             doTestDeadlocks(createCache(PARTITIONED, syncMode, false), NO_OP_TRANSFORMER);
             doTestDeadlocks(createCache(PARTITIONED, syncMode, false), WRAPPING_TRANSFORMER);
@@ -158,6 +159,7 @@ public class TxOptimisticDeadlockDetectionTest extends GridCommonAbstractTest {
      * @throws Exception If failed.
      */
     public void testDeadlocksPartitionedNear() throws Exception {
+        fail("IGNITE-5865");
         for (CacheWriteSynchronizationMode syncMode : CacheWriteSynchronizationMode.values()) {
             doTestDeadlocks(createCache(PARTITIONED, syncMode, true), NO_OP_TRANSFORMER);
             doTestDeadlocks(createCache(PARTITIONED, syncMode, true), WRAPPING_TRANSFORMER);


[12/47] ignite git commit: IGNITE-5729 - IgniteCacheProxy instances from with() methods are not reusable after cache restart

Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/5172541f/modules/core/src/test/java/org/apache/ignite/marshaller/GridMarshallerAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/marshaller/GridMarshallerAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/marshaller/GridMarshallerAbstractTest.java
index 66f0d72..05a8924 100644
--- a/modules/core/src/test/java/org/apache/ignite/marshaller/GridMarshallerAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/marshaller/GridMarshallerAbstractTest.java
@@ -56,7 +56,7 @@ import org.apache.ignite.internal.IgniteServicesImpl;
 import org.apache.ignite.internal.cluster.ClusterGroupAdapter;
 import org.apache.ignite.internal.cluster.ClusterNodeLocalMapImpl;
 import org.apache.ignite.internal.executor.GridExecutorService;
-import org.apache.ignite.internal.processors.cache.IgniteCacheProxy;
+import org.apache.ignite.internal.processors.cache.GatewayProtectedCacheProxy;
 import org.apache.ignite.internal.processors.service.DummyService;
 import org.apache.ignite.internal.util.GridByteArrayList;
 import org.apache.ignite.internal.util.typedef.F;
@@ -171,8 +171,8 @@ public abstract class GridMarshallerAbstractTest extends GridCommonAbstractTest
         assert inBean.getObjectField() != null;
         assert outBean.getObjectField() != null;
 
-        assert inBean.getObjectField().getClass().equals(IgniteCacheProxy.class);
-        assert outBean.getObjectField().getClass().equals(IgniteCacheProxy.class);
+        assert inBean.getObjectField().getClass().equals(GatewayProtectedCacheProxy.class);
+        assert outBean.getObjectField().getClass().equals(GatewayProtectedCacheProxy.class);
 
         assert inBean != outBean;
 
@@ -201,8 +201,8 @@ public abstract class GridMarshallerAbstractTest extends GridCommonAbstractTest
         assert inBean.getObjectField() != null;
         assert outBean.getObjectField() != null;
 
-        assert inBean.getObjectField().getClass().equals(IgniteCacheProxy.class);
-        assert outBean.getObjectField().getClass().equals(IgniteCacheProxy.class);
+        assert inBean.getObjectField().getClass().equals(GatewayProtectedCacheProxy.class);
+        assert outBean.getObjectField().getClass().equals(GatewayProtectedCacheProxy.class);
 
         assert inBean != outBean;
 


[34/47] ignite git commit: IGNITE-5729 Correct handling CacheStoppedException in IgniteCacheProxyImpl.

Posted by ag...@apache.org.
IGNITE-5729 Correct handling CacheStoppedException in IgniteCacheProxyImpl.


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

Branch: refs/heads/master
Commit: 1b7606ce8beaa42bc5db740e5af9cb4d98681b4c
Parents: f975110
Author: Pavel Kovalenko <jo...@gmail.com>
Authored: Fri Jul 28 17:13:30 2017 +0300
Committer: Pavel Kovalenko <jo...@gmail.com>
Committed: Fri Jul 28 17:13:30 2017 +0300

----------------------------------------------------------------------
 .../ignite/internal/processors/cache/IgniteCacheProxyImpl.java    | 3 +++
 1 file changed, 3 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/1b7606ce/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyImpl.java
index 0bc3ba2..f2c2cf7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyImpl.java
@@ -1657,6 +1657,9 @@ public class IgniteCacheProxyImpl<K, V> extends AsyncSupportAdapter<IgniteCache<
         if (e instanceof IgniteCheckedException)
             return CU.convertToCacheException((IgniteCheckedException) e);
 
+        if (X.hasCause(e, CacheStoppedException.class))
+            return CU.convertToCacheException(X.cause(e, CacheStoppedException.class));
+
         if (e instanceof RuntimeException)
             return (RuntimeException) e;
 


[45/47] ignite git commit: IGNITE-5734 Web Console: Fixed transition.

Posted by ag...@apache.org.
IGNITE-5734 Web Console: Fixed transition.


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

Branch: refs/heads/master
Commit: 4d323f374670af277a4c37ee91fe49273bd95d91
Parents: 0376c48
Author: Andrey Novikov <an...@gridgain.com>
Authored: Tue Aug 1 14:27:49 2017 +0700
Committer: Andrey Novikov <an...@gridgain.com>
Committed: Tue Aug 1 14:27:49 2017 +0700

----------------------------------------------------------------------
 modules/web-console/backend/middlewares/api.js  | 38 +++++++++++---------
 .../frontend/app/modules/user/user.module.js    |  2 +-
 2 files changed, 22 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/4d323f37/modules/web-console/backend/middlewares/api.js
----------------------------------------------------------------------
diff --git a/modules/web-console/backend/middlewares/api.js b/modules/web-console/backend/middlewares/api.js
index 9c6395e..2c4c1bd 100644
--- a/modules/web-console/backend/middlewares/api.js
+++ b/modules/web-console/backend/middlewares/api.js
@@ -21,24 +21,28 @@
 
 module.exports = {
     implements: 'middlewares:api',
-    factory: () => {
-        return (req, res, next) => {
-            res.api = {
-                error(err) {
-                    // TODO: removed code from error
-                    res.status(err.httpCode || err.code || 500).send(err.message);
-                },
-                ok(data) {
-                    res.status(200).json(data);
-                },
-                serverError(err) {
-                    err.httpCode = 500;
+    inject: ['require("mongodb-core")']
+};
+
+module.exports.factory = (mongodb) => {
+    return (req, res, next) => {
+        res.api = {
+            error(err) {
+                if (err instanceof mongodb.MongoError)
+                    res.status(500).send(err.message);
 
-                    res.api.error(err);
-                }
-            };
+                res.status(err.httpCode || err.code || 500).send(err.message);
+            },
+            ok(data) {
+                res.status(200).json(data);
+            },
+            serverError(err) {
+                err.httpCode = 500;
 
-            next();
+                res.api.error(err);
+            }
         };
-    }
+
+        next();
+    };
 };

http://git-wip-us.apache.org/repos/asf/ignite/blob/4d323f37/modules/web-console/frontend/app/modules/user/user.module.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/user/user.module.js b/modules/web-console/frontend/app/modules/user/user.module.js
index cac8943..5cd8bc5 100644
--- a/modules/web-console/frontend/app/modules/user/user.module.js
+++ b/modules/web-console/frontend/app/modules/user/user.module.js
@@ -35,7 +35,7 @@ angular.module('ignite-console.user', [
 
                 const stateName = $injector.get('$uiRouterGlobals').current.name;
 
-                if (stateName !== 'signin')
+                if (!_.includes(['', 'signin'], stateName))
                     $injector.get('$state').go('signin');
             }
 


[28/47] ignite git commit: IGNITE-5729 Fixed .NET CacheQueriesTest.

Posted by ag...@apache.org.
IGNITE-5729 Fixed .NET CacheQueriesTest.


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

Branch: refs/heads/master
Commit: 4de9eb1fdab90543a0a1a56ad481fafd1a24c294
Parents: a57a851
Author: Pavel Kovalenko <jo...@gmail.com>
Authored: Fri Jul 28 16:07:43 2017 +0300
Committer: Pavel Kovalenko <jo...@gmail.com>
Committed: Fri Jul 28 16:07:43 2017 +0300

----------------------------------------------------------------------
 .../Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs      | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/4de9eb1f/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
index ae2fe8f..500c3fb 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
@@ -489,7 +489,8 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
             // SQL query.
             err = Assert.Throws<IgniteException>(() => cache.Query(new SqlQuery(typeof(QueryPerson), "age < 50")));
 
-            Assert.AreEqual("Failed to find SQL table for type: QueryPerson", err.Message);
+            Assert.AreEqual("Indexing is disabled for cache: nonindexed_cache. " +
+                "Use setIndexedTypes or setTypeMetadata methods on CacheConfiguration to enable.", err.Message);
         }
 
         /// <summary>


[29/47] ignite git commit: Merge branch 'ignite-2.1.3' of https://github.com/gridgain/apache-ignite into ignite-2.1.3

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


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

Branch: refs/heads/master
Commit: 430bf06adbc3e154a870571da3ed0ae7326d0950
Parents: 4de9eb1 1d4cda9
Author: Pavel Kovalenko <jo...@gmail.com>
Authored: Fri Jul 28 16:08:04 2017 +0300
Committer: Pavel Kovalenko <jo...@gmail.com>
Committed: Fri Jul 28 16:08:04 2017 +0300

----------------------------------------------------------------------
 .../IgniteDiagnosticPrepareContext.java         |   3 +-
 .../apache/ignite/internal/IgniteKernal.java    |   3 +-
 .../mem/file/MappedFileMemoryProvider.java      |   3 +-
 .../GridCachePartitionExchangeManager.java      |   2 +-
 .../GridDhtPartitionsExchangeFuture.java        |  20 +--
 .../GridCacheDatabaseSharedManager.java         |   7 +-
 .../persistence/freelist/FreeListImpl.java      |  18 +--
 .../reader/StandaloneWalRecordsIterator.java    |   4 +-
 .../cluster/GridClusterStateProcessor.java      |   3 +-
 .../datastructures/GridCacheLockImpl.java       |  13 +-
 .../processors/odbc/SqlListenerProcessor.java   |   3 +-
 .../ignite/internal/util/nio/GridNioServer.java |   7 +-
 .../ignite/spi/discovery/tcp/ServerImpl.java    |  38 +++---
 .../IgnitePdsCacheRebalancingAbstractTest.java  |   2 +
 .../ignite/tests/p2p/JobStealingTask.java       |  12 +-
 .../hadoop/jobtracker/HadoopJobTracker.java     |  24 ++--
 .../hadoop/shuffle/HadoopShuffleJob.java        |   5 +-
 .../processors/query/h2/IgniteH2Indexing.java   |  21 ++-
 .../cache/index/H2DynamicTableSelfTest.java     |  32 +++++
 .../apache/ignite/stream/mqtt/MqttStreamer.java |   6 +-
 .../include/ignite/binary/binary_writer.h       |   4 +-
 .../ignite/impl/binary/binary_reader_impl.h     |  50 ++++---
 .../ignite/impl/binary/binary_type_impl.h       |  67 +++++++++
 .../ignite/impl/binary/binary_writer_impl.h     |  43 ++++--
 .../src/impl/binary/binary_reader_impl.cpp      |  63 ++++-----
 .../src/impl/binary/binary_writer_impl.cpp      |  41 +++---
 .../src/binary_reader_writer_raw_test.cpp       |  36 +++++
 .../core-test/src/binary_reader_writer_test.cpp | 135 ++++++++++++++-----
 .../cpp/core/include/ignite/impl/ignite_impl.h  |   1 -
 .../platforms/cpp/core/src/impl/ignite_impl.cpp |   4 +
 .../spi/deployment/uri/UriDeploymentSpi.java    |   3 +-
 modules/web-console/frontend/app/app.js         |   2 +
 .../components/grid-item-selected/component.js  |  28 ++++
 .../components/grid-item-selected/controller.js |  38 ++++++
 .../app/components/grid-item-selected/index.js  |  24 ++++
 .../components/grid-item-selected/template.pug  |  17 +++
 .../list-of-registered-users.tpl.pug            |   2 +-
 37 files changed, 585 insertions(+), 199 deletions(-)
----------------------------------------------------------------------



[40/47] ignite git commit: IGNITE-5793 - Fixed infinite TTL expire on cache gateway leave

Posted by ag...@apache.org.
IGNITE-5793 - Fixed infinite TTL expire on cache gateway leave


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

Branch: refs/heads/master
Commit: 355e8e83d0efcc2fcaacc8edc977b82b39c14d4e
Parents: 6cff481
Author: Ivan Rakov <iv...@gmail.com>
Authored: Mon Jul 31 10:37:11 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Mon Jul 31 10:37:11 2017 +0300

----------------------------------------------------------------------
 .../apache/ignite/IgniteSystemProperties.java   |  6 +++++
 .../processors/cache/GridCacheUtils.java        |  7 +++++-
 .../cache/IgniteCacheOffheapManagerImpl.java    | 26 ++++++++++++--------
 3 files changed, 28 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/355e8e83/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
index 264fb4b..2fa52b6 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
@@ -614,6 +614,12 @@ public final class IgniteSystemProperties {
     public static final String IGNITE_REBALANCE_STATISTICS_TIME_INTERVAL = "IGNITE_REBALANCE_STATISTICS_TIME_INTERVAL";
 
     /**
+     * When cache has entries with expired TTL, each user operation will also remove this amount of expired entries.
+     * Defaults to {@code 5}.
+     */
+    public static final String IGNITE_TTL_EXPIRE_BATCH_SIZE = "IGNITE_TTL_EXPIRE_BATCH_SIZE";
+
+    /**
      * Indexing discovery history size. Protects from duplicate messages maintaining the list of IDs of recently
      * arrived discovery messages.
      * <p>

http://git-wip-us.apache.org/repos/asf/ignite/blob/355e8e83/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
index c93b224..a07b166 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
@@ -42,6 +42,7 @@ import org.apache.ignite.IgniteCache;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.IgniteSystemProperties;
 import org.apache.ignite.cache.CacheAtomicUpdateTimeoutException;
 import org.apache.ignite.cache.CachePartialUpdateException;
 import org.apache.ignite.cache.CacheServerNotFoundException;
@@ -107,6 +108,10 @@ public class GridCacheUtils {
     /** Cheat cache ID for debugging and benchmarking purposes. */
     public static final int cheatCacheId;
 
+    /** Each cache operation removes this amount of entries with expired TTL. */
+    private static final int TTL_BATCH_SIZE = IgniteSystemProperties.getInteger(
+        IgniteSystemProperties.IGNITE_TTL_EXPIRE_BATCH_SIZE, 5);
+
     /*
      *
      */
@@ -851,7 +856,7 @@ public class GridCacheUtils {
     public static void unwindEvicts(GridCacheContext ctx) {
         assert ctx != null;
 
-        ctx.ttl().expire();
+        ctx.ttl().expire(TTL_BATCH_SIZE);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/355e8e83/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 6d16b60..ba6c89d 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
@@ -975,30 +975,35 @@ public class IgniteCacheOffheapManagerImpl implements IgniteCacheOffheapManager
         assert !cctx.isNear() : cctx.name();
 
         if (hasPendingEntries && pendingEntries != null) {
-            cctx.shared().database().checkpointReadLock();
-
-            try {
-                GridCacheVersion obsoleteVer = null;
+            GridCacheVersion obsoleteVer = null;
 
-                long now = U.currentTimeMillis();
+            long now = U.currentTimeMillis();
 
-                GridCursor<PendingRow> cur;
+            GridCursor<PendingRow> cur;
 
             if (grp.sharedGroup())
                 cur = pendingEntries.find(new PendingRow(cctx.cacheId()), new PendingRow(cctx.cacheId(), now, 0));
             else
                 cur = pendingEntries.find(null, new PendingRow(UNDEFINED_CACHE_ID, now, 0));
 
-                int cleared = 0;
+            if (!cur.next())
+                return false;
+
+            int cleared = 0;
 
-                while (cur.next()) {
+            cctx.shared().database().checkpointReadLock();
+
+            try {
+                do {
                     PendingRow row = cur.get();
 
                     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 (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.removex(row)) {
                         if (obsoleteVer == null)
@@ -1009,6 +1014,7 @@ public class IgniteCacheOffheapManagerImpl implements IgniteCacheOffheapManager
 
                     cleared++;
                 }
+                while (cur.next());
             }
             finally {
                 cctx.shared().database().checkpointReadUnlock();


[39/47] ignite git commit: IGNITE-5816 - Fixed race in WAL segment close leading to ClosedChannelException

Posted by ag...@apache.org.
IGNITE-5816 - Fixed race in WAL segment close leading to ClosedChannelException


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

Branch: refs/heads/master
Commit: 6cff4811636209ce39b1e2097b5a14233ee08413
Parents: 97813a8
Author: Ivan Rakov <iv...@gmail.com>
Authored: Fri Jul 28 19:54:07 2017 +0300
Committer: Ivan Rakov <iv...@gmail.com>
Committed: Fri Jul 28 19:54:25 2017 +0300

----------------------------------------------------------------------
 .../cache/persistence/wal/FileWriteAheadLogManager.java         | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/6cff4811/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java
index 85eb480..17db8f8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java
@@ -1881,7 +1881,7 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl
             if (expHead.previous() == null) {
                 FakeRecord frHead = (FakeRecord)expHead;
 
-                if (stop == frHead.stop)
+                if (!stop || frHead.stop) // Protects from CASing terminal FakeRecord(true) to FakeRecord(false)
                     return false;
             }
 
@@ -1891,6 +1891,9 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl
             if (!head.compareAndSet(expHead, new FakeRecord(new FileWALPointer(idx, (int)nextPosition(expHead), 0), stop)))
                 return false;
 
+            if (expHead.chainSize() == 0)
+                return false;
+
             // At this point we grabbed the piece of WAL chain.
             // Any failure in this code must invalidate the environment.
             try {


[25/47] ignite git commit: IGNITE-5448 - Fixed IgniteH2Indexing::tables implementation - Fixes #2254.

Posted by ag...@apache.org.
IGNITE-5448 - Fixed IgniteH2Indexing::tables implementation - Fixes #2254.

Signed-off-by: Alexey Goncharuk <al...@gmail.com>


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

Branch: refs/heads/master
Commit: 99584fedfa79edaced02625a92e84362fc436f1c
Parents: 1ea2da9
Author: Alexander Paschenko <al...@gmail.com>
Authored: Fri Jul 28 14:44:34 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Fri Jul 28 14:44:34 2017 +0300

----------------------------------------------------------------------
 .../processors/query/h2/IgniteH2Indexing.java   | 21 ++++++++-----
 .../cache/index/H2DynamicTableSelfTest.java     | 32 ++++++++++++++++++++
 2 files changed, 46 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/99584fed/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 40eae17..007eeb1 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
@@ -66,14 +66,14 @@ import org.apache.ignite.internal.processors.cache.CacheObjectValueContext;
 import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
 import org.apache.ignite.internal.processors.cache.GridCacheAffinityManager;
 import org.apache.ignite.internal.processors.cache.GridCacheContext;
+import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
+import org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException;
 import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
 import org.apache.ignite.internal.processors.cache.IgniteCacheOffheapManager;
 import org.apache.ignite.internal.processors.cache.KeyCacheObject;
-import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
-import org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException;
 import org.apache.ignite.internal.processors.cache.QueryCursorImpl;
-import org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtInvalidPartitionException;
+import org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO;
 import org.apache.ignite.internal.processors.cache.query.CacheQueryPartitionInfo;
 import org.apache.ignite.internal.processors.cache.query.GridCacheQueryMarshallable;
 import org.apache.ignite.internal.processors.cache.query.GridCacheTwoStepQuery;
@@ -92,14 +92,14 @@ import org.apache.ignite.internal.processors.query.GridRunningQueryInfo;
 import org.apache.ignite.internal.processors.query.IgniteSQLException;
 import org.apache.ignite.internal.processors.query.QueryIndexDescriptorImpl;
 import org.apache.ignite.internal.processors.query.QueryUtils;
-import org.apache.ignite.internal.processors.query.h2.ddl.DdlStatementsProcessor;
-import org.apache.ignite.internal.processors.query.h2.opt.DistributedJoinMode;
 import org.apache.ignite.internal.processors.query.h2.database.H2RowFactory;
 import org.apache.ignite.internal.processors.query.h2.database.H2TreeIndex;
 import org.apache.ignite.internal.processors.query.h2.database.io.H2ExtrasInnerIO;
 import org.apache.ignite.internal.processors.query.h2.database.io.H2ExtrasLeafIO;
 import org.apache.ignite.internal.processors.query.h2.database.io.H2InnerIO;
 import org.apache.ignite.internal.processors.query.h2.database.io.H2LeafIO;
+import org.apache.ignite.internal.processors.query.h2.ddl.DdlStatementsProcessor;
+import org.apache.ignite.internal.processors.query.h2.opt.DistributedJoinMode;
 import org.apache.ignite.internal.processors.query.h2.opt.GridH2DefaultTableEngine;
 import org.apache.ignite.internal.processors.query.h2.opt.GridH2IndexBase;
 import org.apache.ignite.internal.processors.query.h2.opt.GridH2QueryContext;
@@ -1687,7 +1687,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
     }
 
     /** {@inheritDoc} */
-    @Override  public String schema(String cacheName) {
+    @Override public String schema(String cacheName) {
         String res = cacheName2schema.get(cacheName);
 
         if (res == null)
@@ -1708,7 +1708,14 @@ public class IgniteH2Indexing implements GridQueryIndexing {
         if (s == null)
             return Collections.emptySet();
 
-        return s.tables();
+        List<H2TableDescriptor> tbls = new ArrayList<>();
+
+        for (H2TableDescriptor tbl : s.tables()) {
+            if (F.eq(tbl.cache().name(), cacheName))
+                tbls.add(tbl);
+        }
+
+        return tbls;
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/99584fed/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicTableSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicTableSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicTableSelfTest.java
index b0e69f1..d737a0f 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicTableSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicTableSelfTest.java
@@ -47,6 +47,7 @@ import org.apache.ignite.internal.processors.query.GridQueryTypeDescriptor;
 import org.apache.ignite.internal.processors.query.IgniteSQLException;
 import org.apache.ignite.internal.processors.query.QueryTypeDescriptorImpl;
 import org.apache.ignite.internal.processors.query.QueryUtils;
+import org.apache.ignite.internal.processors.query.h2.H2TableDescriptor;
 import org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing;
 import org.apache.ignite.internal.processors.query.h2.ddl.DdlStatementsProcessor;
 import org.apache.ignite.internal.processors.query.h2.opt.GridH2Table;
@@ -834,6 +835,37 @@ public class H2DynamicTableSelfTest extends AbstractSchemaSelfTest {
     }
 
     /**
+     * Test that {@link IgniteH2Indexing#tables(String)} method
+     * only returns tables belonging to given cache.
+     *
+     * @throws Exception if failed.
+     */
+    public void testGetTablesForCache() throws Exception {
+        try {
+            execute("create table t1(id int primary key, name varchar)");
+            execute("create table t2(id int primary key, name varchar)");
+
+            IgniteH2Indexing h2Idx = (IgniteH2Indexing)grid(0).context().query().getIndexing();
+
+            String cacheName = cacheName("T1");
+
+            Collection<H2TableDescriptor> col = GridTestUtils.invoke(h2Idx, "tables", cacheName);
+
+            assertNotNull(col);
+
+            H2TableDescriptor[] tables = col.toArray(new H2TableDescriptor[col.size()]);
+
+            assertEquals(1, tables.length);
+
+            assertEquals(tables[0].table().getName(), "T1");
+        }
+        finally {
+            execute("drop table t1 if exists");
+            execute("drop table t2 if exists");
+        }
+    }
+
+    /**
      * Execute DDL statement on client node.
      *
      * @param sql Statement.


[35/47] ignite git commit: Merge branch 'ignite-2.1.3' of https://github.com/gridgain/apache-ignite into ignite-2.1.3

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


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

Branch: refs/heads/master
Commit: c685e39650ee8a075672f86721a7145af8f52fb8
Parents: 1b7606c 39f7c03
Author: Pavel Kovalenko <jo...@gmail.com>
Authored: Fri Jul 28 17:13:54 2017 +0300
Committer: Pavel Kovalenko <jo...@gmail.com>
Committed: Fri Jul 28 17:13:54 2017 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheProcessor.java        | 16 +++++++---------
 .../processors/cache/IgniteCacheProxyImpl.java      | 14 ++++++++++++++
 2 files changed, 21 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


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


[14/47] ignite git commit: IGNITE-5729 - IgniteCacheProxy instances from with() methods are not reusable after cache restart

Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/5172541f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
index 347e030..22bd676 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
@@ -18,2483 +18,25 @@
 package org.apache.ignite.internal.processors.cache;
 
 import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.Collection;
-import java.util.Collections;
 import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.NoSuchElementException;
-import java.util.Set;
 import java.util.UUID;
-import java.util.concurrent.atomic.AtomicReference;
-import java.util.concurrent.locks.Lock;
-import javax.cache.Cache;
-import javax.cache.CacheException;
-import javax.cache.configuration.CacheEntryListenerConfiguration;
-import javax.cache.configuration.Configuration;
-import javax.cache.expiry.ExpiryPolicy;
-import javax.cache.integration.CompletionListener;
-import javax.cache.processor.EntryProcessor;
-import javax.cache.processor.EntryProcessorException;
-import javax.cache.processor.EntryProcessorResult;
 import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteCacheRestartingException;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.cache.CacheEntry;
-import org.apache.ignite.cache.CacheEntryProcessor;
-import org.apache.ignite.cache.CacheManager;
-import org.apache.ignite.cache.CacheMetrics;
-import org.apache.ignite.cache.CachePeekMode;
-import org.apache.ignite.cache.query.ContinuousQuery;
-import org.apache.ignite.cache.query.FieldsQueryCursor;
-import org.apache.ignite.cache.query.Query;
-import org.apache.ignite.cache.query.QueryCursor;
-import org.apache.ignite.cache.query.QueryDetailMetrics;
-import org.apache.ignite.cache.query.QueryMetrics;
-import org.apache.ignite.cache.query.ScanQuery;
-import org.apache.ignite.cache.query.SpiQuery;
-import org.apache.ignite.cache.query.SqlFieldsQuery;
-import org.apache.ignite.cache.query.SqlQuery;
-import org.apache.ignite.cache.query.TextQuery;
-import org.apache.ignite.cluster.ClusterGroup;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.internal.AsyncSupportAdapter;
-import org.apache.ignite.internal.IgniteEx;
-import org.apache.ignite.internal.IgniteInternalFuture;
-import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
-import org.apache.ignite.internal.processors.cache.query.CacheQuery;
-import org.apache.ignite.internal.processors.cache.query.CacheQueryFuture;
-import org.apache.ignite.internal.processors.cache.query.GridCacheQueryType;
-import org.apache.ignite.internal.processors.query.QueryUtils;
-import org.apache.ignite.internal.util.GridCloseableIteratorAdapter;
-import org.apache.ignite.internal.util.GridEmptyIterator;
-import org.apache.ignite.internal.util.future.GridFutureAdapter;
-import org.apache.ignite.internal.util.future.IgniteFinishedFutureImpl;
-import org.apache.ignite.internal.util.future.IgniteFutureImpl;
-import org.apache.ignite.internal.util.lang.GridCloseableIterator;
-import org.apache.ignite.internal.util.lang.GridClosureException;
-import org.apache.ignite.internal.util.lang.IgniteOutClosureX;
-import org.apache.ignite.internal.util.tostring.GridToStringExclude;
-import org.apache.ignite.internal.util.tostring.GridToStringInclude;
-import org.apache.ignite.internal.util.typedef.CI1;
-import org.apache.ignite.internal.util.typedef.CX1;
-import org.apache.ignite.internal.util.typedef.internal.A;
-import org.apache.ignite.internal.util.typedef.internal.CU;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.lang.IgniteBiPredicate;
-import org.apache.ignite.lang.IgniteClosure;
+import org.apache.ignite.lang.IgniteAsyncSupport;
 import org.apache.ignite.lang.IgniteFuture;
-import org.apache.ignite.lang.IgniteInClosure;
-import org.apache.ignite.mxbean.CacheMetricsMXBean;
-import org.apache.ignite.plugin.security.SecurityPermission;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Cache proxy.
- */
-@SuppressWarnings("unchecked")
-public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V>>
-    implements IgniteCache<K, V>, Externalizable {
-    /** */
-    private static final long serialVersionUID = 0L;
-
-    /** Context. */
-    private volatile GridCacheContext<K, V> ctx;
-
-    /** Gateway. */
-    private volatile GridCacheGateway<K, V> gate;
-
-    /** Delegate. */
-    @GridToStringInclude
-    private volatile IgniteInternalCache<K, V> delegate;
-
-    /** Operation context. */
-    private CacheOperationContext opCtx;
-
-    /** */
-    @GridToStringExclude
-    private GridCacheProxyImpl<K, V> internalProxy;
-
-    /** */
-    @GridToStringExclude
-    private CacheManager cacheMgr;
-
-    /** If {@code false} does not acquire read lock on gateway enter. */
-    @GridToStringExclude
-    private boolean lock;
-
-    /** */
-    private final AtomicReference<GridFutureAdapter<Void>> restartFut = new AtomicReference<>(null);
-
-    /**
-     * Empty constructor required for {@link Externalizable}.
-     */
-    public IgniteCacheProxy() {
-        // No-op.
-    }
-
-    /**
-     * @param ctx Context.
-     * @param delegate Delegate.
-     * @param opCtx Operation context.
-     * @param async Async support flag.
-     */
-    public IgniteCacheProxy(
-        GridCacheContext<K, V> ctx,
-        IgniteInternalCache<K, V> delegate,
-        CacheOperationContext opCtx,
-        boolean async
-    ) {
-        this(ctx, delegate, opCtx, async, true);
-    }
-
-    /**
-     * @param ctx Context.
-     * @param delegate Delegate.
-     * @param opCtx Operation context.
-     * @param async Async support flag.
-     * @param lock If {@code false} does not acquire read lock on gateway enter.
-     */
-    private IgniteCacheProxy(
-        GridCacheContext<K, V> ctx,
-        IgniteInternalCache<K, V> delegate,
-        @Nullable CacheOperationContext opCtx,
-        boolean async,
-        boolean lock
-    ) {
-        super(async);
-
-        assert ctx != null;
-        assert delegate != null;
-
-        this.ctx = ctx;
-        this.delegate = delegate;
-        this.opCtx = opCtx;
-
-        gate = ctx.gate();
-
-        internalProxy = new GridCacheProxyImpl<>(ctx, delegate, opCtx);
-
-        this.lock = lock;
-    }
-
-    /**
-     * @return Operation context.
-     */
-    @Nullable public CacheOperationContext operationContext() {
-        return opCtx;
-    }
-
-    /**
-     * Gets cache proxy which does not acquire read lock on gateway enter, should be used only if grid read lock is
-     * externally acquired.
-     *
-     * @return Ignite cache proxy with simple gate.
-     */
-    public IgniteCacheProxy<K, V> cacheNoGate() {
-        return new IgniteCacheProxy<>(ctx, delegate, opCtx, isAsync(), false);
-    }
-
-    /**
-     * @return Context.
-     */
-    public GridCacheContext<K, V> context() {
-        return ctx;
-    }
-
-    /**
-     * @return Gateway.
-     */
-    public GridCacheGateway<K, V> gate() {
-        return gate;
-    }
-
-    /** {@inheritDoc} */
-    @Override public CacheMetrics metrics() {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            return ctx.cache().clusterMetrics();
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public CacheMetrics metrics(ClusterGroup grp) {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            return ctx.cache().clusterMetrics(grp);
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public CacheMetrics localMetrics() {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            return ctx.cache().localMetrics();
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public CacheMetricsMXBean mxBean() {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            return ctx.cache().clusterMxBean();
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public CacheMetricsMXBean localMxBean() {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            return ctx.cache().localMxBean();
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public <C extends Configuration<K, V>> C getConfiguration(Class<C> clazz) {
-        CacheConfiguration cfg = ctx.config();
-
-        if (!clazz.isAssignableFrom(cfg.getClass()))
-            throw new IllegalArgumentException();
-
-        return clazz.cast(cfg);
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteCache<K, V> withExpiryPolicy(ExpiryPolicy plc) {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            CacheOperationContext prj0 = opCtx != null ? opCtx.withExpiryPolicy(plc) :
-                new CacheOperationContext(false, null, false, plc, false, null, false);
-
-            return new IgniteCacheProxy<>(ctx, delegate, prj0, isAsync(), lock);
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteCache<K, V> withSkipStore() {
-        return skipStore();
-    }
-
-    /** {@inheritDoc} */
-    @Override public <K1, V1> IgniteCache<K1, V1> withKeepBinary() {
-        return keepBinary();
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteCache<K, V> withNoRetries() {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            boolean noRetries = opCtx != null && opCtx.noRetries();
-
-            if (noRetries)
-                return this;
-
-            CacheOperationContext opCtx0 = opCtx != null ? opCtx.setNoRetries(true) :
-                new CacheOperationContext(false, null, false, null, true, null, false);
-
-            return new IgniteCacheProxy<>(ctx,
-                delegate,
-                opCtx0,
-                isAsync(),
-                lock);
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteCache<K, V> withPartitionRecover() {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            boolean recovery = opCtx != null && opCtx.recovery();
-
-            if (recovery)
-                return this;
-
-            CacheOperationContext opCtx0 = opCtx != null ? opCtx.setRecovery(true) :
-                new CacheOperationContext(false, null, false, null, false, null, true);
-
-            return new IgniteCacheProxy<>(ctx,
-                delegate,
-                opCtx0,
-                isAsync(),
-                lock);
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public void loadCache(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args) {
-        try {
-            GridCacheGateway<K, V> gate = this.gate;
-
-            CacheOperationContext prev = onEnter(gate, opCtx);
-
-            try {
-                if (isAsync()) {
-                    if (ctx.cache().isLocal())
-                        setFuture(ctx.cache().localLoadCacheAsync(p, args));
-                    else
-                        setFuture(ctx.cache().globalLoadCacheAsync(p, args));
-                }
-                else {
-                    if (ctx.cache().isLocal())
-                        ctx.cache().localLoadCache(p, args);
-                    else
-                        ctx.cache().globalLoadCache(p, args);
-                }
-            }
-            finally {
-                onLeave(gate, prev);
-            }
-        }
-        catch (IgniteCheckedException e) {
-            throw cacheException(e);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteFuture<Void> loadCacheAsync(@Nullable IgniteBiPredicate<K, V> p,
-        @Nullable Object... args) throws CacheException {
-        try {
-            GridCacheGateway<K, V> gate = this.gate;
-
-            CacheOperationContext prev = onEnter(gate, opCtx);
-
-            try {
-                if (ctx.cache().isLocal())
-                    return (IgniteFuture<Void>)createFuture(ctx.cache().localLoadCacheAsync(p, args));
-                else
-                    return (IgniteFuture<Void>)createFuture(ctx.cache().globalLoadCacheAsync(p, args));
-            }
-            finally {
-                onLeave(gate, prev);
-            }
-        }
-        catch (IgniteCheckedException e) {
-            throw cacheException(e);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public void localLoadCache(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args) {
-        try {
-            GridCacheGateway<K, V> gate = this.gate;
-
-            CacheOperationContext prev = onEnter(gate, opCtx);
-
-            try {
-                if (isAsync())
-                    setFuture(delegate.localLoadCacheAsync(p, args));
-                else
-                    delegate.localLoadCache(p, args);
-            }
-            finally {
-                onLeave(gate, prev);
-            }
-        }
-        catch (IgniteCheckedException e) {
-            throw cacheException(e);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteFuture<Void> localLoadCacheAsync(@Nullable IgniteBiPredicate<K, V> p,
-        @Nullable Object... args) throws CacheException {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            return (IgniteFuture<Void>)createFuture(delegate.localLoadCacheAsync(p, args));
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Nullable @Override public V getAndPutIfAbsent(K key, V val) throws CacheException {
-        try {
-            GridCacheGateway<K, V> gate = this.gate;
-
-            CacheOperationContext prev = onEnter(gate, opCtx);
-
-            try {
-                if (isAsync()) {
-                    setFuture(delegate.getAndPutIfAbsentAsync(key, val));
-
-                    return null;
-                }
-                else
-                    return delegate.getAndPutIfAbsent(key, val);
-            }
-            finally {
-                onLeave(gate, prev);
-            }
-        }
-        catch (IgniteCheckedException e) {
-            throw cacheException(e);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteFuture<V> getAndPutIfAbsentAsync(K key, V val) throws CacheException {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            return createFuture(delegate.getAndPutIfAbsentAsync(key, val));
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public Lock lock(K key) throws CacheException {
-        return lockAll(Collections.singleton(key));
-    }
-
-    /** {@inheritDoc} */
-    @Override public Lock lockAll(final Collection<? extends K> keys) {
-        return new CacheLockImpl<>(gate, delegate, opCtx, keys);
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isLocalLocked(K key, boolean byCurrThread) {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            return byCurrThread ? delegate.isLockedByThread(key) : delegate.isLocked(key);
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /**
-     * @param scanQry ScanQry.
-     * @param transformer Transformer
-     * @param grp Optional cluster group.
-     * @return Cursor.
-     * @throws IgniteCheckedException If failed.
-     */
-    @SuppressWarnings("unchecked")
-    private <T, R> QueryCursor<R> query(
-        final ScanQuery scanQry,
-        @Nullable final IgniteClosure<T, R> transformer,
-        @Nullable ClusterGroup grp)
-        throws IgniteCheckedException {
-
-        final CacheQuery<R> qry;
-
-        boolean isKeepBinary = opCtx != null && opCtx.isKeepBinary();
-
-        IgniteBiPredicate<K, V> p = scanQry.getFilter();
-
-        qry = ctx.queries().createScanQuery(p, transformer, scanQry.getPartition(), isKeepBinary);
-
-        if (scanQry.getPageSize() > 0)
-            qry.pageSize(scanQry.getPageSize());
-
-        if (grp != null)
-            qry.projection(grp);
-
-        final GridCloseableIterator<R> iter = ctx.kernalContext().query().executeQuery(GridCacheQueryType.SCAN,
-            ctx.name(), ctx, new IgniteOutClosureX<GridCloseableIterator<R>>() {
-                @Override public GridCloseableIterator<R> applyx() throws IgniteCheckedException {
-                    final GridCloseableIterator iter0 = qry.executeScanQuery();
-
-                    final boolean needToConvert = transformer == null;
-
-                    return new GridCloseableIteratorAdapter<R>() {
-                        @Override protected R onNext() throws IgniteCheckedException {
-                            Object next = iter0.nextX();
-
-                            if (needToConvert) {
-                                Map.Entry<K, V> entry = (Map.Entry<K, V>)next;
-
-                                return (R)new CacheEntryImpl<>(entry.getKey(), entry.getValue());
-                            }
-
-                            return (R)next;
-                        }
-
-                        @Override protected boolean onHasNext() throws IgniteCheckedException {
-                            return iter0.hasNextX();
-                        }
-
-                        @Override protected void onClose() throws IgniteCheckedException {
-                            iter0.close();
-                        }
-                    };
-                }
-            }, true);
-
-        return new QueryCursorImpl<>(iter);
-    }
-
-    /**
-     * @param filter Filter.
-     * @param grp Optional cluster group.
-     * @return Cursor.
-     * @throws IgniteCheckedException If failed.
-     */
-    @SuppressWarnings("unchecked")
-    private QueryCursor<Cache.Entry<K, V>> query(final Query filter, @Nullable ClusterGroup grp)
-        throws IgniteCheckedException {
-        final CacheQuery qry;
-
-        boolean isKeepBinary = opCtx != null && opCtx.isKeepBinary();
-
-        final CacheQueryFuture fut;
-
-        if (filter instanceof TextQuery) {
-            TextQuery p = (TextQuery)filter;
-
-            qry = ctx.queries().createFullTextQuery(p.getType(), p.getText(), isKeepBinary);
-
-            if (grp != null)
-                qry.projection(grp);
-
-            fut = ctx.kernalContext().query().executeQuery(GridCacheQueryType.TEXT, p.getText(), ctx,
-                new IgniteOutClosureX<CacheQueryFuture<Map.Entry<K, V>>>() {
-                    @Override public CacheQueryFuture<Map.Entry<K, V>> applyx() {
-                        return qry.execute();
-                    }
-                }, false);
-        }
-        else if (filter instanceof SpiQuery) {
-            qry = ctx.queries().createSpiQuery(isKeepBinary);
-
-            if (grp != null)
-                qry.projection(grp);
-
-            fut = ctx.kernalContext().query().executeQuery(GridCacheQueryType.SPI, filter.getClass().getSimpleName(),
-                ctx, new IgniteOutClosureX<CacheQueryFuture<Map.Entry<K, V>>>() {
-                    @Override public CacheQueryFuture<Map.Entry<K, V>> applyx() {
-                        return qry.execute(((SpiQuery)filter).getArgs());
-                    }
-                }, false);
-        }
-        else {
-            if (filter instanceof SqlFieldsQuery)
-                throw new CacheException("Use methods 'queryFields' and 'localQueryFields' for " +
-                    SqlFieldsQuery.class.getSimpleName() + ".");
-
-            throw new CacheException("Unsupported query type: " + filter);
-        }
-
-        return new QueryCursorImpl<>(new GridCloseableIteratorAdapter<Entry<K, V>>() {
-            /** */
-            private Cache.Entry<K, V> cur;
-
-            @Override protected Entry<K, V> onNext() throws IgniteCheckedException {
-                if (!onHasNext())
-                    throw new NoSuchElementException();
-
-                Cache.Entry<K, V> e = cur;
-
-                cur = null;
-
-                return e;
-            }
-
-            @Override protected boolean onHasNext() throws IgniteCheckedException {
-                if (cur != null)
-                    return true;
-
-                Object next = fut.next();
-
-                // Workaround a bug: if IndexingSpi is configured future represents Iterator<Cache.Entry>
-                // instead of Iterator<Map.Entry> due to IndexingSpi interface.
-                if (next == null)
-                    return false;
-
-                if (next instanceof Cache.Entry)
-                    cur = (Cache.Entry)next;
-                else {
-                    Map.Entry e = (Map.Entry)next;
-
-                    cur = new CacheEntryImpl(e.getKey(), e.getValue());
-                }
-
-                return true;
-            }
-
-            @Override protected void onClose() throws IgniteCheckedException {
-                fut.cancel();
-            }
-        });
-    }
-
-    /**
-     * @param loc Enforce local.
-     * @return Local node cluster group.
-     */
-    private ClusterGroup projection(boolean loc) {
-        if (loc || ctx.isLocal() || ctx.isReplicatedAffinityNode())
-            return ctx.kernalContext().grid().cluster().forLocal();
-
-        if (ctx.isReplicated())
-            return ctx.kernalContext().grid().cluster().forDataNodes(ctx.name()).forRandom();
-
-        return null;
-    }
-
-    /**
-     * Executes continuous query.
-     *
-     * @param qry Query.
-     * @param loc Local flag.
-     * @param keepBinary Keep binary flag.
-     * @return Initial iteration cursor.
-     */
-    @SuppressWarnings("unchecked")
-    private QueryCursor<Cache.Entry<K, V>> queryContinuous(ContinuousQuery qry, boolean loc, boolean keepBinary) {
-        if (qry.getInitialQuery() instanceof ContinuousQuery)
-            throw new IgniteException("Initial predicate for continuous query can't be an instance of another " +
-                "continuous query. Use SCAN or SQL query for initial iteration.");
-
-        if (qry.getLocalListener() == null)
-            throw new IgniteException("Mandatory local listener is not set for the query: " + qry);
-
-        if (qry.getRemoteFilter() != null && qry.getRemoteFilterFactory() != null)
-            throw new IgniteException("Should be used either RemoterFilter or RemoteFilterFactory.");
-
-        try {
-            final UUID routineId = ctx.continuousQueries().executeQuery(
-                qry.getLocalListener(),
-                qry.getRemoteFilter(),
-                qry.getRemoteFilterFactory(),
-                qry.getPageSize(),
-                qry.getTimeInterval(),
-                qry.isAutoUnsubscribe(),
-                loc,
-                keepBinary,
-                qry.isIncludeExpired());
-
-            final QueryCursor<Cache.Entry<K, V>> cur =
-                qry.getInitialQuery() != null ? query(qry.getInitialQuery()) : null;
-
-            return new QueryCursor<Cache.Entry<K, V>>() {
-                @Override public Iterator<Cache.Entry<K, V>> iterator() {
-                    return cur != null ? cur.iterator() : new GridEmptyIterator<Cache.Entry<K, V>>();
-                }
-
-                @Override public List<Cache.Entry<K, V>> getAll() {
-                    return cur != null ? cur.getAll() : Collections.<Cache.Entry<K, V>>emptyList();
-                }
-
-                @Override public void close() {
-                    if (cur != null)
-                        cur.close();
-
-                    try {
-                        ctx.kernalContext().continuous().stopRoutine(routineId).get();
-                    }
-                    catch (IgniteCheckedException e) {
-                        throw U.convertException(e);
-                    }
-                }
-            };
-        }
-        catch (IgniteCheckedException e) {
-            throw U.convertException(e);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @SuppressWarnings("unchecked")
-    @Override public FieldsQueryCursor<List<?>> query(SqlFieldsQuery qry) {
-        return (FieldsQueryCursor<List<?>>)query((Query)qry);
-    }
-
-    /** {@inheritDoc} */
-    @SuppressWarnings("unchecked")
-    @Override public <R> QueryCursor<R> query(Query<R> qry) {
-        A.notNull(qry, "qry");
-
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            ctx.checkSecurity(SecurityPermission.CACHE_READ);
-
-            validate(qry);
-
-            convertToBinary(qry);
-
-            CacheOperationContext opCtxCall = ctx.operationContextPerCall();
-
-            boolean keepBinary = opCtxCall != null && opCtxCall.isKeepBinary();
-
-            if (qry instanceof ContinuousQuery)
-                return (QueryCursor<R>)queryContinuous((ContinuousQuery<K, V>)qry, qry.isLocal(), keepBinary);
-
-            if (qry instanceof SqlQuery)
-                return (QueryCursor<R>)ctx.kernalContext().query().querySql(ctx, (SqlQuery)qry, keepBinary);
-
-            if (qry instanceof SqlFieldsQuery)
-                return (FieldsQueryCursor<R>)ctx.kernalContext().query().querySqlFields(ctx, (SqlFieldsQuery)qry,
-                    keepBinary);
-
-            if (qry instanceof ScanQuery)
-                return query((ScanQuery)qry, null, projection(qry.isLocal()));
-
-            return (QueryCursor<R>)query(qry, projection(qry.isLocal()));
-        }
-        catch (Exception e) {
-            if (e instanceof CacheException)
-                throw (CacheException)e;
-
-            throw new CacheException(e);
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public <T, R> QueryCursor<R> query(Query<T> qry, IgniteClosure<T, R> transformer) {
-        A.notNull(qry, "qry");
-        A.notNull(transformer, "transformer");
-
-        if (!(qry instanceof ScanQuery))
-            throw new UnsupportedOperationException("Transformers are supported only for SCAN queries.");
-
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            ctx.checkSecurity(SecurityPermission.CACHE_READ);
-
-            validate(qry);
-
-            return query((ScanQuery<K, V>)qry, transformer, projection(qry.isLocal()));
-        }
-        catch (Exception e) {
-            if (e instanceof CacheException)
-                throw (CacheException)e;
-
-            throw new CacheException(e);
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /**
-     * Convert query arguments to BinaryObjects if binary marshaller used.
-     *
-     * @param qry Query.
-     */
-    private void convertToBinary(final Query qry) {
-        if (ctx.binaryMarshaller()) {
-            if (qry instanceof SqlQuery) {
-                final SqlQuery sqlQry = (SqlQuery) qry;
-
-                convertToBinary(sqlQry.getArgs());
-            }
-            else if (qry instanceof SpiQuery) {
-                final SpiQuery spiQry = (SpiQuery) qry;
-
-                convertToBinary(spiQry.getArgs());
-            }
-            else if (qry instanceof SqlFieldsQuery) {
-                final SqlFieldsQuery fieldsQry = (SqlFieldsQuery) qry;
-
-                convertToBinary(fieldsQry.getArgs());
-            }
-        }
-    }
-
-    /**
-     * Converts query arguments to BinaryObjects if binary marshaller used.
-     *
-     * @param args Arguments.
-     */
-    private void convertToBinary(final Object[] args) {
-        if (args == null)
-            return;
-
-        for (int i = 0; i < args.length; i++)
-            args[i] = ctx.cacheObjects().binary().toBinary(args[i]);
-    }
-
-    /**
-     * Checks query.
-     *
-     * @param qry Query
-     * @throws CacheException If query indexing disabled for sql query.
-     */
-    private void validate(Query qry) {
-        if (!QueryUtils.isEnabled(ctx.config()) && !(qry instanceof ScanQuery) &&
-            !(qry instanceof ContinuousQuery) && !(qry instanceof SpiQuery) && !(qry instanceof SqlQuery) &&
-            !(qry instanceof SqlFieldsQuery))
-            throw new CacheException("Indexing is disabled for cache: " + ctx.cache().name() +
-                ". Use setIndexedTypes or setTypeMetadata methods on CacheConfiguration to enable.");
-
-        if (!ctx.kernalContext().query().moduleEnabled() &&
-            (qry instanceof SqlQuery || qry instanceof SqlFieldsQuery || qry instanceof TextQuery))
-            throw new CacheException("Failed to execute query. Add module 'ignite-indexing' to the classpath " +
-                "of all Ignite nodes.");
-    }
-
-    /** {@inheritDoc} */
-    @Override public Iterable<Cache.Entry<K, V>> localEntries(CachePeekMode... peekModes) throws CacheException {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            return delegate.localEntries(peekModes);
-        }
-        catch (IgniteCheckedException e) {
-            throw cacheException(e);
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public QueryMetrics queryMetrics() {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            return delegate.context().queries().metrics();
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public void resetQueryMetrics() {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            delegate.context().queries().resetMetrics();
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public Collection<? extends QueryDetailMetrics> queryDetailMetrics() {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            return delegate.context().queries().detailMetrics();
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public void resetQueryDetailMetrics() {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            delegate.context().queries().resetDetailMetrics();
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public void localEvict(Collection<? extends K> keys) {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            delegate.evictAll(keys);
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Nullable @Override public V localPeek(K key, CachePeekMode... peekModes) {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            return delegate.localPeek(key, peekModes, null);
-        }
-        catch (IgniteCheckedException e) {
-            throw cacheException(e);
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public int size(CachePeekMode... peekModes) throws CacheException {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            if (isAsync()) {
-                setFuture(delegate.sizeAsync(peekModes));
-
-                return 0;
-            }
-            else
-                return delegate.size(peekModes);
-        }
-        catch (IgniteCheckedException e) {
-            throw cacheException(e);
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteFuture<Integer> sizeAsync(CachePeekMode... peekModes) throws CacheException {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            return createFuture(delegate.sizeAsync(peekModes));
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public long sizeLong(CachePeekMode... peekModes) throws CacheException {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            if (isAsync()) {
-                setFuture(delegate.sizeLongAsync(peekModes));
-
-                return 0;
-            }
-            else
-                return delegate.sizeLong(peekModes);
-        }
-        catch (IgniteCheckedException e) {
-            throw cacheException(e);
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteFuture<Long> sizeLongAsync(CachePeekMode... peekModes) throws CacheException {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            return createFuture(delegate.sizeLongAsync(peekModes));
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public long sizeLong(int part, CachePeekMode... peekModes) throws CacheException {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            if (isAsync()) {
-                setFuture(delegate.sizeLongAsync(part, peekModes));
-
-                return 0;
-            }
-            else
-                return delegate.sizeLong(part, peekModes);
-        }
-        catch (IgniteCheckedException e) {
-            throw cacheException(e);
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteFuture<Long> sizeLongAsync(int part, CachePeekMode... peekModes) throws CacheException {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            return createFuture(delegate.sizeLongAsync(part, peekModes));
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public int localSize(CachePeekMode... peekModes) {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            return delegate.localSize(peekModes);
-        }
-        catch (IgniteCheckedException e) {
-            throw cacheException(e);
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public long localSizeLong(CachePeekMode... peekModes) {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            return delegate.localSizeLong(peekModes);
-        }
-        catch (IgniteCheckedException e) {
-            throw cacheException(e);
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public long localSizeLong(int part, CachePeekMode... peekModes) {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            return delegate.localSizeLong(part, peekModes);
-        }
-        catch (IgniteCheckedException e) {
-            throw cacheException(e);
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public V get(K key) {
-        try {
-            GridCacheGateway<K, V> gate = this.gate;
-
-            CacheOperationContext prev = onEnter(gate, opCtx);
-
-            try {
-                if (isAsync()) {
-                    setFuture(delegate.getAsync(key));
-
-                    return null;
-                }
-                else
-                    return delegate.get(key);
-            }
-            finally {
-                onLeave(gate, prev);
-            }
-        }
-        catch (IgniteCheckedException e) {
-            throw cacheException(e);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteFuture<V> getAsync(K key) {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            return createFuture(delegate.getAsync(key));
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public CacheEntry<K, V> getEntry(K key) {
-        try {
-            GridCacheGateway<K, V> gate = this.gate;
-
-            CacheOperationContext prev = onEnter(gate, opCtx);
-
-            try {
-                if (isAsync()) {
-                    setFuture(delegate.getEntryAsync(key));
-
-                    return null;
-                }
-                else
-                    return delegate.getEntry(key);
-            }
-            finally {
-                onLeave(gate, prev);
-            }
-        }
-        catch (IgniteCheckedException e) {
-            throw cacheException(e);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteFuture<CacheEntry<K, V>> getEntryAsync(K key) {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            return createFuture(delegate.getEntryAsync(key));
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public Map<K, V> getAll(Set<? extends K> keys) {
-        try {
-            GridCacheGateway<K, V> gate = this.gate;
-
-            CacheOperationContext prev = onEnter(gate, opCtx);
-
-            try {
-                if (isAsync()) {
-                    setFuture(delegate.getAllAsync(keys));
-
-                    return null;
-                }
-                else
-                    return delegate.getAll(keys);
-            }
-            finally {
-                onLeave(gate, prev);
-            }
-        }
-        catch (IgniteCheckedException e) {
-            throw cacheException(e);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteFuture<Map<K, V>> getAllAsync(Set<? extends K> keys) {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            return createFuture(delegate.getAllAsync(keys));
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public Collection<CacheEntry<K, V>> getEntries(Set<? extends K> keys) {
-        try {
-            GridCacheGateway<K, V> gate = this.gate;
-
-            CacheOperationContext prev = onEnter(gate, opCtx);
-
-            try {
-                if (isAsync()) {
-                    setFuture(delegate.getEntriesAsync(keys));
-
-                    return null;
-                }
-                else
-                    return delegate.getEntries(keys);
-            }
-            finally {
-                onLeave(gate, prev);
-            }
-        }
-        catch (IgniteCheckedException e) {
-            throw cacheException(e);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteFuture<Collection<CacheEntry<K, V>>> getEntriesAsync(Set<? extends K> keys) {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            return createFuture(delegate.getEntriesAsync(keys));
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public Map<K, V> getAllOutTx(Set<? extends K> keys) {
-        try {
-            GridCacheGateway<K, V> gate = this.gate;
-
-            CacheOperationContext prev = onEnter(gate, opCtx);
-
-            try {
-                if (isAsync()) {
-                    setFuture(delegate.getAllOutTxAsync(keys));
-
-                    return null;
-                }
-                else
-                    return delegate.getAllOutTx(keys);
-            }
-            finally {
-                onLeave(gate, prev);
-            }
-        }
-        catch (IgniteCheckedException e) {
-            throw cacheException(e);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteFuture<Map<K, V>> getAllOutTxAsync(Set<? extends K> keys) {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            return createFuture(delegate.getAllOutTxAsync(keys));
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /**
-     * @param keys Keys.
-     * @return Values map.
-     */
-    public Map<K, V> getAll(Collection<? extends K> keys) {
-        try {
-            GridCacheGateway<K, V> gate = this.gate;
-
-            CacheOperationContext prev = onEnter(gate, opCtx);
-
-            try {
-                if (isAsync()) {
-                    setFuture(delegate.getAllAsync(keys));
-
-                    return null;
-                }
-                else
-                    return delegate.getAll(keys);
-            }
-            finally {
-                onLeave(gate, prev);
-            }
-        }
-        catch (IgniteCheckedException e) {
-            throw cacheException(e);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean containsKey(K key) {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            if (isAsync()) {
-                setFuture(delegate.containsKeyAsync(key));
-
-                return false;
-            }
-            else
-                return delegate.containsKey(key);
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteFuture<Boolean> containsKeyAsync(K key) {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            return createFuture(delegate.containsKeyAsync(key));
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean containsKeys(Set<? extends K> keys) {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            if (isAsync()) {
-                setFuture(delegate.containsKeysAsync(keys));
-
-                return false;
-            }
-            else
-                return delegate.containsKeys(keys);
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteFuture<Boolean> containsKeysAsync(Set<? extends K> keys) {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            return createFuture(delegate.containsKeysAsync(keys));
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public void loadAll(
-        Set<? extends K> keys,
-        boolean replaceExisting,
-        @Nullable final CompletionListener completionLsnr
-    ) {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            IgniteInternalFuture<?> fut = ctx.cache().loadAll(keys, replaceExisting);
-
-            if (completionLsnr != null) {
-                fut.listen(new CI1<IgniteInternalFuture<?>>() {
-                    @Override public void apply(IgniteInternalFuture<?> fut) {
-                        try {
-                            fut.get();
-
-                            completionLsnr.onCompletion();
-                        }
-                        catch (IgniteCheckedException e) {
-                            completionLsnr.onException(cacheException(e));
-                        }
-                    }
-                });
-            }
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public void put(K key, V val) {
-        try {
-            GridCacheGateway<K, V> gate = this.gate;
-
-            CacheOperationContext prev = onEnter(gate, opCtx);
-
-            try {
-                if (isAsync())
-                    setFuture(putAsync0(key, val));
-                else
-                    delegate.put(key, val);
-            }
-            finally {
-                onLeave(gate, prev);
-            }
-        }
-        catch (IgniteCheckedException e) {
-            throw cacheException(e);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteFuture<Void> putAsync(K key, V val) {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            return createFuture(putAsync0(key, val));
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /**
-     * Put async internal operation implementation.
-     *
-     * @param key Key.
-     * @param val Value.
-     * @return Internal future.
-     */
-    private IgniteInternalFuture<Void> putAsync0(K key, V val) {
-        IgniteInternalFuture<Boolean> fut = delegate.putAsync(key, val);
-
-        return fut.chain(new CX1<IgniteInternalFuture<Boolean>, Void>() {
-            @Override public Void applyx(IgniteInternalFuture<Boolean> fut1) throws IgniteCheckedException {
-                try {
-                    fut1.get();
-                }
-                catch (RuntimeException e) {
-                    throw new GridClosureException(e);
-                }
-
-                return null;
-            }
-        });
-    }
-
-    /** {@inheritDoc} */
-    @Override public V getAndPut(K key, V val) {
-        try {
-            GridCacheGateway<K, V> gate = this.gate;
-
-            CacheOperationContext prev = onEnter(gate, opCtx);
-
-            try {
-                if (isAsync()) {
-                    setFuture(delegate.getAndPutAsync(key, val));
-
-                    return null;
-                }
-                else
-                    return delegate.getAndPut(key, val);
-            }
-            finally {
-                onLeave(gate, prev);
-            }
-        }
-        catch (IgniteCheckedException e) {
-            throw cacheException(e);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteFuture<V> getAndPutAsync(K key, V val) {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            return createFuture(delegate.getAndPutAsync(key, val));
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public void putAll(Map<? extends K, ? extends V> map) {
-        try {
-            GridCacheGateway<K, V> gate = this.gate;
-
-            CacheOperationContext prev = onEnter(gate, opCtx);
-
-            try {
-                if (isAsync())
-                    setFuture(delegate.putAllAsync(map));
-                else
-                    delegate.putAll(map);
-            }
-            finally {
-                onLeave(gate, prev);
-            }
-        }
-        catch (IgniteCheckedException e) {
-            throw cacheException(e);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteFuture<Void> putAllAsync(Map<? extends K, ? extends V> map) {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            return (IgniteFuture<Void>)createFuture(delegate.putAllAsync(map));
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean putIfAbsent(K key, V val) {
-        try {
-            GridCacheGateway<K, V> gate = this.gate;
-
-            CacheOperationContext prev = onEnter(gate, opCtx);
-
-            try {
-                if (isAsync()) {
-                    setFuture(delegate.putIfAbsentAsync(key, val));
-
-                    return false;
-                }
-                else
-                    return delegate.putIfAbsent(key, val);
-            }
-            finally {
-                onLeave(gate, prev);
-            }
-        }
-        catch (IgniteCheckedException e) {
-            throw cacheException(e);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteFuture<Boolean> putIfAbsentAsync(K key, V val) {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            return createFuture(delegate.putIfAbsentAsync(key, val));
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean remove(K key) {
-        try {
-            GridCacheGateway<K, V> gate = this.gate;
-
-            CacheOperationContext prev = onEnter(gate, opCtx);
-
-            try {
-                if (isAsync()) {
-                    setFuture(delegate.removeAsync(key));
-
-                    return false;
-                }
-                else
-                    return delegate.remove(key);
-            }
-            finally {
-                onLeave(gate, prev);
-            }
-        }
-        catch (IgniteCheckedException e) {
-            throw cacheException(e);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteFuture<Boolean> removeAsync(K key) {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            return createFuture(delegate.removeAsync(key));
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean remove(K key, V oldVal) {
-        try {
-            GridCacheGateway<K, V> gate = this.gate;
-
-            CacheOperationContext prev = onEnter(gate, opCtx);
-
-            try {
-                if (isAsync()) {
-                    setFuture(delegate.removeAsync(key, oldVal));
-
-                    return false;
-                }
-                else
-                    return delegate.remove(key, oldVal);
-            }
-            finally {
-                onLeave(gate, prev);
-            }
-        }
-        catch (IgniteCheckedException e) {
-            throw cacheException(e);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteFuture<Boolean> removeAsync(K key, V oldVal) {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            return createFuture(delegate.removeAsync(key, oldVal));
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public V getAndRemove(K key) {
-        try {
-            GridCacheGateway<K, V> gate = this.gate;
-
-            CacheOperationContext prev = onEnter(gate, opCtx);
-
-            try {
-                if (isAsync()) {
-                    setFuture(delegate.getAndRemoveAsync(key));
-
-                    return null;
-                }
-                else
-                    return delegate.getAndRemove(key);
-            }
-            finally {
-                onLeave(gate, prev);
-            }
-        }
-        catch (IgniteCheckedException e) {
-            throw cacheException(e);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteFuture<V> getAndRemoveAsync(K key) {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            return createFuture(delegate.getAndRemoveAsync(key));
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean replace(K key, V oldVal, V newVal) {
-        try {
-            GridCacheGateway<K, V> gate = this.gate;
-
-            CacheOperationContext prev = onEnter(gate, opCtx);
-
-            try {
-                if (isAsync()) {
-                    setFuture(delegate.replaceAsync(key, oldVal, newVal));
-
-                    return false;
-                }
-                else
-                    return delegate.replace(key, oldVal, newVal);
-            }
-            finally {
-                onLeave(gate, prev);
-            }
-        }
-        catch (IgniteCheckedException e) {
-            throw cacheException(e);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteFuture<Boolean> replaceAsync(K key, V oldVal, V newVal) {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            return createFuture(delegate.replaceAsync(key, oldVal, newVal));
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean replace(K key, V val) {
-        try {
-            GridCacheGateway<K, V> gate = this.gate;
-
-            CacheOperationContext prev = onEnter(gate, opCtx);
-
-            try {
-                if (isAsync()) {
-                    setFuture(delegate.replaceAsync(key, val));
-
-                    return false;
-                }
-                else
-                    return delegate.replace(key, val);
-            }
-            finally {
-                onLeave(gate, prev);
-            }
-        }
-        catch (IgniteCheckedException e) {
-            throw cacheException(e);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteFuture<Boolean> replaceAsync(K key, V val) {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            return createFuture(delegate.replaceAsync(key, val));
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public V getAndReplace(K key, V val) {
-        try {
-            GridCacheGateway<K, V> gate = this.gate;
-
-            CacheOperationContext prev = onEnter(gate, opCtx);
-
-            try {
-                if (isAsync()) {
-                    setFuture(delegate.getAndReplaceAsync(key, val));
-
-                    return null;
-                }
-                else
-                    return delegate.getAndReplace(key, val);
-            }
-            finally {
-                onLeave(gate, prev);
-            }
-        }
-        catch (IgniteCheckedException e) {
-            throw cacheException(e);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteFuture<V> getAndReplaceAsync(K key, V val) {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            return createFuture(delegate.getAndReplaceAsync(key, val));
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public void removeAll(Set<? extends K> keys) {
-        try {
-            GridCacheGateway<K, V> gate = this.gate;
-
-            CacheOperationContext prev = onEnter(gate, opCtx);
-
-            try {
-                if (isAsync())
-                    setFuture(delegate.removeAllAsync(keys));
-                else
-                    delegate.removeAll(keys);
-            }
-            finally {
-                onLeave(gate, prev);
-            }
-        }
-        catch (IgniteCheckedException e) {
-            throw cacheException(e);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteFuture<Void> removeAllAsync(Set<? extends K> keys) {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            return (IgniteFuture<Void>)createFuture(delegate.removeAllAsync(keys));
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public void removeAll() {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            if (isAsync())
-                setFuture(delegate.removeAllAsync());
-            else
-                delegate.removeAll();
-        }
-        catch (IgniteCheckedException e) {
-            throw cacheException(e);
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteFuture<Void> removeAllAsync() {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            return (IgniteFuture<Void>)createFuture(delegate.removeAllAsync());
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public void clear(K key) {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            if (isAsync())
-                setFuture(delegate.clearAsync(key));
-            else
-                delegate.clear(key);
-        }
-        catch (IgniteCheckedException e) {
-            throw cacheException(e);
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteFuture<Void> clearAsync(K key) {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            return (IgniteFuture<Void>)createFuture(delegate.clearAsync(key));
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public void clearAll(Set<? extends K> keys) {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            if (isAsync())
-                setFuture(delegate.clearAllAsync(keys));
-            else
-                delegate.clearAll(keys);
-        }
-        catch (IgniteCheckedException e) {
-            throw cacheException(e);
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteFuture<Void> clearAllAsync(Set<? extends K> keys) {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            return (IgniteFuture<Void>)createFuture(delegate.clearAllAsync(keys));
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public void clear() {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            if (isAsync())
-                setFuture(delegate.clearAsync());
-            else
-                delegate.clear();
-        }
-        catch (IgniteCheckedException e) {
-            throw cacheException(e);
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteFuture<Void> clearAsync() {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            return (IgniteFuture<Void>)createFuture(delegate.clearAsync());
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public void localClear(K key) {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            delegate.clearLocally(key);
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public void localClearAll(Set<? extends K> keys) {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            for (K key : keys)
-                delegate.clearLocally(key);
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public <T> T invoke(K key, EntryProcessor<K, V, T> entryProcessor, Object... args)
-        throws EntryProcessorException {
-        try {
-            GridCacheGateway<K, V> gate = this.gate;
-
-            CacheOperationContext prev = onEnter(gate, opCtx);
-
-            try {
-                if (isAsync()) {
-                    setFuture(invokeAsync0(key, entryProcessor, args));
-
-                    return null;
-                }
-                else {
-                    EntryProcessorResult<T> res = delegate.invoke(key, entryProcessor, args);
-
-                    return res != null ? res.get() : null;
-                }
-            }
-            finally {
-                onLeave(gate, prev);
-            }
-        }
-        catch (IgniteCheckedException e) {
-            throw cacheException(e);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public <T> IgniteFuture<T> invokeAsync(K key, EntryProcessor<K, V, T> entryProcessor,
-        Object... args) {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            return createFuture(invokeAsync0(key, entryProcessor, args));
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /**
-     * Invoke async operation internal implementation.
-     *
-     * @param key Key.
-     * @param entryProcessor Processor.
-     * @param args Arguments.
-     * @return Internal future.
-     */
-    private <T> IgniteInternalFuture<T> invokeAsync0(K key, EntryProcessor<K, V, T> entryProcessor, Object[] args) {
-        IgniteInternalFuture<EntryProcessorResult<T>> fut = delegate.invokeAsync(key, entryProcessor, args);
-
-        return fut.chain(new CX1<IgniteInternalFuture<EntryProcessorResult<T>>, T>() {
-            @Override public T applyx(IgniteInternalFuture<EntryProcessorResult<T>> fut1)
-                throws IgniteCheckedException {
-                try {
-                    EntryProcessorResult<T> res = fut1.get();
-
-                    return res != null ? res.get() : null;
-                }
-                catch (RuntimeException e) {
-                    throw new GridClosureException(e);
-                }
-            }
-        });
-    }
-
-
-    /** {@inheritDoc} */
-    @Override public <T> T invoke(K key, CacheEntryProcessor<K, V, T> entryProcessor, Object... args)
-        throws EntryProcessorException {
-        return invoke(key, (EntryProcessor<K, V, T>)entryProcessor, args);
-    }
-
-    /** {@inheritDoc} */
-    @Override public <T> IgniteFuture<T> invokeAsync(K key, CacheEntryProcessor<K, V, T> entryProcessor,
-        Object... args) {
-        return invokeAsync(key, (EntryProcessor<K, V, T>)entryProcessor, args);
-    }
-
-    /**
-     * @param topVer Locked topology version.
-     * @param key Key.
-     * @param entryProcessor Entry processor.
-     * @param args Arguments.
-     * @return Invoke result.
-     */
-    public <T> T invoke(@Nullable AffinityTopologyVersion topVer,
-        K key,
-        EntryProcessor<K, V, T> entryProcessor,
-        Object... args) {
-        try {
-            GridCacheGateway<K, V> gate = this.gate;
-
-            CacheOperationContext prev = onEnter(gate, opCtx);
-
-            try {
-                if (isAsync())
-                    throw new UnsupportedOperationException();
-                else {
-                    EntryProcessorResult<T> res = delegate.invoke(topVer, key, entryProcessor, args);
-
-                    return res != null ? res.get() : null;
-                }
-            }
-            finally {
-                onLeave(gate, prev);
-            }
-        }
-        catch (IgniteCheckedException e) {
-            throw cacheException(e);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public <T> Map<K, EntryProcessorResult<T>> invokeAll(Set<? extends K> keys,
-        EntryProcessor<K, V, T> entryProcessor,
-        Object... args) {
-        try {
-            GridCacheGateway<K, V> gate = this.gate;
-
-            CacheOperationContext prev = onEnter(gate, opCtx);
-
-            try {
-                if (isAsync()) {
-                    setFuture(delegate.invokeAllAsync(keys, entryProcessor, args));
-
-                    return null;
-                }
-                else
-                    return delegate.invokeAll(keys, entryProcessor, args);
-            }
-            finally {
-                onLeave(gate, prev);
-            }
-        }
-        catch (IgniteCheckedException e) {
-            throw cacheException(e);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public <T> IgniteFuture<Map<K, EntryProcessorResult<T>>> invokeAllAsync(Set<? extends K> keys,
-        EntryProcessor<K, V, T> entryProcessor, Object... args) {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            return createFuture(delegate.invokeAllAsync(keys, entryProcessor, args));
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public <T> Map<K, EntryProcessorResult<T>> invokeAll(Set<? extends K> keys,
-        CacheEntryProcessor<K, V, T> entryProcessor,
-        Object... args) {
-        try {
-            GridCacheGateway<K, V> gate = this.gate;
-
-            CacheOperationContext prev = onEnter(gate, opCtx);
-
-            try {
-                if (isAsync()) {
-                    setFuture(delegate.invokeAllAsync(keys, entryProcessor, args));
-
-                    return null;
-                }
-                else
-                    return delegate.invokeAll(keys, entryProcessor, args);
-            }
-            finally {
-                onLeave(gate, prev);
-            }
-        }
-        catch (IgniteCheckedException e) {
-            throw cacheException(e);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public <T> IgniteFuture<Map<K, EntryProcessorResult<T>>> invokeAllAsync(Set<? extends K> keys,
-        CacheEntryProcessor<K, V, T> entryProcessor, Object... args) {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            return createFuture(delegate.invokeAllAsync(keys, entryProcessor, args));
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public <T> Map<K, EntryProcessorResult<T>> invokeAll(
-        Map<? extends K, ? extends EntryProcessor<K, V, T>> map,
-        Object... args) {
-        try {
-            GridCacheGateway<K, V> gate = this.gate;
-
-            CacheOperationContext prev = onEnter(gate, opCtx);
-
-            try {
-                if (isAsync()) {
-                    setFuture(delegate.invokeAllAsync(map, args));
-
-                    return null;
-                }
-                else
-                    return delegate.invokeAll(map, args);
-            }
-            finally {
-                onLeave(gate, prev);
-            }
-        }
-        catch (IgniteCheckedException e) {
-            throw cacheException(e);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public <T> IgniteFuture<Map<K, EntryProcessorResult<T>>> invokeAllAsync(
-        Map<? extends K, ? extends EntryProcessor<K, V, T>> map, Object... args) {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            return createFuture(delegate.invokeAllAsync(map, args));
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public String getName() {
-        return delegate.name();
-    }
-
-    /** {@inheritDoc} */
-    @Override public CacheManager getCacheManager() {
-        return cacheMgr;
-    }
 
+public interface IgniteCacheProxy<K, V> extends IgniteCache<K, V>, Externalizable {
     /**
-     * @param cacheMgr Cache manager.
+     * @return Context.
      */
-    public void setCacheManager(CacheManager cacheMgr) {
-        this.cacheMgr = cacheMgr;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void destroy() {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        if (!onEnterIfNoStop(gate))
-            return;
-
-        IgniteInternalFuture<?> fut;
-
-        try {
-            fut = ctx.kernalContext().cache().dynamicDestroyCache(ctx.name(), false, true, false);
-        }
-        finally {
-            onLeave(gate);
-        }
-
-        try {
-            fut.get();
-        }
-        catch (IgniteCheckedException e) {
-            throw cacheException(e);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public void close() {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        if (!onEnterIfNoStop(gate))
-            return;
-
-        IgniteInternalFuture<?> fut;
-
-        try {
-            fut = ctx.kernalContext().cache().dynamicCloseCache(ctx.name());
-        }
-        finally {
-            onLeave(gate);
-        }
-
-        try {
-            fut.get();
-        }
-        catch (IgniteCheckedException e) {
-            throw cacheException(e);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isClosed() {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        if (!onEnterIfNoStop(gate))
-            return true;
-
-        try {
-            return ctx.kernalContext().cache().context().closed(ctx);
-        }
-        finally {
-            onLeave(gate);
-        }
-    }
+    public GridCacheContext<K, V> context();
 
     /**
-     * @return Proxy delegate.
+     * Gets cache proxy which does not acquire read lock on gateway enter, should be used only if grid read lock is
+     * externally acquired.
+     *
+     * @return Ignite cache proxy with simple gate.
      */
-    public IgniteInternalCache delegate() {
-        return delegate;
-    }
-
-    /** {@inheritDoc} */
-    @SuppressWarnings("unchecked")
-    @Override public <T> T unwrap(Class<T> clazz) {
-        if (clazz.isAssignableFrom(getClass()))
-            return (T)this;
-        else if (clazz.isAssignableFrom(IgniteEx.class))
-            return (T)ctx.grid();
-
-        throw new IllegalArgumentException("Unwrapping to class is not supported: " + clazz);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void registerCacheEntryListener(CacheEntryListenerConfiguration<K, V> lsnrCfg) {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            CacheOperationContext opCtx = ctx.operationContextPerCall();
-
-            ctx.continuousQueries().executeJCacheQuery(lsnrCfg, false, opCtx != null && opCtx.isKeepBinary());
-        }
-        catch (IgniteCheckedException e) {
-            throw cacheException(e);
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public void deregisterCacheEntryListener(CacheEntryListenerConfiguration<K, V> lsnrCfg) {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            ctx.continuousQueries().cancelJCacheQuery(lsnrCfg);
-        }
-        catch (IgniteCheckedException e) {
-            throw cacheException(e);
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public Iterator<Cache.Entry<K, V>> iterator() {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            return ctx.cache().igniteIterator();
-        }
-        catch (IgniteCheckedException e) {
-            throw cacheException(e);
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override protected IgniteCache<K, V> createAsyncInstance() {
-        return new IgniteCacheProxy<>(ctx, delegate, opCtx, true, lock);
-    }
+    public IgniteCacheProxy<K, V> cacheNoGate();
 
     /**
      * Creates projection that will operate with binary objects. <p> Projection returned by this method will force
@@ -2520,368 +62,50 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
      * @return Projection for binary objects.
      */
     @SuppressWarnings("unchecked")
-    public <K1, V1> IgniteCache<K1, V1> keepBinary() {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            CacheOperationContext opCtx0 =
-                new CacheOperationContext(
-                    opCtx != null && opCtx.skipStore(),
-                    opCtx != null ? opCtx.subjectId() : null,
-                    true,
-                    opCtx != null ? opCtx.expiry() : null,
-                    opCtx != null && opCtx.noRetries(),
-                    opCtx != null ? opCtx.dataCenterId() : null,
-                    opCtx != null && opCtx.recovery());
-
-            return new IgniteCacheProxy<>((GridCacheContext<K1, V1>)ctx,
-                (IgniteInternalCache<K1, V1>)delegate,
-                opCtx0,
-                isAsync(),
-                lock);
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
+    public <K1, V1> IgniteCache<K1, V1> keepBinary();
 
     /**
      * @param dataCenterId Data center ID.
      * @return Projection for data center id.
      */
     @SuppressWarnings("unchecked")
-    public IgniteCache<K, V> withDataCenterId(byte dataCenterId) {
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            Byte prevDataCenterId = opCtx != null ? opCtx.dataCenterId() : null;
-
-            if (prevDataCenterId != null && dataCenterId == prevDataCenterId)
-                return this;
-
-            CacheOperationContext opCtx0 =
-                new CacheOperationContext(
-                    opCtx != null && opCtx.skipStore(),
-                    opCtx != null ? opCtx.subjectId() : null,
-                    opCtx != null && opCtx.isKeepBinary(),
-                    opCtx != null ? opCtx.expiry() : null,
-                    opCtx != null && opCtx.noRetries(),
-                    dataCenterId,
-                    opCtx != null && opCtx.recovery());
-
-            return new IgniteCacheProxy<>(ctx,
-                delegate,
-                opCtx0,
-                isAsync(),
-                lock);
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
+    public IgniteCache<K, V> withDataCenterId(byte dataCenterId);
 
     /**
      * @return Cache with skip store enabled.
      */
-    public IgniteCache<K, V> skipStore() {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            boolean skip = opCtx != null && opCtx.skipStore();
-
-            if (skip)
-                return this;
-
-            CacheOperationContext opCtx0 =
-                new CacheOperationContext(true,
-                    opCtx != null ? opCtx.subjectId() : null,
-                    opCtx != null && opCtx.isKeepBinary(),
-                    opCtx != null ? opCtx.expiry() : null,
-                    opCtx != null && opCtx.noRetries(),
-                    opCtx != null ? opCtx.dataCenterId() : null,
-                    opCtx != null && opCtx.recovery());
-
-            return new IgniteCacheProxy<>(ctx,
-                delegate,
-                opCtx0,
-                isAsync(),
-                lock);
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /**
-     * @param e Checked exception.
-     * @return Cache exception.
-     */
-    private RuntimeException cacheException(IgniteCheckedException e) {
-        GridFutureAdapter<Void> restartFut = this.restartFut.get();
-
-        if (restartFut != null && !restartFut.isDone() && e.hasCause(CacheStoppedException.class))
-            throw new IgniteCacheRestartingException(new IgniteFutureImpl<>(restartFut), "Cache is restarting: " +
-                ctx.name());
-
-        return CU.convertToCacheException(e);
-    }
-
-    /**
-     * @param fut Future for async operation.
-     */
-    private <R> void setFuture(IgniteInternalFuture<R> fut) {
-        curFut.set(createFuture(fut));
-    }
-
-    /** {@inheritDoc} */
-    @Override protected <R> IgniteFuture<R> createFuture(IgniteInternalFuture<R> fut) {
-        return new IgniteCacheFutureImpl<>(fut);
-    }
+    public IgniteCache<K, V> skipStore();
 
     /**
      * @return Internal proxy.
      */
-    public GridCacheProxyImpl<K, V> internalProxy() {
-        return internalProxy;
-    }
+    public GridCacheProxyImpl<K, V> internalProxy();
 
     /**
      * @return {@code True} if proxy was closed.
      */
-    public boolean proxyClosed() {
-        return !gate.getClass().equals(GridCacheGateway.class);
-    }
+    public boolean isProxyClosed();
 
     /**
      * Closes this proxy instance.
      */
-    public void closeProxy() {
-        gate = new GridCacheGateway<K, V>(ctx) {
-            @Override public void enter() {
-                throw new IllegalStateException("Cache has been closed: " + ctx.name());
-            }
-
-            @Override public boolean enterIfNotStopped() {
-                return false;
-            }
-
-            @Override public boolean enterIfNotStoppedNoLock() {
-                return false;
-            }
-
-            @Override public void leaveNoLock() {
-                assert false;
-            }
-
-            @Override public void leave() {
-                assert false;
-            }
-
-            @Nullable @Override public CacheOperationContext enter(@Nullable CacheOperationContext opCtx) {
-                throw new IllegalStateException("Cache has been closed: " + ctx.name());
-            }
-
-            @Nullable @Override public CacheOperationContext enterNoLock(@Nullable CacheOperationContext opCtx) {
-                throw new IllegalStateException("Cache has been closed: " + ctx.name());
-            }
-
-            @Override public void leave(CacheOperationContext prev) {
-                assert false;
-            }
-
-            @Override public void leaveNoLock(CacheOperationContext prev) {
-                assert false;
-            }
-
-            @Override public void stopped() {
-                // No-op.
-            }
-
-            @Override public void onStopped() {
-                // No-op.
-            }
-        };
-    }
-
-    /**
-     * @param gate Cache gateway.
-     * @param opCtx Cache operation context to guard.
-     * @return Previous projection set on this thread.
-     */
-    private CacheOperationContext onEnter(GridCacheGateway<K, V> gate, CacheOperationContext opCtx) {
-        GridFutureAdapter<Void> restartFut = this.restartFut.get();
-
-        if (restartFut != null && !restartFut.isDone())
-            throw new IgniteCacheRestartingException(new IgniteFutureImpl<>(restartFut), "Cache is restarting: " +
-                ctx.name());
-
-        return lock ? gate.enter(opCtx) : gate.enterNoLock(opCtx);
-    }
-
-    /**
-     * @param gate Cache gateway.
-     * @return {@code True} if enter successful.
-     */
-    private boolean onEnterIfNoStop(GridCacheGateway<K, V> gate) {
-        return lock ? gate.enterIfNotStopped() : gate.enterIfNotStoppedNoLock();
-    }
-
-    /**
-     * @param gate Cache gateway.
-     * @param opCtx Operation context to guard.
-     */
-    private void onLeave(GridCacheGateway<K, V> gate, CacheOperationContext opCtx) {
-        if (lock)
-            gate.leave(opCtx);
-        else
-            gate.leaveNoLock(opCtx);
-    }
-
-    /**
-     * @param gate Cache gateway.
-     */
-    private void onLeave(GridCacheGateway<K, V> gate) {
-        if (lock)
-            gate.leave();
-        else
-            gate.leaveNoLock();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Collection<Integer> lostPartitions() {
-        GridCacheGateway<K, V> gate = this.gate;
-
-        CacheOperationContext prev = onEnter(gate, opCtx);
-
-        try {
-            return delegate.lostPartitions();
-        }
-        finally {
-            onLeave(gate, prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeExternal(ObjectOutput out) throws IOException {
-        out.writeObject(ctx);
-
-        out.writeObject(delegate);
-
-        out.writeObject(opCtx);
-
-        out.writeBoolean(lock);
-    }
-
-    /** {@inheritDoc} */
-    @SuppressWarnings({"unchecked"})
-    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-        ctx = (GridCacheContext<K, V>)in.readObject();
-
-        delegate = (IgniteInternalCache<K, V>)in.readObject();
-
-        opCtx = (CacheOperationContext)in.readObject();
-
-        gate = ctx.gate();
-
-        lock = in.readBoolean();
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteFuture<?> rebalance() {
-        return new IgniteFutureImpl<>(ctx.preloader().forceRebalance());
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteFuture<?> indexReadyFuture() {
-        IgniteInternalFuture fut = ctx.shared().database().indexRebuildFuture(ctx.cacheId());
-
-        if (fut == null)
-            return new IgniteFinishedFutureImpl<>();
-
-        return new IgniteFutureImpl<>(fut);
-    }
+    public void closeProxy();
 
     /**
-     * Gets value without waiting for toplogy changes.
+     * Gets value without waiting for topology changes.
      *
      * @param key Key.
      * @return Value.
      */
-    public V getTopologySafe(K key) {
-        try {
-            GridCacheGateway<K, V> gate = this.gate;
-
-            CacheOperationContext prev = onEnter(gate, opCtx);
-
-            try {
-                return delegate.getTopologySafe(key);
-            }
-            finally {
-                onLeave(gate, prev);
-            }
-        }
-        catch (IgniteCheckedException e) {
-            throw cacheException(e);
-        }
-    }
-
-    /**
-     * @return Restart future.
-     */
-    public boolean isRestarting() {
-        return restartFut.get() != null;
-    }
+    public V getTopologySafe(K key);
 
     /**
-     * Restarts this cache proxy.
+     * @return Future that contains cache destroy operation.
      */
-    public void restart() {
-        GridFutureAdapter<Void> restartFut = new GridFutureAdapter<>();
-
-        final GridFutureAdapter<Void> currentFut = this.restartFut.get();
-
-        boolean changed = this.restartFut.compareAndSet(currentFut, restartFut);
-
-        if (changed && currentFut != null)
-            restartFut.listen(new IgniteInClosure<IgniteInternalFuture<Void>>() {
-                @Override public void apply(IgniteInternalFuture<Void> future) {
-                    if (future.error() != null)
-                        currentFut.onDone(future.error());
-                    else
-                        currentFut.onDone();
-                }
-            });
-    }
+    public IgniteFuture<?> destroyAsync();
 
     /**
-     * Mark this proxy as restarted.
-     *
-     * @param ctx New cache context.
-     * @param delegate New delegate.
+     * @return Future that contains cache close operation.
      */
-    public void onRestarted(GridCacheContext ctx, IgniteInternalCache delegate) {
-        GridFutureAdapter<Void> restartFut = this.restartFut.get();
-
-        assert restartFut != null;
-
-        this.ctx = ctx;
-        this.delegate = delegate;
-
-        gate = ctx.gate();
-
-        internalProxy = new GridCacheProxyImpl<>(ctx, delegate, opCtx);
-
-        restartFut.onDone();
-
-        this.restartFut.compareAndSet(restartFut, null);
-    }
-
-    /** {@inheritDoc} */
-    @Override public String toString() {
-        return S.toString(IgniteCacheProxy.class, this);
-    }
+    public IgniteFuture<?> closeAsync();
 }


[15/47] ignite git commit: IGNITE-5729 - IgniteCacheProxy instances from with() methods are not reusable after cache restart

Posted by ag...@apache.org.
IGNITE-5729 - IgniteCacheProxy instances from with() methods are not reusable after cache restart


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

Branch: refs/heads/master
Commit: 5172541f71e9878b4cc9df18580cdf1863a5820b
Parents: bcbb10d
Author: Pavel Kovalenko <jo...@gmail.com>
Authored: Thu Jul 27 10:41:41 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Thu Jul 27 10:41:41 2017 +0300

----------------------------------------------------------------------
 .../JettyRestProcessorAbstractSelfTest.java     |   18 +-
 .../org/apache/ignite/cache/CacheManager.java   |    4 +-
 .../cache/CacheAffinitySharedManager.java       |   23 +-
 .../processors/cache/CacheOperationContext.java |   15 +
 .../cache/GatewayProtectedCacheProxy.java       | 1754 +++++++++++
 .../processors/cache/GridCacheProcessor.java    |   51 +-
 .../processors/cache/IgniteCacheProxy.java      | 2818 +-----------------
 .../processors/cache/IgniteCacheProxyImpl.java  | 1810 +++++++++++
 .../dr/IgniteDrDataStreamerCacheUpdater.java    |    2 +-
 .../platform/cache/PlatformCache.java           |   33 +-
 .../cache/CacheEntryProcessorCopySelfTest.java  |   11 +-
 .../cache/CacheStopAndDestroySelfTest.java      |    1 +
 .../cache/GridCacheAbstractSelfTest.java        |    2 +
 .../GridCacheOnCopyFlagAbstractSelfTest.java    |    6 +-
 ...idCacheValueConsistencyAbstractSelfTest.java |    4 +-
 .../IgniteCacheConfigVariationsFullApiTest.java |    6 +-
 .../IgniteCacheEntryListenerAbstractTest.java   |    1 -
 .../processors/cache/IgniteCacheGroupsTest.java |   67 +-
 .../cache/IgniteCacheStartStopLoadTest.java     |    1 -
 .../MemoryPolicyInitializationTest.java         |    3 +-
 .../marshaller/GridMarshallerAbstractTest.java  |   10 +-
 21 files changed, 3737 insertions(+), 2903 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/5172541f/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 97321a7..d99f278 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
@@ -17,8 +17,6 @@
 
 package org.apache.ignite.internal.processors.rest;
 
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
@@ -38,6 +36,8 @@ import java.util.Map;
 import java.util.Set;
 import java.util.UUID;
 import java.util.concurrent.ConcurrentHashMap;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.cache.CacheMode;
 import org.apache.ignite.cache.query.SqlQuery;
@@ -76,8 +76,8 @@ import org.apache.ignite.internal.visor.cache.VisorCacheRebalanceTask;
 import org.apache.ignite.internal.visor.cache.VisorCacheRebalanceTaskArg;
 import org.apache.ignite.internal.visor.cache.VisorCacheResetMetricsTask;
 import org.apache.ignite.internal.visor.cache.VisorCacheResetMetricsTaskArg;
-import org.apache.ignite.internal.visor.cache.VisorCacheStartTaskArg;
 import org.apache.ignite.internal.visor.cache.VisorCacheStartTask;
+import org.apache.ignite.internal.visor.cache.VisorCacheStartTaskArg;
 import org.apache.ignite.internal.visor.cache.VisorCacheStopTask;
 import org.apache.ignite.internal.visor.cache.VisorCacheStopTaskArg;
 import org.apache.ignite.internal.visor.compute.VisorComputeCancelSessionsTask;
@@ -87,8 +87,8 @@ import org.apache.ignite.internal.visor.compute.VisorComputeToggleMonitoringTask
 import org.apache.ignite.internal.visor.compute.VisorComputeToggleMonitoringTaskArg;
 import org.apache.ignite.internal.visor.compute.VisorGatewayTask;
 import org.apache.ignite.internal.visor.debug.VisorThreadDumpTask;
-import org.apache.ignite.internal.visor.file.VisorFileBlockTaskArg;
 import org.apache.ignite.internal.visor.file.VisorFileBlockTask;
+import org.apache.ignite.internal.visor.file.VisorFileBlockTaskArg;
 import org.apache.ignite.internal.visor.file.VisorLatestTextFilesTask;
 import org.apache.ignite.internal.visor.file.VisorLatestTextFilesTaskArg;
 import org.apache.ignite.internal.visor.igfs.VisorIgfsFormatTask;
@@ -101,8 +101,8 @@ import org.apache.ignite.internal.visor.igfs.VisorIgfsResetMetricsTask;
 import org.apache.ignite.internal.visor.igfs.VisorIgfsResetMetricsTaskArg;
 import org.apache.ignite.internal.visor.igfs.VisorIgfsSamplingStateTask;
 import org.apache.ignite.internal.visor.igfs.VisorIgfsSamplingStateTaskArg;
-import org.apache.ignite.internal.visor.log.VisorLogSearchTaskArg;
 import org.apache.ignite.internal.visor.log.VisorLogSearchTask;
+import org.apache.ignite.internal.visor.log.VisorLogSearchTaskArg;
 import org.apache.ignite.internal.visor.misc.VisorAckTask;
 import org.apache.ignite.internal.visor.misc.VisorAckTaskArg;
 import org.apache.ignite.internal.visor.misc.VisorChangeGridActiveStateTask;
@@ -121,16 +121,16 @@ import org.apache.ignite.internal.visor.node.VisorNodeSuppressedErrorsTask;
 import org.apache.ignite.internal.visor.node.VisorNodeSuppressedErrorsTaskArg;
 import org.apache.ignite.internal.visor.query.VisorQueryCancelTask;
 import org.apache.ignite.internal.visor.query.VisorQueryCancelTaskArg;
+import org.apache.ignite.internal.visor.query.VisorQueryCleanupTask;
 import org.apache.ignite.internal.visor.query.VisorQueryCleanupTaskArg;
 import org.apache.ignite.internal.visor.query.VisorQueryDetailMetricsCollectorTask;
 import org.apache.ignite.internal.visor.query.VisorQueryDetailMetricsCollectorTaskArg;
-import org.apache.ignite.internal.visor.query.VisorQueryResetMetricsTask;
-import org.apache.ignite.internal.visor.query.VisorQueryResetMetricsTaskArg;
-import org.apache.ignite.internal.visor.query.VisorQueryTaskArg;
-import org.apache.ignite.internal.visor.query.VisorQueryCleanupTask;
 import org.apache.ignite.internal.visor.query.VisorQueryNextPageTask;
 import org.apache.ignite.internal.visor.query.VisorQueryNextPageTaskArg;
+import org.apache.ignite.internal.visor.query.VisorQueryResetMetricsTask;
+import org.apache.ignite.internal.visor.query.VisorQueryResetMetricsTaskArg;
 import org.apache.ignite.internal.visor.query.VisorQueryTask;
+import org.apache.ignite.internal.visor.query.VisorQueryTaskArg;
 import org.apache.ignite.internal.visor.query.VisorRunningQueriesCollectorTask;
 import org.apache.ignite.internal.visor.query.VisorRunningQueriesCollectorTaskArg;
 import org.apache.ignite.lang.IgniteBiPredicate;

http://git-wip-us.apache.org/repos/asf/ignite/blob/5172541f/modules/core/src/main/java/org/apache/ignite/cache/CacheManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/CacheManager.java b/modules/core/src/main/java/org/apache/ignite/cache/CacheManager.java
index 351cd0d..03d1f40 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/CacheManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/CacheManager.java
@@ -43,7 +43,7 @@ import org.apache.ignite.internal.GridKernalState;
 import org.apache.ignite.internal.IgniteKernal;
 import org.apache.ignite.internal.IgnitionEx;
 import org.apache.ignite.internal.mxbean.IgniteStandardMXBean;
-import org.apache.ignite.internal.processors.cache.IgniteCacheProxy;
+import org.apache.ignite.internal.processors.cache.GatewayProtectedCacheProxy;
 import org.apache.ignite.internal.util.IgniteUtils;
 import org.apache.ignite.internal.util.typedef.internal.CU;
 import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
@@ -177,7 +177,7 @@ public class CacheManager implements javax.cache.CacheManager {
             if (res == null)
                 throw new CacheException();
 
-            ((IgniteCacheProxy<K, V>)res).setCacheManager(this);
+            ((GatewayProtectedCacheProxy<K, V>)res).setCacheManager(this);
 
             if (igniteCacheCfg.isManagementEnabled())
                 enableManagement(cacheName, true);

http://git-wip-us.apache.org/repos/asf/ignite/blob/5172541f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java
index 79ab183..d251d52 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java
@@ -703,7 +703,7 @@ public class CacheAffinitySharedManager<K, V> extends GridCacheSharedManagerAdap
                 assert cctx.cacheContext(cacheDesc.cacheId()) == null
                     : "Starting cache has not null context: " + cacheDesc.cacheName();
 
-                IgniteCacheProxy cacheProxy = cctx.cache().jcacheProxy(req.cacheName());
+                IgniteCacheProxyImpl cacheProxy = (IgniteCacheProxyImpl) cctx.cache().jcacheProxy(req.cacheName());
 
                 // If it has proxy then try to start it
                 if (cacheProxy != null) {
@@ -772,28 +772,9 @@ public class CacheAffinitySharedManager<K, V> extends GridCacheSharedManagerAdap
         for (ExchangeActions.CacheActionData action : exchActions.cacheStopRequests())
             cctx.cache().blockGateway(action.request().cacheName(), true, action.request().restart());
 
-        for (ExchangeActions.CacheGroupActionData action : exchActions.cacheGroupsToStop()) {
+        for (ExchangeActions.CacheGroupActionData action : exchActions.cacheGroupsToStop())
             cctx.exchange().clearClientTopology(action.descriptor().groupId());
 
-            CacheGroupContext gctx = cctx.cache().cacheGroup(action.descriptor().groupId());
-
-            if (gctx != null) {
-                IgniteCheckedException ex;
-
-                String msg = "Failed to wait for topology update, cache group is stopping.";
-
-                // If snapshot operation in progress we must throw CacheStoppedException
-                // for correct cache proxy restart. For more details see
-                // IgniteCacheProxy.cacheException()
-                if (cctx.cache().context().snapshot().snapshotOperationInProgress())
-                    ex = new CacheStoppedException(msg);
-                else
-                    ex = new IgniteCheckedException(msg);
-
-                gctx.affinity().cancelFutures(ex);
-            }
-        }
-
         Set<Integer> stoppedGrps = null;
 
         if (crd) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/5172541f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheOperationContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheOperationContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheOperationContext.java
index bcc0ee9..eb2b902 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheOperationContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheOperationContext.java
@@ -233,6 +233,21 @@ public class CacheOperationContext implements Serializable {
     }
 
     /**
+     * @param dataCenterId Data center id.
+     * @return Operation context.
+     */
+    public CacheOperationContext setDataCenterId(byte dataCenterId) {
+        return new CacheOperationContext(
+                skipStore,
+                subjId,
+                keepBinary,
+                expiryPlc,
+                noRetries,
+                dataCenterId,
+                recovery);
+    }
+
+    /**
      * @param recovery Recovery flag.
      * @return New instance of CacheOperationContext with recovery flag.
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/5172541f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GatewayProtectedCacheProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GatewayProtectedCacheProxy.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GatewayProtectedCacheProxy.java
new file mode 100644
index 0000000..5ba6810
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GatewayProtectedCacheProxy.java
@@ -0,0 +1,1754 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.locks.Lock;
+import javax.cache.CacheException;
+import javax.cache.CacheManager;
+import javax.cache.configuration.CacheEntryListenerConfiguration;
+import javax.cache.configuration.Configuration;
+import javax.cache.expiry.ExpiryPolicy;
+import javax.cache.integration.CompletionListener;
+import javax.cache.processor.EntryProcessor;
+import javax.cache.processor.EntryProcessorResult;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheEntry;
+import org.apache.ignite.cache.CacheEntryProcessor;
+import org.apache.ignite.cache.CacheMetrics;
+import org.apache.ignite.cache.CachePeekMode;
+import org.apache.ignite.cache.query.FieldsQueryCursor;
+import org.apache.ignite.cache.query.Query;
+import org.apache.ignite.cache.query.QueryCursor;
+import org.apache.ignite.cache.query.QueryDetailMetrics;
+import org.apache.ignite.cache.query.QueryMetrics;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.cluster.ClusterGroup;
+import org.apache.ignite.internal.AsyncSupportAdapter;
+import org.apache.ignite.internal.util.tostring.GridToStringExclude;
+import org.apache.ignite.lang.IgniteBiPredicate;
+import org.apache.ignite.lang.IgniteClosure;
+import org.apache.ignite.lang.IgniteFuture;
+import org.apache.ignite.mxbean.CacheMetricsMXBean;
+import org.apache.ignite.transactions.TransactionException;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Cache proxy wrapper with gateway lock provided operations and possibility to change cache operation context.
+ */
+public class GatewayProtectedCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V>>
+    implements IgniteCacheProxy<K, V> {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** Cache proxy delegate. */
+    private IgniteCacheProxy<K, V> delegate;
+
+    /** If {@code false} does not acquire read lock on gateway enter. */
+    @GridToStringExclude private boolean lock;
+
+    /** Cache operation context. */
+    private CacheOperationContext opCtx;
+
+    /**
+     * Empty constructor required for {@link Externalizable}.
+     */
+    public GatewayProtectedCacheProxy() {
+    }
+
+    /**
+     *
+     * @param delegate Cache proxy delegate.
+     * @param opCtx Cache operation context.
+     * @param lock True if cache proxy should be protected with gateway lock, false in other case.
+     */
+    public GatewayProtectedCacheProxy(
+        @NotNull IgniteCacheProxy<K, V> delegate,
+        @NotNull CacheOperationContext opCtx,
+        boolean lock
+    ) {
+        this.delegate = delegate;
+        this.opCtx = opCtx;
+        this.lock = lock;
+    }
+
+    /**
+     * Sets CacheManager to delegate.
+     *
+     * @param cacheMgr Cache Manager.
+     */
+    public void setCacheManager(org.apache.ignite.cache.CacheManager cacheMgr) {
+        if (delegate instanceof IgniteCacheProxyImpl)
+            ((IgniteCacheProxyImpl) delegate).setCacheManager(cacheMgr);
+    }
+
+    /** {@inheritDoc} */
+    @Override public GridCacheContext<K, V> context() {
+        return delegate.context();
+    }
+
+    /** {@inheritDoc} */
+    @Override public <C extends Configuration<K, V>> C getConfiguration(Class<C> clazz) {
+        return delegate.getConfiguration(clazz);
+    }
+
+    /** {@inheritDoc} */
+    @Override public String getName() {
+        return delegate.getName();
+    }
+
+    /** {@inheritDoc} */
+    @Override public CacheManager getCacheManager() {
+        return delegate.getCacheManager();
+    }
+
+    /** {@inheritDoc} */
+    @Override public GridCacheProxyImpl<K, V> internalProxy() {
+        return delegate.internalProxy();
+    }
+
+    /** {@inheritDoc} */
+    @Override public GatewayProtectedCacheProxy<K, V> cacheNoGate() {
+        return new GatewayProtectedCacheProxy<>(delegate, opCtx, false);
+    }
+
+    /** {@inheritDoc} */
+    @Override public GatewayProtectedCacheProxy<K, V> withExpiryPolicy(ExpiryPolicy plc) {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return new GatewayProtectedCacheProxy<>(delegate, opCtx.withExpiryPolicy(plc), lock);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public GatewayProtectedCacheProxy<K, V> withSkipStore() {
+        return skipStore();
+    }
+
+    /** {@inheritDoc} */
+    @Override public GatewayProtectedCacheProxy<K, V> skipStore() {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            boolean skip = opCtx.skipStore();
+
+            if (skip)
+                return this;
+
+            return new GatewayProtectedCacheProxy<>(delegate, opCtx.setSkipStore(true), lock);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public GatewayProtectedCacheProxy<K, V> withNoRetries() {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            boolean noRetries = opCtx.noRetries();
+
+            if (noRetries)
+                return this;
+
+            return new GatewayProtectedCacheProxy<>(delegate, opCtx.setNoRetries(true), lock);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public GatewayProtectedCacheProxy<K, V> withPartitionRecover() {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            boolean recovery = opCtx.recovery();
+
+            if (recovery)
+                return this;
+
+            return new GatewayProtectedCacheProxy<>(delegate, opCtx.setRecovery(true), lock);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public <K1, V1> GatewayProtectedCacheProxy<K1, V1> withKeepBinary() {
+        return keepBinary();
+    }
+
+    /** {@inheritDoc} */
+    @Override public <K1, V1> GatewayProtectedCacheProxy<K1, V1> keepBinary() {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return new GatewayProtectedCacheProxy<>((IgniteCacheProxy<K1, V1>) delegate, opCtx.keepBinary(), lock);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public GatewayProtectedCacheProxy<K, V> withDataCenterId(byte dataCenterId) {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            Byte prevDataCenterId = opCtx.dataCenterId();
+
+            if (prevDataCenterId != null && dataCenterId == prevDataCenterId)
+                return this;
+
+            return new GatewayProtectedCacheProxy<>(delegate, opCtx.setDataCenterId(dataCenterId), lock);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public void loadCache(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args) throws CacheException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            delegate.loadCache(p, args);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<Void> loadCacheAsync(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args) throws CacheException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.loadCacheAsync(p, args);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public void localLoadCache(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args) throws CacheException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            delegate.localLoadCache(p, args);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<Void> localLoadCacheAsync(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args) throws CacheException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.localLoadCacheAsync(p, args);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public V getAndPutIfAbsent(K key, V val) throws CacheException, TransactionException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.getAndPutIfAbsent(key, val);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<V> getAndPutIfAbsentAsync(K key, V val) throws CacheException, TransactionException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.getAndPutIfAbsentAsync(key, val);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public Lock lock(K key) {
+        return delegate.lock(key);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Lock lockAll(Collection<? extends K> keys) {
+        return delegate.lockAll(keys);
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isLocalLocked(K key, boolean byCurrThread) {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.isLocalLocked(key, byCurrThread);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public <R> QueryCursor<R> query(Query<R> qry) {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.query(qry);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public FieldsQueryCursor<List<?>> query(SqlFieldsQuery qry) {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.query(qry);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public <T, R> QueryCursor<R> query(Query<T> qry, IgniteClosure<T, R> transformer) {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.query(qry, transformer);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public Iterable<Entry<K, V>> localEntries(CachePeekMode... peekModes) throws CacheException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.localEntries(peekModes);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public QueryMetrics queryMetrics() {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.queryMetrics();
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public void resetQueryMetrics() {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            delegate.resetQueryMetrics();
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public Collection<? extends QueryDetailMetrics> queryDetailMetrics() {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.queryDetailMetrics();
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public void resetQueryDetailMetrics() {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            delegate.resetQueryDetailMetrics();
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public void localEvict(Collection<? extends K> keys) {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            delegate.localEvict(keys);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public V localPeek(K key, CachePeekMode... peekModes) {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.localPeek(key, peekModes);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public int size(CachePeekMode... peekModes) throws CacheException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.size(peekModes);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<Integer> sizeAsync(CachePeekMode... peekModes) throws CacheException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.sizeAsync(peekModes);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public long sizeLong(CachePeekMode... peekModes) throws CacheException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.sizeLong(peekModes);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<Long> sizeLongAsync(CachePeekMode... peekModes) throws CacheException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.sizeLongAsync(peekModes);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public long sizeLong(int partition, CachePeekMode... peekModes) throws CacheException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.sizeLong(partition, peekModes);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<Long> sizeLongAsync(int partition, CachePeekMode... peekModes) throws CacheException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.sizeLongAsync(partition, peekModes);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public int localSize(CachePeekMode... peekModes) {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.localSize(peekModes);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public long localSizeLong(CachePeekMode... peekModes) {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.localSizeLong(peekModes);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public long localSizeLong(int partition, CachePeekMode... peekModes) {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.localSizeLong(partition, peekModes);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public <T> Map<K, EntryProcessorResult<T>> invokeAll(Map<? extends K, ? extends EntryProcessor<K, V, T>> map, Object... args) throws TransactionException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.invokeAll(map, args);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public <T> IgniteFuture<Map<K, EntryProcessorResult<T>>> invokeAllAsync(Map<? extends K, ? extends EntryProcessor<K, V, T>> map, Object... args) throws TransactionException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.invokeAllAsync(map, args);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public V get(K key) throws TransactionException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.get(key);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<V> getAsync(K key) {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.getAsync(key);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public CacheEntry<K, V> getEntry(K key) throws TransactionException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.getEntry(key);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<CacheEntry<K, V>> getEntryAsync(K key) throws TransactionException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.getEntryAsync(key);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public Map<K, V> getAll(Set<? extends K> keys) throws TransactionException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.getAll(keys);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<Map<K, V>> getAllAsync(Set<? extends K> keys) throws TransactionException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.getAllAsync(keys);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public Collection<CacheEntry<K, V>> getEntries(Set<? extends K> keys) throws TransactionException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.getEntries(keys);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<Collection<CacheEntry<K, V>>> getEntriesAsync(Set<? extends K> keys) throws TransactionException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.getEntriesAsync(keys);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public Map<K, V> getAllOutTx(Set<? extends K> keys) {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.getAllOutTx(keys);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<Map<K, V>> getAllOutTxAsync(Set<? extends K> keys) {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.getAllOutTxAsync(keys);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean containsKey(K key) throws TransactionException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.containsKey(key);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public void loadAll(Set<? extends K> keys, boolean replaceExisting, CompletionListener completionListener) {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            delegate.loadAll(keys, replaceExisting, completionListener);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<Boolean> containsKeyAsync(K key) throws TransactionException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.containsKeyAsync(key);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean containsKeys(Set<? extends K> keys) throws TransactionException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.containsKeys(keys);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<Boolean> containsKeysAsync(Set<? extends K> keys) throws TransactionException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.containsKeysAsync(keys);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public void put(K key, V val) throws TransactionException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            delegate.put(key, val);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<Void> putAsync(K key, V val) throws TransactionException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.putAsync(key, val);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public V getAndPut(K key, V val) throws TransactionException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.getAndPut(key, val);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<V> getAndPutAsync(K key, V val) throws TransactionException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.getAndPutAsync(key, val);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public void putAll(Map<? extends K, ? extends V> map) throws TransactionException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            delegate.putAll(map);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<Void> putAllAsync(Map<? extends K, ? extends V> map) throws TransactionException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.putAllAsync(map);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean putIfAbsent(K key, V val) throws TransactionException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.putIfAbsent(key, val);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<Boolean> putIfAbsentAsync(K key, V val) {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.putIfAbsentAsync(key, val);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean remove(K key) throws TransactionException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.remove(key);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<Boolean> removeAsync(K key) throws TransactionException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.removeAsync(key);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean remove(K key, V oldVal) throws TransactionException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.remove(key, oldVal);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<Boolean> removeAsync(K key, V oldVal) throws TransactionException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.removeAsync(key, oldVal);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public V getAndRemove(K key) throws TransactionException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.getAndRemove(key);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<V> getAndRemoveAsync(K key) throws TransactionException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.getAndRemoveAsync(key);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean replace(K key, V oldVal, V newVal) throws TransactionException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.replace(key, oldVal, newVal);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<Boolean> replaceAsync(K key, V oldVal, V newVal) throws TransactionException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.replaceAsync(key, oldVal, newVal);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean replace(K key, V val) throws TransactionException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.replace(key, val);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<Boolean> replaceAsync(K key, V val) throws TransactionException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.replaceAsync(key, val);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public V getAndReplace(K key, V val) throws TransactionException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.getAndReplace(key, val);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<V> getAndReplaceAsync(K key, V val) {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.getAndReplaceAsync(key, val);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public void removeAll(Set<? extends K> keys) throws TransactionException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            delegate.removeAll(keys);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<Void> removeAllAsync(Set<? extends K> keys) throws TransactionException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.removeAllAsync(keys);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public void removeAll() {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            delegate.removeAll();
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<Void> removeAllAsync() {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.removeAllAsync();
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public void clear() {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            delegate.clear();
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<Void> clearAsync() {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.clearAsync();
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public void clear(K key) {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            delegate.clear(key);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<Void> clearAsync(K key) {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.clearAsync(key);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public void clearAll(Set<? extends K> keys) {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            delegate.clearAll(keys);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<Void> clearAllAsync(Set<? extends K> keys) {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.clearAllAsync(keys);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public void localClear(K key) {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            delegate.localClear(key);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public void localClearAll(Set<? extends K> keys) {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            delegate.localClearAll(keys);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public <T> T invoke(K key, EntryProcessor<K, V, T> entryProcessor, Object... arguments) throws TransactionException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.invoke(key, entryProcessor, arguments);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public <T> IgniteFuture<T> invokeAsync(K key, EntryProcessor<K, V, T> entryProcessor, Object... arguments) throws TransactionException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.invokeAsync(key, entryProcessor, arguments);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public <T> T invoke(K key, CacheEntryProcessor<K, V, T> entryProcessor, Object... arguments) throws TransactionException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.invoke(key, entryProcessor, arguments);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public <T> IgniteFuture<T> invokeAsync(K key, CacheEntryProcessor<K, V, T> entryProcessor, Object... arguments) throws TransactionException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.invokeAsync(key, entryProcessor, arguments);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public <T> Map<K, EntryProcessorResult<T>> invokeAll(Set<? extends K> keys, EntryProcessor<K, V, T> entryProcessor, Object... args) throws TransactionException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.invokeAll(keys, entryProcessor, args);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public <T> IgniteFuture<Map<K, EntryProcessorResult<T>>> invokeAllAsync(Set<? extends K> keys, EntryProcessor<K, V, T> entryProcessor, Object... args) throws TransactionException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.invokeAllAsync(keys, entryProcessor, args);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public <T> Map<K, EntryProcessorResult<T>> invokeAll(Set<? extends K> keys, CacheEntryProcessor<K, V, T> entryProcessor, Object... args) throws TransactionException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.invokeAll(keys, entryProcessor, args);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public <T> IgniteFuture<Map<K, EntryProcessorResult<T>>> invokeAllAsync(Set<? extends K> keys, CacheEntryProcessor<K, V, T> entryProcessor, Object... args) throws TransactionException {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.invokeAllAsync(keys, entryProcessor, args);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public <T> T unwrap(Class<T> clazz) {
+        return delegate.unwrap(clazz);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void registerCacheEntryListener(CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration) {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            delegate.registerCacheEntryListener(cacheEntryListenerConfiguration);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public void deregisterCacheEntryListener(CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration) {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            delegate.deregisterCacheEntryListener(cacheEntryListenerConfiguration);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public Iterator<Entry<K, V>> iterator() {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.iterator();
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public void destroy() {
+        GridCacheGateway<K, V> gate = gate();
+
+        if (!onEnterIfNoStop(gate))
+            return;
+
+        IgniteFuture<?> destroyFuture;
+
+        try {
+            destroyFuture = delegate.destroyAsync();
+        }
+        finally {
+            onLeave(gate);
+        }
+
+        if (destroyFuture != null)
+            destroyFuture.get();
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<?> destroyAsync() {
+        return delegate.destroyAsync();
+    }
+
+    /** {@inheritDoc} */
+    @Override public void close() {
+        GridCacheGateway<K, V> gate = gate();
+
+        if (!onEnterIfNoStop(gate))
+            return;
+
+        IgniteFuture<?> closeFuture;
+
+        try {
+            closeFuture = closeAsync();
+        }
+        finally {
+            onLeave(gate);
+        }
+
+        if (closeFuture != null)
+            closeFuture.get();
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<?> closeAsync() {
+        return delegate.closeAsync();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isClosed() {
+        return delegate.isClosed();
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<?> rebalance() {
+        return delegate.rebalance();
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<?> indexReadyFuture() {
+        return delegate.indexReadyFuture();
+    }
+
+    /** {@inheritDoc} */
+    @Override public CacheMetrics metrics() {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.metrics();
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public CacheMetrics metrics(ClusterGroup grp) {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.metrics(grp);
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public CacheMetrics localMetrics() {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.localMetrics();
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public CacheMetricsMXBean mxBean() {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.mxBean();
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public CacheMetricsMXBean localMxBean() {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.localMxBean();
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public Collection<Integer> lostPartitions() {
+        GridCacheGateway<K, V> gate = gate();
+
+        CacheOperationContext prev = onEnter(gate, opCtx);
+
+        try {
+            return delegate.lostPartitions();
+        }
+        finally {
+            onLeave(gate, prev);
+        }
+    }
+
+    /**
+     * Safely get CacheGateway.
+     *
+     * @return Cache Gateway.
+     */
+    @Nullable private GridCacheGateway<K, V> gate() {
+        GridCacheContext<K, V> cacheContext = delegate.context();
+        return cacheContext != null ? cacheContext.gate() : null;
+    }
+
+    /**
+     * Checks that proxy is in valid state (not closed, restarted or destroyed).
+     * Throws IllegalStateException or CacheRestartingException if proxy is in invalid state.
+     *
+     * @param gate Cache gateway.
+     */
+    private void checkProxyIsValid(@Nullable GridCacheGateway<K, V> gate) {
+        if (isProxyClosed())
+            throw new IllegalStateException("Cache has been closed: " + context().name());
+
+        if (delegate instanceof IgniteCacheProxyImpl)
+            ((IgniteCacheProxyImpl) delegate).checkRestart();
+        
+        if (gate == null)
+            throw new IllegalStateException("Gateway is unavailable. Probably cache has been destroyed, but proxy is not closed.");
+    }
+    
+    /**
+     * @param gate Cache gateway.
+     * @param opCtx Cache operation context to guard.
+     * @return Previous projection set on this thread.
+     */
+    private CacheOperationContext onEnter(@Nullable GridCacheGateway<K, V> gate, CacheOperationContext opCtx) {
+        checkProxyIsValid(gate);
+        
+        return lock ? gate.enter(opCtx) : gate.enterNoLock(opCtx);
+    }
+
+    /**
+     * @param gate Cache gateway.
+     * @return {@code True} if enter successful.
+     */
+    private boolean onEnterIfNoStop(@Nullable GridCacheGateway<K, V> gate) {
+        try {
+            checkProxyIsValid(gate);
+        }
+        catch (Exception e) {
+            return false;
+        }
+
+        return lock ? gate.enterIfNotStopped() : gate.enterIfNotStoppedNoLock();
+    }
+
+    /**
+     * @param gate Cache gateway.
+     * @param opCtx Operation context to guard.
+     */
+    private void onLeave(GridCacheGateway<K, V> gate, CacheOperationContext opCtx) {
+        if (lock)
+            gate.leave(opCtx);
+        else
+            gate.leaveNoLock(opCtx);
+    }
+
+    /**
+     * @param gate Cache gateway.
+     */
+    private void onLeave(GridCacheGateway<K, V> gate) {
+        if (lock)
+            gate.leave();
+        else
+            gate.leaveNoLock();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isProxyClosed() {
+        return delegate.isProxyClosed();
+    }
+
+    /** {@inheritDoc} */
+    @Override public void closeProxy() {
+        delegate.closeProxy();
+    }
+
+    /** {@inheritDoc} */
+    @Override public V getTopologySafe(K key) {
+        return delegate.getTopologySafe(key);
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteCache<K, V> withAsync() {
+        return delegate.withAsync();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isAsync() {
+        return delegate.isAsync();
+    }
+
+    /** {@inheritDoc} */
+    @Override public <R> IgniteFuture<R> future() {
+        return delegate.future();
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeExternal(ObjectOutput out) throws IOException {
+        out.writeObject(delegate);
+
+        out.writeBoolean(lock);
+
+        out.writeObject(opCtx);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        delegate = (IgniteCacheProxy<K, V>) in.readObject();
+
+        lock = in.readBoolean();
+
+        opCtx = (CacheOperationContext) in.readObject();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object another) {
+        GatewayProtectedCacheProxy anotherProxy = (GatewayProtectedCacheProxy) another;
+
+        return delegate.equals(anotherProxy.delegate);
+    }
+
+    /** {@inheritDoc} */
+    @Override public int hashCode() {
+        return delegate.hashCode();
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/5172541f/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 9902a92..bbd7500 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
@@ -194,7 +194,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
     private final Map<String, GridCacheAdapter> stoppedCaches = new ConcurrentHashMap<>();
 
     /** Map of proxies. */
-    private final ConcurrentHashMap<String, IgniteCacheProxy<?, ?>> jCacheProxies;
+    private final ConcurrentHashMap<String, IgniteCacheProxyImpl<?, ?>> jCacheProxies;
 
     /** Caches stop sequence. */
     private final Deque<String> stopSeq;
@@ -948,7 +948,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
      */
     public void blockGateways() {
         for (IgniteCacheProxy<?, ?> proxy : jCacheProxies.values())
-            proxy.gate().onStopped();
+            proxy.context().gate().onStopped();
     }
 
     /** {@inheritDoc} */
@@ -1805,7 +1805,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
 
         CacheConfiguration ccfg = new CacheConfiguration(startCfg);
 
-        IgniteCacheProxy<?, ?> proxy = jCacheProxies.get(ccfg.getName());
+        IgniteCacheProxyImpl<?, ?> proxy = jCacheProxies.get(ccfg.getName());
 
         boolean proxyRestart = proxy != null && proxy.isRestarting() && !caches.containsKey(ccfg.getName());
 
@@ -1944,14 +1944,14 @@ public class GridCacheProcessor extends GridProcessorAdapter {
      */
     void blockGateway(String cacheName, boolean stop, boolean restart) {
         // Break the proxy before exchange future is done.
-        IgniteCacheProxy<?, ?> proxy = jCacheProxies.get(cacheName);
+        IgniteCacheProxyImpl<?, ?> proxy = jCacheProxies.get(cacheName);
 
         if (proxy != null) {
             if (stop) {
                 if (restart)
                     proxy.restart();
 
-                proxy.gate().stopped();
+                proxy.context().gate().stopped();
             }
             else
                 proxy.closeProxy();
@@ -1965,7 +1965,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
     private void stopGateway(DynamicCacheChangeRequest req) {
         assert req.stop() : req;
 
-        IgniteCacheProxy<?, ?> proxy;
+        IgniteCacheProxyImpl<?, ?> proxy;
 
         // Break the proxy before exchange future is done.
         if (req.restart()) {
@@ -1978,7 +1978,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
             proxy = jCacheProxies.remove(req.cacheName());
 
         if (proxy != null)
-            proxy.gate().onStopped();
+            proxy.context().gate().onStopped();
     }
 
     /**
@@ -2014,7 +2014,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
 
             if (cacheCtx.startTopologyVersion().equals(startTopVer) ) {
                 if (!jCacheProxies.containsKey(cacheCtx.name()))
-                    jCacheProxies.putIfAbsent(cacheCtx.name(), new IgniteCacheProxy(cache.context(), cache, null, false));
+                    jCacheProxies.putIfAbsent(cacheCtx.name(), new IgniteCacheProxyImpl(cache.context(), cache, false));
 
                 if (cacheCtx.preloader() != null)
                     cacheCtx.preloader().onInitialExchangeComplete(err);
@@ -2079,7 +2079,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
 
             assert cache != null : cctx.name();
 
-            jCacheProxies.put(cctx.name(), new IgniteCacheProxy(cache.context(), cache, null, false));
+            jCacheProxies.put(cctx.name(), new IgniteCacheProxyImpl(cache.context(), cache, false));
         }
         else {
             jCacheProxies.remove(cctx.name());
@@ -2129,6 +2129,18 @@ public class GridCacheProcessor extends GridProcessorAdapter {
             }
 
             for (ExchangeActions.CacheActionData action : exchActions.cacheStopRequests()) {
+                CacheGroupContext gctx = cacheGrps.get(action.descriptor().groupId());
+
+                // Cancel all operations blocking gateway
+                if (gctx != null) {
+                    final String msg = "Failed to wait for topology update, cache group is stopping.";
+
+                    // If snapshot operation in progress we must throw CacheStoppedException
+                    // for correct cache proxy restart. For more details see
+                    // IgniteCacheProxy.cacheException()
+                    gctx.affinity().cancelFutures(new CacheStoppedException(msg));
+                }
+
                 stopGateway(action.request());
 
                 sharedCtx.database().checkpointReadLock();
@@ -2764,7 +2776,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
 
         IgniteCacheProxy<?, ?> proxy = jCacheProxies.get(cacheName);
 
-        if (proxy == null || proxy.proxyClosed())
+        if (proxy == null || proxy.isProxyClosed())
             return new GridFinishedFuture<>(); // No-op.
 
         checkEmptyTransactions();
@@ -3202,7 +3214,11 @@ public class GridCacheProcessor extends GridProcessorAdapter {
      * @return All configured cache instances.
      */
     public Collection<IgniteCacheProxy<?, ?>> jcaches() {
-        return jCacheProxies.values();
+        return F.viewReadOnly(jCacheProxies.values(), new IgniteClosure<IgniteCacheProxyImpl<?, ?>, IgniteCacheProxy<?, ?>>() {
+            @Override public IgniteCacheProxy<?, ?> apply(IgniteCacheProxyImpl<?, ?> entry) {
+                return new GatewayProtectedCacheProxy<>(entry, new CacheOperationContext(), true);
+            }
+        });
     }
 
     /**
@@ -3226,7 +3242,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
                 GridCacheAdapter<?, ?> cacheAdapter = caches.get(name);
 
                 if (cacheAdapter != null)
-                    proxy = new IgniteCacheProxy(cacheAdapter.context(), cacheAdapter, null, false);
+                    proxy = new IgniteCacheProxyImpl(cacheAdapter.context(), cacheAdapter, false);
             }
 
             assert proxy != null : name;
@@ -3301,13 +3317,16 @@ public class GridCacheProcessor extends GridProcessorAdapter {
 
         IgniteCacheProxy<?, ?> cache = jCacheProxies.get(cacheName);
 
+        // Try to start cache, there is no guarantee that cache will be instantiated.
         if (cache == null) {
             dynamicStartCache(null, cacheName, null, false, failIfNotStarted, checkThreadTx).get();
 
             cache = jCacheProxies.get(cacheName);
         }
 
-        return (IgniteCacheProxy<K, V>)cache;
+        return cache != null ?
+            new GatewayProtectedCacheProxy<>((IgniteCacheProxy<K, V>)cache, new CacheOperationContext(), true) :
+            null;
     }
 
     /**
@@ -3424,7 +3443,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
     public <K, V> IgniteCacheProxy<K, V> jcache(String name) {
         assert name != null;
 
-        IgniteCacheProxy<K, V> cache = (IgniteCacheProxy<K, V>)jCacheProxies.get(name);
+        IgniteCacheProxy<K, V> cache = (IgniteCacheProxy<K, V>) jCacheProxies.get(name);
 
         if (cache == null)
             throw new IllegalArgumentException("Cache is not configured: " + name);
@@ -3446,9 +3465,9 @@ public class GridCacheProcessor extends GridProcessorAdapter {
     public Collection<IgniteCacheProxy<?, ?>> publicCaches() {
         Collection<IgniteCacheProxy<?, ?>> res = new ArrayList<>(jCacheProxies.size());
 
-        for (Map.Entry<String, IgniteCacheProxy<?, ?>> entry : jCacheProxies.entrySet()) {
+        for (Map.Entry<String, IgniteCacheProxyImpl<?, ?>> entry : jCacheProxies.entrySet()) {
             if (entry.getValue().context().userCache())
-                res.add(entry.getValue());
+                res.add(new GatewayProtectedCacheProxy(entry.getValue(), new CacheOperationContext(), true));
         }
 
         return res;


[32/47] ignite git commit: IGNITE-5729 Added proper exception handling to test. Fixed test.

Posted by ag...@apache.org.
IGNITE-5729 Added proper exception handling to test. Fixed test.


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

Branch: refs/heads/master
Commit: f975110f54cb08fcf85c09ec67eb0a5b45c429e5
Parents: 591566e
Author: Pavel Kovalenko <jo...@gmail.com>
Authored: Fri Jul 28 16:50:35 2017 +0300
Committer: Pavel Kovalenko <jo...@gmail.com>
Committed: Fri Jul 28 16:50:35 2017 +0300

----------------------------------------------------------------------
 .../processors/cache/IgniteCacheGroupsTest.java | 22 +++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/f975110f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheGroupsTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheGroupsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheGroupsTest.java
index b55e3d0..468bbc8 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheGroupsTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheGroupsTest.java
@@ -2872,13 +2872,25 @@ public class IgniteCacheGroupsTest extends GridCommonAbstractTest {
                     ThreadLocalRandom rnd = ThreadLocalRandom.current();
 
                     while (!stop.get()) {
-                        String grp = rnd.nextBoolean() ? GROUP1 : GROUP2;
-                        int cacheIdx = rnd.nextInt(CACHES);
+                        try {
+                            String grp = rnd.nextBoolean() ? GROUP1 : GROUP2;
+                            int cacheIdx = rnd.nextInt(CACHES);
 
-                        IgniteCache cache = node.cache(grp + "-" + cacheIdx);
+                            IgniteCache cache = node.cache(grp + "-" + cacheIdx);
 
-                        for (int i = 0; i < 10; i++)
-                            cacheOperation(rnd, cache);
+                            for (int i = 0; i < 10; i++)
+                                cacheOperation(rnd, cache);
+                        }
+                        catch (Exception e) {
+                            if (X.hasCause(e, CacheStoppedException.class)) {
+                                // Cache operation can be blocked on
+                                // awaiting new topology version and cancelled with CacheStoppedException cause.
+
+                                continue;
+                            }
+
+                            throw e;
+                        }
                     }
                 }
                 catch (Exception e) {


[42/47] ignite git commit: IGNITE-5876 Fixed typo in template.

Posted by ag...@apache.org.
IGNITE-5876 Fixed typo in template.


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

Branch: refs/heads/master
Commit: e3701f05cb5b28e0be7d99f9c36d0d2e28116ac2
Parents: 09aba54
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Mon Jul 31 14:52:03 2017 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Mon Jul 31 14:52:03 2017 +0700

----------------------------------------------------------------------
 .../frontend/app/modules/states/configuration/clusters/hadoop.pug  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/e3701f05/modules/web-console/frontend/app/modules/states/configuration/clusters/hadoop.pug
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/states/configuration/clusters/hadoop.pug b/modules/web-console/frontend/app/modules/states/configuration/clusters/hadoop.pug
index 22852cb..149c5db 100644
--- a/modules/web-console/frontend/app/modules/states/configuration/clusters/hadoop.pug
+++ b/modules/web-console/frontend/app/modules/states/configuration/clusters/hadoop.pug
@@ -78,7 +78,7 @@ include /app/helpers/jade/mixins
                 .settings-row
                     +number('Max task queue size:', model + '.maxTaskQueueSize', '"maxTaskQueueSize"', 'true', '8192', '1', 'Max task queue size')
                 .settings-row
-                    +ignite-form-group(ng-form=form ng-model=`${addresses}`)
+                    +ignite-form-group(ng-form=form ng-model=`${libs}`)
                         ignite-form-field-label
                             | Native libraries
                         ignite-form-group-tooltip


[44/47] ignite git commit: IGNITE-5697 Web Console: Added host configuration.

Posted by ag...@apache.org.
IGNITE-5697 Web Console: Added host configuration.


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

Branch: refs/heads/master
Commit: 0376c48f056fd11ec6827211725a44533fb75ee1
Parents: d4a70a8
Author: Andrey Novikov <an...@gridgain.com>
Authored: Mon Jul 31 15:17:12 2017 +0700
Committer: Andrey Novikov <an...@gridgain.com>
Committed: Mon Jul 31 15:17:12 2017 +0700

----------------------------------------------------------------------
 modules/web-console/backend/app/settings.js |  3 ++-
 modules/web-console/backend/index.js        | 20 +++++++-------------
 2 files changed, 9 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/0376c48f/modules/web-console/backend/app/settings.js
----------------------------------------------------------------------
diff --git a/modules/web-console/backend/app/settings.js b/modules/web-console/backend/app/settings.js
index 94f3d90..05cb7f6 100644
--- a/modules/web-console/backend/app/settings.js
+++ b/modules/web-console/backend/app/settings.js
@@ -54,6 +54,7 @@ module.exports.factory = function(nconf, fs) {
             dists: 'agent_dists'
         },
         server: {
+            host: nconf.get('server:host') || '127.0.0.1',
             port: _normalizePort(nconf.get('server:port') || 3000),
             SSLOptions: nconf.get('server:ssl') && {
                 enable301Redirects: true,
@@ -64,7 +65,7 @@ module.exports.factory = function(nconf, fs) {
             }
         },
         mail,
-        mongoUrl: nconf.get('mongodb:url') || 'mongodb://localhost/console',
+        mongoUrl: nconf.get('mongodb:url') || 'mongodb://127.0.0.1/console',
         cookieTTL: 3600000 * 24 * 30,
         sessionSecret: nconf.get('server:sessionSecret') || 'keyboard cat',
         tokenLength: 20

http://git-wip-us.apache.org/repos/asf/ignite/blob/0376c48f/modules/web-console/backend/index.js
----------------------------------------------------------------------
diff --git a/modules/web-console/backend/index.js b/modules/web-console/backend/index.js
index 18bb24d..f6ba439 100644
--- a/modules/web-console/backend/index.js
+++ b/modules/web-console/backend/index.js
@@ -41,21 +41,19 @@ catch (ignore) {
 /**
  * Event listener for HTTP server "error" event.
  */
-const _onError = (port, error) => {
+const _onError = (addr, error) => {
     if (error.syscall !== 'listen')
         throw error;
 
-    const bind = typeof port === 'string' ? 'Pipe ' + port : 'Port ' + port;
-
     // Handle specific listen errors with friendly messages.
     switch (error.code) {
         case 'EACCES':
-            console.error(bind + ' requires elevated privileges');
+            console.error(`Requires elevated privileges for bind to ${addr}`);
             process.exit(1);
 
             break;
         case 'EADDRINUSE':
-            console.error(bind + ' is already in use');
+            console.error(`${addr} is already in use`);
             process.exit(1);
 
             break;
@@ -83,16 +81,12 @@ const init = ([settings, apiSrv, agentsHnd, browsersHnd]) => {
     // Start rest server.
     const srv = settings.server.SSLOptions ? https.createServer(settings.server.SSLOptions) : http.createServer();
 
-    srv.listen(settings.server.port);
-
-    srv.on('error', _onError.bind(null, settings.server.port));
-    srv.on('listening', _onListening.bind(null, srv.address()));
+    srv.listen(settings.server.port, settings.server.host);
 
-    process.on('unhandledRejection', (error) => {
-        // Will print "unhandledRejection err is not defined"
-        console.log('unhandledRejection', error);
-    });
+    const addr = `${settings.server.host}:${settings.server.port}`;
 
+    srv.on('error', _onError.bind(null, addr));
+    srv.on('listening', () => console.log(`Start listening on ${addr}`));
 
     apiSrv.attach(srv);
 


[27/47] ignite git commit: IGNITE-5758: CPP: Added pointers semantics for primitive types

Posted by ag...@apache.org.
IGNITE-5758: CPP: Added pointers semantics for primitive types

(cherry picked from commit 1597a18)


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

Branch: refs/heads/master
Commit: 1d4cda94986053b531a60ce5bd3caf4eb428a18f
Parents: 96e7bb1
Author: Igor Sapego <is...@gridgain.com>
Authored: Fri Jul 28 13:51:25 2017 +0300
Committer: Igor Sapego <is...@gridgain.com>
Committed: Fri Jul 28 15:30:09 2017 +0300

----------------------------------------------------------------------
 .../include/ignite/binary/binary_writer.h       |   4 +-
 .../ignite/impl/binary/binary_reader_impl.h     |  50 ++++---
 .../ignite/impl/binary/binary_type_impl.h       |  67 +++++++++
 .../ignite/impl/binary/binary_writer_impl.h     |  43 ++++--
 .../src/impl/binary/binary_reader_impl.cpp      |  63 ++++-----
 .../src/impl/binary/binary_writer_impl.cpp      |  41 +++---
 .../src/binary_reader_writer_raw_test.cpp       |  36 +++++
 .../core-test/src/binary_reader_writer_test.cpp | 135 ++++++++++++++-----
 .../cpp/core/include/ignite/impl/ignite_impl.h  |   1 -
 .../platforms/cpp/core/src/impl/ignite_impl.cpp |   4 +
 10 files changed, 326 insertions(+), 118 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/1d4cda94/modules/platforms/cpp/binary/include/ignite/binary/binary_writer.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/include/ignite/binary/binary_writer.h b/modules/platforms/cpp/binary/include/ignite/binary/binary_writer.h
index 1489494..e609591 100644
--- a/modules/platforms/cpp/binary/include/ignite/binary/binary_writer.h
+++ b/modules/platforms/cpp/binary/include/ignite/binary/binary_writer.h
@@ -58,7 +58,7 @@ namespace ignite
              *
              * @param impl Implementation.
              */
-            BinaryWriter(ignite::impl::binary::BinaryWriterImpl* impl);
+            BinaryWriter(impl::binary::BinaryWriterImpl* impl);
 
             /**
              * Write 8-byte signed integer. Maps to "byte" type in Java.
@@ -337,7 +337,7 @@ namespace ignite
              * Start collection write.
              *
              * @param fieldName Field name.
-             * @param type Collection type.
+             * @param typ Collection type.
              * @return Collection writer.
              */
             template<typename T>

http://git-wip-us.apache.org/repos/asf/ignite/blob/1d4cda94/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_reader_impl.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_reader_impl.h b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_reader_impl.h
index 5621c0d..4a0e2d4 100644
--- a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_reader_impl.h
+++ b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_reader_impl.h
@@ -884,6 +884,17 @@ namespace ignite
                 template<typename T>
                 T ReadTopObject()
                 {
+                    return ignite::binary::ReadHelper<T>::Read(*this);
+                }
+
+                /**
+                 * Read object.
+                 *
+                 * @return Read object.
+                 */
+                template<typename T>
+                void ReadTopObject0(T& res)
+                {
                     int32_t pos = stream->Position();
                     int8_t hdr = stream->ReadInt8();
 
@@ -891,7 +902,9 @@ namespace ignite
                     {
                         case IGNITE_HDR_NULL:
                         {
-                            return GetNull<T>();
+                            res = GetNull<T>();
+
+                            return;
                         }
 
                         case IGNITE_HDR_HND:
@@ -908,11 +921,11 @@ namespace ignite
 
                             stream->Position(curPos + portOff); // Position stream right on the object.
 
-                            T val = ReadTopObject<T>();
+                            ReadTopObject0<T>(res);
 
                             stream->Position(curPos + portLen + 4); // Position stream after binary.
 
-                            return val;
+                            return;
                         }
 
                         case IGNITE_HDR_FULL:
@@ -985,12 +998,11 @@ namespace ignite
                                                         footerBegin, footerEnd, schemaType);
                             ignite::binary::BinaryReader reader(&readerImpl);
 
-                            T val;
-                            BType::Read(reader, val);
+                            BType::Read(reader, res);
 
                             stream->Position(pos + len);
 
-                            return val;
+                            return;
                         }
 
                         default:
@@ -1407,43 +1419,43 @@ namespace ignite
             };
 
             template<>
-            int8_t IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject<int8_t>();
+            void IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject0<int8_t>(int8_t& res);
 
             template<>
-            bool IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject<bool>();
+            void IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject0<bool>(bool& res);
 
             template<>
-            int16_t IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject<int16_t>();
+            void IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject0<int16_t>(int16_t& res);
 
             template<>
-            uint16_t IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject<uint16_t>();
+            void IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject0<uint16_t>(uint16_t& res);
 
             template<>
-            int32_t IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject<int32_t>();
+            void IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject0<int32_t>(int32_t& res);
 
             template<>
-            int64_t IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject<int64_t>();
+            void IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject0<int64_t>(int64_t& res);
 
             template<>
-            float IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject<float>();
+            void IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject0<float>(float& res);
 
             template<>
-            double IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject<double>();
+            void IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject0<double>(double& res);
 
             template<>
-            Guid IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject<Guid>();
+            void IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject0<Guid>(Guid& res);
 
             template<>
-            Date IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject<Date>();
+            void IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject0<Date>(Date& res);
 
             template<>
-            Timestamp IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject<Timestamp>();
+            void IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject0<Timestamp>(Timestamp& res);
 
             template<>
-            Time IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject<Time>();
+            void IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject0<Time>(Time& res);
 
             template<>
-            std::string IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject<std::string>();
+            void IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject0<std::string>(std::string& res);
 
             template<>
             inline int8_t BinaryReaderImpl::GetNull() const

http://git-wip-us.apache.org/repos/asf/ignite/blob/1d4cda94/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_type_impl.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_type_impl.h b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_type_impl.h
index 2548a83..3183d4b 100644
--- a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_type_impl.h
+++ b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_type_impl.h
@@ -18,6 +18,7 @@
 #ifndef _IGNITE_IMPL_BINARY_BINARY_TYPE_IMPL
 #define _IGNITE_IMPL_BINARY_BINARY_TYPE_IMPL
 
+#include <memory>
 #include <stdint.h>
 
 #include <ignite/ignite_error.h>
@@ -55,6 +56,72 @@ namespace ignite
 
             static void Read(BinaryReader& reader, IgniteError& dst);
         };
+
+        /**
+         * Write helper. Takes care of proper writing of pointers.
+         */
+        template<typename T>
+        struct WriteHelper
+        {
+            template<typename W>
+            static void Write(W& writer, const T& val)
+            {
+                writer.WriteTopObject0(val);
+            }
+        };
+
+        /**
+         * Specialization for the pointer case.
+         */
+        template<typename T>
+        struct WriteHelper<T*>
+        {
+            template<typename W>
+            static void Write(W& writer, const T* val)
+            {
+                if (!val)
+                    writer.WriteNull0();
+                else
+                    writer.WriteTopObject0(*val);
+            }
+        };
+
+        /**
+         * Read helper. Takes care of proper reading of pointers.
+         */
+        template<typename T>
+        struct ReadHelper
+        {
+            template<typename R>
+            static T Read(R& reader)
+            {
+                T res;
+
+                reader.template ReadTopObject0<T>(res);
+
+                return res;
+            }
+        };
+
+        /**
+         * Specialization for the pointer case.
+         */
+        template<typename T>
+        struct ReadHelper<T*>
+        {
+            template<typename R>
+            static T* Read(R& reader)
+            {
+                if (reader.SkipIfNull())
+                    return 0;
+
+                std::auto_ptr<T> res(new T());
+
+                reader.template ReadTopObject0<T>(*res);
+
+                return res.release();
+            }
+        };
     }
 }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/1d4cda94/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_writer_impl.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_writer_impl.h b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_writer_impl.h
index 32801ec..d896f3e 100644
--- a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_writer_impl.h
+++ b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_writer_impl.h
@@ -510,6 +510,11 @@ namespace ignite
                 void WriteNull(const char* fieldName);
 
                 /**
+                 * Write NULL value.
+                 */
+                void WriteNull0();
+
+                /**
                  * Start array write.
                  *
                  * @param typ Collection type.
@@ -681,6 +686,18 @@ namespace ignite
                 template<typename T>
                 void WriteTopObject(const T& obj)
                 {
+                    ignite::binary::WriteHelper<T>::Write(*this, obj);
+                }
+
+                /**
+                 * Write object.
+                 * Does not work for primitive pointer types.
+                 *
+                 * @param obj Object to write.
+                 */
+                template<typename T>
+                void WriteTopObject0(const T& obj)
+                {
                     typedef ignite::binary::BinaryType<T> BType;
 
                     if (BType::IsNull(obj))
@@ -982,43 +999,43 @@ namespace ignite
             };
 
             template<>
-            void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject(const int8_t& obj);
+            void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject0(const int8_t& obj);
 
             template<>
-            void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject(const bool& obj);
+            void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject0(const bool& obj);
 
             template<>
-            void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject(const int16_t& obj);
+            void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject0(const int16_t& obj);
 
             template<>
-            void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject(const uint16_t& obj);
+            void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject0(const uint16_t& obj);
 
             template<>
-            void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject(const int32_t& obj);
+            void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject0(const int32_t& obj);
 
             template<>
-            void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject(const int64_t& obj);
+            void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject0(const int64_t& obj);
 
             template<>
-            void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject(const float& obj);
+            void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject0(const float& obj);
 
             template<>
-            void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject(const double& obj);
+            void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject0(const double& obj);
 
             template<>
-            void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject(const Guid& obj);
+            void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject0(const Guid& obj);
 
             template<>
-            void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject(const Date& obj);
+            void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject0(const Date& obj);
 
             template<>
-            void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject(const Timestamp& obj);
+            void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject0(const Timestamp& obj);
 
             template<>
-            void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject(const Time& obj);
+            void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject0(const Time& obj);
 
             template<>
-            void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject(const std::string& obj);
+            void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject0(const std::string& obj);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/1d4cda94/modules/platforms/cpp/binary/src/impl/binary/binary_reader_impl.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/src/impl/binary/binary_reader_impl.cpp b/modules/platforms/cpp/binary/src/impl/binary/binary_reader_impl.cpp
index c6bb4f3..6fd5aea 100644
--- a/modules/platforms/cpp/binary/src/impl/binary/binary_reader_impl.cpp
+++ b/modules/platforms/cpp/binary/src/impl/binary/binary_reader_impl.cpp
@@ -721,9 +721,6 @@ namespace ignite
 
             bool BinaryReaderImpl::SkipIfNull()
             {
-                CheckRawMode(true);
-                CheckSingleMode(true);
-
                 InteropStreamPositionGuard<InteropInputStream> positionGuard(*stream);
 
                 int8_t hdr = stream->ReadInt8();
@@ -746,70 +743,70 @@ namespace ignite
             }
 
             template <>
-            int8_t BinaryReaderImpl::ReadTopObject<int8_t>()
+            void BinaryReaderImpl::ReadTopObject0<int8_t>(int8_t& res)
             {
-                return ReadTopObject0<int8_t>(IGNITE_TYPE_BYTE, BinaryUtils::ReadInt8);
+                res = ReadTopObject0<int8_t>(IGNITE_TYPE_BYTE, BinaryUtils::ReadInt8);
             }
 
             template <>
-            bool BinaryReaderImpl::ReadTopObject<bool>()
+            void BinaryReaderImpl::ReadTopObject0<bool>(bool& res)
             {
-                return ReadTopObject0<bool>(IGNITE_TYPE_BOOL, BinaryUtils::ReadBool);
+                res = ReadTopObject0<bool>(IGNITE_TYPE_BOOL, BinaryUtils::ReadBool);
             }
 
             template <>
-            int16_t BinaryReaderImpl::ReadTopObject<int16_t>()
+            void BinaryReaderImpl::ReadTopObject0<int16_t>(int16_t& res)
             {
-                return ReadTopObject0<int16_t>(IGNITE_TYPE_SHORT, BinaryUtils::ReadInt16);
+                res = ReadTopObject0<int16_t>(IGNITE_TYPE_SHORT, BinaryUtils::ReadInt16);
             }
 
             template <>
-            uint16_t BinaryReaderImpl::ReadTopObject<uint16_t>()
+            void BinaryReaderImpl::ReadTopObject0<uint16_t>(uint16_t& res)
             {
-                return ReadTopObject0<uint16_t>(IGNITE_TYPE_CHAR, BinaryUtils::ReadUInt16);
+                res = ReadTopObject0<uint16_t>(IGNITE_TYPE_CHAR, BinaryUtils::ReadUInt16);
             }
 
             template <>
-            int32_t BinaryReaderImpl::ReadTopObject<int32_t>()
+            void BinaryReaderImpl::ReadTopObject0<int32_t>(int32_t& res)
             {
-                return ReadTopObject0<int32_t>(IGNITE_TYPE_INT, BinaryUtils::ReadInt32);
+                res = ReadTopObject0<int32_t>(IGNITE_TYPE_INT, BinaryUtils::ReadInt32);
             }
 
             template <>
-            int64_t BinaryReaderImpl::ReadTopObject<int64_t>()
+            void BinaryReaderImpl::ReadTopObject0<int64_t>(int64_t& res)
             {
-                return ReadTopObject0<int64_t>(IGNITE_TYPE_LONG, BinaryUtils::ReadInt64);
+                res = ReadTopObject0<int64_t>(IGNITE_TYPE_LONG, BinaryUtils::ReadInt64);
             }
 
             template <>
-            float BinaryReaderImpl::ReadTopObject<float>()
+            void BinaryReaderImpl::ReadTopObject0<float>(float& res)
             {
-                return ReadTopObject0<float>(IGNITE_TYPE_FLOAT, BinaryUtils::ReadFloat);
+                res = ReadTopObject0<float>(IGNITE_TYPE_FLOAT, BinaryUtils::ReadFloat);
             }
 
             template <>
-            double BinaryReaderImpl::ReadTopObject<double>()
+            void BinaryReaderImpl::ReadTopObject0<double>(double& res)
             {
-                return ReadTopObject0<double>(IGNITE_TYPE_DOUBLE, BinaryUtils::ReadDouble);
+                res = ReadTopObject0<double>(IGNITE_TYPE_DOUBLE, BinaryUtils::ReadDouble);
             }
 
             template <>
-            Guid BinaryReaderImpl::ReadTopObject<Guid>()
+            void BinaryReaderImpl::ReadTopObject0<Guid>(Guid& res)
             {
-                return ReadTopObject0<Guid>(IGNITE_TYPE_UUID, BinaryUtils::ReadGuid);
+                res = ReadTopObject0<Guid>(IGNITE_TYPE_UUID, BinaryUtils::ReadGuid);
             }
 
             template <>
-            Date BinaryReaderImpl::ReadTopObject<Date>()
+            void BinaryReaderImpl::ReadTopObject0<Date>(Date& res)
             {
                 int8_t typeId = stream->ReadInt8();
 
                 if (typeId == IGNITE_TYPE_DATE)
-                    return BinaryUtils::ReadDate(stream);
+                    res = BinaryUtils::ReadDate(stream);
                 else if (typeId == IGNITE_TYPE_TIMESTAMP)
-                    return Date(BinaryUtils::ReadTimestamp(stream).GetMilliseconds());
+                    res = Date(BinaryUtils::ReadTimestamp(stream).GetMilliseconds());
                 else if (typeId == IGNITE_HDR_NULL)
-                    return BinaryUtils::GetDefaultValue<Date>();
+                    res = BinaryUtils::GetDefaultValue<Date>();
                 else {
                     int32_t pos = stream->Position() - 1;
 
@@ -819,19 +816,19 @@ namespace ignite
             }
 
             template <>
-            Timestamp BinaryReaderImpl::ReadTopObject<Timestamp>()
+            void BinaryReaderImpl::ReadTopObject0<Timestamp>(Timestamp& res)
             {
-                return ReadTopObject0<Timestamp>(IGNITE_TYPE_TIMESTAMP, BinaryUtils::ReadTimestamp);
+                res = ReadTopObject0<Timestamp>(IGNITE_TYPE_TIMESTAMP, BinaryUtils::ReadTimestamp);
             }
 
             template<>
-            Time BinaryReaderImpl::ReadTopObject<Time>()
+            void BinaryReaderImpl::ReadTopObject0<Time>(Time& res)
             {
-                return ReadTopObject0<Time>(IGNITE_TYPE_TIME, BinaryUtils::ReadTime);
+                res = ReadTopObject0<Time>(IGNITE_TYPE_TIME, BinaryUtils::ReadTime);
             }
 
             template<>
-            std::string BinaryReaderImpl::ReadTopObject<std::string>()
+            void BinaryReaderImpl::ReadTopObject0<std::string>(std::string& res)
             {
                 int8_t typeId = stream->ReadInt8();
 
@@ -839,19 +836,15 @@ namespace ignite
                 {
                     int32_t realLen = stream->ReadInt32();
 
-                    std::string res;
-
                     if (realLen > 0)
                     {
                         res.resize(realLen, 0);
 
                         stream->ReadInt8Array(reinterpret_cast<int8_t*>(&res[0]), realLen);
                     }
-
-                    return res;
                 }
                 else if (typeId == IGNITE_HDR_NULL)
-                    return std::string();
+                    res.clear();
                 else
                 {
                     int32_t pos = stream->Position() - 1;

http://git-wip-us.apache.org/repos/asf/ignite/blob/1d4cda94/modules/platforms/cpp/binary/src/impl/binary/binary_writer_impl.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/src/impl/binary/binary_writer_impl.cpp b/modules/platforms/cpp/binary/src/impl/binary/binary_writer_impl.cpp
index f93f0d3..2ac783a 100644
--- a/modules/platforms/cpp/binary/src/impl/binary/binary_writer_impl.cpp
+++ b/modules/platforms/cpp/binary/src/impl/binary/binary_writer_impl.cpp
@@ -260,7 +260,7 @@ namespace ignite
                     stream->WriteInt32(len);
 
                     for (int i = 0; i < len; i++)
-                        WriteTopObject(val[i]);
+                        WriteTopObject0(val[i]);
                 }
                 else
                 {
@@ -323,7 +323,7 @@ namespace ignite
                     stream->WriteInt32(len);
 
                     for (int i = 0; i < len; i++)
-                        WriteTopObject(val[i]);
+                        WriteTopObject0(val[i]);
                 }
                 else
                     stream->WriteInt8(IGNITE_HDR_NULL);
@@ -384,7 +384,7 @@ namespace ignite
                     stream->WriteInt32(len);
 
                     for (int i = 0; i < len; i++)
-                        WriteTopObject(val[i]);
+                        WriteTopObject0(val[i]);
                 }
                 else
                     stream->WriteInt8(IGNITE_HDR_NULL);
@@ -445,7 +445,7 @@ namespace ignite
                     stream->WriteInt32(len);
 
                     for (int i = 0; i < len; i++)
-                        WriteTopObject(val[i]);
+                        WriteTopObject0(val[i]);
                 }
                 else
                     stream->WriteInt8(IGNITE_HDR_NULL);
@@ -526,7 +526,7 @@ namespace ignite
                 CheckRawMode(true);
                 CheckSingleMode(true);
 
-                stream->WriteInt8(IGNITE_HDR_NULL);
+                WriteNull0();
             }
 
             void BinaryWriterImpl::WriteNull(const char* fieldName)
@@ -535,6 +535,11 @@ namespace ignite
                 CheckSingleMode(true);
 
                 WriteFieldId(fieldName, IGNITE_TYPE_OBJECT);
+                WriteNull0();
+            }
+
+            void BinaryWriterImpl::WriteNull0()
+            {
                 stream->WriteInt8(IGNITE_HDR_NULL);
             }
 
@@ -683,79 +688,79 @@ namespace ignite
             }
 
             template <>
-            void BinaryWriterImpl::WriteTopObject<int8_t>(const int8_t& obj)
+            void BinaryWriterImpl::WriteTopObject0<int8_t>(const int8_t& obj)
             {
                 WriteTopObject0<int8_t>(obj, BinaryUtils::WriteInt8, IGNITE_TYPE_BYTE);
             }
 
             template <>
-            void BinaryWriterImpl::WriteTopObject<bool>(const bool& obj)
+            void BinaryWriterImpl::WriteTopObject0<bool>(const bool& obj)
             {
                 WriteTopObject0<bool>(obj, BinaryUtils::WriteBool, IGNITE_TYPE_BOOL);
             }
 
             template <>
-            void BinaryWriterImpl::WriteTopObject<int16_t>(const int16_t& obj)
+            void BinaryWriterImpl::WriteTopObject0<int16_t>(const int16_t& obj)
             {
                 WriteTopObject0<int16_t>(obj, BinaryUtils::WriteInt16, IGNITE_TYPE_SHORT);
             }
 
             template <>
-            void BinaryWriterImpl::WriteTopObject<uint16_t>(const uint16_t& obj)
+            void BinaryWriterImpl::WriteTopObject0<uint16_t>(const uint16_t& obj)
             {
                 WriteTopObject0<uint16_t>(obj, BinaryUtils::WriteUInt16, IGNITE_TYPE_CHAR);
             }
 
             template <>
-            void BinaryWriterImpl::WriteTopObject<int32_t>(const int32_t& obj)
+            void BinaryWriterImpl::WriteTopObject0<int32_t>(const int32_t& obj)
             {
                 WriteTopObject0<int32_t>(obj, BinaryUtils::WriteInt32, IGNITE_TYPE_INT);
             }
 
             template <>
-            void BinaryWriterImpl::WriteTopObject<int64_t>(const int64_t& obj)
+            void BinaryWriterImpl::WriteTopObject0<int64_t>(const int64_t& obj)
             {
                 WriteTopObject0<int64_t>(obj, BinaryUtils::WriteInt64, IGNITE_TYPE_LONG);
             }
 
             template <>
-            void BinaryWriterImpl::WriteTopObject<float>(const float& obj)
+            void BinaryWriterImpl::WriteTopObject0<float>(const float& obj)
             {
                 WriteTopObject0<float>(obj, BinaryUtils::WriteFloat, IGNITE_TYPE_FLOAT);
             }
 
             template <>
-            void BinaryWriterImpl::WriteTopObject<double>(const double& obj)
+            void BinaryWriterImpl::WriteTopObject0<double>(const double& obj)
             {
                 WriteTopObject0<double>(obj, BinaryUtils::WriteDouble, IGNITE_TYPE_DOUBLE);
             }
 
             template <>
-            void BinaryWriterImpl::WriteTopObject<Guid>(const Guid& obj)
+            void BinaryWriterImpl::WriteTopObject0<Guid>(const Guid& obj)
             {
                 WriteTopObject0<Guid>(obj, BinaryUtils::WriteGuid, IGNITE_TYPE_UUID);
             }
 
             template <>
-            void BinaryWriterImpl::WriteTopObject<Date>(const Date& obj)
+            void BinaryWriterImpl::WriteTopObject0<Date>(const Date& obj)
             {
                 WriteTopObject0<Date>(obj, BinaryUtils::WriteDate, IGNITE_TYPE_DATE);
             }
 
             template <>
-            void BinaryWriterImpl::WriteTopObject<Timestamp>(const Timestamp& obj)
+            void BinaryWriterImpl::WriteTopObject0<Timestamp>(const Timestamp& obj)
             {
                 WriteTopObject0<Timestamp>(obj, BinaryUtils::WriteTimestamp, IGNITE_TYPE_TIMESTAMP);
             }
 
             template <>
-            void BinaryWriterImpl::WriteTopObject<Time>(const Time& obj)
+            void BinaryWriterImpl::WriteTopObject0<Time>(const Time& obj)
             {
                 WriteTopObject0<Time>(obj, BinaryUtils::WriteTime, IGNITE_TYPE_TIME);
             }
 
             template<>
-            void BinaryWriterImpl::WriteTopObject(const std::string& obj)
+            void BinaryWriterImpl::WriteTopObject0(const std::string& obj)
             {
                 const char* obj0 = obj.c_str();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/1d4cda94/modules/platforms/cpp/core-test/src/binary_reader_writer_raw_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/binary_reader_writer_raw_test.cpp b/modules/platforms/cpp/core-test/src/binary_reader_writer_raw_test.cpp
index 53e584f..10a0bb2 100644
--- a/modules/platforms/cpp/core-test/src/binary_reader_writer_raw_test.cpp
+++ b/modules/platforms/cpp/core-test/src/binary_reader_writer_raw_test.cpp
@@ -1279,4 +1279,40 @@ BOOST_AUTO_TEST_CASE(TestUserType)
     BOOST_REQUIRE(actual == expected);
 }
 
+BOOST_AUTO_TEST_CASE(TestPrimitivePointers)
+{
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    BinaryWriterImpl writer(&out, 0);
+    BinaryRawWriter rawWriter(&writer);
+
+    out.Position(IGNITE_DFLT_HDR_LEN);
+
+    std::string field1 = "Lorem ipsum";
+    int32_t field2 = 42;
+
+    rawWriter.WriteObject(&field1);
+    rawWriter.WriteObject<int8_t*>(0);
+    rawWriter.WriteObject(&field2);
+
+    writer.PostWrite();
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+    BinaryReaderImpl reader(&in);
+    BinaryRawReader rawReader(&reader);
+
+    in.Position(IGNITE_DFLT_HDR_LEN);
+
+    std::auto_ptr<std::string> field1Res(rawReader.ReadObject<std::string*>());
+    std::auto_ptr<int8_t> fieldNullRes(rawReader.ReadObject<int8_t*>());
+    std::auto_ptr<int32_t> field2Res(rawReader.ReadObject<int32_t*>());
+
+    BOOST_CHECK_EQUAL(*field1Res, field1);
+    BOOST_CHECK(fieldNullRes.get() == 0);
+    BOOST_CHECK_EQUAL(*field2Res, field2);
+}
+
 BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/1d4cda94/modules/platforms/cpp/core-test/src/binary_reader_writer_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/binary_reader_writer_test.cpp b/modules/platforms/cpp/core-test/src/binary_reader_writer_test.cpp
index f494cb0..b76bcc1 100644
--- a/modules/platforms/cpp/core-test/src/binary_reader_writer_test.cpp
+++ b/modules/platforms/cpp/core-test/src/binary_reader_writer_test.cpp
@@ -19,6 +19,8 @@
 #   define BOOST_TEST_DYN_LINK
 #endif
 
+#include <memory>
+
 #include <boost/test/unit_test.hpp>
 
 #include "ignite/impl/interop/interop.h"
@@ -61,7 +63,8 @@ void CheckPrimitive(T val)
     int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
     int32_t footerEnd = footerBegin + 5;
 
-    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+        footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
     BinaryReader reader(&readerImpl);
 
     BOOST_CHECK_EXCEPTION(Read<T>(reader, NULL), IgniteError, IsBinaryError);
@@ -116,7 +119,8 @@ void CheckPrimitiveArray(T dflt, T val1, T val2)
         int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
         int32_t footerEnd = footerBegin + 5;
 
-        BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+        BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+            footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
         BinaryReader reader(&readerImpl);
 
         in.Position(IGNITE_DFLT_HDR_LEN);
@@ -149,7 +153,8 @@ void CheckPrimitiveArray(T dflt, T val1, T val2)
         int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
         int32_t footerEnd = footerBegin + 5;
 
-        BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+        BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+            footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
         BinaryReader reader(&readerImpl);
 
         in.Position(IGNITE_DFLT_HDR_LEN);
@@ -186,7 +191,8 @@ void CheckPrimitiveArray(T dflt, T val1, T val2)
         int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
         int32_t footerEnd = footerBegin + 5;
 
-        BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+        BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+            footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
         BinaryReader reader(&readerImpl);
 
         in.Position(IGNITE_DFLT_HDR_LEN);
@@ -226,7 +232,8 @@ void CheckPrimitiveArray(T dflt, T val1, T val2)
         int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
         int32_t footerEnd = footerBegin + 5;
 
-        BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+        BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+            footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
         BinaryReader reader(&readerImpl);
 
         in.Position(IGNITE_DFLT_HDR_LEN);
@@ -335,7 +342,8 @@ void CheckCollectionEmpty(CollectionType::Type* colType)
     int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
     int32_t footerEnd = footerBegin + 5 * 2;
 
-    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+        footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
     BinaryReader reader(&readerImpl);
 
     in.Position(IGNITE_DFLT_HDR_LEN);
@@ -398,7 +406,8 @@ void CheckCollection(CollectionType::Type* colType)
     int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
     int32_t footerEnd = footerBegin + 5 * 2;
 
-    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+        footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
     BinaryReader reader(&readerImpl);
 
     in.Position(IGNITE_DFLT_HDR_LEN);
@@ -466,7 +475,8 @@ void CheckCollectionIterators(CollectionType::Type* colType)
     int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
     int32_t footerEnd = footerBegin + 5 * 2;
 
-    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+        footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
     BinaryReader reader(&readerImpl);
 
     in.Position(IGNITE_DFLT_HDR_LEN);
@@ -524,7 +534,8 @@ void CheckMapEmpty(MapType::Type* mapType)
     int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
     int32_t footerEnd = footerBegin + 5 * 2;
 
-    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+        footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
     BinaryReader reader(&readerImpl);
 
     in.Position(IGNITE_DFLT_HDR_LEN);
@@ -589,7 +600,8 @@ void CheckMap(MapType::Type* mapType)
     int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
     int32_t footerEnd = footerBegin + 5 * 2;
 
-    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+        footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
     BinaryReader reader(&readerImpl);
 
     in.Position(IGNITE_DFLT_HDR_LEN);
@@ -801,7 +813,8 @@ BOOST_AUTO_TEST_CASE(TestGuidNull)
     int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
     int32_t footerEnd = footerBegin + 5;
 
-    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+        footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
     BinaryReader reader(&readerImpl);
     
     in.Position(IGNITE_DFLT_HDR_LEN);
@@ -839,7 +852,8 @@ BOOST_AUTO_TEST_CASE(TestDateNull)
     int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
     int32_t footerEnd = footerBegin + 5;
 
-    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+        footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
     BinaryReader reader(&readerImpl);
     
     in.Position(IGNITE_DFLT_HDR_LEN);
@@ -877,7 +891,8 @@ BOOST_AUTO_TEST_CASE(TestTimeNull)
     int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
     int32_t footerEnd = footerBegin + 5;
 
-    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+        footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
     BinaryReader reader(&readerImpl);
 
     in.Position(IGNITE_DFLT_HDR_LEN);
@@ -915,7 +930,8 @@ BOOST_AUTO_TEST_CASE(TestTimestampNull)
     int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
     int32_t footerEnd = footerBegin + 5;
 
-    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+        footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
     BinaryReader reader(&readerImpl);
 
     in.Position(IGNITE_DFLT_HDR_LEN);
@@ -964,7 +980,8 @@ BOOST_AUTO_TEST_CASE(TestString) {
     int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
     int32_t footerEnd = footerBegin + 5 * 5;
 
-    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+        footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
     BinaryReader reader(&readerImpl);
 
     in.Position(IGNITE_DFLT_HDR_LEN);
@@ -1023,7 +1040,8 @@ BOOST_AUTO_TEST_CASE(TestStringArrayNull)
     int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
     int32_t footerEnd = footerBegin + 5 * 2;
 
-    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+        footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
     BinaryReader reader(&readerImpl);
 
     in.Position(IGNITE_DFLT_HDR_LEN);
@@ -1079,7 +1097,8 @@ BOOST_AUTO_TEST_CASE(TestStringArrayEmpty)
     int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
     int32_t footerEnd = footerBegin + 5 * 2;
 
-    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+        footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
     BinaryReader reader(&readerImpl);
 
     in.Position(IGNITE_DFLT_HDR_LEN);
@@ -1146,7 +1165,8 @@ BOOST_AUTO_TEST_CASE(TestStringArray)
     int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
     int32_t footerEnd = footerBegin + 5 * 2;
 
-    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+        footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
     BinaryReader reader(&readerImpl);
 
     in.Position(IGNITE_DFLT_HDR_LEN);
@@ -1241,7 +1261,8 @@ BOOST_AUTO_TEST_CASE(TestObject)
     int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
     int32_t footerEnd = footerBegin + 5 * 3;
 
-    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+        footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
     BinaryReader reader(&readerImpl);
 
     in.Position(IGNITE_DFLT_HDR_LEN); 
@@ -1285,7 +1306,8 @@ BOOST_AUTO_TEST_CASE(TestNestedObject)
     int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
     int32_t footerEnd = footerBegin + 5 * 3;
 
-    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+        footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
     BinaryReader reader(&readerImpl);
 
     in.Position(IGNITE_DFLT_HDR_LEN);
@@ -1327,7 +1349,8 @@ BOOST_AUTO_TEST_CASE(TestArrayNull)
     int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
     int32_t footerEnd = footerBegin + 5 * 2;
 
-    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+        footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
     BinaryReader reader(&readerImpl);
 
     in.Position(IGNITE_DFLT_HDR_LEN);
@@ -1376,7 +1399,8 @@ BOOST_AUTO_TEST_CASE(TestArrayEmpty)
     int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
     int32_t footerEnd = footerBegin + 5 * 2;
 
-    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+        footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
     BinaryReader reader(&readerImpl);
 
     in.Position(IGNITE_DFLT_HDR_LEN);
@@ -1433,7 +1457,8 @@ BOOST_AUTO_TEST_CASE(TestArray)
     int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
     int32_t footerEnd = footerBegin + 5 * 2;
 
-    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+        footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
     BinaryReader reader(&readerImpl);
 
     in.Position(IGNITE_DFLT_HDR_LEN);
@@ -1485,7 +1510,8 @@ BOOST_AUTO_TEST_CASE(TestCollectionNull)
     int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
     int32_t footerEnd = footerBegin + 5 * 2;
 
-    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+        footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
     BinaryReader reader(&readerImpl);
 
     in.Position(IGNITE_DFLT_HDR_LEN);
@@ -1562,7 +1588,8 @@ BOOST_AUTO_TEST_CASE(TestMapNull)
     int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
     int32_t footerEnd = footerBegin + 5 * 2;
 
-    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+        footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
     BinaryReader reader(&readerImpl);
 
     in.Position(IGNITE_DFLT_HDR_LEN);
@@ -1634,7 +1661,8 @@ BOOST_AUTO_TEST_CASE(TestRawMode)
     int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
     int32_t footerEnd = footerBegin;
 
-    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 1000, footerBegin, footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 1000, footerBegin,
+        footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
     BinaryReader reader(&readerImpl);
     
     in.Position(IGNITE_DFLT_HDR_LEN);
@@ -1824,7 +1852,8 @@ BOOST_AUTO_TEST_CASE(TestSchemaOffset2ByteFields)
     int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
     int32_t footerEnd = footerBegin + 6 * fieldsNum;
 
-    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::TWO_BYTES);
+    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+        footerBegin, footerEnd, BinaryOffsetType::TWO_BYTES);
     BinaryReader reader(&readerImpl);
 
     in.Position(IGNITE_DFLT_HDR_LEN);
@@ -1869,7 +1898,8 @@ BOOST_AUTO_TEST_CASE(TestSchemaOffset4ByteFields)
     int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
     int32_t footerEnd = footerBegin + 8 * fieldsNum;
 
-    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::FOUR_BYTES);
+    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+        footerBegin, footerEnd, BinaryOffsetType::FOUR_BYTES);
     BinaryReader reader(&readerImpl);
 
     in.Position(IGNITE_DFLT_HDR_LEN);
@@ -1909,7 +1939,8 @@ BOOST_AUTO_TEST_CASE(TestSchemaOffset2ByteArray)
     int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
     int32_t footerEnd = footerBegin + 6 * 2;
 
-    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::TWO_BYTES);
+    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+        footerBegin, footerEnd, BinaryOffsetType::TWO_BYTES);
     BinaryReader reader(&readerImpl);
 
     in.Position(IGNITE_DFLT_HDR_LEN);
@@ -1943,7 +1974,8 @@ BOOST_AUTO_TEST_CASE(TestSchemaOffset4ByteArray)
     int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
     int32_t footerEnd = footerBegin + 8 * 2;
 
-    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::FOUR_BYTES);
+    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+        footerBegin, footerEnd, BinaryOffsetType::FOUR_BYTES);
     BinaryReader reader(&readerImpl);
 
     in.Position(IGNITE_DFLT_HDR_LEN);
@@ -1951,4 +1983,47 @@ BOOST_AUTO_TEST_CASE(TestSchemaOffset4ByteArray)
     BOOST_REQUIRE(reader.ReadInt32("field2") == 42);
 }
 
+BOOST_AUTO_TEST_CASE(TestPrimitivePointers)
+{
+    TemplatedBinaryIdResolver<BinaryDummy> idRslvr;
+
+    InteropUnpooledMemory mem(1024);
+
+    InteropOutputStream out(&mem);
+    BinaryWriterImpl writerImpl(&out, &idRslvr, 0, 0, 0);
+    BinaryWriter writer(&writerImpl);
+
+    out.Position(IGNITE_DFLT_HDR_LEN);
+
+    std::string field1 = "Lorem ipsum";
+    int32_t field2 = 42;
+
+    writer.WriteObject("field1", &field1);
+    writer.WriteObject<int8_t*>("null", 0);
+    writer.WriteObject("field2", &field2);
+
+    writerImpl.PostWrite();
+
+    out.Synchronize();
+
+    InteropInputStream in(&mem);
+
+    int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
+    int32_t footerEnd = footerBegin + 5 * 3;
+
+    BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+        footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+    BinaryReader reader(&readerImpl);
+
+    in.Position(IGNITE_DFLT_HDR_LEN);
+
+    std::auto_ptr<int32_t> field2Res(reader.ReadObject<int32_t*>("field2"));
+    std::auto_ptr<int8_t> fieldNullRes(reader.ReadObject<int8_t*>("null"));
+    std::auto_ptr<std::string> field1Res(reader.ReadObject<std::string*>("field1"));
+
+    BOOST_CHECK_EQUAL(*field1Res, field1);
+    BOOST_CHECK(fieldNullRes.get() == 0);
+    BOOST_CHECK_EQUAL(*field2Res, field2);
+}
+
 BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/1d4cda94/modules/platforms/cpp/core/include/ignite/impl/ignite_impl.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/impl/ignite_impl.h b/modules/platforms/cpp/core/include/ignite/impl/ignite_impl.h
index ea192e2..6d98ec0 100644
--- a/modules/platforms/cpp/core/include/ignite/impl/ignite_impl.h
+++ b/modules/platforms/cpp/core/include/ignite/impl/ignite_impl.h
@@ -46,7 +46,6 @@ namespace ignite
              * Constructor used to create new instance.
              *
              * @param env Environment.
-             * @param javaRef Reference to java object.
              */
             IgniteImpl(SP_IgniteEnvironment env, jobject javaRef);
             

http://git-wip-us.apache.org/repos/asf/ignite/blob/1d4cda94/modules/platforms/cpp/core/src/impl/ignite_impl.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/impl/ignite_impl.cpp b/modules/platforms/cpp/core/src/impl/ignite_impl.cpp
index 16e954c..f06d452 100644
--- a/modules/platforms/cpp/core/src/impl/ignite_impl.cpp
+++ b/modules/platforms/cpp/core/src/impl/ignite_impl.cpp
@@ -19,6 +19,10 @@
 
 using namespace ignite::common::concurrent;
 using namespace ignite::jni::java;
+using namespace ignite::impl::interop;
+using namespace ignite::impl::binary;
+
+using namespace ignite::binary;
 
 namespace ignite
 {    


[04/47] ignite git commit: IGNITE-5830 - Introduce cache start and stop order during cluster activation

Posted by ag...@apache.org.
IGNITE-5830 - Introduce cache start and stop order during cluster activation


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

Branch: refs/heads/master
Commit: 7915fd88b1f3e399777bbc46f4e5625b68fb90c9
Parents: 85f1702
Author: Jokser <jo...@gmail.com>
Authored: Wed Jul 26 12:08:03 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Wed Jul 26 12:08:03 2017 +0300

----------------------------------------------------------------------
 .../processors/cache/ClusterCachesInfo.java     | 135 ++++++++++++-------
 .../processors/cache/ExchangeActions.java       |   4 +-
 .../processors/cache/GridCacheProcessor.java    |  29 ++--
 3 files changed, 106 insertions(+), 62 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/7915fd88/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
index 949bc19..1a05b96 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
@@ -21,6 +21,7 @@ import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.Comparator;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.LinkedHashMap;
@@ -58,6 +59,7 @@ import org.apache.ignite.plugin.CachePluginContext;
 import org.apache.ignite.plugin.CachePluginProvider;
 import org.apache.ignite.plugin.PluginProvider;
 import org.apache.ignite.spi.discovery.DiscoveryDataBag;
+import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
 import static org.apache.ignite.cache.CacheMode.LOCAL;
@@ -97,10 +99,10 @@ class ClusterCachesInfo {
     private GridData gridData;
 
     /** */
-    private List<T2<DynamicCacheDescriptor, NearCacheConfiguration>> locJoinStartCaches;
+    private List<T2<DynamicCacheDescriptor, NearCacheConfiguration>> locJoinStartCaches = Collections.emptyList();
 
     /** */
-    private Map<String, T2<CacheConfiguration, NearCacheConfiguration>> locCfgsForActivation;
+    private Map<String, T2<CacheConfiguration, NearCacheConfiguration>> locCfgsForActivation = Collections.emptyMap();
 
     /** */
     private Map<UUID, CacheClientReconnectDiscoveryData> clientReconnectReqs;
@@ -111,7 +113,7 @@ class ClusterCachesInfo {
     /**
      * @param ctx Context.
      */
-    ClusterCachesInfo(GridKernalContext ctx) {
+    public ClusterCachesInfo(GridKernalContext ctx) {
         this.ctx = ctx;
 
         log = ctx.log(getClass());
@@ -121,7 +123,7 @@ class ClusterCachesInfo {
      * @param joinDiscoData Information about configured caches and templates.
      * @throws IgniteCheckedException If configuration validation failed.
      */
-    void onStart(CacheJoinNodeDiscoveryData joinDiscoData) throws IgniteCheckedException {
+    public void onStart(CacheJoinNodeDiscoveryData joinDiscoData) throws IgniteCheckedException {
         this.joinDiscoData = joinDiscoData;
 
         Map<String, CacheConfiguration> grpCfgs = new HashMap<>();
@@ -159,7 +161,7 @@ class ClusterCachesInfo {
      * @param checkConsistency {@code True} if need check cache configurations consistency.
      * @throws IgniteCheckedException If failed.
      */
-    void onKernalStart(boolean checkConsistency) throws IgniteCheckedException {
+    public void onKernalStart(boolean checkConsistency) throws IgniteCheckedException {
         if (gridData != null && gridData.conflictErr != null)
             throw new IgniteCheckedException(gridData.conflictErr);
 
@@ -330,7 +332,7 @@ class ClusterCachesInfo {
      * @param msg Message.
      * @param node Node sent message.
      */
-    void onClientCacheChange(ClientCacheChangeDiscoveryMessage msg, ClusterNode node) {
+    public void onClientCacheChange(ClientCacheChangeDiscoveryMessage msg, ClusterNode node) {
         Map<Integer, Boolean> startedCaches = msg.startedCaches();
 
         if (startedCaches != null) {
@@ -359,12 +361,13 @@ class ClusterCachesInfo {
             }
         }
     }
+
     /**
      * @param batch Cache change request.
      * @param topVer Topology version.
      * @return {@code True} if minor topology version should be increased.
      */
-    boolean onCacheChangeRequested(DynamicCacheChangeBatch batch, AffinityTopologyVersion topVer) {
+    public boolean onCacheChangeRequested(DynamicCacheChangeBatch batch, AffinityTopologyVersion topVer) {
         DiscoveryDataClusterState state = ctx.state().clusterState();
 
         if (state.active() && !state.transition()) {
@@ -779,30 +782,28 @@ class ClusterCachesInfo {
      *
      * @return Caches to be started when this node starts.
      */
-    List<T2<DynamicCacheDescriptor, NearCacheConfiguration>> cachesToStartOnLocalJoin() {
+    @NotNull public List<T2<DynamicCacheDescriptor, NearCacheConfiguration>> cachesToStartOnLocalJoin() {
         if (ctx.isDaemon())
             return Collections.emptyList();
 
-        assert locJoinStartCaches != null;
-
-        List<T2<DynamicCacheDescriptor, NearCacheConfiguration>> locJoinStartCaches = this.locJoinStartCaches;
+        List<T2<DynamicCacheDescriptor, NearCacheConfiguration>> result = locJoinStartCaches;
 
-        this.locJoinStartCaches = null;
+        locJoinStartCaches = Collections.emptyList();
 
-        return locJoinStartCaches;
+        return result;
     }
 
     /**
      * @param joinedNodeId Joined node ID.
      * @return New caches received from joined node.
      */
-    List<DynamicCacheDescriptor> cachesReceivedFromJoin(UUID joinedNodeId) {
+    @NotNull public List<DynamicCacheDescriptor> cachesReceivedFromJoin(UUID joinedNodeId) {
         assert joinedNodeId != null;
 
         List<DynamicCacheDescriptor> started = null;
 
         if (!ctx.isDaemon()) {
-            for (DynamicCacheDescriptor desc : registeredCaches.values()) {
+            for (DynamicCacheDescriptor desc : orderedCaches(CacheComparators.DIRECT)) {
                 if (desc.staticallyConfigured()) {
                     assert desc.receivedFrom() != null : desc;
 
@@ -826,7 +827,7 @@ class ClusterCachesInfo {
      * @param node Event node.
      * @param topVer Topology version.
      */
-    void onDiscoveryEvent(int type, ClusterNode node, AffinityTopologyVersion topVer) {
+    public void onDiscoveryEvent(int type, ClusterNode node, AffinityTopologyVersion topVer) {
         if (type == EVT_NODE_JOINED && !ctx.isDaemon()) {
             for (CacheGroupDescriptor desc : registeredCacheGrps.values()) {
                 if (node.id().equals(desc.receivedFrom()))
@@ -856,7 +857,7 @@ class ClusterCachesInfo {
     /**
      * @param dataBag Discovery data bag.
      */
-    void collectGridNodeData(DiscoveryDataBag dataBag) {
+    public void collectGridNodeData(DiscoveryDataBag dataBag) {
         if (ctx.isDaemon())
             return;
 
@@ -931,7 +932,7 @@ class ClusterCachesInfo {
     /**
      * @param data Discovery data.
      */
-    void onGridDataReceived(DiscoveryDataBag.GridDiscoveryData data) {
+    public void onGridDataReceived(DiscoveryDataBag.GridDiscoveryData data) {
         if (ctx.isDaemon() || data.commonData() == null)
             return;
 
@@ -1045,6 +1046,9 @@ class ClusterCachesInfo {
     }
 
     /**
+     * Initialize collection with caches to be start:
+     * {@code locJoinStartCaches} or {@code locCfgsForActivation} if cluster is inactive.
+     *
      * @param firstNode {@code True} if first node in cluster starts.
      */
     private void initStartCachesForLocalJoin(boolean firstNode) {
@@ -1062,7 +1066,7 @@ class ClusterCachesInfo {
 
             boolean active = ctx.state().clusterState().active();
 
-            for (DynamicCacheDescriptor desc : registeredCaches.values()) {
+            for (DynamicCacheDescriptor desc : orderedCaches(CacheComparators.DIRECT)) {
                 if (firstNode && !joinDiscoData.caches().containsKey(desc.cacheName()))
                     continue;
 
@@ -1096,13 +1100,8 @@ class ClusterCachesInfo {
                 if (locCfg != null ||
                     joinDiscoData.startCaches() ||
                     CU.affinityNode(ctx.discovery().localNode(), desc.groupDescriptor().config().getNodeFilter())) {
-                    if (active) {
-                        // Move system and internal caches first.
-                        if (desc.cacheType().userCache())
-                            locJoinStartCaches.add(new T2<>(desc, nearCfg));
-                        else
-                            locJoinStartCaches.add(0, new T2<>(desc, nearCfg));
-                    }
+                    if (active)
+                        locJoinStartCaches.add(new T2<>(desc, nearCfg));
                     else
                         locCfgsForActivation.put(desc.cacheName(), new T2<>(desc.cacheConfiguration(), nearCfg));
                 }
@@ -1113,7 +1112,7 @@ class ClusterCachesInfo {
     /**
      * @param msg Message.
      */
-    void onStateChangeFinish(ChangeGlobalStateFinishMessage msg) {
+    public void onStateChangeFinish(ChangeGlobalStateFinishMessage msg) {
         if (joinOnTransition) {
             initStartCachesForLocalJoin(false);
 
@@ -1127,17 +1126,14 @@ class ClusterCachesInfo {
      * @return Exchange action.
      * @throws IgniteCheckedException If configuration validation failed.
      */
-    ExchangeActions onStateChangeRequest(ChangeGlobalStateMessage msg, AffinityTopologyVersion topVer)
+    public ExchangeActions onStateChangeRequest(ChangeGlobalStateMessage msg, AffinityTopologyVersion topVer)
         throws IgniteCheckedException {
         ExchangeActions exchangeActions = new ExchangeActions();
 
         if (msg.activate()) {
-            for (DynamicCacheDescriptor desc : registeredCaches.values()) {
+            for (DynamicCacheDescriptor desc : orderedCaches(CacheComparators.DIRECT)) {
                 desc.startTopologyVersion(topVer);
 
-                T2<CacheConfiguration, NearCacheConfiguration> locCfg = !F.isEmpty(locCfgsForActivation) ?
-                    locCfgsForActivation.get(desc.cacheName()) : null;
-
                 DynamicCacheChangeRequest req = new DynamicCacheChangeRequest(msg.requestId(),
                     desc.cacheName(),
                     msg.initiatorNodeId());
@@ -1145,6 +1141,8 @@ class ClusterCachesInfo {
                 req.startCacheConfiguration(desc.cacheConfiguration());
                 req.cacheType(desc.cacheType());
 
+                T2<CacheConfiguration, NearCacheConfiguration> locCfg = locCfgsForActivation.get(desc.cacheName());
+
                 if (locCfg != null) {
                     if (locCfg.get1() != null)
                         req.startCacheConfiguration(locCfg.get1());
@@ -1199,7 +1197,7 @@ class ClusterCachesInfo {
         else {
             locCfgsForActivation = new HashMap<>();
 
-            for (DynamicCacheDescriptor desc : registeredCaches.values()) {
+            for (DynamicCacheDescriptor desc : orderedCaches(CacheComparators.REVERSE)) {
                 DynamicCacheChangeRequest req = DynamicCacheChangeRequest.stopRequest(ctx,
                     desc.cacheName(),
                     desc.sql(),
@@ -1221,7 +1219,7 @@ class ClusterCachesInfo {
     /**
      * @param data Joining node data.
      */
-    void onJoiningNodeDataReceived(DiscoveryDataBag.JoiningNodeDiscoveryData data) {
+    public void onJoiningNodeDataReceived(DiscoveryDataBag.JoiningNodeDiscoveryData data) {
         if (data.hasJoiningNodeData()) {
             Serializable joiningNodeData = data.joiningNodeData();
 
@@ -1264,8 +1262,10 @@ class ClusterCachesInfo {
     }
 
     /**
+     * Checks cache configuration on conflict with already registered caches and cache groups.
+     *
      * @param cfg Cache configuration.
-     * @return {@code True} if validation passed.
+     * @return {@code null} if validation passed, error message in other case.
      */
     private String checkCacheConflict(CacheConfiguration<?, ?> cfg) {
         int cacheId = CU.cacheId(cfg.getName());
@@ -1480,17 +1480,10 @@ class ClusterCachesInfo {
     }
 
     /**
-     * @return Registered cache groups.
-     */
-    ConcurrentMap<Integer, CacheGroupDescriptor> registeredCacheGroups() {
-        return registeredCacheGrps;
-    }
-
-    /**
      * @param ccfg Cache configuration to start.
      * @throws IgniteCheckedException If failed.
      */
-    void validateStartCacheConfiguration(CacheConfiguration ccfg) throws IgniteCheckedException {
+    public void validateStartCacheConfiguration(CacheConfiguration ccfg) throws IgniteCheckedException {
         if (ccfg.getGroupName() != null) {
             CacheGroupDescriptor grpDesc = cacheGroupByName(ccfg.getGroupName());
 
@@ -1563,9 +1556,29 @@ class ClusterCachesInfo {
     }
 
     /**
+     * @return Registered cache groups.
+     */
+    ConcurrentMap<Integer, CacheGroupDescriptor> registeredCacheGroups() {
+        return registeredCacheGrps;
+    }
+
+    /**
+     * Returns registered cache descriptors ordered by {@code comparator}
+     * @param comparator Comparator (DIRECT, REVERSE or custom) to order cache descriptors.
+     * @return Ordered by comparator cache descriptors.
+     */
+    private Collection<DynamicCacheDescriptor> orderedCaches(Comparator<DynamicCacheDescriptor> comparator) {
+        List<DynamicCacheDescriptor> ordered = new ArrayList<>();
+        ordered.addAll(registeredCaches.values());
+
+        Collections.sort(ordered, comparator);
+        return ordered;
+    }
+
+    /**
      *
      */
-    void onDisconnect() {
+    public void onDisconnected() {
         cachesOnDisconnect = new CachesOnDisconnect(
             ctx.state().clusterState(),
             new HashMap<>(registeredCacheGrps),
@@ -1583,7 +1596,7 @@ class ClusterCachesInfo {
      * @param transition {@code True} if reconnected while state transition in progress.
      * @return Information about stopped caches and cache groups.
      */
-    ClusterCachesReconnectResult onReconnected(boolean active, boolean transition) {
+    public ClusterCachesReconnectResult onReconnected(boolean active, boolean transition) {
         assert disconnectedState();
 
         Set<String> stoppedCaches = new HashSet<>();
@@ -1685,6 +1698,38 @@ class ClusterCachesInfo {
     }
 
     /**
+     * Holds direct comparator (first system caches) and reverse comparator (first user caches).
+     * Use DIRECT comparator for ordering cache start operations.
+     * Use REVERSE comparator for ordering cache stop operations.
+     */
+    private static class CacheComparators {
+        /**
+         * DIRECT comparator for cache descriptors (first system caches).
+         */
+        static Comparator<DynamicCacheDescriptor> DIRECT = new Comparator<DynamicCacheDescriptor>() {
+            @Override
+            public int compare(DynamicCacheDescriptor o1, DynamicCacheDescriptor o2) {
+                if (!o1.cacheType().userCache())
+                    return -1;
+                if (!o2.cacheType().userCache())
+                    return 1;
+
+                return o1.cacheId().compareTo(o2.cacheId());
+            }
+        };
+
+        /**
+         * REVERSE comparator for cache descriptors (first user caches).
+         */
+        static Comparator<DynamicCacheDescriptor> REVERSE = new Comparator<DynamicCacheDescriptor>() {
+            @Override
+            public int compare(DynamicCacheDescriptor o1, DynamicCacheDescriptor o2) {
+                return -DIRECT.compare(o1, o2);
+            }
+        };
+    }
+
+    /**
      *
      */
     private static class GridData {

http://git-wip-us.apache.org/repos/asf/ignite/blob/7915fd88/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ExchangeActions.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ExchangeActions.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ExchangeActions.java
index 1cc6438..91ad003 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ExchangeActions.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ExchangeActions.java
@@ -20,8 +20,8 @@ package org.apache.ignite.internal.processors.cache;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.HashSet;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -224,7 +224,7 @@ public class ExchangeActions {
         assert desc != null;
 
         if (map == null)
-            map = new HashMap<>();
+            map = new LinkedHashMap<>();
 
         CacheActionData old = map.put(req.cacheName(), new CacheActionData(req, desc));
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/7915fd88/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 5b709b3..9902a92 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
@@ -146,6 +146,7 @@ import org.apache.ignite.spi.IgniteNodeValidationResult;
 import org.apache.ignite.spi.discovery.DiscoveryDataBag;
 import org.apache.ignite.spi.discovery.DiscoveryDataBag.GridDiscoveryData;
 import org.apache.ignite.spi.discovery.DiscoveryDataBag.JoiningNodeDiscoveryData;
+import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
 import static org.apache.ignite.IgniteSystemProperties.IGNITE_CACHE_REMOVED_ENTRIES_TTL;
@@ -1046,7 +1047,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
 
         sharedCtx.onDisconnected(reconnectFut);
 
-        cachesInfo.onDisconnect();
+        cachesInfo.onDisconnected();
     }
 
     /**
@@ -1733,7 +1734,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
     /**
      * @return Caches to be started when this node starts.
      */
-    public List<T2<DynamicCacheDescriptor, NearCacheConfiguration>> cachesToStartOnLocalJoin() {
+    @NotNull public List<T2<DynamicCacheDescriptor, NearCacheConfiguration>> cachesToStartOnLocalJoin() {
         return cachesInfo.cachesToStartOnLocalJoin();
     }
 
@@ -1771,22 +1772,20 @@ public class GridCacheProcessor extends GridProcessorAdapter {
         throws IgniteCheckedException {
         List<DynamicCacheDescriptor> started = cachesInfo.cachesReceivedFromJoin(nodeId);
 
-        if (started != null) {
-            for (DynamicCacheDescriptor desc : started) {
-                IgnitePredicate<ClusterNode> filter = desc.groupDescriptor().config().getNodeFilter();
-
-                if (CU.affinityNode(ctx.discovery().localNode(), filter)) {
-                    prepareCacheStart(
-                        desc.cacheConfiguration(),
-                        desc,
-                        null,
-                        exchTopVer
-                    );
-                }
+        for (DynamicCacheDescriptor desc : started) {
+            IgnitePredicate<ClusterNode> filter = desc.groupDescriptor().config().getNodeFilter();
+
+            if (CU.affinityNode(ctx.discovery().localNode(), filter)) {
+                prepareCacheStart(
+                    desc.cacheConfiguration(),
+                    desc,
+                    null,
+                    exchTopVer
+                );
             }
         }
 
-        return started != null ? started : Collections.<DynamicCacheDescriptor>emptyList();
+        return started;
     }
 
     /**


[19/47] ignite git commit: IGNITE-4767: rollback exception hides the origin exception (e.g. commit): Suppressing or logging rollback exceptions instead of hiding the origin exception Fixes #1599

Posted by ag...@apache.org.
IGNITE-4767: rollback exception hides the origin exception (e.g. commit): Suppressing or logging rollback exceptions instead of hiding the origin exception
Fixes #1599


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

Branch: refs/heads/master
Commit: a07d7b91d148df8dfd7c4bbad2a63f8dea97b036
Parents: be5a9ea
Author: Alexandr Kuramshin <ei...@gmail.com>
Authored: Thu Jul 27 15:04:42 2017 +0300
Committer: dpavlov <dp...@gridgain.com>
Committed: Thu Jul 27 15:05:16 2017 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheAdapter.java      | 16 ++++--
 .../dht/GridDhtTransactionalCacheAdapter.java   |  7 ++-
 .../distributed/dht/GridDhtTxPrepareFuture.java | 24 +++++++--
 .../cache/transactions/IgniteTxHandler.java     | 51 +++++++++++++++-----
 .../cache/transactions/IgniteTxManager.java     |  7 ++-
 .../apache/ignite/stream/flume/IgniteSink.java  |  7 ++-
 6 files changed, 91 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/a07d7b91/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 9213be3..4ba4e48 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
@@ -4072,7 +4072,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
                         catch (IgniteCheckedException | AssertionError | RuntimeException e1) {
                             U.error(log, "Failed to rollback transaction (cache may contain stale locks): " + tx, e1);
 
-                            U.addLastCause(e, e1, log);
+                            e.addSuppressed(e1);
                         }
                     }
 
@@ -4205,7 +4205,12 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
                                         throw e;
                                     }
                                     catch (IgniteCheckedException e1) {
-                                        tx0.rollbackNearTxLocalAsync();
+                                        try {
+                                            tx0.rollbackNearTxLocalAsync();
+                                        }
+                                        catch (Throwable e2) {
+                                            e1.addSuppressed(e2);
+                                        }
 
                                         throw e1;
                                     }
@@ -4231,7 +4236,12 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
                         throw e;
                     }
                     catch (IgniteCheckedException e1) {
-                        tx0.rollbackNearTxLocalAsync();
+                        try {
+                            tx0.rollbackNearTxLocalAsync();
+                        }
+                        catch (Throwable e2) {
+                            e1.addSuppressed(e2);
+                        }
 
                         throw e1;
                     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/a07d7b91/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
index 73942ff..063986f9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
@@ -1338,7 +1338,12 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach
                 ", res=" + res + ']', e);
 
             if (tx != null)
-                tx.rollbackDhtLocalAsync();
+                try {
+                    tx.rollbackDhtLocalAsync();
+                }
+                catch (Throwable e1) {
+                    e.addSuppressed(e1);
+                }
 
             // Convert to closure exception as this method is only called form closures.
             throw new GridClosureException(e);

http://git-wip-us.apache.org/repos/asf/ignite/blob/a07d7b91/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
index 6ed4781..a31c540 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
@@ -736,16 +736,27 @@ public final class GridDhtTxPrepareFuture extends GridCacheCompoundFuture<Ignite
 
                             tx.systemInvalidate(true);
 
-                            fut = tx.rollbackAsync();
+                            try {
+                                fut = tx.rollbackAsync();
 
-                            fut.listen(resClo);
+                                fut.listen(resClo);
+                            }
+                            catch (Throwable e1) {
+                                e.addSuppressed(e1);
+                            }
 
                             throw e;
                         }
 
                     }
                     else if (!cctx.kernalContext().isStopping())
-                        fut = tx.rollbackAsync();
+                        try {
+                            fut = tx.rollbackAsync();
+                        }
+                        catch (Throwable e) {
+                            err.addSuppressed(e);
+                            fut = null;
+                        }
 
                     if (fut != null)
                         fut.listen(resClo);
@@ -1199,7 +1210,12 @@ public final class GridDhtTxPrepareFuture extends GridCacheCompoundFuture<Ignite
                 if (err0 != null) {
                     ERR_UPD.compareAndSet(this, null, err0);
 
-                    tx.rollbackAsync();
+                    try {
+                        tx.rollbackAsync();
+                    }
+                    catch (Throwable e) {
+                        err0.addSuppressed(e);
+                    }
 
                     final GridNearTxPrepareResponse res = createPrepareResponse(err);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a07d7b91/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
index c473bfe..b7ff319 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
@@ -863,14 +863,17 @@ public class IgniteTxHandler {
 
             U.error(log, "Failed completing transaction [commit=" + req.commit() + ", tx=" + tx + ']', e);
 
-            IgniteInternalFuture<IgniteInternalTx> res;
+            IgniteInternalFuture<IgniteInternalTx> res = null;
 
-            IgniteInternalFuture<IgniteInternalTx> rollbackFut = tx.rollbackDhtLocalAsync();
-
-            // Only for error logging.
-            rollbackFut.listen(CU.errorLogger(log));
+            try {
+                res = tx.rollbackDhtLocalAsync();
 
-            res = rollbackFut;
+                // Only for error logging.
+                res.listen(CU.errorLogger(log));
+            }
+            catch (Throwable e1) {
+                e.addSuppressed(e1);
+            }
 
             if (e instanceof Error)
                 throw (Error)e;
@@ -906,7 +909,12 @@ public class IgniteTxHandler {
                 throw e;
 
             if (tx != null)
-                return tx.rollbackNearTxLocalAsync();
+                try {
+                    return tx.rollbackNearTxLocalAsync();
+                }
+                catch (Throwable e1) {
+                    e.addSuppressed(e1);
+                }
 
             return new GridFinishedFuture<>(e);
         }
@@ -1000,7 +1008,12 @@ public class IgniteTxHandler {
                 U.error(log, "Failed to process prepare request: " + req, e);
 
             if (nearTx != null)
-                nearTx.rollbackRemoteTx();
+                try {
+                    nearTx.rollbackRemoteTx();
+                }
+                catch (Throwable e1) {
+                    e.addSuppressed(e1);
+                }
 
             res = new GridDhtTxPrepareResponse(
                 req.partition(),
@@ -1261,7 +1274,13 @@ public class IgniteTxHandler {
             tx.invalidate(true);
             tx.systemInvalidate(true);
 
-            tx.rollbackRemoteTx();
+            try {
+                tx.rollbackRemoteTx();
+            }
+            catch (Throwable e1) {
+                e.addSuppressed(e1);
+                U.error(log, "Failed to automatically rollback transaction: " + tx, e1);
+            }
 
             if (e instanceof Error)
                 throw (Error)e;
@@ -1307,10 +1326,20 @@ public class IgniteTxHandler {
             }
 
             if (nearTx != null)
-                nearTx.rollbackRemoteTx();
+                try {
+                    nearTx.rollbackRemoteTx();
+                }
+                catch (Throwable e1) {
+                    e.addSuppressed(e1);
+                }
 
             if (dhtTx != null)
-                dhtTx.rollbackRemoteTx();
+                try {
+                    dhtTx.rollbackRemoteTx();
+                }
+                catch (Throwable e1) {
+                    e.addSuppressed(e1);
+                }
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a07d7b91/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 26a4a91..7d612ec 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
@@ -2422,7 +2422,12 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
                     log.debug("Optimistic failure while committing prepared transaction (will rollback): " +
                         tx);
 
-                tx.rollbackAsync();
+                try {
+                    tx.rollbackAsync();
+                }
+                catch (Throwable e) {
+                    U.error(log, "Failed to automatically rollback transaction: " + tx, e);
+                }
             }
             catch (IgniteCheckedException e) {
                 U.error(log, "Failed to commit transaction during failover: " + tx, e);

http://git-wip-us.apache.org/repos/asf/ignite/blob/a07d7b91/modules/flume/src/main/java/org/apache/ignite/stream/flume/IgniteSink.java
----------------------------------------------------------------------
diff --git a/modules/flume/src/main/java/org/apache/ignite/stream/flume/IgniteSink.java b/modules/flume/src/main/java/org/apache/ignite/stream/flume/IgniteSink.java
index 083e833..64559ef 100644
--- a/modules/flume/src/main/java/org/apache/ignite/stream/flume/IgniteSink.java
+++ b/modules/flume/src/main/java/org/apache/ignite/stream/flume/IgniteSink.java
@@ -178,7 +178,12 @@ public class IgniteSink extends AbstractSink implements Configurable {
         catch (Exception e) {
             log.error("Failed to process events", e);
 
-            transaction.rollback();
+            try {
+                transaction.rollback();
+            }
+            catch (Throwable e1) {
+                e.addSuppressed(e1);
+            }
 
             throw new EventDeliveryException(e);
         }