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/07/27 12:33:58 UTC

[01/40] ignite git commit: IGNITE-5762: LGPL modules are no longer deployed into Maven repository.

Repository: ignite
Updated Branches:
  refs/heads/ignite-5757 75df32989 -> c6fc03a91


IGNITE-5762: LGPL modules are no longer deployed into Maven repository.


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

Branch: refs/heads/ignite-5757
Commit: 1a2dde91083a2d733e2ccc1c03bc9959caa921af
Parents: 3c1749d
Author: Oleg Ostanin <oo...@gridgain.com>
Authored: Mon Jul 17 15:10:36 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Mon Jul 17 15:10:36 2017 +0300

----------------------------------------------------------------------
 examples/pom.xml              |  7 +++++++
 modules/geospatial/pom.xml    | 24 ++++++++++++++++++++++++
 modules/hibernate-4.2/pom.xml | 24 ++++++++++++++++++++++++
 modules/hibernate-5.1/pom.xml | 24 ++++++++++++++++++++++++
 modules/schedule/pom.xml      | 24 ++++++++++++++++++++++++
 5 files changed, 103 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/1a2dde91/examples/pom.xml
----------------------------------------------------------------------
diff --git a/examples/pom.xml b/examples/pom.xml
index 58da342..6042781 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -312,6 +312,13 @@
                     </execution>
                 </executions>
             </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-deploy-plugin</artifactId>
+                <configuration>
+                    <skip>true</skip>
+                </configuration>
+            </plugin>
         </plugins>
     </build>
 </project>

http://git-wip-us.apache.org/repos/asf/ignite/blob/1a2dde91/modules/geospatial/pom.xml
----------------------------------------------------------------------
diff --git a/modules/geospatial/pom.xml b/modules/geospatial/pom.xml
index c715ffa..488a4a4 100644
--- a/modules/geospatial/pom.xml
+++ b/modules/geospatial/pom.xml
@@ -83,6 +83,23 @@
         </dependency>
     </dependencies>
 
+    <profiles>
+        <profile>
+            <id>lgpl</id>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-deploy-plugin</artifactId>
+                        <configuration>
+                            <skip>false</skip>
+                        </configuration>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
+
     <build>
         <plugins>
             <!-- Generate the OSGi MANIFEST.MF for this bundle.
@@ -99,6 +116,13 @@
                     </instructions>
                 </configuration>
             </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-deploy-plugin</artifactId>
+                <configuration>
+                    <skip>true</skip>
+                </configuration>
+            </plugin>
         </plugins>
     </build>
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/1a2dde91/modules/hibernate-4.2/pom.xml
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/pom.xml b/modules/hibernate-4.2/pom.xml
index adcf1b1..e40a550 100644
--- a/modules/hibernate-4.2/pom.xml
+++ b/modules/hibernate-4.2/pom.xml
@@ -132,6 +132,23 @@
         </dependency>
     </dependencies>
 
+    <profiles>
+        <profile>
+            <id>lgpl</id>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-deploy-plugin</artifactId>
+                        <configuration>
+                            <skip>false</skip>
+                        </configuration>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
+
     <build>
         <testResources>
             <testResource>
@@ -154,6 +171,13 @@
                 <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
             </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-deploy-plugin</artifactId>
+                <configuration>
+                    <skip>true</skip>
+                </configuration>
+            </plugin>
         </plugins>
     </build>
 </project>

http://git-wip-us.apache.org/repos/asf/ignite/blob/1a2dde91/modules/hibernate-5.1/pom.xml
----------------------------------------------------------------------
diff --git a/modules/hibernate-5.1/pom.xml b/modules/hibernate-5.1/pom.xml
index 8424806..a99408e 100644
--- a/modules/hibernate-5.1/pom.xml
+++ b/modules/hibernate-5.1/pom.xml
@@ -132,6 +132,23 @@
         </dependency>
     </dependencies>
 
+    <profiles>
+        <profile>
+            <id>lgpl</id>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-deploy-plugin</artifactId>
+                        <configuration>
+                            <skip>false</skip>
+                        </configuration>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
+
     <build>
         <testResources>
             <testResource>
@@ -154,6 +171,13 @@
                 <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
             </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-deploy-plugin</artifactId>
+                <configuration>
+                    <skip>true</skip>
+                </configuration>
+            </plugin>
         </plugins>
     </build>
 </project>

http://git-wip-us.apache.org/repos/asf/ignite/blob/1a2dde91/modules/schedule/pom.xml
----------------------------------------------------------------------
diff --git a/modules/schedule/pom.xml b/modules/schedule/pom.xml
index 22c2571..2686701 100644
--- a/modules/schedule/pom.xml
+++ b/modules/schedule/pom.xml
@@ -83,6 +83,23 @@
         </dependency>
     </dependencies>
 
+    <profiles>
+        <profile>
+            <id>lgpl</id>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-deploy-plugin</artifactId>
+                        <configuration>
+                            <skip>false</skip>
+                        </configuration>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
+
     <build>
         <plugins>
             <!-- Generate the OSGi MANIFEST.MF for this fragment. It is a fragment because it contains internal processors
@@ -96,6 +113,13 @@
                     </instructions>
                 </configuration>
             </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-deploy-plugin</artifactId>
+                <configuration>
+                    <skip>true</skip>
+                </configuration>
+            </plugin>
         </plugins>
     </build>
 </project>


[11/40] ignite git commit: IGNITE-5772 - Fixed race between WAL segment rollover and a concurrent log. Closes #2313

Posted by ag...@apache.org.
IGNITE-5772 - Fixed race between WAL segment rollover and a concurrent log. Closes #2313


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

Branch: refs/heads/ignite-5757
Commit: 6de0571c21ffdb77af7bb1d18e9659126d7f321b
Parents: 199b954
Author: Ilya Lantukh <il...@gridgain.com>
Authored: Fri Jul 21 16:35:43 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Fri Jul 21 16:35:43 2017 +0300

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


http://git-wip-us.apache.org/repos/asf/ignite/blob/6de0571c/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 897f903..b655ddf 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
@@ -319,7 +319,7 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl
         try {
             if (mode == WALMode.BACKGROUND) {
                 if (currHnd != null)
-                    currHnd.flush((FileWALPointer)null);
+                    currHnd.flush((FileWALPointer)null, true);
             }
 
             if (currHnd != null)
@@ -526,7 +526,7 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl
             return;
 
         if (mode == WALMode.LOG_ONLY || forceFlush) {
-            cur.flushOrWait(filePtr);
+            cur.flushOrWait(filePtr, false);
 
             return;
         }
@@ -535,7 +535,7 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl
         if (filePtr != null && !cur.needFsync(filePtr))
             return;
 
-        cur.fsync(filePtr);
+        cur.fsync(filePtr, false);
     }
 
     /** {@inheritDoc} */
@@ -1700,12 +1700,29 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl
             this.maxSegmentSize = maxSegmentSize;
             this.serializer = serializer;
 
-            head.set(new FakeRecord(new FileWALPointer(idx, (int)pos, 0)));
+            head.set(new FakeRecord(new FileWALPointer(idx, (int)pos, 0), false));
             written = pos;
             lastFsyncPos = pos;
         }
 
         /**
+         * Checks if current head is a close fake record and returns {@code true} if so.
+         *
+         * @return {@code true} if current head is close record.
+         */
+        private boolean stopped() {
+            return stopped(head.get());
+        }
+
+        /**
+         * @param record Record to check.
+         * @return {@code true} if the record is fake close record.
+         */
+        private boolean stopped(WALRecord record) {
+            return record instanceof FakeRecord && ((FakeRecord)record).stop;
+        }
+
+        /**
          * @param rec Record to be added to record chain as new {@link #head}
          * @return Pointer or null if roll over to next segment is required or already started by other thread.
          * @throws StorageException If failed.
@@ -1721,9 +1738,7 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl
 
                 long nextPos = nextPosition(h);
 
-                // It is important that we read `stop` after `head` in this loop for correct close,
-                // because otherwise we will have a race on the last flush in close.
-                if (nextPos + rec.size() >= maxSegmentSize || stop.get()) {
+                if (nextPos + rec.size() >= maxSegmentSize || stopped(h)) {
                     // Can not write to this segment, need to switch to the next one.
                     return null;
                 }
@@ -1731,7 +1746,7 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl
                 int newChainSize = h.chainSize() + rec.size();
 
                 if (newChainSize > tlbSize && !flushed) {
-                    boolean res = h.previous() == null || flush(h);
+                    boolean res = h.previous() == null || flush(h, false);
 
                     if (rec.size() > tlbSize)
                         flushed = res;
@@ -1770,7 +1785,7 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl
          * @param ptr Pointer.
          * @throws IgniteCheckedException If failed.
          */
-        private void flushOrWait(FileWALPointer ptr) throws IgniteCheckedException {
+        private void flushOrWait(FileWALPointer ptr, boolean stop) throws IgniteCheckedException {
             long expWritten;
 
             if (ptr != null) {
@@ -1783,7 +1798,7 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl
             else // We read head position before the flush because otherwise we can get wrong position.
                 expWritten = recordOffset(head.get());
 
-            if (flush(ptr))
+            if (flush(ptr, stop))
                 return;
 
             // Spin-wait for a while before acquiring the lock.
@@ -1810,18 +1825,20 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl
          * @throws IgniteCheckedException If failed.
          * @throws StorageException If failed.
          */
-        private boolean flush(FileWALPointer ptr) throws IgniteCheckedException, StorageException {
+        private boolean flush(FileWALPointer ptr, boolean stop) throws IgniteCheckedException, StorageException {
             if (ptr == null) { // Unconditional flush.
                 for (; ; ) {
                     WALRecord expHead = head.get();
 
                     if (expHead.previous() == null) {
-                        assert expHead instanceof FakeRecord;
+                        FakeRecord frHead = (FakeRecord)expHead;
 
-                        return false;
+                        if (frHead.stop == stop || frHead.stop ||
+                            head.compareAndSet(expHead, new FakeRecord(frHead.position(), stop)))
+                            return false;
                     }
 
-                    if (flush(expHead))
+                    if (flush(expHead, stop))
                         return true;
                 }
             }
@@ -1835,7 +1852,7 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl
                 if (chainBeginPosition(h) > ptr.fileOffset())
                     return false;
 
-                if (flush(h))
+                if (flush(h, stop))
                     return true; // We are lucky.
             }
         }
@@ -1853,17 +1870,18 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl
          * @throws IgniteCheckedException If failed.
          * @throws StorageException If failed.
          */
-        private boolean flush(WALRecord expHead) throws StorageException, IgniteCheckedException {
+        private boolean flush(WALRecord expHead, boolean stop) throws StorageException, IgniteCheckedException {
             if (expHead.previous() == null) {
-                assert expHead instanceof FakeRecord;
+                FakeRecord frHead = (FakeRecord)expHead;
 
-                return false;
+                if (stop == frHead.stop)
+                    return false;
             }
 
             // Fail-fast before CAS.
             checkEnvironment();
 
-            if (!head.compareAndSet(expHead, new FakeRecord(new FileWALPointer(idx, (int)nextPosition(expHead), 0))))
+            if (!head.compareAndSet(expHead, new FakeRecord(new FileWALPointer(idx, (int)nextPosition(expHead), 0), stop)))
                 return false;
 
             // At this point we grabbed the piece of WAL chain.
@@ -1976,7 +1994,7 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl
          * @param ptr Pointer to sync.
          * @throws StorageException If failed.
          */
-        private void fsync(FileWALPointer ptr) throws StorageException, IgniteCheckedException {
+        private void fsync(FileWALPointer ptr, boolean stop) throws StorageException, IgniteCheckedException {
             lock.lock();
 
             try {
@@ -1984,7 +2002,7 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl
                     if (!needFsync(ptr))
                         return;
 
-                    if (fsyncDelay > 0 && !stop.get()) {
+                    if (fsyncDelay > 0 && !stopped()) {
                         // Delay fsync to collect as many updates as possible: trade latency for throughput.
                         U.await(fsync, fsyncDelay, TimeUnit.NANOSECONDS);
 
@@ -1993,7 +2011,7 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl
                     }
                 }
 
-                flushOrWait(ptr);
+                flushOrWait(ptr, stop);
 
                 if (lastFsyncPos != written) {
                     assert lastFsyncPos < written; // Fsync position must be behind.
@@ -2031,13 +2049,14 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl
          * @throws StorageException If failed.
          */
         private boolean close(boolean rollOver) throws IgniteCheckedException, StorageException {
-            if (stop.compareAndSet(false, true)) {
-                // Here we can be sure that no other records will be added and this fsync will be the last.
-                if (mode == WALMode.DEFAULT)
-                    fsync(null);
-                else
-                    flushOrWait(null);
+            if (mode == WALMode.DEFAULT)
+                fsync(null, true);
+            else
+                flushOrWait(null, true);
+
+            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;
 
@@ -2068,8 +2087,8 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl
 
                 return true;
             }
-
-            return false;
+            else
+                return false;
         }
 
         /**
@@ -2271,17 +2290,27 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl
      * Fake record is allowed to have no previous record.
      */
     private static final class FakeRecord extends WALRecord {
+        /** */
+        private final boolean stop;
+
         /**
          * @param pos Position.
          */
-        FakeRecord(FileWALPointer pos) {
+        FakeRecord(FileWALPointer pos, boolean stop) {
             position(pos);
+
+            this.stop = stop;
         }
 
         /** {@inheritDoc} */
         @Override public RecordType type() {
             return null;
         }
+
+        /** {@inheritDoc} */
+        @Override public FileWALPointer position() {
+            return (FileWALPointer) super.position();
+        }
     }
 
     /**
@@ -2492,7 +2521,7 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl
     private void doFlush() {
         final FileWriteHandle hnd = currentHandle();
         try {
-            hnd.flush(hnd.head.get());
+            hnd.flush(hnd.head.get(), false);
         }
         catch (Exception e) {
             U.warn(log, "Failed to flush WAL record queue", e);


[22/40] 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/ignite-5757
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;
     }


[32/40] 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;
 


[09/40] ignite git commit: IGNITE-5788 Web Console: Fixed dependencies for maven project with c3p0.

Posted by ag...@apache.org.
IGNITE-5788 Web Console: Fixed dependencies for maven project with c3p0.


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

Branch: refs/heads/ignite-5757
Commit: 02a1bdca57ce6af7fe7636b0a9f99048c89b88b6
Parents: 70d0f99
Author: Andrey Novikov <an...@gridgain.com>
Authored: Thu Jul 20 15:47:49 2017 +0700
Committer: Andrey Novikov <an...@gridgain.com>
Committed: Thu Jul 20 15:47:49 2017 +0700

----------------------------------------------------------------------
 modules/web-console/frontend/app/data/pom-dependencies.json | 5 ++++-
 .../app/modules/configuration/generator/Maven.service.js    | 9 +++------
 modules/web-console/frontend/webpack/webpack.common.js      | 4 ++--
 3 files changed, 9 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/02a1bdca/modules/web-console/frontend/app/data/pom-dependencies.json
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/data/pom-dependencies.json b/modules/web-console/frontend/app/data/pom-dependencies.json
index 945e3f5..8d3fa81 100644
--- a/modules/web-console/frontend/app/data/pom-dependencies.json
+++ b/modules/web-console/frontend/app/data/pom-dependencies.json
@@ -11,7 +11,10 @@
     "HadoopIgfsJcl": {"artifactId": "ignite-hadoop"},
     "SLF4J": {"artifactId": "ignite-slf4j"},
 
-    "Generic": {"groupId": "com.mchange", "artifactId": "c3p0", "version": "0.9.5.2"},
+    "Generic": [
+        {"groupId": "com.mchange", "artifactId": "c3p0", "version": "0.9.5.2"},
+        {"groupId": "com.mchange", "artifactId": "mchange-commons-java", "version": "0.2.11"}
+    ],
     "MySQL": {"groupId": "mysql", "artifactId": "mysql-connector-java", "version": "5.1.40"},
     "PostgreSQL": {"groupId": "org.postgresql", "artifactId": "postgresql", "version": "9.4.1212.jre7"},
     "H2": {"groupId": "com.h2database", "artifactId": "h2", "version": [

http://git-wip-us.apache.org/repos/asf/ignite/blob/02a1bdca/modules/web-console/frontend/app/modules/configuration/generator/Maven.service.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/configuration/generator/Maven.service.js b/modules/web-console/frontend/app/modules/configuration/generator/Maven.service.js
index 81d7d10..abbada9 100644
--- a/modules/web-console/frontend/app/modules/configuration/generator/Maven.service.js
+++ b/modules/web-console/frontend/app/modules/configuration/generator/Maven.service.js
@@ -47,12 +47,9 @@ export default class IgniteMavenGenerator {
             return _.isArray(version) ? _.find(version, (v) => versionService.since(igniteVer, v.range)).version : version;
         };
 
-        if (!_.has(POM_DEPENDENCIES, key))
-            return;
-
-        const {groupId, artifactId, version, jar} = POM_DEPENDENCIES[key];
-
-        this.addDependency(deps, groupId || 'org.apache.ignite', artifactId, extractVersion(version) || dfltVer, jar);
+        _.forEach(POM_DEPENDENCIES[key], ({groupId, artifactId, version, jar}) => {
+            this.addDependency(deps, groupId || 'org.apache.ignite', artifactId, extractVersion(version) || dfltVer, jar);
+        });
     }
 
     addResource(sb, dir, exclude) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/02a1bdca/modules/web-console/frontend/webpack/webpack.common.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/webpack/webpack.common.js b/modules/web-console/frontend/webpack/webpack.common.js
index a303d6e..5a3763e 100644
--- a/modules/web-console/frontend/webpack/webpack.common.js
+++ b/modules/web-console/frontend/webpack/webpack.common.js
@@ -138,7 +138,7 @@ export default {
             },
             {
                 test: /\.(jpe?g|png|gif)$/i,
-                loader: 'file?name=assets/images/[name]_[hash].[ext]'
+                loader: 'file?name=assets/images/[name].[hash].[ext]'
             },
             {
                 test: require.resolve('jquery'),
@@ -178,7 +178,7 @@ export default {
         new HtmlWebpackPlugin({
             template: './views/index.pug'
         }),
-        new ExtractTextPlugin({filename: 'assets/css/[name].css', allChunks: true}),
+        new ExtractTextPlugin({filename: 'assets/css/[name].[hash].css', allChunks: true}),
         new CopyWebpackPlugin([
             { context: 'public', from: '**/*.png' },
             { context: 'public', from: '**/*.svg' },


[33/40] 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());
     }


[21/40] ignite git commit: IGNITE-5829 Linked TODO with ticket.

Posted by ag...@apache.org.
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/ignite-5757
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());


[26/40] 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/ignite-5757
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.


[07/40] ignite git commit: Enable forcible node prop for failover tests.

Posted by ag...@apache.org.
Enable forcible node prop for failover tests.


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

Branch: refs/heads/ignite-5757
Commit: 23f26af5887782b8ac3946231f72c9d9f63e4f05
Parents: cf345b8
Author: Andrey V. Mashenkov <an...@gmail.com>
Authored: Tue Jul 18 20:36:20 2017 +0300
Committer: Andrey V. Mashenkov <an...@gmail.com>
Committed: Tue Jul 18 20:36:20 2017 +0300

----------------------------------------------------------------------
 .../cache/GridCachePutAllFailoverSelfTest.java       | 15 +++++++++++++++
 .../cache/IgniteCachePutAllRestartTest.java          | 15 +++++++++++++++
 .../CacheGetInsideLockChangingTopologyTest.java      |  5 +++++
 .../GridCacheAbstractNodeRestartSelfTest.java        | 12 +++++++++++-
 .../cache/distributed/IgniteCacheGetRestartTest.java |  5 +++++
 .../dht/IgniteCachePutRetryAbstractSelfTest.java     |  5 +++++
 .../testsuites/IgniteCacheRestartTestSuite2.java     |  2 ++
 7 files changed, 58 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/23f26af5/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePutAllFailoverSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePutAllFailoverSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePutAllFailoverSelfTest.java
index 71eb767..19bef92 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePutAllFailoverSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePutAllFailoverSelfTest.java
@@ -37,6 +37,7 @@ import org.apache.ignite.IgniteCache;
 import org.apache.ignite.IgniteCompute;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.IgniteSystemProperties;
 import org.apache.ignite.cache.CacheAtomicityMode;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.compute.ComputeJobContext;
@@ -119,6 +120,20 @@ public class GridCachePutAllFailoverSelfTest extends GridCommonAbstractTest {
     /** Test failover SPI. */
     private MasterFailoverSpi failoverSpi = new MasterFailoverSpi((IgnitePredicate)workerNodesFilter);
 
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        System.setProperty(IgniteSystemProperties.IGNITE_ENABLE_FORCIBLE_NODE_KILL, "true");
+
+        super.beforeTestsStarted();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTestsStopped() throws Exception {
+        super.afterTestsStopped();
+
+        System.clearProperty(IgniteSystemProperties.IGNITE_ENABLE_FORCIBLE_NODE_KILL);
+    }
+
     /**
      * @throws Exception If failed.
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/23f26af5/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePutAllRestartTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePutAllRestartTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePutAllRestartTest.java
index b00b3c8..5adafb1 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePutAllRestartTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePutAllRestartTest.java
@@ -26,6 +26,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
 import javax.cache.CacheException;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteSystemProperties;
 import org.apache.ignite.cache.CacheMode;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
@@ -79,6 +80,20 @@ public class IgniteCachePutAllRestartTest extends GridCommonAbstractTest {
     }
 
     /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        System.setProperty(IgniteSystemProperties.IGNITE_ENABLE_FORCIBLE_NODE_KILL, "true");
+
+        super.beforeTestsStarted();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTestsStopped() throws Exception {
+        super.afterTestsStopped();
+
+        System.clearProperty(IgniteSystemProperties.IGNITE_ENABLE_FORCIBLE_NODE_KILL);
+    }
+
+    /** {@inheritDoc} */
     @Override protected void afterTest() throws Exception {
         stopAllGrids();
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/23f26af5/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheGetInsideLockChangingTopologyTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheGetInsideLockChangingTopologyTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheGetInsideLockChangingTopologyTest.java
index bb2a55d..6ec1440 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheGetInsideLockChangingTopologyTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheGetInsideLockChangingTopologyTest.java
@@ -28,6 +28,7 @@ import javax.cache.CacheException;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteSystemProperties;
 import org.apache.ignite.cache.CacheAtomicityMode;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
@@ -118,6 +119,8 @@ public class CacheGetInsideLockChangingTopologyTest extends GridCommonAbstractTe
 
     /** {@inheritDoc} */
     @Override protected void beforeTestsStarted() throws Exception {
+        System.setProperty(IgniteSystemProperties.IGNITE_ENABLE_FORCIBLE_NODE_KILL, "true");
+
         super.beforeTestsStarted();
 
         startGridsMultiThreaded(SRVS);
@@ -149,6 +152,8 @@ public class CacheGetInsideLockChangingTopologyTest extends GridCommonAbstractTe
         stopAllGrids();
 
         super.afterTestsStopped();
+
+        System.clearProperty(IgniteSystemProperties.IGNITE_ENABLE_FORCIBLE_NODE_KILL);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/23f26af5/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractNodeRestartSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractNodeRestartSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractNodeRestartSelfTest.java
index 8d5a4aa..d849559 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractNodeRestartSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractNodeRestartSelfTest.java
@@ -33,6 +33,7 @@ import javax.cache.CacheException;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteSystemProperties;
 import org.apache.ignite.IgniteTransactions;
 import org.apache.ignite.cache.CacheAtomicityMode;
 import org.apache.ignite.cache.CacheRebalanceMode;
@@ -161,7 +162,16 @@ public abstract class GridCacheAbstractNodeRestartSelfTest extends GridCommonAbs
 
     /** {@inheritDoc} */
     @Override protected void beforeTestsStarted() throws Exception {
-        // No-op.
+        System.setProperty(IgniteSystemProperties.IGNITE_ENABLE_FORCIBLE_NODE_KILL, "true");
+
+        super.beforeTestsStarted();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTestsStopped() throws Exception {
+        super.afterTestsStopped();
+
+        System.clearProperty(IgniteSystemProperties.IGNITE_ENABLE_FORCIBLE_NODE_KILL);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/23f26af5/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheGetRestartTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheGetRestartTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheGetRestartTest.java
index fb57ecd..aa82b9a 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheGetRestartTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheGetRestartTest.java
@@ -26,6 +26,7 @@ import java.util.concurrent.atomic.AtomicInteger;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.IgniteDataStreamer;
+import org.apache.ignite.IgniteSystemProperties;
 import org.apache.ignite.cache.CacheMode;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
@@ -90,6 +91,8 @@ public class IgniteCacheGetRestartTest extends GridCommonAbstractTest {
 
     /** {@inheritDoc} */
     @Override protected void beforeTestsStarted() throws Exception {
+        System.setProperty(IgniteSystemProperties.IGNITE_ENABLE_FORCIBLE_NODE_KILL, "true");
+
         super.beforeTestsStarted();
 
         startGrids(SRVS);
@@ -108,6 +111,8 @@ public class IgniteCacheGetRestartTest extends GridCommonAbstractTest {
         super.afterTestsStopped();
 
         stopAllGrids();
+
+        System.clearProperty(IgniteSystemProperties.IGNITE_ENABLE_FORCIBLE_NODE_KILL);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/23f26af5/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryAbstractSelfTest.java
index e65bff4..0620f60 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryAbstractSelfTest.java
@@ -34,6 +34,7 @@ import javax.cache.processor.EntryProcessorResult;
 import javax.cache.processor.MutableEntry;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteSystemProperties;
 import org.apache.ignite.cache.CacheAtomicityMode;
 import org.apache.ignite.cache.CacheEntryProcessor;
 import org.apache.ignite.cache.CachePartialUpdateException;
@@ -136,6 +137,8 @@ public abstract class IgniteCachePutRetryAbstractSelfTest extends GridCommonAbst
 
     /** {@inheritDoc} */
     @Override protected void beforeTestsStarted() throws Exception {
+        System.setProperty(IgniteSystemProperties.IGNITE_ENABLE_FORCIBLE_NODE_KILL, "true");
+
         super.beforeTestsStarted();
 
         startGridsMultiThreaded(GRID_CNT);
@@ -146,6 +149,8 @@ public abstract class IgniteCachePutRetryAbstractSelfTest extends GridCommonAbst
         super.afterTestsStopped();
 
         stopAllGrids();
+
+        System.clearProperty(IgniteSystemProperties.IGNITE_ENABLE_FORCIBLE_NODE_KILL);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/23f26af5/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheRestartTestSuite2.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheRestartTestSuite2.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheRestartTestSuite2.java
index 1901283..6a4c487 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheRestartTestSuite2.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheRestartTestSuite2.java
@@ -18,6 +18,8 @@
 package org.apache.ignite.testsuites;
 
 import junit.framework.TestSuite;
+import org.apache.ignite.IgniteSystemProperties;
+import org.apache.ignite.internal.IgniteProperties;
 import org.apache.ignite.internal.processors.cache.GridCachePutAllFailoverSelfTest;
 import org.apache.ignite.internal.processors.cache.IgniteCacheAtomicPutAllFailoverSelfTest;
 import org.apache.ignite.internal.processors.cache.IgniteCachePutAllRestartTest;


[27/40] 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/ignite-5757
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;


[34/40] 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();
 }


[13/40] ignite git commit: IGNITE-5067 - Fixed absolute swap file path handling for memory policy configuration. Fixes #1867

Posted by ag...@apache.org.
IGNITE-5067 - Fixed absolute swap file path handling for memory policy configuration. Fixes #1867


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

Branch: refs/heads/ignite-5757
Commit: 6f749bf4bebb135250a3f99923ed87b4b7d0c29f
Parents: c1a3b37
Author: Sergey Chugunov <se...@gmail.com>
Authored: Fri Jul 21 17:59:10 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Fri Jul 21 18:00:40 2017 +0300

----------------------------------------------------------------------
 .../IgniteCacheDatabaseSharedManager.java       |  22 ++-
 .../database/SwapPathConstructionSelfTest.java  | 157 +++++++++++++++++++
 .../ignite/testsuites/IgniteBasicTestSuite.java |   3 +
 3 files changed, 174 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/6f749bf4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/IgniteCacheDatabaseSharedManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/IgniteCacheDatabaseSharedManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/IgniteCacheDatabaseSharedManager.java
index eec3b85..e07c51e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/IgniteCacheDatabaseSharedManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/IgniteCacheDatabaseSharedManager.java
@@ -25,7 +25,6 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import javax.management.JMException;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteLogger;
 import org.apache.ignite.MemoryMetrics;
@@ -204,8 +203,9 @@ public class IgniteCacheDatabaseSharedManager extends GridCacheSharedManagerAdap
 
     /**
      * @param memCfg Database config.
+     * @throws IgniteCheckedException If failed to initialize swap path.
      */
-    protected void initPageMemoryPolicies(MemoryConfiguration memCfg) {
+    protected void initPageMemoryPolicies(MemoryConfiguration memCfg) throws IgniteCheckedException {
         MemoryPolicyConfiguration[] memPlcsCfgs = memCfg.getMemoryPolicies();
 
         if (memPlcsCfgs == null) {
@@ -261,12 +261,13 @@ public class IgniteCacheDatabaseSharedManager extends GridCacheSharedManagerAdap
      * @param memCfg Database config.
      * @param memPlcCfg Memory policy config.
      * @param memPlcName Memory policy name.
+     * @throws IgniteCheckedException If failed to initialize swap path.
      */
     private void addMemoryPolicy(
         MemoryConfiguration memCfg,
         MemoryPolicyConfiguration memPlcCfg,
         String memPlcName
-    ) {
+    ) throws IgniteCheckedException {
         String dfltMemPlcName = memCfg.getDefaultMemoryPolicyName();
 
         if (dfltMemPlcName == null)
@@ -844,12 +845,14 @@ public class IgniteCacheDatabaseSharedManager extends GridCacheSharedManagerAdap
      * @param plcCfg memory policy with PageMemory specific parameters.
      * @param memMetrics {@link MemoryMetrics} object to collect memory usage metrics.
      * @return Memory policy instance.
+     *
+     * @throws IgniteCheckedException If failed to initialize swap path.
      */
     private MemoryPolicy initMemory(
         MemoryConfiguration memCfg,
         MemoryPolicyConfiguration plcCfg,
         MemoryMetricsImpl memMetrics
-    ) {
+    ) throws IgniteCheckedException {
         File allocPath = buildAllocPath(plcCfg);
 
         DirectMemoryProvider memProvider = allocPath == null ?
@@ -892,8 +895,10 @@ public class IgniteCacheDatabaseSharedManager extends GridCacheSharedManagerAdap
      * Builds allocation path for memory mapped file to be used with PageMemory.
      *
      * @param plc MemoryPolicyConfiguration.
+     *
+     * @throws IgniteCheckedException If resolving swap directory fails.
      */
-    @Nullable protected File buildAllocPath(MemoryPolicyConfiguration plc) {
+    @Nullable protected File buildAllocPath(MemoryPolicyConfiguration plc) throws IgniteCheckedException {
         String path = plc.getSwapFilePath();
 
         if (path == null)
@@ -938,13 +943,14 @@ public class IgniteCacheDatabaseSharedManager extends GridCacheSharedManagerAdap
      * @param path Path to the working directory.
      * @param consId Consistent ID of the local node.
      * @return DB storage path.
+     *
+     * @throws IgniteCheckedException If resolving swap directory fails.
      */
-    protected File buildPath(String path, String consId) {
+    protected File buildPath(String path, String consId) throws IgniteCheckedException {
         String igniteHomeStr = U.getIgniteHome();
 
-        File igniteHome = igniteHomeStr != null ? new File(igniteHomeStr) : null;
+        File workDir = igniteHomeStr == null ? new File(path) : U.resolveWorkDirectory(igniteHomeStr, path, false);
 
-        File workDir = igniteHome == null ? new File(path) : new File(igniteHome, path);
 
         return new File(workDir, consId);
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/6f749bf4/modules/core/src/test/java/org/apache/ignite/internal/processors/database/SwapPathConstructionSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/SwapPathConstructionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/SwapPathConstructionSelfTest.java
new file mode 100644
index 0000000..53e5daf
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/SwapPathConstructionSelfTest.java
@@ -0,0 +1,157 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.database;
+
+import java.io.File;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Map;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.MemoryConfiguration;
+import org.apache.ignite.configuration.MemoryPolicyConfiguration;
+import org.apache.ignite.internal.GridKernalContext;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.pagemem.PageMemory;
+import org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager;
+import org.apache.ignite.internal.processors.cache.persistence.MemoryPolicy;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ * Test verifies correct construction of swap file path {@link MemoryPolicyConfiguration#setSwapFilePath(String)}
+ * when absolute or relative paths are provided via configuration.
+ */
+public class SwapPathConstructionSelfTest extends GridCommonAbstractTest {
+    /** */
+    private MemoryConfiguration memCfg;
+
+    /** */
+    private static final String RELATIVE_SWAP_PATH = "relSwapPath";
+
+    /** */
+    private static final String ABSOLUTE_SWAP_PATH = "absoluteSwapPath";
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
+
+        cfg.setMemoryConfiguration(memCfg);
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        stopAllGrids();
+
+        cleanUpSwapDir();
+    }
+
+    /**
+     * Cleans up swap files and directories after test.
+     */
+    private void cleanUpSwapDir() {
+        Path relDir = Paths.get(U.getIgniteHome(), RELATIVE_SWAP_PATH);
+
+        deleteRecursively(relDir.toFile());
+
+        Path absDir = Paths.get(getTmpDir(), ABSOLUTE_SWAP_PATH);
+
+        deleteRecursively(absDir.toFile());
+    }
+
+    /**
+     * Verifies relative swap file path construction. Directory with swap files is cleaned up during after-test phase.
+     */
+    public void testRelativeSwapFilePath() throws Exception {
+        memCfg = createMemoryConfiguration(true);
+
+        IgniteEx ignite = startGrid(0);
+
+        String allocPath = extractDefaultPageMemoryAllocPath(ignite.context());
+
+        assertNotNull(allocPath);
+
+        assertTrue(allocPath.contains(Paths.get(U.getIgniteHome(), RELATIVE_SWAP_PATH).toString()));
+    }
+
+    /**
+     * Verifies absolute swap file path construction. System tmp directory is used to allocate swap files,
+     * so no clean up is needed.
+     */
+    public void testAbsoluteSwapFilePath() throws Exception {
+        memCfg = createMemoryConfiguration(false);
+
+        IgniteEx ignite = startGrid(0);
+
+        String allocPath = extractDefaultPageMemoryAllocPath(ignite.context());
+
+        assertNotNull(allocPath);
+
+        String expectedPath = Paths.get(getTmpDir(), ABSOLUTE_SWAP_PATH).toString();
+
+        assertTrue("Expected path: "
+                        + expectedPath
+                        + "; actual path: "
+                        + allocPath,
+                allocPath.startsWith(expectedPath));
+    }
+
+    /**
+     * @param context Context.
+     */
+    private String extractDefaultPageMemoryAllocPath(GridKernalContext context) {
+        IgniteCacheDatabaseSharedManager dbMgr = context.cache().context().database();
+
+        Map<String, MemoryPolicy> memPlcMap = U.field(dbMgr, "memPlcMap");
+
+        PageMemory pageMem = memPlcMap.get("default").pageMemory();
+
+        Object memProvider = U.field(pageMem, "directMemoryProvider");
+
+        return ((File) U.field(memProvider, "allocationPath")).getAbsolutePath();
+    }
+
+    /**
+     * @param isRelativePath flag is set to {@code true} if relative path should be used for memory policy configuration.
+     */
+    private MemoryConfiguration createMemoryConfiguration(boolean isRelativePath) {
+        MemoryConfiguration memCfg = new MemoryConfiguration();
+
+        MemoryPolicyConfiguration memPlcCfg = new MemoryPolicyConfiguration();
+
+        memPlcCfg.setName("default");
+        memPlcCfg.setMaxSize(20 * 1024 * 1024);
+
+        if (isRelativePath)
+            memPlcCfg.setSwapFilePath(RELATIVE_SWAP_PATH);
+        else
+            memPlcCfg.setSwapFilePath(Paths.get(getTmpDir(), ABSOLUTE_SWAP_PATH).toString());
+
+        memCfg.setMemoryPolicies(memPlcCfg);
+
+        return memCfg;
+    }
+
+    /**
+     *
+     */
+    private String getTmpDir() {
+        return System.getProperty("java.io.tmpdir");
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6f749bf4/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
index d79e868..2ec2c74 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
@@ -20,6 +20,8 @@ package org.apache.ignite.testsuites;
 import java.util.Set;
 import junit.framework.TestSuite;
 import org.apache.ignite.GridSuppressedExceptionSelfTest;
+import org.apache.ignite.internal.processors.database.SwapPathConstructionSelfTest;
+import org.apache.ignite.util.AttributeNodeFilterSelfTest;
 import org.apache.ignite.internal.ClusterGroupHostsSelfTest;
 import org.apache.ignite.internal.ClusterGroupSelfTest;
 import org.apache.ignite.internal.GridFailFastNodeFailureDetectionSelfTest;
@@ -173,6 +175,7 @@ public class IgniteBasicTestSuite extends TestSuite {
         suite.addTestSuite(MetadataStorageSelfTest.class);
         suite.addTestSuite(FreeListImplSelfTest.class);
         suite.addTestSuite(MemoryMetricsSelfTest.class);
+        suite.addTestSuite(SwapPathConstructionSelfTest.class);
 
         suite.addTestSuite(IgniteMarshallerCacheFSRestoreTest.class);
         suite.addTestSuite(IgniteMarshallerCacheClassNameConflictTest.class);


[38/40] 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/ignite-5757
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);


[19/40] ignite git commit: IGNITE-5697 Web Console: Upgrade dependencies.

Posted by ag...@apache.org.
IGNITE-5697 Web Console: Upgrade dependencies.


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

Branch: refs/heads/ignite-5757
Commit: f277530ab6a9a6f03fd66f95a7a4d91a3506dcf5
Parents: 39fa8fa
Author: Andrey Novikov <an...@gridgain.com>
Authored: Tue Jul 25 15:24:13 2017 +0700
Committer: Andrey Novikov <an...@gridgain.com>
Committed: Tue Jul 25 15:24:13 2017 +0700

----------------------------------------------------------------------
 modules/web-console/backend/.eslintrc           | 39 ++++++------
 modules/web-console/backend/package.json        | 27 ++++----
 modules/web-console/frontend/.eslintrc          | 40 +++++-------
 modules/web-console/frontend/app/app.js         | 37 ++++++-----
 .../components/activities-user-dialog/index.js  | 28 ++++-----
 .../page-configure-advanced/controller.js       |  9 +--
 .../components/page-configure-basic/service.js  |  8 +--
 .../app/components/page-configure/controller.js | 12 +---
 .../page-configure/controller.spec.js           | 48 --------------
 .../page-configure/services/PageConfigure.js    | 18 +++---
 .../components/web-console-header/component.js  | 12 ++--
 .../app/components/web-console-header/index.js  |  4 +-
 .../frontend/app/modules/ace.module.js          |  6 +-
 .../app/modules/branding/branding.module.js     | 16 +++--
 .../generator/ConfigurationGenerator.js         |  2 +-
 .../generator/PlatformGenerator.js              |  4 +-
 .../frontend/app/modules/demo/Demo.module.js    | 10 +--
 .../app/modules/dialog/dialog.controller.js     |  4 --
 .../app/modules/form/field/label.directive.js   |  4 +-
 .../app/modules/form/field/tooltip.directive.js |  4 +-
 .../frontend/app/modules/sql/sql.controller.js  |  2 +-
 .../frontend/app/modules/sql/sql.module.js      | 66 ++++++++++----------
 .../frontend/app/modules/states/admin.state.js  |  6 +-
 .../app/modules/states/configuration.state.js   | 35 ++++++-----
 .../summary/summary-zipper.service.js           |  2 +-
 .../frontend/app/modules/states/errors.state.js |  4 +-
 .../frontend/app/modules/states/logout.state.js | 12 ++--
 .../app/modules/states/password.state.js        |  4 +-
 .../app/modules/states/profile.state.js         |  9 ++-
 .../frontend/app/modules/states/signin.state.js | 32 +++++-----
 .../app/modules/user/AclRoute.provider.js       |  6 +-
 .../frontend/app/modules/user/user.module.js    | 30 ++++++++-
 .../app/services/CopyToClipboard.service.js     |  4 +-
 .../app/services/LegacyTable.service.js         |  2 +-
 modules/web-console/frontend/app/vendor.js      |  8 ++-
 modules/web-console/frontend/package.json       | 57 ++++++++---------
 modules/web-console/frontend/views/index.pug    | 14 +----
 37 files changed, 292 insertions(+), 333 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/f277530a/modules/web-console/backend/.eslintrc
----------------------------------------------------------------------
diff --git a/modules/web-console/backend/.eslintrc b/modules/web-console/backend/.eslintrc
index 7eb04b7..1915518 100644
--- a/modules/web-console/backend/.eslintrc
+++ b/modules/web-console/backend/.eslintrc
@@ -3,19 +3,21 @@ env:
     node: true
     mocha: true
 
-ecmaFeatures:
-    arrowFunctions: true
-    blockBindings: true
-    classes: true
-    defaultParams: true
-    destructuring: true
-    module: true
-    objectLiteralComputedProperties: true
-    objectLiteralShorthandMethods: true
-    objectLiteralShorthandProperties: true
-    spread: true
-    templateStrings: true
-    experimentalObjectRestSpread: true
+parserOptions:
+    sourceType: module
+    ecmaFeatures:
+        arrowFunctions: true
+        blockBindings: true
+        classes: true
+        defaultParams: true
+        destructuring: true
+        module: true
+        objectLiteralComputedProperties: true
+        objectLiteralShorthandMethods: true
+        objectLiteralShorthandProperties: true
+        spread: true
+        templateStrings: true
+        experimentalObjectRestSpread: true
 
 globals:
     _: true
@@ -47,7 +49,7 @@ rules:
     guard-for-in: 1
     handle-callback-err: 0
     id-length: [2, {"min": 1, "max": 60}]
-    indent: [2, 4, {"SwitchCase": 1}]
+    indent: [2, 4, {"SwitchCase": 1, "MemberExpression": "off", "CallExpression": {"arguments": "off"}}]
     key-spacing: [2, { "beforeColon": false, "afterColon": true }]
     lines-around-comment: 0
     linebreak-style: [0, "unix"]
@@ -104,7 +106,7 @@ rules:
     no-loop-func: 2
     no-mixed-requires: [0, false]
     no-mixed-spaces-and-tabs: [2, true]
-    no-multi-spaces: 2
+    no-multi-spaces: ["error", {"exceptions": { "VariableDeclarator": true }}]
     no-multi-str: 2
     no-multiple-empty-lines: [0, {"max": 2}]
     no-native-reassign: 2
@@ -130,7 +132,7 @@ rules:
     no-script-url: 0
     no-self-compare: 2
     no-sequences: 2
-    no-shadow: 2
+    no-shadow: 0
     no-shadow-restricted-names: 2
     no-spaced-func: 2
     no-sparse-arrays: 1
@@ -162,7 +164,7 @@ rules:
     prefer-const: 1
     prefer-spread: 2
     quote-props: [2, "as-needed"]
-    quotes: [2, "single"]
+    quotes: [2, "single", {"allowTemplateLiterals": true}]
     radix: 1
     semi: [2, "always"]
     semi-spacing: [2, {"before": false, "after": true}]
@@ -181,6 +183,3 @@ rules:
     wrap-iife: 0
     wrap-regex: 0
     yoda: [2, "never"]
-
-parserOptions:
-    sourceType: module

http://git-wip-us.apache.org/repos/asf/ignite/blob/f277530a/modules/web-console/backend/package.json
----------------------------------------------------------------------
diff --git a/modules/web-console/backend/package.json b/modules/web-console/backend/package.json
index 2af7787..837f41c 100644
--- a/modules/web-console/backend/package.json
+++ b/modules/web-console/backend/package.json
@@ -29,19 +29,19 @@
     "win32"
   ],
   "dependencies": {
-    "body-parser": "1.17.1",
+    "body-parser": "1.17.2",
     "connect-mongo": "1.3.2",
-    "cookie-parser": "~1.4.0",
-    "express": "4.15.2",
-    "express-session": "1.15.2",
+    "cookie-parser": "1.4.3",
+    "express": "4.15.3",
+    "express-session": "1.15.4",
     "fire-up": "1.0.0",
-    "glob": "7.1.1",
+    "glob": "7.1.2",
     "jszip": "3.1.3",
     "lodash": "4.17.4",
-    "mongoose": "4.9.4",
-    "morgan": "1.8.1",
+    "mongoose": "4.11.4",
+    "morgan": "1.8.2",
     "nconf": "0.8.4",
-    "nodemailer": "3.1.4",
+    "nodemailer": "4.0.1",
     "passport": "0.3.2",
     "passport-local": "1.0.0",
     "passport-local-mongoose": "4.0.0",
@@ -49,12 +49,11 @@
     "socket.io": "1.7.3"
   },
   "devDependencies": {
-    "chai": "3.5.0",
-    "cross-env": "4.0.0",
-    "eslint": "3.19.0",
-    "eslint-friendly-formatter": "2.0.7",
-    "jasmine-core": "2.5.2",
-    "mocha": "3.2.0",
+    "chai": "4.1.0",
+    "cross-env": "5.0.1",
+    "eslint": "4.3.0",
+    "eslint-friendly-formatter": "3.0.0",
+    "mocha": "3.4.2",
     "mocha-teamcity-reporter": "1.1.1",
     "mockgoose": "6.0.8",
     "supertest": "3.0.0"

http://git-wip-us.apache.org/repos/asf/ignite/blob/f277530a/modules/web-console/frontend/.eslintrc
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/.eslintrc b/modules/web-console/frontend/.eslintrc
index d88fb97..4e24d0b 100644
--- a/modules/web-console/frontend/.eslintrc
+++ b/modules/web-console/frontend/.eslintrc
@@ -6,20 +6,21 @@ plugins:
 env:
     es6: true
     browser: true
-
-ecmaFeatures:
-    arrowFunctions: true
-    blockBindings: true
-    classes: true
-    defaultParams: true
-    destructuring: true
-    module: true
-    objectLiteralComputedProperties: true
-    objectLiteralShorthandMethods: true
-    objectLiteralShorthandProperties: true
-    spread: true
-    templateStrings: true
-    experimentalObjectRestSpread: true
+parserOptions:
+    sourceType: module
+    ecmaFeatures:
+        arrowFunctions: true
+        blockBindings: true
+        classes: true
+        defaultParams: true
+        destructuring: true
+        module: true
+        objectLiteralComputedProperties: true
+        objectLiteralShorthandMethods: true
+        objectLiteralShorthandProperties: true
+        spread: true
+        templateStrings: true
+        experimentalObjectRestSpread: true
 
 globals:
     _: true
@@ -29,10 +30,6 @@ globals:
     window: true
     global: true
     angular: true
-    $generatorCommon: true
-    $generatorSpring: true
-    $generatorJava: true
-    $generatorOptional: true
     saveAs: true
     process: true
     require: true
@@ -63,7 +60,7 @@ rules:
     guard-for-in: 1
     handle-callback-err: 0
     id-length: [2, {"min": 1, "max": 60}]
-    indent: [2, 4, {"SwitchCase": 1}]
+    indent: [2, 4, {"SwitchCase": 1, "MemberExpression": "off", "CallExpression": {"arguments": "off"}}]
     key-spacing: [2, { "beforeColon": false, "afterColon": true }]
     lines-around-comment: 0
     linebreak-style: [0, "unix"]
@@ -138,7 +135,7 @@ rules:
     no-path-concat: 0
     no-plusplus: 0
     no-process-env: 0
-    no-process-exit: 1
+    no-process-exit: 0
     no-proto: 2
     no-redeclare: 2
     no-regex-spaces: 1
@@ -198,6 +195,3 @@ rules:
     wrap-regex: 0
     yoda: [2, "never"]
     babel/semi: 2
-
-parserOptions:
-    sourceType: module

http://git-wip-us.apache.org/repos/asf/ignite/blob/f277530a/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 0667e8f..e2d609a 100644
--- a/modules/web-console/frontend/app/app.js
+++ b/modules/web-console/frontend/app/app.js
@@ -133,8 +133,7 @@ import IgniteModules from 'IgniteModules/index';
 
 import baseTemplate from 'views/base.pug';
 
-angular
-.module('ignite-console', [
+angular.module('ignite-console', [
     // Optional AngularJS modules.
     'ngAnimate',
     'ngSanitize',
@@ -143,6 +142,7 @@ angular
     'btford.socket-io',
     'mgcrea.ngStrap',
     'ui.router',
+    'ui.router.state.events',
     'gridster',
     'dndLists',
     'nvd3',
@@ -278,33 +278,32 @@ angular
     $urlRouterProvider.otherwise('/404');
     $locationProvider.html5Mode(true);
 }])
-.run(['$rootScope', '$state', 'MetaTags', 'gettingStarted', ($root, $state, $meta, gettingStarted) => {
+.run(['$rootScope', '$state', 'gettingStarted', ($root, $state, gettingStarted) => {
     $root._ = _;
     $root.$state = $state;
-    $root.$meta = $meta;
     $root.gettingStarted = gettingStarted;
 }])
 .run(['$rootScope', 'AgentManager', ($root, agentMgr) => {
     $root.$on('user', () => agentMgr.connect());
 }])
-.run(['$rootScope', ($root) => {
-    $root.$on('$stateChangeStart', () => {
+.run(['$transitions', ($transitions) => {
+    $transitions.onStart({ }, () => {
         _.forEach(angular.element('.modal'), (m) => angular.element(m).scope().$hide());
     });
 
-    if (!$root.IgniteDemoMode) {
-        $root.$on('$stateChangeSuccess', (event, {name, unsaved}, params) => {
-            try {
-                if (unsaved)
-                    localStorage.removeItem('lastStateChangeSuccess');
-                else
-                    localStorage.setItem('lastStateChangeSuccess', JSON.stringify({name, params}));
-            }
-            catch (ignored) {
-                // No-op.
-            }
-        });
-    }
+    $transitions.onSuccess({ }, (trans) => {
+        try {
+            const {name, params, unsaved} = trans.$to();
+
+            if (unsaved)
+                localStorage.removeItem('lastStateChangeSuccess');
+            else
+                localStorage.setItem('lastStateChangeSuccess', JSON.stringify({name, params}));
+        }
+        catch (ignored) {
+            // No-op.
+        }
+    });
 }])
 .run(['$rootScope', '$http', '$state', 'IgniteMessages', 'User', 'IgniteNotebookData',
     ($root, $http, $state, Messages, User, Notebook) => { // eslint-disable-line no-shadow

http://git-wip-us.apache.org/repos/asf/ignite/blob/f277530a/modules/web-console/frontend/app/components/activities-user-dialog/index.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/components/activities-user-dialog/index.js b/modules/web-console/frontend/app/components/activities-user-dialog/index.js
index 02c7c1e..13c1d95 100644
--- a/modules/web-console/frontend/app/components/activities-user-dialog/index.js
+++ b/modules/web-console/frontend/app/components/activities-user-dialog/index.js
@@ -15,20 +15,20 @@
  * limitations under the License.
  */
 
- import controller from './activities-user-dialog.controller';
- import templateUrl from './activities-user-dialog.tpl.pug';
+import controller from './activities-user-dialog.controller';
+import templateUrl from './activities-user-dialog.tpl.pug';
 
- export default ['$modal', ($modal) => ({ show = true, user }) => {
-     const ActivitiesUserDialog = $modal({
-         templateUrl,
-         show,
-         resolve: {
-             user: () => user
-         },
-         controller,
-         controllerAs: 'ctrl'
-     });
+export default ['$modal', ($modal) => ({ show = true, user }) => {
+    const ActivitiesUserDialog = $modal({
+        templateUrl,
+        show,
+        resolve: {
+            user: () => user
+        },
+        controller,
+        controllerAs: 'ctrl'
+    });
 
-     return ActivitiesUserDialog.$promise
+    return ActivitiesUserDialog.$promise
          .then(() => ActivitiesUserDialog);
- }];
+}];

http://git-wip-us.apache.org/repos/asf/ignite/blob/f277530a/modules/web-console/frontend/app/components/page-configure-advanced/controller.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/components/page-configure-advanced/controller.js b/modules/web-console/frontend/app/components/page-configure-advanced/controller.js
index 0e73ae3..da20527 100644
--- a/modules/web-console/frontend/app/components/page-configure-advanced/controller.js
+++ b/modules/web-console/frontend/app/components/page-configure-advanced/controller.js
@@ -16,7 +16,7 @@
  */
 
 export default class PageConfigureAdvancedController {
-    static $inject = ['PageConfigureAdvanced', '$scope'];
+    static $inject = ['$scope'];
 
     static menuItems = [
         { text: 'Clusters', sref: 'base.configuration.tabs.advanced.clusters' },
@@ -26,14 +26,11 @@ export default class PageConfigureAdvancedController {
         { text: 'Summary', sref: 'base.configuration.tabs.advanced.summary' }
     ];
 
-    constructor(PageConfigureAdvanced, $scope) {
-        Object.assign(this, {PageConfigureAdvanced, $scope});
+    constructor($scope) {
+        Object.assign(this, {$scope});
     }
 
     $onInit() {
         this.menuItems = this.constructor.menuItems;
-        this.$scope.$on('$stateChangeSuccess', (e, toState) => {
-            this.PageConfigureAdvanced.onStateEnterRedirect(toState);
-        });
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/f277530a/modules/web-console/frontend/app/components/page-configure-basic/service.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/components/page-configure-basic/service.js b/modules/web-console/frontend/app/components/page-configure-basic/service.js
index 4db61ea..0032106 100644
--- a/modules/web-console/frontend/app/components/page-configure-basic/service.js
+++ b/modules/web-console/frontend/app/components/page-configure-basic/service.js
@@ -50,7 +50,7 @@ export default class PageConfigureBasic {
         const noFakeIDCaches = caches.map(stripFakeID);
         cluster = cloneDeep(stripFakeID(cluster));
         return this.$q.all(noFakeIDCaches.map((cache) => (
-                this.caches.saveCache(cache)
+            this.caches.saveCache(cache)
                 .then(
                     ({data}) => data,
                     (e) => {
@@ -58,7 +58,7 @@ export default class PageConfigureBasic {
                         return this.$q.resolve(null);
                     }
                 )
-            )))
+        )))
         .then((cacheIDs) => {
             // Make sure we don't loose new IDs even if some requests fail
             this.pageConfigure.upsertCaches(
@@ -115,8 +115,8 @@ export default class PageConfigureBasic {
     setCluster(_id) {
         this.ConfigureState.dispatchAction(
             isNewItem({_id})
-            ? {type: SET_CLUSTER, _id, cluster: this.clusters.getBlankCluster()}
-            : {type: SET_CLUSTER, _id}
+                ? {type: SET_CLUSTER, _id, cluster: this.clusters.getBlankCluster()}
+                : {type: SET_CLUSTER, _id}
         );
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/f277530a/modules/web-console/frontend/app/components/page-configure/controller.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/components/page-configure/controller.js b/modules/web-console/frontend/app/components/page-configure/controller.js
index 3dcd14e..5ead0bb 100644
--- a/modules/web-console/frontend/app/components/page-configure/controller.js
+++ b/modules/web-console/frontend/app/components/page-configure/controller.js
@@ -16,15 +16,9 @@
  */
 
 export default class PageConfigureController {
-    static $inject = ['$scope', 'PageConfigure'];
+    static $inject = ['$scope'];
 
-    constructor($scope, PageConfigure) {
-        Object.assign(this, {$scope, PageConfigure});
-    }
-
-    $onInit() {
-        this.$scope.$on('$stateChangeSuccess', (e, toState) => {
-            this.PageConfigure.onStateEnterRedirect(toState);
-        });
+    constructor($scope) {
+        Object.assign(this, {$scope});
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/f277530a/modules/web-console/frontend/app/components/page-configure/controller.spec.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/components/page-configure/controller.spec.js b/modules/web-console/frontend/app/components/page-configure/controller.spec.js
deleted file mode 100644
index e30eb65..0000000
--- a/modules/web-console/frontend/app/components/page-configure/controller.spec.js
+++ /dev/null
@@ -1,48 +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.
- */
-
-import {suite, test} from 'mocha';
-import {assert} from 'chai';
-import {spy} from 'sinon';
-
-import Controller from './controller';
-
-const mocks = () => new Map([
-    ['$scope', {
-        $on: spy()
-    }],
-    ['PageConfigure', {
-        onStateEnterRedirect: spy()
-    }]
-]);
-
-suite('page-configure component controller', () => {
-    test('State change success redirect', () => {
-        const c = new Controller(...mocks().values());
-        c.$onInit();
-        c.$scope.$on.getCall(0).args[1](null, {name: 'base.items'});
-        assert.isOk(
-            c.PageConfigure.onStateEnterRedirect.calledOnce,
-            'calls PageConfigure.onStateEnterRedirect every $stateChangeSuccess'
-        );
-        assert.deepEqual(
-            c.PageConfigure.onStateEnterRedirect.getCall(0).args,
-            [{name: 'base.items'}],
-            'calls PageConfigure.onStateEnterRedirect with correct arguments'
-        );
-    });
-});

http://git-wip-us.apache.org/repos/asf/ignite/blob/f277530a/modules/web-console/frontend/app/components/page-configure/services/PageConfigure.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/components/page-configure/services/PageConfigure.js b/modules/web-console/frontend/app/components/page-configure/services/PageConfigure.js
index a712aca..34a292a 100644
--- a/modules/web-console/frontend/app/components/page-configure/services/PageConfigure.js
+++ b/modules/web-console/frontend/app/components/page-configure/services/PageConfigure.js
@@ -31,15 +31,17 @@ export default class PageConfigure {
     }
 
     onStateEnterRedirect(toState) {
-        if (toState.name !== 'base.configuration.tabs') return this.$q.resolve();
+        if (toState.name !== 'base.configuration.tabs')
+            return this.$q.resolve();
+
         return this.configuration.read()
-        .then((data) => {
-            this.loadList(data);
-            const nextState = data.clusters.length
-                ? 'base.configuration.tabs.advanced'
-                : 'base.configuration.tabs.basic';
-            return this.$state.go(nextState, null, {location: 'replace'});
-        });
+            .then((data) => {
+                this.loadList(data);
+
+                return this.$q.resolve(data.clusters.length
+                    ? 'base.configuration.tabs.advanced'
+                    : 'base.configuration.tabs.basic');
+            });
     }
 
     loadList(list) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/f277530a/modules/web-console/frontend/app/components/web-console-header/component.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/components/web-console-header/component.js b/modules/web-console/frontend/app/components/web-console-header/component.js
index d4c5c4b..66f09e9 100644
--- a/modules/web-console/frontend/app/components/web-console-header/component.js
+++ b/modules/web-console/frontend/app/components/web-console-header/component.js
@@ -33,11 +33,15 @@ export default {
             Object.assign(this, {$rootScope, $scope, $state, branding, UserNotifications});
         }
 
+        setWebAgentDownloadVisible() {
+            this.isWebAgentDownloadVisible =
+                this.constructor.webAgentDownloadVisibleStates.some((state) => this.$state.includes(state));
+        }
+
         $onInit() {
-            this.$scope.$on('$stateChangeSuccess', () => {
-                this.isWebAgentDownloadVisible =
-                    this.constructor.webAgentDownloadVisibleStates.some((state) => this.$state.includes(state));
-            });
+            this.setWebAgentDownloadVisible();
+
+            this.$scope.$on('$stateChangeSuccess', () => this.setWebAgentDownloadVisible());
         }
     },
     transclude: {

http://git-wip-us.apache.org/repos/asf/ignite/blob/f277530a/modules/web-console/frontend/app/components/web-console-header/index.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/components/web-console-header/index.js b/modules/web-console/frontend/app/components/web-console-header/index.js
index 36caa3d..e41e1cc 100644
--- a/modules/web-console/frontend/app/components/web-console-header/index.js
+++ b/modules/web-console/frontend/app/components/web-console-header/index.js
@@ -19,5 +19,5 @@ import angular from 'angular';
 import component from './component';
 
 export default angular
-	.module('ignite-console.web-console-header', [])
-	.component('webConsoleHeader', component);
+    .module('ignite-console.web-console-header', [])
+    .component('webConsoleHeader', component);

http://git-wip-us.apache.org/repos/asf/ignite/blob/f277530a/modules/web-console/frontend/app/modules/ace.module.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/ace.module.js b/modules/web-console/frontend/app/modules/ace.module.js
index 4920a6f..a28536a 100644
--- a/modules/web-console/frontend/app/modules/ace.module.js
+++ b/modules/web-console/frontend/app/modules/ace.module.js
@@ -184,10 +184,10 @@ angular
                     return (e) => {
                         const newValue = session.getValue();
 
+                        // HACK make sure to only trigger the apply outside of the
+                        // digest loop 'cause ACE is actually using this callback
+                        // for any text transformation !
                         if (ngModel && newValue !== ngModel.$viewValue &&
-                                // HACK make sure to only trigger the apply outside of the
-                                // digest loop 'cause ACE is actually using this callback
-                                // for any text transformation !
                             !scope.$$phase && !scope.$root.$$phase)
                             scope.$eval(() => ngModel.$setViewValue(newValue));
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/f277530a/modules/web-console/frontend/app/modules/branding/branding.module.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/branding/branding.module.js b/modules/web-console/frontend/app/modules/branding/branding.module.js
index cae7c91..9c4a5e5 100644
--- a/modules/web-console/frontend/app/modules/branding/branding.module.js
+++ b/modules/web-console/frontend/app/modules/branding/branding.module.js
@@ -28,14 +28,18 @@ import ignitePoweredByApache from './powered-by-apache.directive';
 
 angular
 .module('ignite-console.branding', [
-    'ui.router.metatags'
+    'tf.metatags'
 ])
 .provider(...IgniteBranding)
-.config(['UIRouterMetatagsProvider', (UIRouterMetatagsProvider) => {
-    UIRouterMetatagsProvider
-        .setDefaultTitle('Apache Ignite - Management Tool and Configuration Wizard')
-        .setTitleSuffix(' – Apache Ignite Web Console')
-        .setDefaultDescription('The Apache Ignite Web Console is an interactive management tool and configuration wizard which walks you through the creation of config files. Try it now.');
+.config(['tfMetaTagsProvider', (tfMetaTagsProvider) => {
+    tfMetaTagsProvider.setDefaults({
+        title: 'Apache Ignite - Management Tool and Configuration Wizard',
+        properties: {
+            description: 'The Apache Ignite Web Console is an interactive management tool and configuration wizard which walks you through the creation of config files. Try it now.'
+        }
+    });
+
+    tfMetaTagsProvider.setTitleSuffix(' – Apache Ignite Web Console');
 }])
 .directive(...ignitePoweredByApache)
 .directive(...igniteHeaderLogo)

http://git-wip-us.apache.org/repos/asf/ignite/blob/f277530a/modules/web-console/frontend/app/modules/configuration/generator/ConfigurationGenerator.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/configuration/generator/ConfigurationGenerator.js b/modules/web-console/frontend/app/modules/configuration/generator/ConfigurationGenerator.js
index 8299b9b..a14bfd3 100644
--- a/modules/web-console/frontend/app/modules/configuration/generator/ConfigurationGenerator.js
+++ b/modules/web-console/frontend/app/modules/configuration/generator/ConfigurationGenerator.js
@@ -887,7 +887,7 @@ export default class IgniteConfigurationGenerator {
             cfg.intProperty('peerClassLoadingMissedResourcesCacheSize')
                 .intProperty('peerClassLoadingThreadPoolSize')
                 .varArgProperty('p2pLocClsPathExcl', 'peerClassLoadingLocalClassPathExclude',
-                   cluster.peerClassLoadingLocalClassPathExclude);
+                    cluster.peerClassLoadingLocalClassPathExclude);
         }
 
         // Since ignite 2.0

http://git-wip-us.apache.org/repos/asf/ignite/blob/f277530a/modules/web-console/frontend/app/modules/configuration/generator/PlatformGenerator.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/configuration/generator/PlatformGenerator.js b/modules/web-console/frontend/app/modules/configuration/generator/PlatformGenerator.js
index b076193..234c7ec 100644
--- a/modules/web-console/frontend/app/modules/configuration/generator/PlatformGenerator.js
+++ b/modules/web-console/frontend/app/modules/configuration/generator/PlatformGenerator.js
@@ -168,7 +168,7 @@ export default ['JavaTypes', 'igniteClusterPlatformDefaults', 'igniteCachePlatfo
                 .intProperty('unacknowledgedMessagesBufferSize')
                 // .intProperty('socketWriteTimeout')
                 .intProperty('selectorsCount');
-                // .emptyBeanProperty('addressResolver');
+            // .emptyBeanProperty('addressResolver');
 
             if (commSpi.nonEmpty())
                 cfg.beanProperty('CommunicationSpi', commSpi);
@@ -176,7 +176,7 @@ export default ['JavaTypes', 'igniteClusterPlatformDefaults', 'igniteCachePlatfo
             cfg.intProperty('networkTimeout', 'NetworkTimeout')
                 .intProperty('networkSendRetryDelay')
                 .intProperty('networkSendRetryCount');
-                // .intProperty('discoveryStartupDelay');
+            // .intProperty('discoveryStartupDelay');
 
             return cfg;
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/f277530a/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 d75beda..2445461 100644
--- a/modules/web-console/frontend/app/modules/demo/Demo.module.js
+++ b/modules/web-console/frontend/app/modules/demo/Demo.module.js
@@ -24,7 +24,7 @@ angular
 .module('ignite-console.demo', [
     'ignite-console.socket'
 ])
-.config(['$stateProvider', 'AclRouteProvider', ($stateProvider, AclRoute) => {
+.config(['$stateProvider', ($stateProvider) => {
     $stateProvider
         .state('demo', {
             abstract: true,
@@ -33,17 +33,17 @@ angular
         })
         .state('demo.resume', {
             url: '/resume',
-            onEnter: AclRoute.checkAccess('demo'),
+            permission: 'demo',
             controller: ['$state', ($state) => {
                 $state.go('base.configuration.tabs.advanced.clusters');
             }],
-            metaTags: {
+            tfMetaTags: {
                 title: 'Demo resume'
             }
         })
         .state('demo.reset', {
             url: '/reset',
-            onEnter: AclRoute.checkAccess('demo'),
+            permission: 'demo',
             controller: ['$state', '$http', 'IgniteMessages', ($state, $http, Messages) => {
                 $http.post('/api/v1/demo/reset')
                     .then(() => $state.go('base.configuration.tabs.advanced.clusters'))
@@ -53,7 +53,7 @@ angular
                         Messages.showError(res);
                     });
             }],
-            metaTags: {
+            tfMetaTags: {
                 title: 'Demo reset'
             }
         });

http://git-wip-us.apache.org/repos/asf/ignite/blob/f277530a/modules/web-console/frontend/app/modules/dialog/dialog.controller.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/dialog/dialog.controller.js b/modules/web-console/frontend/app/modules/dialog/dialog.controller.js
index 05518d3..0256b84 100644
--- a/modules/web-console/frontend/app/modules/dialog/dialog.controller.js
+++ b/modules/web-console/frontend/app/modules/dialog/dialog.controller.js
@@ -33,8 +33,4 @@ export default ['$rootScope', '$scope', 'IgniteDialog', function($root, $scope,
     $scope.$watch(() => ctrl.content, () => {
         $scope.content = ctrl.content;
     });
-
-    $root.$on('$stateChangeStart', () => {
-        dialog.hide();
-    });
 }];

http://git-wip-us.apache.org/repos/asf/ignite/blob/f277530a/modules/web-console/frontend/app/modules/form/field/label.directive.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/form/field/label.directive.js b/modules/web-console/frontend/app/modules/form/field/label.directive.js
index 97ba598..94f7889 100644
--- a/modules/web-console/frontend/app/modules/form/field/label.directive.js
+++ b/modules/web-console/frontend/app/modules/form/field/label.directive.js
@@ -20,7 +20,7 @@ export default ['igniteFormFieldLabel', [() => {
         restrict: 'E',
         compile() {
             return {
-                post($scope, $element, $attrs, [form, field], $transclude) {
+                post($scope, $element, $attrs, [field], $transclude) {
                     $transclude($scope, function(clone) {
                         const text = clone.text();
 
@@ -42,6 +42,6 @@ export default ['igniteFormFieldLabel', [() => {
         },
         replace: true,
         transclude: true,
-        require: ['^form', '?^igniteFormField']
+        require: ['?^igniteFormField']
     };
 }]];

http://git-wip-us.apache.org/repos/asf/ignite/blob/f277530a/modules/web-console/frontend/app/modules/form/field/tooltip.directive.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/form/field/tooltip.directive.js b/modules/web-console/frontend/app/modules/form/field/tooltip.directive.js
index 4f440a1..9e764bc 100644
--- a/modules/web-console/frontend/app/modules/form/field/tooltip.directive.js
+++ b/modules/web-console/frontend/app/modules/form/field/tooltip.directive.js
@@ -18,7 +18,7 @@
 const template = '<i class="tipField icon-help"></i>';
 
 export default ['igniteFormFieldTooltip', ['$tooltip', ($tooltip) => {
-    const link = ($scope, $element, $attrs, [form, field], $transclude) => {
+    const link = ($scope, $element, $attrs, [field], $transclude) => {
         const content = Array.prototype.slice
             .apply($transclude($scope))
             .reduce((html, el) => html += el.outerHTML || el.textContent || el, '');
@@ -44,6 +44,6 @@ export default ['igniteFormFieldTooltip', ['$tooltip', ($tooltip) => {
         link,
         replace: true,
         transclude: true,
-        require: ['^form', '?^igniteFormField']
+        require: ['?^igniteFormField']
     };
 }]];

http://git-wip-us.apache.org/repos/asf/ignite/blob/f277530a/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 633f167..3d38634 100644
--- a/modules/web-console/frontend/app/modules/sql/sql.controller.js
+++ b/modules/web-console/frontend/app/modules/sql/sql.controller.js
@@ -1247,7 +1247,7 @@ export default ['$rootScope', '$scope', '$http', '$q', '$timeout', '$interval',
 
             const chartHistory = paragraph.chartHistory;
 
-                // Clear history on query change.
+            // Clear history on query change.
             if (clearChart) {
                 chartHistory.length = 0;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/f277530a/modules/web-console/frontend/app/modules/sql/sql.module.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/sql/sql.module.js b/modules/web-console/frontend/app/modules/sql/sql.module.js
index 79614c2..da9955c 100644
--- a/modules/web-console/frontend/app/modules/sql/sql.module.js
+++ b/modules/web-console/frontend/app/modules/sql/sql.module.js
@@ -27,37 +27,35 @@ import sqlTplUrl from 'app/../views/sql/sql.tpl.pug';
 angular.module('ignite-console.sql', [
     'ui.router'
 ])
-    .config(['$stateProvider', 'AclRouteProvider',
-        ($stateProvider, AclRoute) => {
-            // set up the states
-            $stateProvider
-                .state('base.sql', {
-                    url: '/queries',
-                    abstract: true,
-                    template: '<ui-view></ui-view>'
-                })
-                .state('base.sql.notebook', {
-                    url: '/notebook/{noteId}',
-                    templateUrl: sqlTplUrl,
-                    onEnter: AclRoute.checkAccess('query'),
-                    metaTags: {
-                        title: 'Query notebook'
-                    },
-                    controller,
-                    controllerAs: '$ctrl'
-                })
-                .state('base.sql.demo', {
-                    url: '/demo',
-                    templateUrl: sqlTplUrl,
-                    onEnter: AclRoute.checkAccess('query'),
-                    metaTags: {
-                        title: 'SQL demo'
-                    },
-                    controller,
-                    controllerAs: '$ctrl'
-                });
-        }]
-    )
-    .service('IgniteNotebookData', NotebookData)
-    .service('IgniteNotebook', Notebook)
-    .controller('notebookController', notebook);
+.config(['$stateProvider', ($stateProvider) => {
+    // set up the states
+    $stateProvider
+        .state('base.sql', {
+            url: '/queries',
+            abstract: true,
+            template: '<ui-view></ui-view>'
+        })
+        .state('base.sql.notebook', {
+            url: '/notebook/{noteId}',
+            templateUrl: sqlTplUrl,
+            permission: 'query',
+            tfMetaTags: {
+                title: 'Query notebook'
+            },
+            controller,
+            controllerAs: '$ctrl'
+        })
+        .state('base.sql.demo', {
+            url: '/demo',
+            templateUrl: sqlTplUrl,
+            permission: 'query',
+            tfMetaTags: {
+                title: 'SQL demo'
+            },
+            controller,
+            controllerAs: '$ctrl'
+        });
+}])
+.service('IgniteNotebookData', NotebookData)
+.service('IgniteNotebook', Notebook)
+.controller('notebookController', notebook);

http://git-wip-us.apache.org/repos/asf/ignite/blob/f277530a/modules/web-console/frontend/app/modules/states/admin.state.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/states/admin.state.js b/modules/web-console/frontend/app/modules/states/admin.state.js
index 7189508..65e13aa 100644
--- a/modules/web-console/frontend/app/modules/states/admin.state.js
+++ b/modules/web-console/frontend/app/modules/states/admin.state.js
@@ -24,7 +24,7 @@ angular
 .module('ignite-console.states.admin', [
     'ui.router'
 ])
-.config(['$stateProvider', 'AclRouteProvider', function($stateProvider, AclRoute) {
+.config(['$stateProvider', function($stateProvider) {
     // set up the states
     $stateProvider
     .state('base.settings.admin', {
@@ -50,8 +50,8 @@ angular
             }
         },
         // templateUrl,
-        onEnter: AclRoute.checkAccess('admin_page'),
-        metaTags: {
+        permission: 'admin_page',
+        tfMetaTags: {
             title: 'Admin panel'
         }
     });

http://git-wip-us.apache.org/repos/asf/ignite/blob/f277530a/modules/web-console/frontend/app/modules/states/configuration.state.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/states/configuration.state.js b/modules/web-console/frontend/app/modules/states/configuration.state.js
index faf9315..d2c1410 100644
--- a/modules/web-console/frontend/app/modules/states/configuration.state.js
+++ b/modules/web-console/frontend/app/modules/states/configuration.state.js
@@ -51,7 +51,7 @@ angular.module('ignite-console.states.configuration', ['ui.router'])
         $templateCache.put('summary-tabs.html', summaryTabsTemplateUrl);
     }])
     // Configure state provider.
-    .config(['$stateProvider', 'AclRouteProvider', ($stateProvider, AclRoute) => {
+    .config(['$stateProvider', ($stateProvider) => {
         // Setup the states.
         $stateProvider
             .state('base.configuration', {
@@ -64,15 +64,21 @@ angular.module('ignite-console.states.configuration', ['ui.router'])
             })
             .state('base.configuration.tabs', {
                 url: '/configuration',
+                permission: 'configuration',
                 template: '<page-configure></page-configure>',
-                metaTags: {
+                redirectTo: (trans) => {
+                    const PageConfigure = trans.injector().get('PageConfigure');
+
+                    return PageConfigure.onStateEnterRedirect(trans.to());
+                },
+                tfMetaTags: {
                     title: 'Configuration'
                 }
             })
             .state('base.configuration.tabs.basic', {
                 url: '/basic',
                 template: '<page-configure-basic></page-configure-basic>',
-                metaTags: {
+                tfMetaTags: {
                     title: 'Basic Configuration'
                 },
                 resolve: {
@@ -88,13 +94,14 @@ angular.module('ignite-console.states.configuration', ['ui.router'])
             })
             .state('base.configuration.tabs.advanced', {
                 url: '/advanced',
-                template: '<page-configure-advanced></page-configure-advanced>'
+                template: '<page-configure-advanced></page-configure-advanced>',
+                redirectTo: 'base.configuration.tabs.advanced.clusters'
             })
             .state('base.configuration.tabs.advanced.clusters', {
                 url: '/clusters',
                 templateUrl: clustersTpl,
-                onEnter: AclRoute.checkAccess('configuration'),
-                metaTags: {
+                permission: 'configuration',
+                tfMetaTags: {
                     title: 'Configure Clusters'
                 },
                 controller: clustersCtrl,
@@ -103,8 +110,8 @@ angular.module('ignite-console.states.configuration', ['ui.router'])
             .state('base.configuration.tabs.advanced.caches', {
                 url: '/caches',
                 templateUrl: cachesTpl,
-                onEnter: AclRoute.checkAccess('configuration'),
-                metaTags: {
+                permission: 'configuration',
+                tfMetaTags: {
                     title: 'Configure Caches'
                 },
                 controller: cachesCtrl,
@@ -113,8 +120,8 @@ angular.module('ignite-console.states.configuration', ['ui.router'])
             .state('base.configuration.tabs.advanced.domains', {
                 url: '/domains',
                 templateUrl: domainsTpl,
-                onEnter: AclRoute.checkAccess('configuration'),
-                metaTags: {
+                permission: 'configuration',
+                tfMetaTags: {
                     title: 'Configure Domain Model'
                 },
                 controller: domainsCtrl,
@@ -123,8 +130,8 @@ angular.module('ignite-console.states.configuration', ['ui.router'])
             .state('base.configuration.tabs.advanced.igfs', {
                 url: '/igfs',
                 templateUrl: igfsTpl,
-                onEnter: AclRoute.checkAccess('configuration'),
-                metaTags: {
+                permission: 'configuration',
+                tfMetaTags: {
                     title: 'Configure IGFS'
                 },
                 controller: igfsCtrl,
@@ -133,10 +140,10 @@ angular.module('ignite-console.states.configuration', ['ui.router'])
             .state('base.configuration.tabs.advanced.summary', {
                 url: '/summary',
                 templateUrl: summaryTpl,
-                onEnter: AclRoute.checkAccess('configuration'),
+                permission: 'configuration',
                 controller: ConfigurationSummaryCtrl,
                 controllerAs: 'ctrl',
-                metaTags: {
+                tfMetaTags: {
                     title: 'Configurations Summary'
                 }
             });

http://git-wip-us.apache.org/repos/asf/ignite/blob/f277530a/modules/web-console/frontend/app/modules/states/configuration/summary/summary-zipper.service.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/states/configuration/summary/summary-zipper.service.js b/modules/web-console/frontend/app/modules/states/configuration/summary/summary-zipper.service.js
index 0259d39..47ce9ad 100644
--- a/modules/web-console/frontend/app/modules/states/configuration/summary/summary-zipper.service.js
+++ b/modules/web-console/frontend/app/modules/states/configuration/summary/summary-zipper.service.js
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-import Worker from 'worker?inline=true!./summary.worker';
+import Worker from 'worker!./summary.worker';
 
 export default ['$q', function($q) {
     return function(message) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/f277530a/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 e3d4d41..3cc03be 100644
--- a/modules/web-console/frontend/app/modules/states/errors.state.js
+++ b/modules/web-console/frontend/app/modules/states/errors.state.js
@@ -29,7 +29,7 @@ angular
             .state('404', {
                 url: '/404',
                 templateUrl: templateNotFoundPage,
-                metaTags: {
+                tfMetaTags: {
                     title: 'Page not found'
                 },
                 unsaved: true
@@ -37,7 +37,7 @@ angular
             .state('403', {
                 url: '/403',
                 templateUrl: templateNotAuthorizedPage,
-                metaTags: {
+                tfMetaTags: {
                     title: 'Not authorized'
                 },
                 unsaved: true

http://git-wip-us.apache.org/repos/asf/ignite/blob/f277530a/modules/web-console/frontend/app/modules/states/logout.state.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/states/logout.state.js b/modules/web-console/frontend/app/modules/states/logout.state.js
index 42795ea..9f9c7c6 100644
--- a/modules/web-console/frontend/app/modules/states/logout.state.js
+++ b/modules/web-console/frontend/app/modules/states/logout.state.js
@@ -17,18 +17,16 @@
 
 import angular from 'angular';
 
-angular
-.module('ignite-console.states.logout', [
+angular.module('ignite-console.states.logout', [
     'ui.router'
 ])
-.config(['$stateProvider', 'AclRouteProvider', function($stateProvider, AclRoute) {
+.config(['$stateProvider', function($stateProvider) {
     // set up the states
-    $stateProvider
-    .state('logout', {
+    $stateProvider.state('logout', {
         url: '/logout',
-        onEnter: AclRoute.checkAccess('logout'),
+        permission: 'logout',
         controller: ['Auth', (Auth) => Auth.logout()],
-        metaTags: {
+        tfMetaTags: {
             title: 'Logout'
         }
     });

http://git-wip-us.apache.org/repos/asf/ignite/blob/f277530a/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 587f83d..8e326bf 100644
--- a/modules/web-console/frontend/app/modules/states/password.state.js
+++ b/modules/web-console/frontend/app/modules/states/password.state.js
@@ -34,14 +34,14 @@ angular
     .state('password.reset', {
         url: '/reset?{token}',
         templateUrl,
-        metaTags: {
+        tfMetaTags: {
             title: 'Reset password'
         }
     })
     .state('password.send', {
         url: '/send',
         templateUrl,
-        metaTags: {
+        tfMetaTags: {
             title: 'Password Send'
         }
     });

http://git-wip-us.apache.org/repos/asf/ignite/blob/f277530a/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 3298bdc..87d1d02 100644
--- a/modules/web-console/frontend/app/modules/states/profile.state.js
+++ b/modules/web-console/frontend/app/modules/states/profile.state.js
@@ -23,14 +23,13 @@ angular
 .module('ignite-console.states.profile', [
     'ui.router'
 ])
-.config(['$stateProvider', 'AclRouteProvider', function($stateProvider, AclRoute) {
+.config(['$stateProvider', 'AclRouteProvider', function($stateProvider) {
     // set up the states
-    $stateProvider
-    .state('base.settings.profile', {
+    $stateProvider.state('base.settings.profile', {
         url: '/profile',
         templateUrl,
-        onEnter: AclRoute.checkAccess('profile'),
-        metaTags: {
+        permission: 'profile',
+        tfMetaTags: {
             title: 'User profile'
         }
     });

http://git-wip-us.apache.org/repos/asf/ignite/blob/f277530a/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 b7be51d..f5a4964 100644
--- a/modules/web-console/frontend/app/modules/states/signin.state.js
+++ b/modules/web-console/frontend/app/modules/states/signin.state.js
@@ -24,30 +24,26 @@ angular
     // services
     'ignite-console.user'
 ])
-.config(['$stateProvider', 'AclRouteProvider', function($stateProvider) {
+.config(['$stateProvider', function($stateProvider) {
     // set up the states
     $stateProvider
     .state('signin', {
         url: '/',
         templateUrl,
-        resolve: {
-            user: ['$state', 'User', ($state, User) => {
-                return User.read()
-                    .then(() => {
-                        try {
-                            const {name, params} = JSON.parse(localStorage.getItem('lastStateChangeSuccess'));
+        redirectTo: (trans) => {
+            return trans.injector().get('User').read()
+                .then(() => {
+                    try {
+                        const {name, params} = JSON.parse(localStorage.getItem('lastStateChangeSuccess'));
 
-                            $state.go(name, params);
-                        } catch (ignored) {
-                            $state.go('base.configuration.tabs');
-                        }
-                    })
-                    .catch(() => {});
-            }]
-        },
-        controllerAs: '$ctrl',
-        controller() {},
-        metaTags: {
+                        const restored = trans.router.stateService.target(name, params);
+
+                        return restored.valid() ? restored : 'base.configuration.tabs';
+                    } catch (ignored) {
+                        return 'base.configuration.tabs';
+                    }
+                })
+                .catch(() => true);
         }
     });
 }]);

http://git-wip-us.apache.org/repos/asf/ignite/blob/f277530a/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
index 4225bc4..f5556ff 100644
--- a/modules/web-console/frontend/app/modules/user/AclRoute.provider.js
+++ b/modules/web-console/frontend/app/modules/user/AclRoute.provider.js
@@ -17,11 +17,9 @@
 
 export default [() => {
     class AclRoute {
-        static checkAccess(permissions, failState) {
-            failState = failState || '403';
-
+        static checkAccess(permissions, failState = '403') {
             return ['$q', '$state', 'AclService', 'User', 'IgniteActivitiesData', function($q, $state, AclService, User, Activities) {
-                const action = this.name ? $state.href(this.name) : null;
+                const action = '';
 
                 return User.read()
                     .catch(() => {

http://git-wip-us.apache.org/repos/asf/ignite/blob/f277530a/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 b86a62e..721d07f 100644
--- a/modules/web-console/frontend/app/modules/user/user.module.js
+++ b/modules/web-console/frontend/app/modules/user/user.module.js
@@ -50,7 +50,7 @@ angular.module('ignite-console.user', [
 .service(...Auth)
 .service(...User)
 .provider('AclRoute', AclRouteProvider)
-.run(['$rootScope', 'AclService', ($root, AclService) => {
+.run(['$rootScope', '$transitions', 'AclService', 'User', 'IgniteActivitiesData', ($root, $transitions, AclService, User, Activities) => {
     AclService.setAbilities(aclData);
     AclService.attachRole('guest');
 
@@ -70,4 +70,32 @@ angular.module('ignite-console.user', [
 
         AclService.attachRole(role);
     });
+
+    $transitions.onBefore({}, (t) => {
+        const $state = t.router.stateService;
+        const {name, permission} = t.to();
+
+        return User.read()
+            .catch(() => {
+                User.clean();
+
+                if (name !== 'signin')
+                    return $state.target('signin');
+
+                return true;
+            })
+            .then(() => {
+                if (_.isEmpty(permission))
+                    return true;
+
+                if (AclService.can(permission)) {
+                    Activities.post({action: $state.href(name, t.params('to'))});
+
+                    return true;
+                }
+
+                return $state.target(t.to().failState || '403');
+            });
+
+    });
 }]);

http://git-wip-us.apache.org/repos/asf/ignite/blob/f277530a/modules/web-console/frontend/app/services/CopyToClipboard.service.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/services/CopyToClipboard.service.js b/modules/web-console/frontend/app/services/CopyToClipboard.service.js
index 74c4764..df0bb8a 100644
--- a/modules/web-console/frontend/app/services/CopyToClipboard.service.js
+++ b/modules/web-console/frontend/app/services/CopyToClipboard.service.js
@@ -38,10 +38,10 @@ export default ['IgniteCopyToClipboard', ['$window', 'IgniteMessages', ($window,
                 if (document.execCommand('copy'))
                     Messages.showInfo('Value copied to clipboard');
                 else
-                    window.prompt('Copy to clipboard: Ctrl+C, Enter', toCopy);  // eslint-disable-line no-alert
+                    window.prompt('Copy to clipboard: Ctrl+C, Enter', toCopy); // eslint-disable-line no-alert
             }
             catch (err) {
-                window.prompt('Copy to clipboard: Ctrl+C, Enter', toCopy);  // eslint-disable-line no-alert
+                window.prompt('Copy to clipboard: Ctrl+C, Enter', toCopy); // eslint-disable-line no-alert
             }
 
             textArea.remove();

http://git-wip-us.apache.org/repos/asf/ignite/blob/f277530a/modules/web-console/frontend/app/services/LegacyTable.service.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/services/LegacyTable.service.js b/modules/web-console/frontend/app/services/LegacyTable.service.js
index a024a3b..ab95164 100644
--- a/modules/web-console/frontend/app/services/LegacyTable.service.js
+++ b/modules/web-console/frontend/app/services/LegacyTable.service.js
@@ -25,7 +25,7 @@ export default ['IgniteLegacyTable',
                 return item;
 
             path = path.replace(/\[(\w+)\]/g, '.$1'); // convert indexes to properties
-            path = path.replace(/^\./, '');           // strip a leading dot
+            path = path.replace(/^\./, ''); // strip a leading dot
 
             const segs = path.split('.');
             let root = item;

http://git-wip-us.apache.org/repos/asf/ignite/blob/f277530a/modules/web-console/frontend/app/vendor.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/vendor.js b/modules/web-console/frontend/app/vendor.js
index 3bbb322..ea0f63c 100644
--- a/modules/web-console/frontend/app/vendor.js
+++ b/modules/web-console/frontend/app/vendor.js
@@ -24,9 +24,12 @@ import 'angular-strap';
 import 'angular-strap/dist/angular-strap.tpl';
 import 'angular-socket-io';
 import 'angular-retina';
-import 'angular-ui-router';
+
+import '@uirouter/angularjs';
+import '@uirouter/angularjs/lib/legacy/stateEvents';
+
+import 'tf-metatags';
 import 'angular-translate';
-import 'ui-router-metatags/dist/ui-router-metatags';
 import 'angular-smart-table';
 import 'angular-ui-grid/ui-grid';
 import 'angular-drag-and-drop-lists';
@@ -49,6 +52,7 @@ import 'file-saver';
 import 'jszip';
 import 'nvd3';
 import 'lodash';
+
 import 'angular-gridster/dist/angular-gridster.min.css';
 import 'angular-tree-control/css/tree-control-attribute.css';
 import 'angular-tree-control/css/tree-control.css';

http://git-wip-us.apache.org/repos/asf/ignite/blob/f277530a/modules/web-console/frontend/package.json
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/package.json b/modules/web-console/frontend/package.json
index 05c6eec..6b049ff 100644
--- a/modules/web-console/frontend/package.json
+++ b/modules/web-console/frontend/package.json
@@ -8,7 +8,7 @@
     "dev": "npm start",
     "build": "webpack --config ./webpack/webpack.prod.babel.js",
     "test": "karma start ./test/karma.conf.js",
-    "eslint": "eslint --format node_modules/eslint-friendly-formatter gulpfile.babel.js/ app/ controllers/ ignite_modules/ -- --eff-by-issue"
+    "eslint": "eslint --format node_modules/eslint-friendly-formatter app/ controllers/ ignite_modules/ -- --eff-by-issue"
   },
   "author": "",
   "contributors": [
@@ -45,13 +45,13 @@
     "angular-socket-io": "0.7.0",
     "angular-strap": "2.3.12",
     "angular-touch": "1.5.11",
-    "angular-translate": "2.15.1",
+    "angular-translate": "2.15.2",
     "angular-tree-control": "0.2.28",
-    "angular-ui-grid": "4.0.4",
-    "angular-ui-router": "0.4.2",
-    "babel-core": "6.24.1",
+    "angular-ui-grid": "4.0.6",
+    "@uirouter/angularjs": "1.0.5",
+    "babel-core": "6.25.0",
     "babel-eslint": "7.2.3",
-    "babel-loader": "7.0.0",
+    "babel-loader": "7.1.1",
     "babel-plugin-add-module-exports": "0.2.1",
     "babel-plugin-transform-runtime": "6.23.0",
     "babel-polyfill": "6.23.0",
@@ -61,45 +61,46 @@
     "bootstrap-sass": "3.3.7",
     "brace": "0.10.0",
     "copy-webpack-plugin": "4.0.1",
-    "css-loader": "0.28.3",
-    "eslint": "3.19.0",
+    "css-loader": "0.28.4",
+    "eslint": "4.3.0",
     "eslint-friendly-formatter": "3.0.0",
-    "eslint-loader": "1.7.1",
-    "eslint-plugin-babel": "^4.1.1",
+    "eslint-loader": "1.9.0",
+    "eslint-plugin-babel": "4.1.1",
     "expose-loader": "0.7.3",
-    "extract-text-webpack-plugin": "2.1.0",
-    "file-loader": "0.11.1",
+    "extract-text-webpack-plugin": "3.0.0",
+    "file-loader": "0.11.2",
     "file-saver": "1.3.3",
     "font-awesome": "4.7.0",
     "glob": "7.1.2",
     "html-loader": "0.4.5",
-    "html-webpack-plugin": "2.28.0",
+    "html-webpack-plugin": "2.29.0",
     "jquery": "3.2.1",
-    "json-loader": "0.5.4",
+    "json-loader": "0.5.7",
     "jszip": "3.1.3",
     "lodash": "4.17.4",
     "node-sass": "4.5.3",
     "nvd3": "1.8.4",
-    "progress-bar-webpack-plugin": "1.9.3",
+    "progress-bar-webpack-plugin": "1.10.0",
     "pug-html-loader": "1.1.0",
     "pug-loader": "2.3.0",
     "raleway-webfont": "3.0.1",
-    "resolve-url-loader": "2.0.2",
+    "resolve-url-loader": "2.1.0",
     "roboto-font": "0.1.0",
-    "rxjs": "5.4.0",
-    "sass-loader": "6.0.5",
+    "rxjs": "5.4.2",
+    "sass-loader": "6.0.6",
     "socket.io-client": "1.7.3",
-    "style-loader": "0.18.1",
-    "svg-sprite-loader": "^3.0.5",
-    "ui-router-metatags": "1.0.3",
-    "webpack": "2.6.1",
-    "webpack-dev-server": "2.4.5",
+    "style-loader": "0.18.2",
+    "svg-sprite-loader": "3.0.7",
+    "tf-metatags": "2.0.0",
+    "webpack": "3.3.0",
+    "webpack-dev-server": "2.6.1",
     "webpack-merge": "4.1.0",
-    "worker-loader": "0.8.0"
+    "worker-loader": "0.8.1"
   },
   "devDependencies": {
-    "chai": "4.0.2",
-    "jasmine-core": "2.6.2",
+    "chai": "4.1.0",
+    "type-detect": "4.0.3",
+    "jasmine-core": "2.6.4",
     "karma": "1.7.0",
     "karma-babel-preprocessor": "6.0.1",
     "karma-jasmine": "1.1.0",
@@ -107,10 +108,10 @@
     "karma-mocha-reporter": "2.2.3",
     "karma-phantomjs-launcher": "1.0.4",
     "karma-teamcity-reporter": "1.0.0",
-    "karma-webpack": "2.0.3",
+    "karma-webpack": "2.0.4",
     "mocha": "3.4.2",
     "mocha-teamcity-reporter": "1.1.1",
     "phantomjs-prebuilt": "2.1.14",
-    "sinon": "2.3.4"
+    "sinon": "2.3.8"
   }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/f277530a/modules/web-console/frontend/views/index.pug
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/views/index.pug b/modules/web-console/frontend/views/index.pug
index f8f13dd..1881b38 100644
--- a/modules/web-console/frontend/views/index.pug
+++ b/modules/web-console/frontend/views/index.pug
@@ -23,23 +23,13 @@ html(ng-app='ignite-console' id='app' ng-strict-di)
         meta(http-equiv='content-language' content='en')
         meta(http-equiv='X-UA-Compatible' content='IE=Edge')
 
-        title(ng-bind='$meta.title')
+        title(ng-bind='tfMetaTags.title')
+        meta(ng-repeat='(key, value) in tfMetaTags.properties' name='{{::key}}' content='{{::value}}')
 
         meta(name='fragment' content='!')
-        meta(name='description' content='{{$meta.description}}')
-        meta(name='keywords' content='{{$meta.keywords}}')
-        meta(ng-repeat='(key, value) in $meta.properties' name='{{::key}}' content='{{::value}}')
 
     body.theme-line.body-overlap
 
-        .splash.splash-max-foreground(hide-on-state-change)
-            .splash-wrapper
-                .spinner
-                    .bounce1
-                    .bounce2
-                    .bounce3
-
-                .splash-wellcome Loading...
 
         .ribbon-wrapper.right(ng-cloak)
             .ribbon(ng-style='IgniteDemoMode && {"background": "#1b6d88"}')


[02/40] ignite git commit: removed excluding ML sources from assembly file - Fixes #2310.

Posted by ag...@apache.org.
removed excluding ML sources from assembly file - Fixes #2310.

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/219f2894
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/219f2894
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/219f2894

Branch: refs/heads/ignite-5757
Commit: 219f28948d22a36f9292ae34b02e18171486d3cc
Parents: 1a2dde9
Author: oleg-ostanin <oo...@gridgain.com>
Authored: Mon Jul 17 16:29:16 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Mon Jul 17 16:29:16 2017 +0300

----------------------------------------------------------------------
 assembly/release-fabric-base.xml | 1 -
 1 file changed, 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/219f2894/assembly/release-fabric-base.xml
----------------------------------------------------------------------
diff --git a/assembly/release-fabric-base.xml b/assembly/release-fabric-base.xml
index 7484dfa..5007785 100644
--- a/assembly/release-fabric-base.xml
+++ b/assembly/release-fabric-base.xml
@@ -239,7 +239,6 @@
             <excludes>
                 <exclude>**/package.html</exclude>
                 <exclude>src/test/**</exclude>
-                <exclude>src/main/ml/**</exclude>
             </excludes>
         </fileSet>
 


[31/40] 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/ignite-5757
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;
     }


[25/40] 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/ignite-5757
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);


[39/40] 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/ignite-5757
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);
         }


[04/40] ignite git commit: IGNITE-5774 - Added more information about long-running partition release future

Posted by ag...@apache.org.
IGNITE-5774 - Added more information about long-running partition release future


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

Branch: refs/heads/ignite-5757
Commit: a71691ae22e30eea775324363d13e8875be8c4d9
Parents: 0d6b730
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Tue Jul 18 12:37:14 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Tue Jul 18 12:37:14 2017 +0300

----------------------------------------------------------------------
 .../apache/ignite/IgniteSystemProperties.java   |  7 +++
 .../cache/CacheObjectsReleaseFuture.java        | 60 ++++++++++++++++++++
 .../cache/GridCacheExplicitLockSpan.java        | 10 +++-
 .../processors/cache/GridCacheMvccManager.java  | 24 +++++---
 .../cache/GridCacheSharedContext.java           |  4 +-
 .../GridDhtPartitionsExchangeFuture.java        | 30 +++++++---
 .../cache/transactions/IgniteTxAdapter.java     | 44 ++++++++++++--
 .../cache/transactions/IgniteTxManager.java     |  5 +-
 .../util/future/GridCompoundFuture.java         |  6 +-
 9 files changed, 161 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/a71691ae/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 1a2887a..616ac3f 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
@@ -677,6 +677,13 @@ public final class IgniteSystemProperties {
         "IGNITE_CLIENT_CACHE_CHANGE_MESSAGE_TIMEOUT";
 
     /**
+     * If a partition release future completion time during an exchange exceeds this threshold, the contents of
+     * the future will be dumped to the log on exchange. Default is {@code 0} (disabled).
+     */
+    public static final String IGNITE_PARTITION_RELEASE_FUTURE_DUMP_THRESHOLD =
+        "IGNITE_PARTITION_RELEASE_FUTURE_DUMP_THRESHOLD";
+
+    /**
      * Enforces singleton.
      */
     private IgniteSystemProperties() {

http://git-wip-us.apache.org/repos/asf/ignite/blob/a71691ae/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectsReleaseFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectsReleaseFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectsReleaseFuture.java
new file mode 100644
index 0000000..f7af009
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectsReleaseFuture.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.internal.util.future.GridCompoundFuture;
+import org.apache.ignite.lang.IgniteReducer;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ *
+ */
+public class CacheObjectsReleaseFuture<T, R> extends GridCompoundFuture<T, R> {
+    /** */
+    private AffinityTopologyVersion topVer;
+
+    /** */
+    private String type;
+
+    /**
+     * @param type Wait object type.
+     * @param topVer Topology version to wait for.
+     */
+    public CacheObjectsReleaseFuture(String type, AffinityTopologyVersion topVer) {
+        this.type = type;
+        this.topVer = topVer;
+    }
+
+    /**
+     * @param type Wait object type.
+     * @param topVer Topology version to wait for.
+     * @param rdc Reducer object.
+     */
+    public CacheObjectsReleaseFuture(String type, AffinityTopologyVersion topVer, @Nullable IgniteReducer<T, R> rdc) {
+        super(rdc);
+
+        this.topVer = topVer;
+        this.type = type;
+    }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return type + "ReleaseFuture [topVer=" + topVer + ", futures=" + futures() + "]";
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/a71691ae/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheExplicitLockSpan.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheExplicitLockSpan.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheExplicitLockSpan.java
index df32e77..b0cb302 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheExplicitLockSpan.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheExplicitLockSpan.java
@@ -51,15 +51,21 @@ public class GridCacheExplicitLockSpan extends ReentrantLock {
 
     /** Span lock release future. */
     @GridToStringExclude
-    private final GridFutureAdapter<Object> releaseFut = new GridFutureAdapter<>();
+    private final GridFutureAdapter<Object> releaseFut;
 
     /**
      * @param topVer Topology version.
      * @param cand Candidate.
      */
-    public GridCacheExplicitLockSpan(AffinityTopologyVersion topVer, GridCacheMvccCandidate cand) {
+    public GridCacheExplicitLockSpan(final AffinityTopologyVersion topVer, final GridCacheMvccCandidate cand) {
         this.topVer = topVer;
 
+        releaseFut = new GridFutureAdapter<Object>() {
+            @Override public String toString() {
+                return "ExplicitLockSpan [topVer=" + topVer + ", firstCand=" + cand + "]";
+            }
+        };
+
         ensureDeque(cand.key()).addFirst(cand);
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a71691ae/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
index b156708..09bf762 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
@@ -1048,7 +1048,7 @@ public class GridCacheMvccManager extends GridCacheSharedManagerAdapter {
      * @return Explicit locks release future.
      */
     public IgniteInternalFuture<?> finishExplicitLocks(AffinityTopologyVersion topVer) {
-        GridCompoundFuture<Object, Object> res = new GridCompoundFuture<>();
+        GridCompoundFuture<Object, Object> res = new CacheObjectsReleaseFuture<>("ExplicitLock", topVer);
 
         for (GridCacheExplicitLockSpan span : pendingExplicit.values()) {
             AffinityTopologyVersion snapshot = span.topologyVersion();
@@ -1069,7 +1069,7 @@ public class GridCacheMvccManager extends GridCacheSharedManagerAdapter {
      */
     @SuppressWarnings("unchecked")
     public IgniteInternalFuture<?> finishAtomicUpdates(AffinityTopologyVersion topVer) {
-        GridCompoundFuture<Object, Object> res = new FinishAtomicUpdateFuture();
+        GridCompoundFuture<Object, Object> res = new FinishAtomicUpdateFuture("AtomicUpdate", topVer);
 
         for (GridCacheAtomicFuture<?> fut : atomicFuts.values()) {
             IgniteInternalFuture<Void> complete = fut.completeFuture(topVer);
@@ -1088,11 +1088,13 @@ public class GridCacheMvccManager extends GridCacheSharedManagerAdapter {
      * @return Finish update future.
      */
     @SuppressWarnings("unchecked")
-    public IgniteInternalFuture<?> finishDataStreamerUpdates() {
-        GridCompoundFuture<Object, Object> res = new GridCompoundFuture<>();
+    public IgniteInternalFuture<?> finishDataStreamerUpdates(AffinityTopologyVersion topVer) {
+        GridCompoundFuture<Void, Object> res = new CacheObjectsReleaseFuture<>("DataStreamer", topVer);
 
-        for (IgniteInternalFuture fut : dataStreamerFuts)
-            res.add(fut);
+        for (DataStreamerFuture fut : dataStreamerFuts) {
+            if (fut.topVer.compareTo(topVer) < 0)
+                res.add(fut);
+        }
 
         res.markInitialized();
 
@@ -1340,10 +1342,18 @@ public class GridCacheMvccManager extends GridCacheSharedManagerAdapter {
     /**
      * Finish atomic update future.
      */
-    private static class FinishAtomicUpdateFuture extends GridCompoundFuture<Object, Object> {
+    private static class FinishAtomicUpdateFuture extends CacheObjectsReleaseFuture<Object, Object> {
         /** */
         private static final long serialVersionUID = 0L;
 
+        /**
+         * @param type Type.
+         * @param topVer Topology version.
+         */
+        private FinishAtomicUpdateFuture(String type, AffinityTopologyVersion topVer) {
+            super(type, topVer);
+        }
+
         /** {@inheritDoc} */
         @Override protected boolean ignoreFailure(Throwable err) {
             Class cls = err.getClass();

http://git-wip-us.apache.org/repos/asf/ignite/blob/a71691ae/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedContext.java
index efd90a8..5387cc8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedContext.java
@@ -809,12 +809,12 @@ public class GridCacheSharedContext<K, V> {
      */
     @SuppressWarnings({"unchecked"})
     public IgniteInternalFuture<?> partitionReleaseFuture(AffinityTopologyVersion topVer) {
-        GridCompoundFuture f = new GridCompoundFuture();
+        GridCompoundFuture f = new CacheObjectsReleaseFuture("Partition", topVer);
 
         f.add(mvcc().finishExplicitLocks(topVer));
         f.add(tm().finishTxs(topVer));
         f.add(mvcc().finishAtomicUpdates(topVer));
-        f.add(mvcc().finishDataStreamerUpdates());
+        f.add(mvcc().finishDataStreamerUpdates(topVer));
 
         f.markInitialized();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a71691ae/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 ea34f75..c4a4f83 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
@@ -35,6 +35,7 @@ import java.util.concurrent.atomic.AtomicReference;
 import java.util.concurrent.locks.ReadWriteLock;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.IgniteSystemProperties;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.configuration.NearCacheConfiguration;
 import org.apache.ignite.events.CacheEvent;
@@ -92,6 +93,7 @@ import org.jetbrains.annotations.Nullable;
 import org.jsr166.ConcurrentHashMap8;
 
 import static org.apache.ignite.IgniteSystemProperties.IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT_LIMIT;
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_PARTITION_RELEASE_FUTURE_DUMP_THRESHOLD;
 import static org.apache.ignite.IgniteSystemProperties.IGNITE_THREAD_DUMP_ON_EXCHANGE_TIMEOUT;
 import static org.apache.ignite.IgniteSystemProperties.getBoolean;
 import static org.apache.ignite.IgniteSystemProperties.getLong;
@@ -111,6 +113,10 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
     public static final String EXCHANGE_LOG = "org.apache.ignite.internal.exchange.time";
 
     /** */
+    private static final int RELEASE_FUTURE_DUMP_THRESHOLD =
+        IgniteSystemProperties.getInteger(IGNITE_PARTITION_RELEASE_FUTURE_DUMP_THRESHOLD, 0);
+
+    /** */
     @GridToStringExclude
     private volatile DiscoCache discoCache;
 
@@ -623,9 +629,8 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
     /**
      * @param crd Coordinator flag.
      * @return Exchange type.
-     * @throws IgniteCheckedException If failed.
      */
-    private ExchangeType onClusterStateChangeRequest(boolean crd) throws IgniteCheckedException {
+    private ExchangeType onClusterStateChangeRequest(boolean crd) {
         assert exchActions != null && !exchActions.empty() : this;
 
         StateChangeRequest req = exchActions.stateChangeRequest();
@@ -894,14 +899,15 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
             IgniteInternalFuture fut = cctx.snapshot()
                 .tryStartLocalSnapshotOperation(discoEvt);
 
-            if (fut != null)
+            if (fut != null) {
                 fut.get();
 
-            long end = U.currentTimeMillis();
+                long end = U.currentTimeMillis();
 
-            if (log.isInfoEnabled())
-                log.info("Snapshot initialization completed [topVer=" + exchangeId().topologyVersion() +
-                    ", time=" + (end - start) + "ms]");
+                if (log.isInfoEnabled())
+                    log.info("Snapshot initialization completed [topVer=" + exchangeId().topologyVersion() +
+                        ", time=" + (end - start) + "ms]");
+            }
         }
         catch (IgniteCheckedException e) {
             U.error(log, "Error while starting snapshot operation", e);
@@ -955,9 +961,15 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
 
         long waitEnd = U.currentTimeMillis();
 
-        if (log.isInfoEnabled())
+        if (log.isInfoEnabled()) {
+            long waitTime = (waitEnd - waitStart);
+
+            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]");
+                ", waitTime=" + (waitEnd - waitStart) + "ms, futInfo=" + futInfo + "]");
+        }
 
         IgniteInternalFuture<?> locksFut = cctx.mvcc().finishLocks(exchId.topologyVersion());
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a71691ae/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
index 880d9b9..91ce3ce 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
@@ -938,11 +938,7 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter implement
                 fut = finFut;
 
                 if (fut == null) {
-                    fut = new GridFutureAdapter<IgniteInternalTx>() {
-                        @Override public String toString() {
-                            return S.toString(GridFutureAdapter.class, this, "tx", IgniteTxAdapter.this);
-                        }
-                    };
+                    fut = new TxFinishFuture(this);
 
                     finFut = fut;
                 }
@@ -2287,4 +2283,42 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter implement
             return S.toString(TxShadow.class, this);
         }
     }
+
+    /**
+     *
+     */
+    private static class TxFinishFuture extends GridFutureAdapter<IgniteInternalTx> {
+        /** */
+        @GridToStringInclude
+        private IgniteTxAdapter tx;
+
+        /** */
+        private volatile long completionTime;
+
+        /**
+         * @param tx Transaction being awaited.
+         */
+        private TxFinishFuture(IgniteTxAdapter tx) {
+            this.tx = tx;
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean onDone(@Nullable IgniteInternalTx res, @Nullable Throwable err) {
+            completionTime = U.currentTimeMillis();
+
+            return super.onDone(res, err);
+        }
+
+        /** {@inheritDoc} */
+        @Override public String toString() {
+            long ct = completionTime;
+
+            if (ct == 0)
+                ct = U.currentTimeMillis();
+
+            long duration = ct - tx.startTime();
+
+            return S.toString(TxFinishFuture.class, this, "duration", duration);
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/a71691ae/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 3a3b766..26a4a91 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
@@ -42,6 +42,7 @@ import org.apache.ignite.internal.managers.communication.GridIoPolicy;
 import org.apache.ignite.internal.managers.communication.GridMessageListener;
 import org.apache.ignite.internal.managers.eventstorage.GridLocalEventListener;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.internal.processors.cache.CacheObjectsReleaseFuture;
 import org.apache.ignite.internal.processors.cache.GridCacheContext;
 import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
 import org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException;
@@ -535,7 +536,9 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
      */
     public IgniteInternalFuture<Boolean> finishTxs(AffinityTopologyVersion topVer) {
         GridCompoundFuture<IgniteInternalTx, Boolean> res =
-            new GridCompoundFuture<>(
+            new CacheObjectsReleaseFuture<>(
+                "Tx",
+                topVer,
                 new IgniteReducer<IgniteInternalTx, Boolean>() {
                     @Override public boolean collect(IgniteInternalTx e) {
                         return true;

http://git-wip-us.apache.org/repos/asf/ignite/blob/a71691ae/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridCompoundFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridCompoundFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridCompoundFuture.java
index 3e08cd9..74a8f41 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridCompoundFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridCompoundFuture.java
@@ -166,7 +166,7 @@ public class GridCompoundFuture<T, R> extends GridFutureAdapter<R> implements Ig
      * @return Collection of futures.
      */
     @SuppressWarnings("unchecked")
-    public synchronized final Collection<IgniteInternalFuture<T>> futures() {
+    public final synchronized Collection<IgniteInternalFuture<T>> futures() {
         if (futs == null)
             return Collections.emptyList();
 
@@ -249,7 +249,7 @@ public class GridCompoundFuture<T, R> extends GridFutureAdapter<R> implements Ig
     /**
      * Clear futures.
      */
-    protected synchronized final void clear() {
+    protected final synchronized void clear() {
         futs = null;
     }
 
@@ -338,7 +338,7 @@ public class GridCompoundFuture<T, R> extends GridFutureAdapter<R> implements Ig
     /**
      * @return {@code True} if has at least one future.
      */
-    protected synchronized final boolean hasFutures() {
+    protected final synchronized boolean hasFutures() {
         return futs != null;
     }
 


[36/40] 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/ignite-5757
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;


[18/40] ignite git commit: IGNITE-5812 Set width for dropdown as for element.

Posted by ag...@apache.org.
IGNITE-5812 Set width for dropdown as for element.


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

Branch: refs/heads/ignite-5757
Commit: 39fa8fae3ec80fd3a4c07f4610ab46817b75dd23
Parents: 0d2992c
Author: Dmitriy Shabalin <ds...@gridgain.com>
Authored: Tue Jul 25 14:30:47 2017 +0700
Committer: Andrey Novikov <an...@gridgain.com>
Committed: Tue Jul 25 14:30:47 2017 +0700

----------------------------------------------------------------------
 modules/web-console/frontend/app/app.js         |   8 +-
 .../frontend/app/decorator/select.js            |  77 --------------
 .../frontend/app/decorator/tooltip.js           |  73 -------------
 .../services/AngularStrapSelect.decorator.js    |  77 ++++++++++++++
 .../services/AngularStrapTooltip.decorator.js   | 103 +++++++++++++++++++
 .../views/configuration/domains-import.tpl.pug  |   4 +-
 6 files changed, 186 insertions(+), 156 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/39fa8fae/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 dc5c6e9..0667e8f 100644
--- a/modules/web-console/frontend/app/app.js
+++ b/modules/web-console/frontend/app/app.js
@@ -20,9 +20,6 @@ import '../app/primitives';
 
 import './app.config';
 
-import './decorator/select';
-import './decorator/tooltip';
-
 import './modules/form/form.module';
 import './modules/agent/agent.module';
 import './modules/sql/sql.module';
@@ -97,6 +94,9 @@ import UnsavedChangesGuard from './services/UnsavedChangesGuard.service';
 import Clusters from './services/Clusters';
 import Caches from './services/Caches';
 
+import AngularStrapTooltip from './services/AngularStrapTooltip.decorator';
+import AngularStrapSelect from './services/AngularStrapSelect.decorator';
+
 // Filters.
 import byName from './filters/byName.filter';
 import defaultName from './filters/default-name.filter';
@@ -195,6 +195,8 @@ angular
     gridColumnSelector.name,
     bsSelectMenu.name,
     protectFromBsSelectRender.name,
+    AngularStrapTooltip.name,
+    AngularStrapSelect.name,
     // Ignite modules.
     IgniteModules.name
 ])

http://git-wip-us.apache.org/repos/asf/ignite/blob/39fa8fae/modules/web-console/frontend/app/decorator/select.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/decorator/select.js b/modules/web-console/frontend/app/decorator/select.js
deleted file mode 100644
index 2d22707..0000000
--- a/modules/web-console/frontend/app/decorator/select.js
+++ /dev/null
@@ -1,77 +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.
- */
-
-import angular from 'angular';
-
-/**
- * Special decorator that fix problem in AngularStrap selectAll / deselectAll methods.
- * If this problem will be fixed in AngularStrap we can remove this delegate.
- */
-angular.module('mgcrea.ngStrap.select')
-    .decorator('$select', ['$delegate', ($delegate) => {
-        function SelectFactoryDecorated(element, controller, config) {
-            const delegate = $delegate(element, controller, config);
-
-            // Common vars.
-            const options = angular.extend({}, $delegate.defaults, config);
-
-            const scope = delegate.$scope;
-
-            const valueByIndex = (index) => {
-                if (angular.isUndefined(scope.$matches[index]))
-                    return null;
-
-                return scope.$matches[index].value;
-            };
-
-            const selectAll = (active) => {
-                const selected = [];
-
-                scope.$apply(() => {
-                    for (let i = 0; i < scope.$matches.length; i++) {
-                        if (scope.$isActive(i) === active) {
-                            selected[i] = scope.$matches[i].value;
-
-                            delegate.activate(i);
-
-                            controller.$setViewValue(scope.$activeIndex.map(valueByIndex));
-                        }
-                    }
-                });
-
-                // Emit events.
-                for (let i = 0; i < selected.length; i++) {
-                    if (selected[i])
-                        scope.$emit(options.prefixEvent + '.select', selected[i], i, delegate);
-                }
-            };
-
-            scope.$selectAll = () => {
-                scope.$$postDigest(selectAll.bind(this, false));
-            };
-
-            scope.$selectNone = () => {
-                scope.$$postDigest(selectAll.bind(this, true));
-            };
-
-            return delegate;
-        }
-
-        SelectFactoryDecorated.defaults = $delegate.defaults;
-
-        return SelectFactoryDecorated;
-    }]);

http://git-wip-us.apache.org/repos/asf/ignite/blob/39fa8fae/modules/web-console/frontend/app/decorator/tooltip.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/decorator/tooltip.js b/modules/web-console/frontend/app/decorator/tooltip.js
deleted file mode 100644
index 71ea694..0000000
--- a/modules/web-console/frontend/app/decorator/tooltip.js
+++ /dev/null
@@ -1,73 +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.
- */
-
-import angular from 'angular';
-
-/**
- * Special decorator that fix problem in AngularStrap $tooltip in special case.
- * Case: when tooltip is shown on table row remove button and user click this button.
- * If this problem will be fixed in AngularStrap we can remove this delegate.
- */
-angular.module('mgcrea.ngStrap.tooltip')
-    .decorator('$tooltip', ['$delegate', ($delegate) => {
-        function TooltipFactoryDecorated(element, config) {
-            let tipElementEntered = false;
-
-            config.onShow = ($tooltip) => {
-                // Workaround for tooltip detection.
-                if ($tooltip.$element && $tooltip.$options.trigger === 'click hover') {
-                    $tooltip.$element.on('mouseenter', () => tipElementEntered = true);
-                    $tooltip.$element.on('mouseleave', () => {
-                        tipElementEntered = false;
-
-                        $tooltip.leave();
-                    });
-                }
-            };
-
-            const $tooltip = $delegate(element, config);
-
-            const scope = $tooltip.$scope;
-            const options = $tooltip.$options;
-
-            const _hide = $tooltip.hide;
-
-            $tooltip.hide = (blur) => {
-                if (!$tooltip.$isShown || tipElementEntered)
-                    return;
-
-                if ($tooltip.$element) {
-                    $tooltip.$element.off('mouseenter');
-                    $tooltip.$element.off('mouseleave');
-
-                    return _hide(blur);
-                }
-
-                scope.$emit(options.prefixEvent + '.hide.before', $tooltip);
-
-                if (angular.isDefined(options.onBeforeHide) && angular.isFunction(options.onBeforeHide))
-                    options.onBeforeHide($tooltip);
-
-                $tooltip.$isShown = scope.$isShown = false;
-                scope.$$phase || (scope.$root && scope.$root.$$phase) || scope.$digest();
-            };
-
-            return $tooltip;
-        }
-
-        return TooltipFactoryDecorated;
-    }]);

http://git-wip-us.apache.org/repos/asf/ignite/blob/39fa8fae/modules/web-console/frontend/app/services/AngularStrapSelect.decorator.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/services/AngularStrapSelect.decorator.js b/modules/web-console/frontend/app/services/AngularStrapSelect.decorator.js
new file mode 100644
index 0000000..39f7ccd
--- /dev/null
+++ b/modules/web-console/frontend/app/services/AngularStrapSelect.decorator.js
@@ -0,0 +1,77 @@
+/*
+ * 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';
+
+/**
+ * Special decorator that fix problem in AngularStrap selectAll / deselectAll methods.
+ * If this problem will be fixed in AngularStrap we can remove this delegate.
+ */
+export default angular.module('mgcrea.ngStrap.select')
+    .decorator('$select', ['$delegate', ($delegate) => {
+        function SelectFactoryDecorated(element, controller, config) {
+            const delegate = $delegate(element, controller, config);
+
+            // Common vars.
+            const options = angular.extend({}, $delegate.defaults, config);
+
+            const scope = delegate.$scope;
+
+            const valueByIndex = (index) => {
+                if (angular.isUndefined(scope.$matches[index]))
+                    return null;
+
+                return scope.$matches[index].value;
+            };
+
+            const selectAll = (active) => {
+                const selected = [];
+
+                scope.$apply(() => {
+                    for (let i = 0; i < scope.$matches.length; i++) {
+                        if (scope.$isActive(i) === active) {
+                            selected[i] = scope.$matches[i].value;
+
+                            delegate.activate(i);
+
+                            controller.$setViewValue(scope.$activeIndex.map(valueByIndex));
+                        }
+                    }
+                });
+
+                // Emit events.
+                for (let i = 0; i < selected.length; i++) {
+                    if (selected[i])
+                        scope.$emit(options.prefixEvent + '.select', selected[i], i, delegate);
+                }
+            };
+
+            scope.$selectAll = () => {
+                scope.$$postDigest(selectAll.bind(this, false));
+            };
+
+            scope.$selectNone = () => {
+                scope.$$postDigest(selectAll.bind(this, true));
+            };
+
+            return delegate;
+        }
+
+        SelectFactoryDecorated.defaults = $delegate.defaults;
+
+        return SelectFactoryDecorated;
+    }]);

http://git-wip-us.apache.org/repos/asf/ignite/blob/39fa8fae/modules/web-console/frontend/app/services/AngularStrapTooltip.decorator.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/services/AngularStrapTooltip.decorator.js b/modules/web-console/frontend/app/services/AngularStrapTooltip.decorator.js
new file mode 100644
index 0000000..d01a450
--- /dev/null
+++ b/modules/web-console/frontend/app/services/AngularStrapTooltip.decorator.js
@@ -0,0 +1,103 @@
+/*
+ * 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 flow from 'lodash/flow';
+
+/**
+ * Decorator that fix problem in AngularStrap $tooltip.
+ */
+export default angular
+    .module('mgcrea.ngStrap.tooltip')
+    /**
+     * Don't hide tooltip when mouse move from element to tooltip.
+     */
+    .decorator('$tooltip', ['$delegate', ($delegate) => {
+        function TooltipFactoryDecorated(element, config) {
+            let tipElementEntered = false;
+
+            config.onShow = ($tooltip) => {
+                // Workaround for tooltip detection.
+                if ($tooltip.$element && $tooltip.$options.trigger === 'click hover') {
+                    $tooltip.$element.on('mouseenter', () => tipElementEntered = true);
+                    $tooltip.$element.on('mouseleave', () => {
+                        tipElementEntered = false;
+
+                        $tooltip.leave();
+                    });
+                }
+            };
+
+            const $tooltip = $delegate(element, config);
+
+            const scope = $tooltip.$scope;
+            const options = $tooltip.$options;
+
+            const _hide = $tooltip.hide;
+
+            $tooltip.hide = (blur) => {
+                if (!$tooltip.$isShown || tipElementEntered)
+                    return;
+
+                if ($tooltip.$element) {
+                    $tooltip.$element.off('mouseenter');
+                    $tooltip.$element.off('mouseleave');
+
+                    return _hide(blur);
+                }
+
+                scope.$emit(options.prefixEvent + '.hide.before', $tooltip);
+
+                if (angular.isDefined(options.onBeforeHide) && angular.isFunction(options.onBeforeHide))
+                    options.onBeforeHide($tooltip);
+
+                $tooltip.$isShown = scope.$isShown = false;
+                scope.$$phase || (scope.$root && scope.$root.$$phase) || scope.$digest();
+            };
+
+            return $tooltip;
+        }
+
+        return TooltipFactoryDecorated;
+    }])
+    /**
+     * Set width for dropdown as for element.
+     */
+    .decorator('$tooltip', ['$delegate', ($delegate) => {
+        return function(el, config) {
+            const $tooltip = $delegate(el, config);
+
+            $tooltip.$referenceElement = el;
+            $tooltip.destroy = flow($tooltip.destroy, () => $tooltip.$referenceElement = null);
+            $tooltip.$applyPlacement = flow($tooltip.$applyPlacement, () => {
+                if (!$tooltip.$element)
+                    return;
+
+                const refWidth = $tooltip.$referenceElement[0].getBoundingClientRect().width;
+                const elWidth = $tooltip.$element[0].getBoundingClientRect().width;
+
+                if (refWidth > elWidth) {
+                    $tooltip.$element.css({
+                        width: refWidth,
+                        maxWidth: 'initial'
+                    });
+                }
+            });
+
+            return $tooltip;
+        };
+    }]);

http://git-wip-us.apache.org/repos/asf/ignite/blob/39fa8fae/modules/web-console/frontend/views/configuration/domains-import.tpl.pug
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/views/configuration/domains-import.tpl.pug b/modules/web-console/frontend/views/configuration/domains-import.tpl.pug
index 7097197..e9ed6f3 100644
--- a/modules/web-console/frontend/views/configuration/domains-import.tpl.pug
+++ b/modules/web-console/frontend/views/configuration/domains-import.tpl.pug
@@ -65,13 +65,11 @@ mixin td-ellipses-lbl(w, lbl)
                             +ignite-form-field-dropdown('Driver JAR:', 'ui.selectedJdbcDriverJar', '"jdbcDriverJar"', false, true, false,
                                 'Choose JDBC driver', '', 'jdbcDriverJars',
                                 'Select appropriate JAR with JDBC driver<br> To add another driver you need to place it into "/jdbc-drivers" folder of Ignite Web Agent<br> Refer to Ignite Web Agent README.txt for for more information'
-                            )(
-                                data-ignite-form-field-input-autofocus='true'
                             )
                         .settings-row.settings-row_small-label
                             +java-class('JDBC driver:', 'selectedPreset.jdbcDriverClass', '"jdbcDriverClass"', true, true, 'Fully qualified class name of JDBC driver that will be used to connect to database')
                         .settings-row.settings-row_small-label
-                            +text('JDBC URL:', 'selectedPreset.jdbcUrl', '"jdbcUrl"', true, 'JDBC URL', 'JDBC URL for connecting to database<br>Refer to your database documentation for details')
+                            +text-enabled-autofocus('JDBC URL:', 'selectedPreset.jdbcUrl', '"jdbcUrl"', true, true, 'JDBC URL', 'JDBC URL for connecting to database<br>Refer to your database documentation for details')
                         .settings-row.settings-row_small-label
                             +text('User:', 'selectedPreset.user', '"jdbcUser"', false, '', 'User name for connecting to database')
                         .settings-row.settings-row_small-label


[30/40] 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/ignite-5757
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"}},


[28/40] 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/ignite-5757
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();


[12/40] ignite git commit: IGNITE-5786 .NET: Fix cache store session handling for cross-cache transactions

Posted by ag...@apache.org.
IGNITE-5786 .NET: Fix cache store session handling for cross-cache transactions

This closes #2331


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

Branch: refs/heads/ignite-5757
Commit: c1a3b3744f89e27906621e62e9d73281791fcf30
Parents: 6de0571
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Fri Jul 21 17:04:39 2017 +0300
Committer: Pavel Tupitsyn <pt...@apache.org>
Committed: Fri Jul 21 17:04:39 2017 +0300

----------------------------------------------------------------------
 .../dotnet/PlatformDotNetCacheStore.java        | 31 +++++++
 .../Apache.Ignite.Core.Tests.csproj             |  5 ++
 .../Cache/Store/CacheStoreSessionTest.cs        | 90 +++++++++++++-------
 .../Store/CacheStoreSessionTestCodeConfig.cs    | 68 +++++++++++++++
 .../Store/CacheStoreSessionTestSharedFactory.cs | 48 +++++++++++
 .../Cache/Store/CacheStoreTest.cs               | 10 ++-
 .../cache-store-session-shared-factory.xml      | 76 +++++++++++++++++
 .../Config/Cache/Store/cache-store-session.xml  | 20 ++---
 .../Impl/Cache/Store/CacheStoreInternal.cs      | 14 ++-
 9 files changed, 320 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/c1a3b374/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetCacheStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetCacheStore.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetCacheStore.java
index dd61a54..471eb01 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetCacheStore.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetCacheStore.java
@@ -47,6 +47,7 @@ import javax.cache.integration.CacheLoaderException;
 import javax.cache.integration.CacheWriterException;
 import java.util.Collection;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Map;
 
 /**
@@ -90,6 +91,9 @@ public class PlatformDotNetCacheStore<K, V> implements CacheStore<K, V>, Platfor
     /** Key used to distinguish session deployment.  */
     private static final Object KEY_SES = new Object();
 
+    /** Key to designate a set of stores that share current session.  */
+    private static final Object KEY_SES_STORES = new Object();
+
     /** */
     @CacheStoreSessionResource
     private CacheStoreSession ses;
@@ -337,6 +341,23 @@ public class PlatformDotNetCacheStore<K, V> implements CacheStore<K, V>, Platfor
                     writer.writeLong(session());
                     writer.writeString(ses.cacheName());
                     writer.writeBoolean(commit);
+
+                    // When multiple stores (caches) participate in a single transaction,
+                    // they share a single session, but sessionEnd is called on each store.
+                    // Same thing happens on platform side: session is shared; each store must be notified,
+                    // then session should be closed.
+                    Collection<Long> stores = (Collection<Long>) ses.properties().get(KEY_SES_STORES);
+                    assert stores != null;
+
+                    stores.remove(ptr);
+                    boolean last = stores.isEmpty();
+
+                    writer.writeBoolean(last);
+
+                    if (last) {
+                        // Session object has been released on platform side, remove marker.
+                        ses.properties().remove(KEY_SES);
+                    }
                 }
             }, null);
         }
@@ -415,6 +436,16 @@ public class PlatformDotNetCacheStore<K, V> implements CacheStore<K, V>, Platfor
             ses.properties().put(KEY_SES, sesPtr);
         }
 
+        // Keep track of all stores that use current session (cross-cache tx uses single session for all caches).
+        Collection<Long> stores = (Collection<Long>) ses.properties().get(KEY_SES_STORES);
+
+        if (stores == null) {
+            stores = new HashSet<>();
+            ses.properties().put(KEY_SES_STORES, stores);
+        }
+
+        stores.add(ptr);
+
         return sesPtr;
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/c1a3b374/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
index 90b7970..e4f65bc 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
@@ -89,6 +89,8 @@
     <Compile Include="Cache\Query\Linq\CacheLinqTest.Misc.cs" />
     <Compile Include="Cache\Query\Linq\CacheLinqTest.Custom.cs" />
     <Compile Include="Cache\Query\Linq\CacheLinqTest.Contains.cs" />
+    <Compile Include="Cache\Store\CacheStoreSessionTestCodeConfig.cs" />
+    <Compile Include="Cache\Store\CacheStoreSessionTestSharedFactory.cs" />
     <Compile Include="Deployment\CacheGetFunc.cs" />
     <Compile Include="Deployment\GetAddressFunc.cs" />
     <Compile Include="Deployment\PeerAssemblyLoadingAllApisTest.cs" />
@@ -314,6 +316,9 @@
     <Content Include="Config\Cache\Affinity\affinity-function.xml">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </Content>
+    <Content Include="Config\Cache\Store\cache-store-session-shared-factory.xml">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
     <Content Include="Config\Cache\Store\cache-store-session.xml">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </Content>

http://git-wip-us.apache.org/repos/asf/ignite/blob/c1a3b374/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreSessionTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreSessionTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreSessionTest.cs
index 315e285..818948c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreSessionTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreSessionTest.cs
@@ -28,16 +28,13 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
     /// <summary>
     /// Tests for store session.
     /// </summary>
-    public sealed class CacheStoreSessionTest
+    public class CacheStoreSessionTest
     {
-        /** Grid name. */
-        private const string IgniteName = "grid";
-
         /** Cache 1 name. */
-        private const string Cache1 = "cache1";
+        protected const string Cache1 = "cache1";
 
         /** Cache 2 name. */
-        private const string Cache2 = "cache2";
+        protected const string Cache2 = "cache2";
 
         /** Operations. */
         private static ConcurrentBag<ICollection<Operation>> _dumps;
@@ -48,11 +45,26 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
         [TestFixtureSetUp]
         public void BeforeTests()
         {
-            Ignition.Start(new IgniteConfiguration(TestUtils.GetTestConfiguration())
+            Ignition.Start(GetIgniteConfiguration());
+        }
+
+        /// <summary>
+        /// Gets the ignite configuration.
+        /// </summary>
+        protected virtual IgniteConfiguration GetIgniteConfiguration()
+        {
+            return new IgniteConfiguration(TestUtils.GetTestConfiguration())
             {
-                IgniteInstanceName = IgniteName,
                 SpringConfigUrl = @"config\cache\store\cache-store-session.xml"
-            });
+            };
+        }
+
+        /// <summary>
+        /// Gets the store count.
+        /// </summary>
+        protected virtual int StoreCount
+        {
+            get { return 2; }
         }
 
         /// <summary>
@@ -61,21 +73,29 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
         [TestFixtureTearDown]
         public void AfterTests()
         {
-            Ignition.StopAll(true);
+            try
+            {
+                TestUtils.AssertHandleRegistryHasItems(Ignition.GetIgnite(), 2, 1000);
+            }
+            finally 
+            {
+                Ignition.StopAll(true);
+            }
         }
         
         /// <summary>
         /// Test basic session API.
         /// </summary>
         [Test]
+        [Timeout(30000)]
         public void TestSession()
         {
             _dumps = new ConcurrentBag<ICollection<Operation>>();
 
-            var ignite = Ignition.GetIgnite(IgniteName);
+            var ignite = Ignition.GetIgnite();
 
-            var cache1 = Ignition.GetIgnite(IgniteName).GetCache<int, int>(Cache1);
-            var cache2 = Ignition.GetIgnite(IgniteName).GetCache<int, int>(Cache2);
+            var cache1 = ignite.GetCache<int, int>(Cache1);
+            var cache2 = ignite.GetCache<int, int>(Cache2);
 
             // 1. Test rollback.
             using (var tx = ignite.GetTransactions().TxStart())
@@ -86,11 +106,15 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
                 tx.Rollback();
             }
 
-            Assert.AreEqual(1, _dumps.Count);
-            var ops = _dumps.First();
-            Assert.AreEqual(1, ops.Count);
+            // SessionEnd is called once per store instance.
+            Assert.AreEqual(StoreCount, _dumps.Count);
 
-            Assert.AreEqual(1, ops.Count(op => op.Type == OperationType.SesEnd && !op.Commit));
+            foreach (var ops in _dumps)
+            {
+                var op = ops.Single();
+                Assert.AreEqual(OperationType.SesEnd, op.Type);
+                Assert.IsFalse(op.Commit);
+            }
 
             _dumps = new ConcurrentBag<ICollection<Operation>>();
 
@@ -103,13 +127,17 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
                 tx.Commit();
             }
 
-            Assert.AreEqual(1, _dumps.Count);
-            ops = _dumps.First();
-            Assert.AreEqual(3, ops.Count);
+            Assert.AreEqual(StoreCount, _dumps.Count);
 
-            Assert.AreEqual(1, ops.Count(op => op.Type == OperationType.Write && Cache1.Equals(op.CacheName) && 1.Equals(op.Key) && 1.Equals(op.Value)));
-            Assert.AreEqual(1, ops.Count(op => op.Type == OperationType.Write && Cache2.Equals(op.CacheName) && 2.Equals(op.Key) && 2.Equals(op.Value)));
-            Assert.AreEqual(1, ops.Count(op => op.Type == OperationType.SesEnd && op.Commit));
+            foreach (var ops in _dumps)
+            {
+                Assert.AreEqual(2 + StoreCount, ops.Count);
+                Assert.AreEqual(1, ops.Count(op => op.Type == OperationType.Write
+                                                   && Cache1 == op.CacheName && 1 == op.Key && 1 == op.Value));
+                Assert.AreEqual(1, ops.Count(op => op.Type == OperationType.Write
+                                                   && Cache2 == op.CacheName && 2 == op.Key && 2 == op.Value));
+                Assert.AreEqual(StoreCount, ops.Count(op => op.Type == OperationType.SesEnd && op.Commit));
+            }
 
             _dumps = new ConcurrentBag<ICollection<Operation>>();
 
@@ -122,13 +150,17 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
                 tx.Commit();
             }
 
-            Assert.AreEqual(1, _dumps.Count);
-            ops = _dumps.First();
-            Assert.AreEqual(3, ops.Count);
+            Assert.AreEqual(StoreCount, _dumps.Count);
+            foreach (var ops in _dumps)
+            {
+                Assert.AreEqual(2 + StoreCount, ops.Count);
 
-            Assert.AreEqual(1, ops.Count(op => op.Type == OperationType.Delete && Cache1.Equals(op.CacheName) && 1.Equals(op.Key)));
-            Assert.AreEqual(1, ops.Count(op => op.Type == OperationType.Delete && Cache2.Equals(op.CacheName) && 2.Equals(op.Key)));
-            Assert.AreEqual(1, ops.Count(op => op.Type == OperationType.SesEnd && op.Commit));
+                Assert.AreEqual(1, ops.Count(op => op.Type == OperationType.Delete
+                                                   && Cache1 == op.CacheName && 1 == op.Key));
+                Assert.AreEqual(1, ops.Count(op => op.Type == OperationType.Delete
+                                                   && Cache2 == op.CacheName && 2 == op.Key));
+                Assert.AreEqual(StoreCount, ops.Count(op => op.Type == OperationType.SesEnd && op.Commit));
+            }
         }
 
         /// <summary>

http://git-wip-us.apache.org/repos/asf/ignite/blob/c1a3b374/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreSessionTestCodeConfig.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreSessionTestCodeConfig.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreSessionTestCodeConfig.cs
new file mode 100644
index 0000000..0b5f474
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreSessionTestCodeConfig.cs
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Tests.Cache.Store
+{
+    using Apache.Ignite.Core.Cache.Configuration;
+    using Apache.Ignite.Core.Cache.Store;
+    using Apache.Ignite.Core.Common;
+    using NUnit.Framework;
+
+    /// <summary>
+    /// Tests store session with programmatic configuration (uses different store factory on Java side).
+    /// </summary>
+    [TestFixture]
+    public class CacheStoreSessionTestCodeConfig : CacheStoreSessionTest
+    {
+        /** <inheritdoc /> */
+        protected override IgniteConfiguration GetIgniteConfiguration()
+        {
+            return new IgniteConfiguration(TestUtils.GetTestConfiguration())
+            {
+                CacheConfiguration = new[]
+                {
+                    new CacheConfiguration(Cache1)
+                    {
+                        AtomicityMode = CacheAtomicityMode.Transactional,
+                        ReadThrough = true,
+                        WriteThrough = true,
+                        CacheStoreFactory = new StoreFactory()
+                    },
+                    new CacheConfiguration(Cache2)
+                    {
+                        AtomicityMode = CacheAtomicityMode.Transactional,
+                        ReadThrough = true,
+                        WriteThrough = true,
+                        CacheStoreFactory = new StoreFactory()
+                    }
+                }
+            };
+        }
+
+        /// <summary>
+        /// Store factory.
+        /// </summary>
+        private class StoreFactory : IFactory<ICacheStore>
+        {
+            /** <inheritdoc /> */
+            public ICacheStore CreateInstance()
+            {
+                return new Store();
+            }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/c1a3b374/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreSessionTestSharedFactory.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreSessionTestSharedFactory.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreSessionTestSharedFactory.cs
new file mode 100644
index 0000000..2af5915
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreSessionTestSharedFactory.cs
@@ -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.
+ */
+
+namespace Apache.Ignite.Core.Tests.Cache.Store
+{
+    using NUnit.Framework;
+
+    /// <summary>
+    /// Session test with shared PlatformDotNetCacheStoreFactory,
+    /// which causes the same store insance to be used for both caches.
+    /// </summary>
+    [TestFixture]
+    public class CacheStoreSessionTestSharedFactory : CacheStoreSessionTest
+    {
+        /** <inheritdoc /> */
+        protected override IgniteConfiguration GetIgniteConfiguration()
+        {
+            return new IgniteConfiguration(TestUtils.GetTestConfiguration())
+            {
+                SpringConfigUrl = @"config\cache\store\cache-store-session-shared-factory.xml"
+            };
+        }
+
+        /** <inheritdoc /> */
+        protected override int StoreCount
+        {
+            get
+            {
+                // Shared PlatformDotNetCacheStoreFactory results in a single store instance.
+                return 1;
+            }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/c1a3b374/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
index e05f4bd..d3e4ab6 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
@@ -64,7 +64,15 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
         [TestFixtureTearDown]
         public void AfterTests()
         {
-            Ignition.StopAll(true);
+            try
+            {
+                // 3 stores are expected in HandleRegistry.
+                TestUtils.AssertHandleRegistryHasItems(Ignition.GetIgnite(), 3, 1000);
+            }
+            finally
+            {
+                Ignition.StopAll(true);
+            }
         }
 
         /// <summary>

http://git-wip-us.apache.org/repos/asf/ignite/blob/c1a3b374/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Cache/Store/cache-store-session-shared-factory.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Cache/Store/cache-store-session-shared-factory.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Cache/Store/cache-store-session-shared-factory.xml
new file mode 100644
index 0000000..05515c4
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Cache/Store/cache-store-session-shared-factory.xml
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:util="http://www.springframework.org/schema/util"
+       xsi:schemaLocation="
+        http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans.xsd
+        http://www.springframework.org/schema/util
+        http://www.springframework.org/schema/util/spring-util.xsd">
+    <bean id="storeFactory" class="org.apache.ignite.platform.dotnet.PlatformDotNetCacheStoreFactory">
+        <property name="typeName" value="Apache.Ignite.Core.Tests.Cache.Store.CacheStoreSessionTest+Store, Apache.Ignite.Core.Tests"/>
+    </bean>
+  
+    <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+        <property name="localHost" value="127.0.0.1"/>
+        <property name="connectorConfiguration"><null/></property>
+
+        <property name="cacheConfiguration">
+            <list>
+                <bean class="org.apache.ignite.configuration.CacheConfiguration">
+                    <property name="name" value="cache1"/>
+                    <property name="cacheMode" value="LOCAL"/>
+                    <property name="atomicityMode" value="TRANSACTIONAL"/>
+                    <property name="writeThrough" value="true"/>
+                    <property name="readThrough" value="true"/>
+
+                    <property name="cacheStoreFactory" ref="storeFactory" />
+                </bean>
+
+                <bean class="org.apache.ignite.configuration.CacheConfiguration">
+                    <property name="name" value="cache2"/>
+                    <property name="cacheMode" value="LOCAL"/>
+                    <property name="atomicityMode" value="TRANSACTIONAL"/>
+                    <property name="writeThrough" value="true"/>
+                    <property name="readThrough" value="true"/>
+
+                    <property name="cacheStoreFactory" ref="storeFactory" />
+                </bean>
+            </list>
+        </property>
+
+        <property name="discoverySpi">
+            <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+                <property name="ipFinder">
+                    <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+                        <property name="addresses">
+                            <list>
+                                <!-- In distributed environment, replace with actual host IP address. -->
+                                <value>127.0.0.1:47500</value>
+                            </list>
+                        </property>
+                    </bean>
+                </property>
+                <property name="socketTimeout" value="300" />
+            </bean>
+        </property>
+    </bean>
+</beans>

http://git-wip-us.apache.org/repos/asf/ignite/blob/c1a3b374/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Cache/Store/cache-store-session.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Cache/Store/cache-store-session.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Cache/Store/cache-store-session.xml
index 3cc9efa..14dc78e 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Cache/Store/cache-store-session.xml
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Cache/Store/cache-store-session.xml
@@ -25,18 +25,10 @@
         http://www.springframework.org/schema/beans/spring-beans.xsd
         http://www.springframework.org/schema/util
         http://www.springframework.org/schema/util/spring-util.xsd">
-    <bean id="storeFactory" class="org.apache.ignite.platform.dotnet.PlatformDotNetCacheStoreFactory">
-        <property name="typeName" value="Apache.Ignite.Core.Tests.Cache.Store.CacheStoreSessionTest+Store, Apache.Ignite.Core.Tests"/>
-    </bean>
-  
     <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
         <property name="localHost" value="127.0.0.1"/>
         <property name="connectorConfiguration"><null/></property>
 
-        <property name="includeEventTypes">
-            <util:constant static-field="org.apache.ignite.events.EventType.EVTS_CACHE"/>
-        </property>
-      
         <property name="cacheConfiguration">
             <list>
                 <bean class="org.apache.ignite.configuration.CacheConfiguration">
@@ -46,7 +38,11 @@
                     <property name="writeThrough" value="true"/>
                     <property name="readThrough" value="true"/>
 
-                    <property name="cacheStoreFactory" ref="storeFactory" />
+                    <property name="cacheStoreFactory">
+                        <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetCacheStoreFactory">
+                            <property name="typeName" value="Apache.Ignite.Core.Tests.Cache.Store.CacheStoreSessionTest+Store, Apache.Ignite.Core.Tests"/>
+                        </bean>
+                    </property>
                 </bean>
 
                 <bean class="org.apache.ignite.configuration.CacheConfiguration">
@@ -56,7 +52,11 @@
                     <property name="writeThrough" value="true"/>
                     <property name="readThrough" value="true"/>
 
-                    <property name="cacheStoreFactory" ref="storeFactory" />
+                    <property name="cacheStoreFactory">
+                        <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetCacheStoreFactory">
+                            <property name="typeName" value="Apache.Ignite.Core.Tests.Cache.Store.CacheStoreSessionTest+Store, Apache.Ignite.Core.Tests"/>
+                        </bean>
+                    </property>
                 </bean>
             </list>
         </property>

http://git-wip-us.apache.org/repos/asf/ignite/blob/c1a3b374/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStoreInternal.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStoreInternal.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStoreInternal.cs
index f147579..df4c1ae 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStoreInternal.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStoreInternal.cs
@@ -111,6 +111,8 @@ namespace Apache.Ignite.Core.Impl.Cache.Store
 
             CacheStoreSession ses = grid.HandleRegistry.Get<CacheStoreSession>(sesId, true);
 
+            // Session cache name may change in cross-cache transaction.
+            // Single session is used for all stores in cross-cache transactions.
             ses.CacheName = rawReader.ReadString();
 
             _sesProxy.SetSession(ses);
@@ -223,11 +225,19 @@ namespace Apache.Ignite.Core.Impl.Cache.Store
                         break;
 
                     case OpSesEnd:
-                        grid.HandleRegistry.Release(sesId);
+                    {
+                        var commit = rawReader.ReadBoolean();
+                        var last = rawReader.ReadBoolean();
 
-                        _store.SessionEnd(rawReader.ReadBoolean());
+                        if (last)
+                        {
+                            grid.HandleRegistry.Release(sesId);
+                        }
+
+                        _store.SessionEnd(commit);
 
                         break;
+                    }
 
                     default:
                         throw new IgniteException("Invalid operation type: " + opType);


[06/40] ignite git commit: Partial fix of IGNITE-5473: Introduce troubleshooting logger

Posted by ag...@apache.org.
Partial fix of IGNITE-5473: Introduce troubleshooting logger


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

Branch: refs/heads/ignite-5757
Commit: cf345b81820fbbcb82e5fcb2283b43ea286a40b4
Parents: e46cf95
Author: Andrey V. Mashenkov <an...@gmail.com>
Authored: Tue Jul 18 15:50:03 2017 +0300
Committer: Andrey V. Mashenkov <an...@gmail.com>
Committed: Tue Jul 18 15:50:03 2017 +0300

----------------------------------------------------------------------
 .../apache/ignite/IgniteSystemProperties.java   |  7 ++
 ...idNearAtomicAbstractSingleUpdateRequest.java |  9 ++-
 ...GridNearAtomicSingleUpdateInvokeRequest.java |  6 ++
 .../atomic/GridNearAtomicUpdateResponse.java    |  2 +-
 .../processors/service/ServiceContextImpl.java  |  2 +
 .../util/tostring/GridToStringBuilder.java      |  2 +-
 .../communication/tcp/TcpCommunicationSpi.java  | 66 ++++++++++--------
 .../ignite/spi/discovery/tcp/ServerImpl.java    | 72 ++++++++++++++------
 .../spi/discovery/tcp/TcpDiscoverySpi.java      | 16 +++--
 9 files changed, 123 insertions(+), 59 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/cf345b81/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 5da7bd6..264fb4b 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
@@ -146,6 +146,13 @@ public final class IgniteSystemProperties {
     public static final String IGNITE_QUIET = "IGNITE_QUIET";
 
     /**
+     * Setting this option to {@code true} will enable troubleshooting logger.
+     * Troubleshooting logger makes logging more verbose without enabling debug mode
+     * to provide more detailed logs without performance penalty.
+     */
+    public static final String IGNITE_TROUBLESHOOTING_LOGGER = "IGNITE_TROUBLESHOOTING_LOGGER";
+
+    /**
      * Setting to {@code true} enables writing sensitive information in {@code toString()} output.
      */
     public static final String IGNITE_TO_STRING_INCLUDE_SENSITIVE = "IGNITE_TO_STRING_INCLUDE_SENSITIVE";

http://git-wip-us.apache.org/repos/asf/ignite/blob/cf345b81/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicAbstractSingleUpdateRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicAbstractSingleUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicAbstractSingleUpdateRequest.java
index 7022561..45ccb0e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicAbstractSingleUpdateRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicAbstractSingleUpdateRequest.java
@@ -21,10 +21,10 @@ import java.io.Externalizable;
 import java.util.UUID;
 import javax.cache.expiry.ExpiryPolicy;
 import org.apache.ignite.cache.CacheWriteSynchronizationMode;
-import org.apache.ignite.internal.GridDirectTransient;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
 import org.apache.ignite.internal.processors.cache.CacheEntryPredicate;
 import org.apache.ignite.internal.processors.cache.GridCacheOperation;
+import org.apache.ignite.internal.util.typedef.internal.S;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
@@ -100,4 +100,11 @@ public abstract class GridNearAtomicAbstractSingleUpdateRequest extends GridNear
     @Nullable @Override public CacheEntryPredicate[] filter() {
         return NO_FILTER;
     }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return S.toString(GridNearAtomicAbstractSingleUpdateRequest.class, this,
+            "nodeId", nodeId, "futId", futId, "topVer", topVer,
+            "parent", super.toString());
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/cf345b81/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java
index b1fb530..865d6f8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java
@@ -34,6 +34,7 @@ import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
 import org.apache.ignite.internal.processors.cache.KeyCacheObject;
 import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
 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.plugin.extensions.communication.MessageCollectionItemType;
 import org.apache.ignite.plugin.extensions.communication.MessageReader;
@@ -282,4 +283,9 @@ public class GridNearAtomicSingleUpdateInvokeRequest extends GridNearAtomicSingl
     @Override public short directType() {
         return 126;
     }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return S.toString(GridNearAtomicSingleUpdateRequest.class, this, super.toString());
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/cf345b81/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java
index 9492164..37fe824 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java
@@ -536,6 +536,6 @@ public class GridNearAtomicUpdateResponse extends GridCacheIdMessage implements
 
     /** {@inheritDoc} */
     @Override public String toString() {
-        return S.toString(GridNearAtomicUpdateResponse.class, this, "parent");
+        return S.toString(GridNearAtomicUpdateResponse.class, this, super.toString());
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/cf345b81/modules/core/src/main/java/org/apache/ignite/internal/processors/service/ServiceContextImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/ServiceContextImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/ServiceContextImpl.java
index 66061d5..490b598 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/ServiceContextImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/ServiceContextImpl.java
@@ -23,6 +23,7 @@ import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.ExecutorService;
 import org.apache.ignite.internal.util.tostring.GridToStringExclude;
+import org.apache.ignite.internal.util.tostring.GridToStringInclude;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.services.Service;
 import org.apache.ignite.services.ServiceContext;
@@ -48,6 +49,7 @@ public class ServiceContextImpl implements ServiceContext {
     private final String cacheName;
 
     /** Affinity key. */
+    @GridToStringInclude
     private final Object affKey;
 
     /** Executor service. */

http://git-wip-us.apache.org/repos/asf/ignite/blob/cf345b81/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringBuilder.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringBuilder.java b/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringBuilder.java
index 0c49b51..8d578ac 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringBuilder.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringBuilder.java
@@ -87,7 +87,7 @@ public class GridToStringBuilder {
     private static final ReadWriteLock rwLock = new ReentrantReadWriteLock();
 
     /** Maximum number of collection (map) entries to print. */
-    public static final int MAX_COL_SIZE = 100;
+    public static final int MAX_COL_SIZE = 200;
 
     /** {@link IgniteSystemProperties#IGNITE_TO_STRING_INCLUDE_SENSITIVE} */
     public static final boolean INCLUDE_SENSITIVE =

http://git-wip-us.apache.org/repos/asf/ignite/blob/cf345b81/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
index af12d3b..35d3032 100755
--- a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
@@ -346,6 +346,10 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter implements Communicati
     private boolean enableForcibleNodeKill = IgniteSystemProperties
         .getBoolean(IgniteSystemProperties.IGNITE_ENABLE_FORCIBLE_NODE_KILL);
 
+    /** */
+    private boolean enableTroubleshootingLog = IgniteSystemProperties
+        .getBoolean(IgniteSystemProperties.IGNITE_TROUBLESHOOTING_LOGGER);
+
     /** Server listener. */
     private final GridNioServerListener<Message> srvLsnr =
         new GridNioServerListenerAdapter<Message>() {
@@ -459,8 +463,8 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter implements Communicati
                 final ClusterNode rmtNode = getSpiContext().node(sndId);
 
                 if (rmtNode == null) {
-                    if (log.isDebugEnabled())
-                        log.debug("Close incoming connection, unknown node: " + sndId);
+                    U.warn(log, "Close incoming connection, unknown node [nodeId=" + sndId +
+                        ", ses=" + ses + ']');
 
                     ses.close();
 
@@ -523,10 +527,10 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter implements Communicati
 
                     if (oldClient != null) {
                         if (oldClient instanceof GridTcpNioCommunicationClient) {
-                            if (log.isDebugEnabled())
-                                log.debug("Received incoming connection when already connected " +
-                                    "to this node, rejecting [locNode=" + locNode.id() +
-                                    ", rmtNode=" + sndId + ']');
+                            if (log.isInfoEnabled())
+                                log.info("Received incoming connection when already connected " +
+                                "to this node, rejecting [locNode=" + locNode.id() +
+                                ", rmtNode=" + sndId + ']');
 
                             ses.send(new RecoveryLastReceivedMessage(ALREADY_CONNECTED));
 
@@ -555,10 +559,10 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter implements Communicati
                             if (oldClient instanceof GridTcpNioCommunicationClient) {
                                 assert oldClient.connectionIndex() == connKey.connectionIndex() : oldClient;
 
-                                if (log.isDebugEnabled())
-                                    log.debug("Received incoming connection when already connected " +
-                                        "to this node, rejecting [locNode=" + locNode.id() +
-                                        ", rmtNode=" + sndId + ']');
+                                if (log.isInfoEnabled())
+                                    log.info("Received incoming connection when already connected " +
+                                    "to this node, rejecting [locNode=" + locNode.id() +
+                                    ", rmtNode=" + sndId + ']');
 
                                 ses.send(new RecoveryLastReceivedMessage(ALREADY_CONNECTED));
 
@@ -578,7 +582,7 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter implements Communicati
 
                         if (log.isDebugEnabled())
                             log.debug("Received incoming connection from remote node " +
-                                "[rmtNode=" + rmtNode.id() + ", reserved=" + reserved +
+                            "[rmtNode=" + rmtNode.id() + ", reserved=" + reserved +
                                 ", recovery=" + recoveryDesc + ']');
 
                         if (reserved) {
@@ -595,11 +599,11 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter implements Communicati
                     }
                     else {
                         if (oldFut instanceof ConnectFuture && locNode.order() < rmtNode.order()) {
-                            if (log.isDebugEnabled()) {
-                                log.debug("Received incoming connection from remote node while " +
-                                    "connecting to this node, rejecting [locNode=" + locNode.id() +
-                                    ", locNodeOrder=" + locNode.order() + ", rmtNode=" + rmtNode.id() +
-                                    ", rmtNodeOrder=" + rmtNode.order() + ']');
+                            if (log.isInfoEnabled()) {
+                                log.info("Received incoming connection from remote node while " +
+                                "connecting to this node, rejecting [locNode=" + locNode.id() +
+                                ", locNodeOrder=" + locNode.order() + ", rmtNode=" + rmtNode.id() +
+                                ", rmtNodeOrder=" + rmtNode.order() + ']');
                             }
 
                             ses.send(new RecoveryLastReceivedMessage(ALREADY_CONNECTED));
@@ -3131,11 +3135,11 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter implements Communicati
                                 ", addr=" + addr + ", err=" + e + ']');
 
                     if (attempt == reconCnt || connTimeout0 > maxConnTimeout) {
-                        if (log.isDebugEnabled())
-                            log.debug("Handshake timedout (will stop attempts to perform the handshake) " +
-                                "[timeout=" + connTimeout0 + ", maxConnTimeout=" + maxConnTimeout +
-                                ", attempt=" + attempt + ", reconCnt=" + reconCnt +
-                                ", err=" + e.getMessage() + ", addr=" + addr + ']');
+                        U.warn(log, "Handshake timedout (will stop attempts to perform the handshake) " +
+                            "[node=" + node.id() + ", timeout=" + connTimeout0 +
+                            ", maxConnTimeout=" + maxConnTimeout +
+                            ", attempt=" + attempt + ", reconCnt=" + reconCnt +
+                            ", err=" + e.getMessage() + ", addr=" + addr + ']');
 
                         if (errs == null)
                             errs = new IgniteCheckedException("Failed to connect to node (is node still alive?). " +
@@ -3172,6 +3176,11 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter implements Communicati
 
                     boolean failureDetThrReached = timeoutHelper.checkFailureTimeoutReached(e);
 
+                    if (enableTroubleshootingLog)
+                        U.error(log, "Failed to establish connection to a remote node [node=" + node +
+                            ", addr=" + addr + ", connectAttempts=" + connectAttempts +
+                            ", failureDetThrReached=" + failureDetThrReached + ']', e);
+
                     if (failureDetThrReached)
                         LT.warn(log, "Connect timed out (consider increasing 'failureDetectionTimeout' " +
                             "configuration property) [addr=" + addr + ", failureDetectionTimeout=" +
@@ -3216,15 +3225,14 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter implements Communicati
                     "operating system firewall is disabled on local and remote hosts) " +
                     "[addrs=" + addrs + ']');
 
-            if (enableForcibleNodeKill) {
-                if (getSpiContext().node(node.id()) != null && (CU.clientNode(node) || !CU.clientNode(getLocalNode())) &&
-                    X.hasCause(errs, ConnectException.class, HandshakeException.class,
-                        SocketTimeoutException.class, HandshakeTimeoutException.class,
-                        IgniteSpiOperationTimeoutException.class)) {
+            if (enableForcibleNodeKill) {if (getSpiContext().node(node.id()) != null && (CU.clientNode(node) || !CU.clientNode(getLocalNode())) &&
+                X.hasCause(errs, ConnectException.class,HandshakeException.class, SocketTimeoutException.class, HandshakeTimeoutException.class,
+                    IgniteSpiOperationTimeoutException.class)) {String msg = "TcpCommunicationSpi failed to establish connection to node, node will be dropped from " +
+                        "cluster [" + "rmtNode=" + node + ']';
 
-                    U.error(log, "TcpCommunicationSpi failed to establish connection to node, node will be dropped from " +
-                        "cluster [" +
-                        "rmtNode=" + node + "]", errs);
+                if(enableTroubleshootingLog)U.error(log, msg, errs);
+                    else
+                    U.warn(log, msg);
 
                     getSpiContext().failNode(node.id(), "TcpCommunicationSpi failed to establish connection to node [" +
                         "rmtNode=" + node +

http://git-wip-us.apache.org/repos/asf/ignite/blob/cf345b81/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 d75aae9..d621fb3 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
@@ -521,9 +521,6 @@ class ServerImpl extends TcpDiscoveryImpl {
     @Override public boolean pingNode(UUID nodeId) {
         assert nodeId != null;
 
-        if (log.isDebugEnabled())
-            log.debug("Pinging node: " + nodeId + "]");
-
         if (nodeId == getLocalNodeId())
             return true;
 
@@ -535,8 +532,18 @@ class ServerImpl extends TcpDiscoveryImpl {
         if (!nodeAlive(nodeId))
             return false;
 
+        long start = U.currentTimeMillis();
+
+        if (log.isInfoEnabled())
+            log.info("Pinging node: " + nodeId);
+
         boolean res = pingNode(node);
 
+        long end = System.currentTimeMillis();
+
+        if (log.isInfoEnabled())
+            log.info("Finished node ping [nodeId=" + nodeId + ", res=" + res + ", time=" + (end - start) + "ms]");
+
         if (!res && !node.isClient() && nodeAlive(nodeId)) {
             LT.warn(log, "Failed to ping node (status check will be initiated): " + nodeId);
 
@@ -1698,9 +1705,9 @@ class ServerImpl extends TcpDiscoveryImpl {
 
         assert log.isInfoEnabled();
 
-        synchronized (mux) {
-            StringBuilder b = new StringBuilder(U.nl());
+        StringBuilder b = new StringBuilder(U.nl());
 
+        synchronized (mux) {
             b.append(">>>").append(U.nl());
             b.append(">>>").append("Dumping discovery SPI debug info.").append(U.nl());
             b.append(">>>").append(U.nl());
@@ -1747,9 +1754,9 @@ class ServerImpl extends TcpDiscoveryImpl {
             b.append(U.nl());
 
             b.append("Stats: ").append(spi.stats).append(U.nl());
-
-            U.quietAndInfo(log, b.toString());
         }
+
+        U.quietAndInfo(log, b.toString());
     }
 
     /**
@@ -3137,12 +3144,8 @@ class ServerImpl extends TcpDiscoveryImpl {
 
                             // If node existed on connection initialization we should check
                             // whether it has not gone yet.
-                            if (nextNodeExists)
-                                U.warn(log, "Failed to send message to next node [msg=" + msg + ", next=" + next +
-                                    ", errMsg=" + (err != null ? err.getMessage() : "N/A") + ']');
-                            else if (log.isDebugEnabled())
-                                log.debug("Failed to send message to next node [msg=" + msg + ", next=" + next +
-                                    ", errMsg=" + (err != null ? err.getMessage() : "N/A") + ']');
+                            U.warn(log, "Failed to send message to next node [msg=" + msg + ", next=" + next +
+                                ", errMsg=" + (err != null ? err.getMessage() : "N/A") + ']');
                         }
                     }
 
@@ -3324,6 +3327,8 @@ class ServerImpl extends TcpDiscoveryImpl {
                 if (existingNode != null) {
                     if (!node.socketAddresses().equals(existingNode.socketAddresses())) {
                         if (!pingNode(existingNode)) {
+                            U.warn(log, "Sending node failed message for existing node: " + node);
+
                             addMessage(new TcpDiscoveryNodeFailedMessage(locNodeId,
                                 existingNode.id(), existingNode.internalOrder()));
 
@@ -5373,8 +5378,7 @@ class ServerImpl extends TcpDiscoveryImpl {
 
             if (msgs != null) {
                 for (TcpDiscoveryNodeFailedMessage msg : msgs) {
-                    if (log.isDebugEnabled())
-                        log.debug("Add node failed message for node from failed nodes list: " + msg);
+                    U.warn(log, "Added node failed message for node from failed nodes list: " + msg);
 
                     addMessage(msg);
                 }
@@ -5593,8 +5597,9 @@ class ServerImpl extends TcpDiscoveryImpl {
 
                     long tstamp = U.currentTimeMillis();
 
-                    if (log.isDebugEnabled())
-                        log.debug("Accepted incoming connection from addr: " + sock.getInetAddress());
+                    if (log.isInfoEnabled())
+                        log.info("TCP discovery accepted incoming connection " +
+                            "[rmtAddr=" + sock.getInetAddress() + ", rmtPort=" + sock.getPort() + ']');
 
                     SocketReader reader = new SocketReader(sock);
 
@@ -5602,6 +5607,10 @@ class ServerImpl extends TcpDiscoveryImpl {
                         readers.add(reader);
                     }
 
+                    if (log.isInfoEnabled())
+                        log.info("TCP discovery spawning a new thread for connection " +
+                            "[rmtAddr=" + sock.getInetAddress() + ", rmtPort=" + sock.getPort() + ']');
+
                     reader.start();
 
                     spi.stats.onServerSocketInitialized(U.currentTimeMillis() - tstamp);
@@ -5664,6 +5673,12 @@ class ServerImpl extends TcpDiscoveryImpl {
 
             ClientMessageWorker clientMsgWrk = null;
 
+            SocketAddress rmtAddr = sock.getRemoteSocketAddress();
+
+            if (log.isInfoEnabled())
+                log.info("Started serving remote node connection [rmtAddr=" + rmtAddr +
+                    ", rmtPort=" + sock.getPort() + ']');
+
             boolean srvSock;
 
             try {
@@ -5696,11 +5711,11 @@ class ServerImpl extends TcpDiscoveryImpl {
                         else {
                             if (log.isDebugEnabled())
                                 log.debug("Failed to read magic header (too few bytes received) " +
-                                    "[rmtAddr=" + sock.getRemoteSocketAddress() +
+                                    "[rmtAddr=" + rmtAddr +
                                     ", locAddr=" + sock.getLocalSocketAddress() + ']');
 
                             LT.warn(log, "Failed to read magic header (too few bytes received) [rmtAddr=" +
-                                sock.getRemoteSocketAddress() + ", locAddr=" + sock.getLocalSocketAddress() + ']');
+                                rmtAddr + ", locAddr=" + sock.getLocalSocketAddress() + ']');
 
                             return;
                         }
@@ -5712,7 +5727,7 @@ class ServerImpl extends TcpDiscoveryImpl {
                                 "this Ignite port?" +
                                 (!spi.isSslEnabled() ? " missed SSL configuration?" : "" ) +
                                 ") " +
-                                "[rmtAddr=" + sock.getRemoteSocketAddress() +
+                                "[rmtAddr=" + rmtAddr +
                                 ", locAddr=" + sock.getLocalSocketAddress() + ']');
 
                         LT.warn(log, "Unknown connection detected (is some other software connecting to " +
@@ -5733,6 +5748,11 @@ class ServerImpl extends TcpDiscoveryImpl {
                         if (!spi.isNodeStopping0()) {
                             TcpDiscoveryPingRequest req = (TcpDiscoveryPingRequest)msg;
 
+                            if (log.isInfoEnabled())
+                                log.info("Received ping request from the remote node " +
+                                    "[rmtNodeId=" + msg.creatorNodeId() +
+                                    ", rmtAddr=" + rmtAddr + ", rmtPort=" + sock.getPort() + "]");
+
                             TcpDiscoveryPingResponse res = new TcpDiscoveryPingResponse(locNodeId);
 
                             IgniteSpiOperationTimeoutHelper timeoutHelper =
@@ -5746,6 +5766,12 @@ class ServerImpl extends TcpDiscoveryImpl {
                             }
 
                             spi.writeToSocket(sock, res, timeoutHelper.nextTimeoutChunk(spi.getSocketTimeout()));
+
+                            sock.shutdownOutput();
+
+                            if (log.isInfoEnabled())
+                                log.info("Finished writing ping response " + "[rmtNodeId=" + msg.creatorNodeId() +
+                                    ", rmtAddr=" + rmtAddr + ", rmtPort=" + sock.getPort() + "]");
                         }
                         else if (log.isDebugEnabled())
                             log.debug("Ignore ping request, node is stopping.");
@@ -5872,7 +5898,7 @@ class ServerImpl extends TcpDiscoveryImpl {
                     else if (e.hasCause(ClassNotFoundException.class))
                         LT.warn(log, "Failed to read message due to ClassNotFoundException " +
                             "(make sure same versions of all classes are available on all nodes) " +
-                            "[rmtAddr=" + sock.getRemoteSocketAddress() +
+                            "[rmtAddr=" + rmtAddr +
                             ", err=" + X.cause(e, ClassNotFoundException.class).getMessage() + ']');
 
                         // Always report marshalling problems.
@@ -6162,6 +6188,10 @@ class ServerImpl extends TcpDiscoveryImpl {
                 }
 
                 U.closeQuiet(sock);
+
+                if (log.isInfoEnabled())
+                    log.info("Finished serving remote node connection [rmtAddr=" + rmtAddr +
+                        ", rmtPort=" + sock.getPort());
             }
         }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/cf345b81/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
index 371f308..c988d7e 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
@@ -1585,7 +1585,8 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements DiscoverySpi {
         catch (IOException | IgniteCheckedException e) {
             if (X.hasCause(e, SocketTimeoutException.class))
                 LT.warn(log, "Timed out waiting for message to be read (most probably, the reason is " +
-                    "in long GC pauses on remote node) [curTimeout=" + timeout + ']');
+                    "long GC pauses on remote node) [curTimeout=" + timeout +
+                    ", rmtAddr=" + sock.getRemoteSocketAddress() + ", rmtPort=" + sock.getPort() + ']');
 
             throw e;
         }
@@ -1626,8 +1627,9 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements DiscoverySpi {
         catch (SocketTimeoutException e) {
             LT.warn(log, "Timed out waiting for message delivery receipt (most probably, the reason is " +
                 "in long GC pauses on remote node; consider tuning GC and increasing 'ackTimeout' " +
-                "configuration property). Will retry to send message with increased timeout. " +
-                "Current timeout: " + timeout + '.');
+                "configuration property). Will retry to send message with increased timeout " +
+                "[currentTimeout=" + timeout + ", rmtAddr=" + sock.getRemoteSocketAddress() +
+                ", rmtPort=" + sock.getPort() + ']');
 
             stats.onAckTimeout();
 
@@ -2164,9 +2166,11 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements DiscoverySpi {
 
                 LT.warn(log, "Socket write has timed out (consider increasing " +
                     (failureDetectionTimeoutEnabled() ?
-                    "'IgniteConfiguration.failureDetectionTimeout' configuration property) [" +
-                    "failureDetectionTimeout=" + failureDetectionTimeout() + ']' :
-                    "'sockTimeout' configuration property) [sockTimeout=" + sockTimeout + ']'));
+                        "'IgniteConfiguration.failureDetectionTimeout' configuration property) [" +
+                        "failureDetectionTimeout=" + failureDetectionTimeout() :
+                        "'sockTimeout' configuration property) [sockTimeout=" + sockTimeout) +
+                    ", rmtAddr=" + sock.getRemoteSocketAddress() + ", rmtPort=" + sock.getPort() +
+                    ", sockTimeout=" + sockTimeout + ']');
 
                 stats.onSocketTimeout();
             }


[29/40] 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/ignite-5757
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 {


[03/40] ignite git commit: Revert "removed excluding ML sources from assembly file - Fixes #2310."

Posted by ag...@apache.org.
Revert "removed excluding ML sources from assembly file - Fixes #2310."

This reverts commit 219f28948d22a36f9292ae34b02e18171486d3cc.


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

Branch: refs/heads/ignite-5757
Commit: e88fcd8d228e2f15187ff05218f3afb242c65fed
Parents: 219f289
Author: devozerov <vo...@gridgain.com>
Authored: Mon Jul 17 17:13:16 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Mon Jul 17 17:13:16 2017 +0300

----------------------------------------------------------------------
 assembly/release-fabric-base.xml | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/e88fcd8d/assembly/release-fabric-base.xml
----------------------------------------------------------------------
diff --git a/assembly/release-fabric-base.xml b/assembly/release-fabric-base.xml
index 5007785..7484dfa 100644
--- a/assembly/release-fabric-base.xml
+++ b/assembly/release-fabric-base.xml
@@ -239,6 +239,7 @@
             <excludes>
                 <exclude>**/package.html</exclude>
                 <exclude>src/test/**</exclude>
+                <exclude>src/main/ml/**</exclude>
             </excludes>
         </fileSet>
 


[24/40] 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/ignite-5757
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;
     }
 
     /**


[08/40] ignite git commit: IGNITE-4728 Web Console: Saved last succeeded state and redirect to it on reload.

Posted by ag...@apache.org.
IGNITE-4728 Web Console: Saved last succeeded state and redirect to it on reload.


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

Branch: refs/heads/ignite-5757
Commit: 70d0f9918c708cb117e69163cc7b7c119c9a693c
Parents: 23f26af
Author: Dmitriy Shabalin <ds...@gridgain.com>
Authored: Thu Jul 20 15:08:20 2017 +0700
Committer: Andrey Novikov <an...@gridgain.com>
Committed: Thu Jul 20 15:08:20 2017 +0700

----------------------------------------------------------------------
 modules/web-console/frontend/app/app.js               | 14 ++++++++++++++
 .../frontend/app/modules/states/errors.state.js       |  6 ++++--
 .../frontend/app/modules/states/signin.state.js       | 10 +++++++++-
 3 files changed, 27 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/70d0f991/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 c707810..dc5c6e9 100644
--- a/modules/web-console/frontend/app/app.js
+++ b/modules/web-console/frontend/app/app.js
@@ -289,6 +289,20 @@ angular
     $root.$on('$stateChangeStart', () => {
         _.forEach(angular.element('.modal'), (m) => angular.element(m).scope().$hide());
     });
+
+    if (!$root.IgniteDemoMode) {
+        $root.$on('$stateChangeSuccess', (event, {name, unsaved}, params) => {
+            try {
+                if (unsaved)
+                    localStorage.removeItem('lastStateChangeSuccess');
+                else
+                    localStorage.setItem('lastStateChangeSuccess', JSON.stringify({name, params}));
+            }
+            catch (ignored) {
+                // No-op.
+            }
+        });
+    }
 }])
 .run(['$rootScope', '$http', '$state', 'IgniteMessages', 'User', 'IgniteNotebookData',
     ($root, $http, $state, Messages, User, Notebook) => { // eslint-disable-line no-shadow

http://git-wip-us.apache.org/repos/asf/ignite/blob/70d0f991/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 e816ff8..e3d4d41 100644
--- a/modules/web-console/frontend/app/modules/states/errors.state.js
+++ b/modules/web-console/frontend/app/modules/states/errors.state.js
@@ -31,13 +31,15 @@ angular
                 templateUrl: templateNotFoundPage,
                 metaTags: {
                     title: 'Page not found'
-                }
+                },
+                unsaved: true
             })
             .state('403', {
                 url: '/403',
                 templateUrl: templateNotAuthorizedPage,
                 metaTags: {
                     title: 'Not authorized'
-                }
+                },
+                unsaved: true
             });
     }]);

http://git-wip-us.apache.org/repos/asf/ignite/blob/70d0f991/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 5155bde..b7be51d 100644
--- a/modules/web-console/frontend/app/modules/states/signin.state.js
+++ b/modules/web-console/frontend/app/modules/states/signin.state.js
@@ -33,7 +33,15 @@ angular
         resolve: {
             user: ['$state', 'User', ($state, User) => {
                 return User.read()
-                    .then(() => $state.go('base.configuration.tabs'))
+                    .then(() => {
+                        try {
+                            const {name, params} = JSON.parse(localStorage.getItem('lastStateChangeSuccess'));
+
+                            $state.go(name, params);
+                        } catch (ignored) {
+                            $state.go('base.configuration.tabs');
+                        }
+                    })
                     .catch(() => {});
             }]
         },


[10/40] ignite git commit: IGNITE-5752 Fixed updateSequence updating in GridDhtPartitionMap. - Fixes #2297.

Posted by ag...@apache.org.
IGNITE-5752 Fixed updateSequence updating in GridDhtPartitionMap. - Fixes #2297.

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/199b9543
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/199b9543
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/199b9543

Branch: refs/heads/ignite-5757
Commit: 199b954345f179851718acd131188506668cd4f3
Parents: 02a1bdc
Author: Pavel Kovalenko <jo...@gmail.com>
Authored: Fri Jul 21 16:29:15 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Fri Jul 21 16:29:15 2017 +0300

----------------------------------------------------------------------
 .../cache/distributed/dht/preloader/GridDhtPartitionMap.java  | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/199b9543/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionMap.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionMap.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionMap.java
index cfd4400..735ca1e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionMap.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionMap.java
@@ -24,7 +24,6 @@ import java.io.ObjectOutput;
 import java.util.Map;
 import java.util.Set;
 import java.util.UUID;
-
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState;
@@ -202,9 +201,13 @@ public class GridDhtPartitionMap implements Comparable<GridDhtPartitionMap>, Ext
      * @return Old update sequence value.
      */
     public long updateSequence(long updateSeq, AffinityTopologyVersion topVer) {
+        assert topVer.compareTo(top) >= 0 : "Invalid topology version [cur=" + top + ", new=" + topVer + "]";
+
         long old = this.updateSeq;
 
-        assert updateSeq >= old : "Invalid update sequence [cur=" + old + ", new=" + updateSeq + ']';
+        // Overwrite update sequence without checking in case of greater topology version
+        if (topVer.compareTo(top) == 0)
+            assert updateSeq >= old : "Invalid update sequence [cur=" + old + ", new=" + updateSeq + ']';
 
         this.updateSeq = updateSeq;
 


[16/40] ignite git commit: ignite-2.1.3 Merged with ignite-2.1.2.

Posted by ag...@apache.org.
ignite-2.1.3 Merged with ignite-2.1.2.


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

Branch: refs/heads/ignite-5757
Commit: 03f02d30fda66ed12b3bd8b3af0671fa69b2b298
Parents: abc6e46 e88fcd8
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Mon Jul 24 13:49:32 2017 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Mon Jul 24 13:49:32 2017 +0700

----------------------------------------------------------------------
 examples/pom.xml              |  7 +++++++
 modules/geospatial/pom.xml    | 24 ++++++++++++++++++++++++
 modules/hibernate-4.2/pom.xml | 24 ++++++++++++++++++++++++
 modules/hibernate-5.1/pom.xml | 24 ++++++++++++++++++++++++
 modules/schedule/pom.xml      | 24 ++++++++++++++++++++++++
 5 files changed, 103 insertions(+)
----------------------------------------------------------------------



[17/40] ignite git commit: Web Console: Fixed UI for header menu.

Posted by ag...@apache.org.
Web Console: Fixed UI for header menu.


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

Branch: refs/heads/ignite-5757
Commit: 0d2992c502d54f14b71afbc98529770f49f32345
Parents: 03f02d3
Author: Andrey Novikov <an...@gridgain.com>
Authored: Mon Jul 24 14:30:05 2017 +0700
Committer: Andrey Novikov <an...@gridgain.com>
Committed: Mon Jul 24 14:30:05 2017 +0700

----------------------------------------------------------------------
 .../components/web-console-header/style.scss    |  6 +--
 .../states/configuration/clusters/memory.pug    |  8 ++--
 .../frontend/app/primitives/panel/index.scss    |  2 +-
 .../frontend/views/includes/header-left.pug     | 41 ++++++++++----------
 4 files changed, 29 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/0d2992c5/modules/web-console/frontend/app/components/web-console-header/style.scss
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/components/web-console-header/style.scss b/modules/web-console/frontend/app/components/web-console-header/style.scss
index 376edd9..5cc2355 100644
--- a/modules/web-console/frontend/app/components/web-console-header/style.scss
+++ b/modules/web-console/frontend/app/components/web-console-header/style.scss
@@ -18,7 +18,7 @@
 web-console-header {
     @import "./../../../public/stylesheets/variables.scss";
 
-    $nav-item-margin: 42px;
+    $nav-item-margin: 40px;
     $bottom-border-width: 4px;
 
     display: block;
@@ -51,7 +51,7 @@ web-console-header {
         }
 
         &.wch-slot-left {
-            margin-left: 105px;
+            margin-left: 80px;
         }
 
         &.wch-slot-right {
@@ -73,7 +73,7 @@ web-console-header {
     }
 
     .wch-nav-item,
-    a.wch-nav-item {
+    .wch-nav-item > a {
         cursor: pointer;
         white-space: nowrap;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/0d2992c5/modules/web-console/frontend/app/modules/states/configuration/clusters/memory.pug
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/states/configuration/clusters/memory.pug b/modules/web-console/frontend/app/modules/states/configuration/clusters/memory.pug
index 0ba1ab4..a09fedd 100644
--- a/modules/web-console/frontend/app/modules/states/configuration/clusters/memory.pug
+++ b/modules/web-console/frontend/app/modules/states/configuration/clusters/memory.pug
@@ -58,12 +58,12 @@ include /app/helpers/jade/mixins
                             | Memory policies configuration
                         .group-content
                             .details-row
-                                +text('Default region name:', model + '.defaultMemoryPolicyName', '"defaultMemoryPolicyName"',
-                                'false', 'default', 'Name of the memory policy that defines the default memory region')
+                                +text('Default memory policy name:', model + '.defaultMemoryPolicyName', '"defaultMemoryPolicyName"',
+                                'false', 'default', 'Name of a memory policy to be used as default one')
                             .details-row(ng-hide='(' + model + '.defaultMemoryPolicyName || "default") !== "default"')
-                                +number('Default region size:', model + '.defaultMemoryPolicySize', '"defaultMemoryPolicySize"',
+                                +number('Default memory policy size:', model + '.defaultMemoryPolicySize', '"defaultMemoryPolicySize"',
                                 'true', '0.8 * totalMemoryAvailable', '10485760',
-                                'Size of the memory policy that defines the default memory region')
+                                'Specify desired size of default memory policy without having to use more verbose syntax of MemoryPolicyConfiguration elements')
                             .details-row(ng-init='memoryPoliciesTbl={type: "memoryPolicies", model: "memoryPolicies", focusId: "name", ui: "memory-policies-table"}')
                                 +ignite-form-group()
                                     ignite-form-field-label

http://git-wip-us.apache.org/repos/asf/ignite/blob/0d2992c5/modules/web-console/frontend/app/primitives/panel/index.scss
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/primitives/panel/index.scss b/modules/web-console/frontend/app/primitives/panel/index.scss
index 38d18dd..56cecfe 100644
--- a/modules/web-console/frontend/app/primitives/panel/index.scss
+++ b/modules/web-console/frontend/app/primitives/panel/index.scss
@@ -31,7 +31,7 @@
         padding: 22px 20px;
 
         background-color: initial;
-        border-bottom: 1px solid $panel-default-border;
+        border-bottom: 1px solid $ignite-brand-primary;
 
         &:hover {
             text-decoration: none;

http://git-wip-us.apache.org/repos/asf/ignite/blob/0d2992c5/modules/web-console/frontend/views/includes/header-left.pug
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/views/includes/header-left.pug b/modules/web-console/frontend/views/includes/header-left.pug
index e9db53b..6b7fe6a 100644
--- a/modules/web-console/frontend/views/includes/header-left.pug
+++ b/modules/web-console/frontend/views/includes/header-left.pug
@@ -14,15 +14,13 @@
     See the License for the specific language governing permissions and
     limitations under the License.
 
-a.wch-nav-item(
-    ui-sref='base.configuration.tabs'
-    ui-sref-active='active'
-)
-    | Configure
+.wch-nav-item
+    a(ui-sref='base.configuration.tabs' ui-sref-active='active')
+        | Configure
 
 .wch-nav-item(ng-controller='notebookController')
-    div(ng-if='IgniteDemoMode' ui-sref='base.sql.demo' ng-class='{active: $state.includes("base.sql")}')
-        span Queries
+    a(ng-if='IgniteDemoMode' ui-sref='base.sql.demo' ui-sref-active='active')
+        | Queries
 
     div(ng-if='!IgniteDemoMode')
         div(ng-if='!notebooks.length' ng-class='{active: $state.includes("base.sql")}')
@@ -41,16 +39,19 @@ a.wch-nav-item(
             span Queries
                 span.caret
 
-.wch-nav-item(ignite-navbar)
-    div(ng-click='$event.stopPropagation()'
-        ng-class='{active: $state.includes("base.monitoring")}'
-        ng-repeat='item in navbar.items'
-        bs-dropdown='item.children'
-        data-placement='bottom-left'
-        data-trigger='hover focus'
-        data-container='self'
-        aria-haspopup='true'
-        aria-expanded='false'
-    )
-        span {{::item.text}}
-            span.caret
+.wch-content(ignite-navbar)
+    .wch-nav-item(ng-repeat='item in navbar.items')
+        div(ng-if='item.children' ng-click='$event.stopPropagation()'
+                ng-class='{active: $state.includes(item.sref)}'
+                bs-dropdown='item.children'
+                data-placement='bottom-left'
+                data-trigger='hover focus'
+                data-container='self'
+                aria-haspopup='true'
+                aria-expanded='false'
+            )
+                span {{::item.text}}
+                    span.caret
+
+        a(ng-if='!item.children' ui-sref='{{item.sref}}' ui-sref-active='active')
+            | {{::item.text}}
\ No newline at end of file


[14/40] ignite git commit: Fixed checking full map on updates.

Posted by ag...@apache.org.
Fixed checking full map on updates.


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

Branch: refs/heads/ignite-5757
Commit: 95f4abc709bcf2a4534f9631b3ecea8266cfc485
Parents: 6f749bf
Author: Pavel Kovalenko <jo...@gmail.com>
Authored: Fri Jul 21 18:03:07 2017 +0300
Committer: Pavel Kovalenko <jo...@gmail.com>
Committed: Fri Jul 21 18:03:44 2017 +0300

----------------------------------------------------------------------
 .../cache/distributed/dht/GridClientPartitionTopology.java  | 9 +++++++--
 .../cache/distributed/dht/GridDhtPartitionTopologyImpl.java | 9 +++++++--
 2 files changed, 14 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/95f4abc7/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridClientPartitionTopology.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridClientPartitionTopology.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridClientPartitionTopology.java
index f4ed517..6ff572b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridClientPartitionTopology.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridClientPartitionTopology.java
@@ -628,8 +628,13 @@ public class GridClientPartitionTopology implements GridDhtPartitionTopology {
                     }
                 }
 
-                for (GridDhtPartitionMap part : partMap.values())
-                    fullMapUpdated |= !node2part.containsKey(part);
+                // Check that we have new nodes.
+                for (GridDhtPartitionMap part : partMap.values()) {
+                    if (fullMapUpdated)
+                        break;
+
+                    fullMapUpdated = !node2part.containsKey(part.nodeId());
+                }
 
                 // Remove entry if node left.
                 for (Iterator<UUID> it = partMap.keySet().iterator(); it.hasNext(); ) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/95f4abc7/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
index 601da1b..0ca291d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
@@ -1154,8 +1154,13 @@ public class GridDhtPartitionTopologyImpl implements GridDhtPartitionTopology {
                     }
                 }
 
-                for (GridDhtPartitionMap part : partMap.values())
-                    fullMapUpdated |= !node2part.containsKey(part);
+                // Check that we have new nodes.
+                for (GridDhtPartitionMap part : partMap.values()) {
+                    if (fullMapUpdated)
+                        break;
+
+                    fullMapUpdated = !node2part.containsKey(part.nodeId());
+                }
 
                 // Remove entry if node left.
                 for (Iterator<UUID> it = partMap.keySet().iterator(); it.hasNext(); ) {


[23/40] 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/ignite-5757
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();


[37/40] 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/ignite-5757
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());


[05/40] ignite git commit: Forcible node drop makes cluster unstable in some cases. Disable forcible node drop by default.

Posted by ag...@apache.org.
Forcible node drop makes cluster unstable in some cases. Disable forcible node drop by default.


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

Branch: refs/heads/ignite-5757
Commit: e46cf9582bb05c22a45b868c2c78ea7ed4818d62
Parents: a71691a
Author: Andrey V. Mashenkov <an...@gmail.com>
Authored: Tue Jul 18 15:49:00 2017 +0300
Committer: Andrey V. Mashenkov <an...@gmail.com>
Committed: Tue Jul 18 15:49:00 2017 +0300

----------------------------------------------------------------------
 .../apache/ignite/IgniteSystemProperties.java   |  6 ++
 .../service/GridServiceProcessor.java           |  4 +-
 .../spi/IgniteSpiOperationTimeoutHelper.java    |  8 +-
 .../communication/tcp/TcpCommunicationSpi.java  | 81 ++++++++++++++------
 .../IgniteClientReconnectAbstractTest.java      |  5 ++
 ...niteBinaryMetadataUpdateNodeRestartTest.java | 10 +++
 .../IgniteCacheNearRestartRollbackSelfTest.java | 15 ++++
 ...teSynchronizationModesMultithreadedTest.java |  5 ++
 .../org/apache/ignite/spi/GridTcpForwarder.java | 26 +++++++
 .../tcp/TcpCommunicationSpiDropNodesTest.java   | 15 ++++
 .../TcpCommunicationSpiFaultyClientTest.java    | 20 +++--
 11 files changed, 160 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/e46cf958/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 616ac3f..5da7bd6 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
@@ -684,6 +684,12 @@ public final class IgniteSystemProperties {
         "IGNITE_PARTITION_RELEASE_FUTURE_DUMP_THRESHOLD";
 
     /**
+     * If this property is set, a node will forcible fail a remote node when it fails to establish a communication
+     * connection.
+     */
+    public static final String IGNITE_ENABLE_FORCIBLE_NODE_KILL = "IGNITE_ENABLE_FORCIBLE_NODE_KILL";
+
+    /**
      * Enforces singleton.
      */
     private IgniteSystemProperties() {

http://git-wip-us.apache.org/repos/asf/ignite/blob/e46cf958/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
index 23a29f8..db632ec 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
@@ -1528,7 +1528,7 @@ public class GridServiceProcessor extends GridProcessorAdapter implements Ignite
         private volatile AffinityTopologyVersion currTopVer = null;
 
         /** {@inheritDoc} */
-        @Override public void onEvent(DiscoveryEvent evt, final DiscoCache discoCache) {
+        @Override public void onEvent(final DiscoveryEvent evt, final DiscoCache discoCache) {
             GridSpinBusyLock busyLock = GridServiceProcessor.this.busyLock;
 
             if (busyLock == null || !busyLock.enterBusy())
@@ -1589,7 +1589,7 @@ public class GridServiceProcessor extends GridProcessorAdapter implements Ignite
                                             log.info("Service processor detected a topology change during " +
                                                 "assignments calculation (will abort current iteration and " +
                                                 "re-calculate on the newer version): " +
-                                                "[topVer=" + topVer + ", newTopVer=" + currTopVer + ']');
+                                                "[topVer=" + topVer + ", newTopVer=" + currTopVer0 + ']');
 
                                         return;
                                     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/e46cf958/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiOperationTimeoutHelper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiOperationTimeoutHelper.java b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiOperationTimeoutHelper.java
index c685ea9..b2432ce 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiOperationTimeoutHelper.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiOperationTimeoutHelper.java
@@ -98,7 +98,9 @@ public class IgniteSpiOperationTimeoutHelper {
         if (!failureDetectionTimeoutEnabled)
             return false;
 
-        return e instanceof IgniteSpiOperationTimeoutException || e instanceof SocketTimeoutException ||
-            X.hasCause(e, IgniteSpiOperationTimeoutException.class, SocketException.class);
+        if (X.hasCause(e, IgniteSpiOperationTimeoutException.class, SocketTimeoutException.class, SocketException.class))
+            return true;
+
+        return (timeout - (U.currentTimeMillis() - lastOperStartTs) <= 0);
     }
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/e46cf958/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
index 5aca2f9..af12d3b 100755
--- a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
@@ -23,6 +23,7 @@ import java.io.OutputStream;
 import java.net.ConnectException;
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
+import java.net.SocketException;
 import java.net.SocketTimeoutException;
 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
@@ -341,6 +342,10 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter implements Communicati
     /** */
     private ConnectionPolicy connPlc;
 
+    /** */
+    private boolean enableForcibleNodeKill = IgniteSystemProperties
+        .getBoolean(IgniteSystemProperties.IGNITE_ENABLE_FORCIBLE_NODE_KILL);
+
     /** Server listener. */
     private final GridNioServerListener<Message> srvLsnr =
         new GridNioServerListenerAdapter<Message>() {
@@ -2663,8 +2668,13 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter implements Communicati
                                     }
                                 }
                             }
-                            else
+                            else {
                                 U.sleep(200);
+
+                                if (getSpiContext().node(node.id()) == null)
+                                    throw new ClusterTopologyCheckedException("Failed to send message " +
+                                        "(node left topology): " + node);
+                            }
                         }
 
                         fut.onDone(client0);
@@ -3088,6 +3098,7 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter implements Communicati
                     }
 
                     if (failureDetectionTimeoutEnabled() && (e instanceof HandshakeTimeoutException ||
+                        X.hasCause(e, SocketException.class) ||
                         timeoutHelper.checkFailureTimeoutReached(e))) {
 
                         String msg = "Handshake timed out (failure detection timeout is reached) " +
@@ -3179,8 +3190,10 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter implements Communicati
                         "[addr=" + addr + ", err=" + e.getMessage() + ']', e));
 
                     // Reconnect for the second time, if connection is not established.
-                    if (!failureDetThrReached && connectAttempts < 2 &&
-                        (e instanceof ConnectException || X.hasCause(e, ConnectException.class))) {
+                    if (!failureDetThrReached && connectAttempts < 5 &&
+                        (X.hasCause(e, ConnectException.class, HandshakeException.class, SocketTimeoutException.class))) {
+                        U.sleep(200);
+
                         connectAttempts++;
 
                         continue;
@@ -3203,21 +3216,25 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter implements Communicati
                     "operating system firewall is disabled on local and remote hosts) " +
                     "[addrs=" + addrs + ']');
 
-            if (getSpiContext().node(node.id()) != null && (CU.clientNode(node) || !CU.clientNode(getLocalNode())) &&
-                X.hasCause(errs, ConnectException.class, SocketTimeoutException.class, HandshakeTimeoutException.class,
-                    IgniteSpiOperationTimeoutException.class)) {
+            if (enableForcibleNodeKill) {
+                if (getSpiContext().node(node.id()) != null && (CU.clientNode(node) || !CU.clientNode(getLocalNode())) &&
+                    X.hasCause(errs, ConnectException.class, HandshakeException.class,
+                        SocketTimeoutException.class, HandshakeTimeoutException.class,
+                        IgniteSpiOperationTimeoutException.class)) {
 
-                U.error(log, "TcpCommunicationSpi failed to establish connection to node, node will be dropped from " +
-                    "cluster [" +
-                    "rmtNode=" + node + "]", errs);
+                    U.error(log, "TcpCommunicationSpi failed to establish connection to node, node will be dropped from " +
+                        "cluster [" +
+                        "rmtNode=" + node + "]", errs);
 
-                getSpiContext().failNode(node.id(), "TcpCommunicationSpi failed to establish connection to node [" +
-                    "rmtNode=" + node +
-                    ", errs=" + errs +
-                    ", connectErrs=" + Arrays.toString(errs.getSuppressed()) + ']');
+                    getSpiContext().failNode(node.id(), "TcpCommunicationSpi failed to establish connection to node [" +
+                        "rmtNode=" + node +
+                        ", errs=" + errs +
+                        ", connectErrs=" + Arrays.toString(errs.getSuppressed()) + ']');
+                }
             }
 
-            throw errs;
+            if (X.hasCause(errs, ConnectException.class, HandshakeException.class))
+                throw errs;
         }
 
         return client;
@@ -3269,7 +3286,7 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter implements Communicati
                         sslHnd = new BlockingSslHandler(sslMeta.sslEngine(), ch, directBuf, ByteOrder.nativeOrder(), log);
 
                         if (!sslHnd.handshake())
-                            throw new IgniteCheckedException("SSL handshake is not completed.");
+                            throw new HandshakeException("SSL handshake is not completed.");
 
                         ByteBuffer handBuff = sslHnd.applicationBuffer();
 
@@ -3279,7 +3296,7 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter implements Communicati
                             int read = ch.read(buf);
 
                             if (read == -1)
-                                throw new IgniteCheckedException("Failed to read remote node ID (connection closed).");
+                                throw new HandshakeException("Failed to read remote node ID (connection closed).");
 
                             buf.flip();
 
@@ -3295,7 +3312,7 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter implements Communicati
                             int read = ch.read(buf);
 
                             if (read == -1)
-                                throw new IgniteCheckedException("Failed to read remote node ID (connection closed).");
+                                throw new HandshakeException("Failed to read remote node ID (connection closed).");
 
                             i += read;
                         }
@@ -3304,7 +3321,7 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter implements Communicati
                     UUID rmtNodeId0 = U.bytesToUuid(buf.array(), Message.DIRECT_TYPE_SIZE);
 
                     if (!rmtNodeId.equals(rmtNodeId0))
-                        throw new IgniteCheckedException("Remote node ID is not as expected [expected=" + rmtNodeId +
+                        throw new HandshakeException("Remote node ID is not as expected [expected=" + rmtNodeId +
                             ", rcvd=" + rmtNodeId0 + ']');
                     else if (log.isDebugEnabled())
                         log.debug("Received remote node ID: " + rmtNodeId0);
@@ -3391,7 +3408,7 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter implements Communicati
                                 int read = ch.read(buf);
 
                                 if (read == -1)
-                                    throw new IgniteCheckedException("Failed to read remote node recovery handshake " +
+                                    throw new HandshakeException("Failed to read remote node recovery handshake " +
                                         "(connection closed).");
 
                                 buf.flip();
@@ -3429,7 +3446,7 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter implements Communicati
                                 int read = ch.read(buf);
 
                                 if (read == -1)
-                                    throw new IgniteCheckedException("Failed to read remote node recovery handshake " +
+                                    throw new HandshakeException("Failed to read remote node recovery handshake " +
                                         "(connection closed).");
 
                                 i += read;
@@ -3471,8 +3488,9 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter implements Communicati
 
             // Ignoring whatever happened after timeout - reporting only timeout event.
             if (!cancelled)
-                throw new HandshakeTimeoutException("Failed to perform handshake due to timeout (consider increasing " +
-                    "'connectionTimeout' configuration property).");
+                throw new HandshakeTimeoutException(
+                    new IgniteSpiOperationTimeoutException("Failed to perform handshake due to timeout " +
+                        "(consider increasing 'connectionTimeout' configuration property)."));
         }
 
         return rcvCnt;
@@ -3662,18 +3680,31 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter implements Communicati
     }
 
     /** Internal exception class for proper timeout handling. */
-    private static class HandshakeTimeoutException extends IgniteCheckedException {
+    private static class HandshakeException extends IgniteCheckedException {
         /** */
         private static final long serialVersionUID = 0L;
 
         /**
-         * @param msg Message.
+         * @param msg Error message.
          */
-        HandshakeTimeoutException(String msg) {
+        HandshakeException(String msg) {
             super(msg);
         }
     }
 
+    /** Internal exception class for proper timeout handling. */
+    private static class HandshakeTimeoutException extends IgniteCheckedException {
+        /** */
+        private static final long serialVersionUID = 0L;
+
+        /**
+         * @param cause Exception cause
+         */
+        HandshakeTimeoutException(IgniteSpiOperationTimeoutException cause) {
+            super(cause);
+        }
+    }
+
     /**
      * This worker takes responsibility to shut the server down when stopping,
      * No other thread shall stop passed server.

http://git-wip-us.apache.org/repos/asf/ignite/blob/e46cf958/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectAbstractTest.java
index 10fa6ad..fa9cc35 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectAbstractTest.java
@@ -33,6 +33,7 @@ import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteClientDisconnectedException;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.IgniteSystemProperties;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.events.Event;
@@ -152,6 +153,8 @@ public abstract class IgniteClientReconnectAbstractTest extends GridCommonAbstra
     @Override protected void beforeTestsStarted() throws Exception {
         super.beforeTestsStarted();
 
+        System.setProperty(IgniteSystemProperties.IGNITE_ENABLE_FORCIBLE_NODE_KILL, "true");
+
         int srvs = serverCount();
 
         if (srvs > 0)
@@ -172,6 +175,8 @@ public abstract class IgniteClientReconnectAbstractTest extends GridCommonAbstra
     @Override protected void afterTestsStopped() throws Exception {
         super.afterTestsStopped();
 
+        System.clearProperty(IgniteSystemProperties.IGNITE_ENABLE_FORCIBLE_NODE_KILL);
+
         stopAllGrids();
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/e46cf958/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteBinaryMetadataUpdateNodeRestartTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteBinaryMetadataUpdateNodeRestartTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteBinaryMetadataUpdateNodeRestartTest.java
index ee1b48e..420fdd8 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteBinaryMetadataUpdateNodeRestartTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteBinaryMetadataUpdateNodeRestartTest.java
@@ -26,6 +26,7 @@ import javax.cache.processor.MutableEntry;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteSystemProperties;
 import org.apache.ignite.cache.CacheAtomicityMode;
 import org.apache.ignite.cache.CacheEntryProcessor;
 import org.apache.ignite.cluster.ClusterTopologyException;
@@ -89,9 +90,18 @@ public class IgniteBinaryMetadataUpdateNodeRestartTest extends GridCommonAbstrac
     }
 
     /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        super.beforeTestsStarted();
+
+        System.setProperty(IgniteSystemProperties.IGNITE_ENABLE_FORCIBLE_NODE_KILL,"true");
+    }
+
+    /** {@inheritDoc} */
     @Override protected void afterTestsStopped() throws Exception {
         stopAllGrids();
 
+        System.clearProperty(IgniteSystemProperties.IGNITE_ENABLE_FORCIBLE_NODE_KILL);
+
         super.afterTestsStopped();
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/e46cf958/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheNearRestartRollbackSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheNearRestartRollbackSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheNearRestartRollbackSelfTest.java
index 79f15ad..1a9e13a 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheNearRestartRollbackSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheNearRestartRollbackSelfTest.java
@@ -31,6 +31,7 @@ import javax.cache.processor.EntryProcessorException;
 import javax.cache.processor.MutableEntry;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteSystemProperties;
 import org.apache.ignite.cache.CacheAtomicityMode;
 import org.apache.ignite.cache.CacheRebalanceMode;
 import org.apache.ignite.cache.CacheWriteSynchronizationMode;
@@ -92,6 +93,20 @@ public class IgniteCacheNearRestartRollbackSelfTest extends GridCommonAbstractTe
         return cfg;
     }
 
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        super.beforeTestsStarted();
+
+        System.setProperty(IgniteSystemProperties.IGNITE_ENABLE_FORCIBLE_NODE_KILL,"true");
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTestsStopped() throws Exception {
+        super.afterTestsStopped();
+
+        System.clearProperty(IgniteSystemProperties.IGNITE_ENABLE_FORCIBLE_NODE_KILL);
+    }
+
     /**
      * @param igniteInstanceName Ignite instance name.
      * @return Cache configuration.

http://git-wip-us.apache.org/repos/asf/ignite/blob/e46cf958/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxCacheWriteSynchronizationModesMultithreadedTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxCacheWriteSynchronizationModesMultithreadedTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxCacheWriteSynchronizationModesMultithreadedTest.java
index d23e870..8e57387 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxCacheWriteSynchronizationModesMultithreadedTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxCacheWriteSynchronizationModesMultithreadedTest.java
@@ -32,6 +32,7 @@ import javax.cache.integration.CacheWriterException;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteSystemProperties;
 import org.apache.ignite.cache.CacheWriteSynchronizationMode;
 import org.apache.ignite.cache.store.CacheStore;
 import org.apache.ignite.cache.store.CacheStoreAdapter;
@@ -106,6 +107,8 @@ public class IgniteTxCacheWriteSynchronizationModesMultithreadedTest extends Gri
     @Override protected void beforeTestsStarted() throws Exception {
         super.beforeTestsStarted();
 
+        System.setProperty(IgniteSystemProperties.IGNITE_ENABLE_FORCIBLE_NODE_KILL,"true");
+
         startGrids(SRVS);
 
         clientMode = true;
@@ -121,6 +124,8 @@ public class IgniteTxCacheWriteSynchronizationModesMultithreadedTest extends Gri
     @Override protected void afterTestsStopped() throws Exception {
         stopAllGrids();
 
+        System.clearProperty(IgniteSystemProperties.IGNITE_ENABLE_FORCIBLE_NODE_KILL);
+
         super.afterTestsStopped();
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/e46cf958/modules/core/src/test/java/org/apache/ignite/spi/GridTcpForwarder.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/GridTcpForwarder.java b/modules/core/src/test/java/org/apache/ignite/spi/GridTcpForwarder.java
index d08321e..68d97c1 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/GridTcpForwarder.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/GridTcpForwarder.java
@@ -23,6 +23,7 @@ import java.io.OutputStream;
 import java.net.InetAddress;
 import java.net.ServerSocket;
 import java.net.Socket;
+import org.apache.ignite.IgniteException;
 import org.apache.ignite.IgniteLogger;
 import org.apache.ignite.internal.util.typedef.internal.U;
 
@@ -85,6 +86,10 @@ public final class GridTcpForwarder implements AutoCloseable {
                                 outputCon.getInputStream(), inputCon.getOutputStream()
                             );
 
+                            //Force closing sibling if one of thread failed.
+                            forwardThread1.setUncaughtExceptionHandler(new ForwarderExceptionHandler(forwardThread2));
+                            forwardThread2.setUncaughtExceptionHandler(new ForwarderExceptionHandler(forwardThread1));
+
                             forwardThread1.start();
                             forwardThread2.start();
 
@@ -128,6 +133,25 @@ public final class GridTcpForwarder implements AutoCloseable {
     }
 
     /**
+     *
+     */
+    private static class ForwarderExceptionHandler implements Thread.UncaughtExceptionHandler {
+        /** */
+        private Thread siblingThread;
+
+        /** */
+        public ForwarderExceptionHandler(Thread siblingThread) {
+
+            this.siblingThread = siblingThread;
+        }
+
+        /** */
+        @Override public void uncaughtException(Thread t, Throwable e) {
+            siblingThread.interrupt();
+        }
+    }
+
+    /**
      * Thread reads data from input stream and write to output stream.
      */
     private class ForwardThread extends Thread {
@@ -166,6 +190,8 @@ public final class GridTcpForwarder implements AutoCloseable {
             }
             catch (IOException e) {
                 log.error("IOException while forwarding data [threadName=" + getName() + "]", e);
+
+                throw new IgniteException(e);
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/e46cf958/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpiDropNodesTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpiDropNodesTest.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpiDropNodesTest.java
index ddebd40..e215a34 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpiDropNodesTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpiDropNodesTest.java
@@ -25,6 +25,7 @@ import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.CyclicBarrier;
 import java.util.concurrent.TimeUnit;
 import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteSystemProperties;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.events.Event;
@@ -82,6 +83,20 @@ public class TcpCommunicationSpiDropNodesTest extends GridCommonAbstractTest {
     }
 
     /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        super.beforeTestsStarted();
+
+        System.setProperty(IgniteSystemProperties.IGNITE_ENABLE_FORCIBLE_NODE_KILL,"true");
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTestsStopped() throws Exception {
+        super.afterTestsStopped();
+
+        System.clearProperty(IgniteSystemProperties.IGNITE_ENABLE_FORCIBLE_NODE_KILL);
+    }
+
+    /** {@inheritDoc} */
     @Override protected void beforeTest() throws Exception {
         super.beforeTest();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/e46cf958/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpiFaultyClientTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpiFaultyClientTest.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpiFaultyClientTest.java
index b4d6cbc..bead697 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpiFaultyClientTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpiFaultyClientTest.java
@@ -18,18 +18,16 @@
 package org.apache.ignite.spi.communication.tcp;
 
 import java.io.IOException;
-import java.io.OutputStream;
 import java.net.InetAddress;
 import java.net.ServerSocket;
-import java.net.Socket;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
-import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteSystemProperties;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.events.Event;
@@ -44,8 +42,6 @@ import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
 import org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
-import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage;
-import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryNodeFailedMessage;
 import org.apache.ignite.testframework.GridTestUtils;
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 
@@ -95,6 +91,20 @@ public class TcpCommunicationSpiFaultyClientTest extends GridCommonAbstractTest
     }
 
     /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        super.beforeTestsStarted();
+
+        System.setProperty(IgniteSystemProperties.IGNITE_ENABLE_FORCIBLE_NODE_KILL,"true");
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTestsStopped() throws Exception {
+        super.afterTestsStopped();
+
+        System.clearProperty(IgniteSystemProperties.IGNITE_ENABLE_FORCIBLE_NODE_KILL);
+    }
+
+    /** {@inheritDoc} */
     @Override protected void beforeTest() throws Exception {
         super.beforeTest();
 


[35/40] 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/ignite-5757
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;


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

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


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

Branch: refs/heads/ignite-5757
Commit: c6fc03a9124e6096f1c1f262131f68f536eab17a
Parents: 75df329 a07d7b9
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Thu Jul 27 15:33:17 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Thu Jul 27 15:33:17 2017 +0300

----------------------------------------------------------------------
 examples/pom.xml                                |    7 +
 .../JettyRestProcessorAbstractSelfTest.java     |   18 +-
 .../apache/ignite/IgniteSystemProperties.java   |   20 +
 .../org/apache/ignite/cache/CacheManager.java   |    4 +-
 .../discovery/GridDiscoveryManager.java         |   10 +
 .../cache/CacheAffinitySharedManager.java       |   23 +-
 .../cache/CacheObjectsReleaseFuture.java        |   60 +
 .../processors/cache/CacheOperationContext.java |   15 +
 .../processors/cache/ClusterCachesInfo.java     |  135 +-
 .../processors/cache/ExchangeActions.java       |    4 +-
 .../cache/GatewayProtectedCacheProxy.java       | 1754 +++++++++++
 .../processors/cache/GridCacheAdapter.java      |   16 +-
 .../cache/GridCacheExplicitLockSpan.java        |   10 +-
 .../processors/cache/GridCacheMvccManager.java  |   24 +-
 .../processors/cache/GridCacheProcessor.java    |   80 +-
 .../cache/GridCacheSharedContext.java           |    4 +-
 .../processors/cache/IgniteCacheProxy.java      | 2818 +-----------------
 .../processors/cache/IgniteCacheProxyImpl.java  | 1810 +++++++++++
 .../dht/GridClientPartitionTopology.java        |    9 +-
 .../dht/GridDhtPartitionTopologyImpl.java       |    9 +-
 .../dht/GridDhtTransactionalCacheAdapter.java   |    7 +-
 .../distributed/dht/GridDhtTxPrepareFuture.java |   24 +-
 ...idNearAtomicAbstractSingleUpdateRequest.java |    9 +-
 ...GridNearAtomicSingleUpdateInvokeRequest.java |    6 +
 .../atomic/GridNearAtomicUpdateResponse.java    |    2 +-
 .../dht/preloader/GridDhtPartitionMap.java      |    7 +-
 .../GridDhtPartitionsExchangeFuture.java        |   30 +-
 ...arOptimisticSerializableTxPrepareFuture.java |    9 +
 .../near/GridNearOptimisticTxPrepareFuture.java |   15 +
 .../GridNearPessimisticTxPrepareFuture.java     |    9 +-
 .../IgniteCacheDatabaseSharedManager.java       |   22 +-
 .../persistence/freelist/FreeListImpl.java      |    4 +-
 .../wal/FileWriteAheadLogManager.java           |   93 +-
 .../cache/transactions/IgniteTxAdapter.java     |   44 +-
 .../cache/transactions/IgniteTxHandler.java     |   51 +-
 .../cache/transactions/IgniteTxManager.java     |   12 +-
 .../dr/IgniteDrDataStreamerCacheUpdater.java    |    2 +-
 .../platform/cache/PlatformCache.java           |   33 +-
 .../dotnet/PlatformDotNetCacheStore.java        |   31 +
 .../service/GridServiceProcessor.java           |    4 +-
 .../processors/service/ServiceContextImpl.java  |    2 +
 .../ignite/internal/util/IgniteUtils.java       |   65 +
 .../util/future/GridCompoundFuture.java         |    6 +-
 .../util/tostring/GridToStringBuilder.java      |    2 +-
 .../visor/cache/VisorCacheJdbcType.java         |    2 +-
 .../spi/IgniteSpiOperationTimeoutHelper.java    |    8 +-
 .../communication/tcp/TcpCommunicationSpi.java  |  131 +-
 .../ignite/spi/discovery/tcp/ServerImpl.java    |   72 +-
 .../spi/discovery/tcp/TcpDiscoverySpi.java      |   16 +-
 .../store/jdbc/CacheJdbcPojoStoreTest.java      |   55 +-
 .../cache/store/jdbc/model/BinaryTest.java      |  122 +
 .../cache/store/jdbc/model/BinaryTestKey.java   |   87 +
 .../IgniteClientReconnectAbstractTest.java      |    5 +
 .../cache/CacheEntryProcessorCopySelfTest.java  |   11 +-
 .../cache/CacheStopAndDestroySelfTest.java      |    1 +
 .../cache/GridCacheAbstractSelfTest.java        |    1 +
 .../GridCacheOnCopyFlagAbstractSelfTest.java    |    6 +-
 .../cache/GridCachePutAllFailoverSelfTest.java  |   15 +
 ...idCacheValueConsistencyAbstractSelfTest.java |    4 +-
 .../IgniteCacheConfigVariationsFullApiTest.java |    6 +-
 .../IgniteCacheEntryListenerAbstractTest.java   |    1 -
 .../processors/cache/IgniteCacheGroupsTest.java |   67 +-
 .../cache/IgniteCachePutAllRestartTest.java     |   15 +
 .../cache/IgniteCacheStartStopLoadTest.java     |    1 -
 .../CacheGetInsideLockChangingTopologyTest.java |    5 +
 .../GridCacheAbstractNodeRestartSelfTest.java   |   12 +-
 ...niteBinaryMetadataUpdateNodeRestartTest.java |   10 +
 .../distributed/IgniteCacheGetRestartTest.java  |    5 +
 .../IgniteCacheNearRestartRollbackSelfTest.java |   15 +
 ...teSynchronizationModesMultithreadedTest.java |    5 +
 .../IgniteCachePutRetryAbstractSelfTest.java    |    5 +
 .../dht/NotMappedPartitionInTxTest.java         |  264 ++
 .../MemoryPolicyInitializationTest.java         |    3 +-
 .../db/IgnitePdsWholeClusterRestartTest.java    |    2 +
 .../database/SwapPathConstructionSelfTest.java  |  157 +
 .../marshaller/GridMarshallerAbstractTest.java  |   10 +-
 .../org/apache/ignite/spi/GridTcpForwarder.java |   26 +
 .../tcp/TcpCommunicationSpiDropNodesTest.java   |   15 +
 .../TcpCommunicationSpiFaultyClientTest.java    |   20 +-
 .../testframework/junits/GridAbstractTest.java  |    4 +-
 .../junits/common/GridCommonAbstractTest.java   |    6 +-
 .../ignite/testsuites/IgniteBasicTestSuite.java |    3 +
 .../IgniteCacheRestartTestSuite2.java           |    2 +
 .../testsuites/IgniteCacheTestSuite5.java       |    2 +
 .../apache/ignite/stream/flume/IgniteSink.java  |    7 +-
 modules/geospatial/pom.xml                      |   24 +
 modules/hibernate-4.2/pom.xml                   |   24 +
 modules/hibernate-5.1/pom.xml                   |   24 +
 ...eDbSingleNodeWithIndexingWalRestoreTest.java |  197 ++
 .../IgnitePdsWithIndexingTestSuite.java         |    2 +
 .../Apache.Ignite.Core.Tests.csproj             |    5 +
 .../Cache/Store/CacheStoreSessionTest.cs        |   90 +-
 .../Store/CacheStoreSessionTestCodeConfig.cs    |   68 +
 .../Store/CacheStoreSessionTestSharedFactory.cs |   48 +
 .../Cache/Store/CacheStoreTest.cs               |   10 +-
 .../cache-store-session-shared-factory.xml      |   76 +
 .../Config/Cache/Store/cache-store-session.xml  |   20 +-
 .../Impl/Cache/Store/CacheStoreInternal.cs      |   14 +-
 modules/schedule/pom.xml                        |   24 +
 modules/web-console/backend/.eslintrc           |   39 +-
 modules/web-console/backend/app/agentSocket.js  |    4 +-
 .../web-console/backend/app/browsersHandler.js  |    2 +-
 modules/web-console/backend/package.json        |   27 +-
 modules/web-console/frontend/.eslintrc          |   40 +-
 modules/web-console/frontend/app/app.config.js  |    3 +-
 modules/web-console/frontend/app/app.js         |   33 +-
 .../components/activities-user-dialog/index.js  |   28 +-
 .../app/components/bs-select-menu/style.scss    |   16 +
 .../app/components/bs-select-menu/template.pug  |    2 +
 .../page-configure-advanced/controller.js       |    9 +-
 .../components/page-configure-basic/service.js  |    8 +-
 .../app/components/page-configure/controller.js |   12 +-
 .../page-configure/controller.spec.js           |   48 -
 .../page-configure/services/PageConfigure.js    |   18 +-
 .../components/web-console-header/component.js  |   12 +-
 .../app/components/web-console-header/index.js  |    4 +-
 .../components/web-console-header/style.scss    |    6 +-
 .../frontend/app/data/jdbc-types.json           |    6 +-
 .../frontend/app/data/pom-dependencies.json     |    5 +-
 .../frontend/app/decorator/select.js            |   77 -
 .../frontend/app/decorator/tooltip.js           |   73 -
 .../frontend/app/modules/ace.module.js          |    6 +-
 .../app/modules/branding/branding.module.js     |   16 +-
 .../generator/ConfigurationGenerator.js         |    2 +-
 .../configuration/generator/Maven.service.js    |    9 +-
 .../generator/PlatformGenerator.js              |    4 +-
 .../frontend/app/modules/demo/Demo.module.js    |   10 +-
 .../app/modules/dialog/dialog.controller.js     |    4 -
 .../app/modules/form/field/label.directive.js   |    4 +-
 .../app/modules/form/field/tooltip.directive.js |    4 +-
 .../frontend/app/modules/sql/sql.controller.js  |    2 +-
 .../frontend/app/modules/sql/sql.module.js      |   66 +-
 .../frontend/app/modules/states/admin.state.js  |    6 +-
 .../app/modules/states/configuration.state.js   |   35 +-
 .../states/configuration/clusters/memory.pug    |    8 +-
 .../summary/summary-zipper.service.js           |    2 +-
 .../frontend/app/modules/states/errors.state.js |   10 +-
 .../frontend/app/modules/states/logout.state.js |   12 +-
 .../app/modules/states/password.state.js        |    4 +-
 .../app/modules/states/profile.state.js         |    9 +-
 .../frontend/app/modules/states/signin.state.js |   26 +-
 .../app/modules/user/AclRoute.provider.js       |    6 +-
 .../frontend/app/modules/user/user.module.js    |   30 +-
 .../frontend/app/primitives/dropdown/index.scss |   68 -
 .../frontend/app/primitives/modal/index.scss    |    9 +
 .../frontend/app/primitives/panel/index.scss    |    2 +-
 .../services/AngularStrapSelect.decorator.js    |   77 +
 .../services/AngularStrapTooltip.decorator.js   |  103 +
 .../app/services/CopyToClipboard.service.js     |    4 +-
 .../app/services/LegacyTable.service.js         |    2 +-
 modules/web-console/frontend/app/vendor.js      |    8 +-
 modules/web-console/frontend/package.json       |   57 +-
 .../views/configuration/domains-import.tpl.pug  |    4 +-
 .../frontend/views/includes/header-left.pug     |   41 +-
 modules/web-console/frontend/views/index.pug    |   14 +-
 .../frontend/webpack/webpack.common.js          |    4 +-
 .../console/agent/handlers/RestListener.java    |    7 +-
 .../ignite/console/agent/rest/RestExecutor.java |   49 +-
 158 files changed, 6526 insertions(+), 3819 deletions(-)
----------------------------------------------------------------------


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

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

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

http://git-wip-us.apache.org/repos/asf/ignite/blob/c6fc03a9/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
----------------------------------------------------------------------


[15/40] ignite git commit: IGNITE-5754 Web Console agent: Use POST instead of GET for requests.

Posted by ag...@apache.org.
IGNITE-5754 Web Console agent: Use POST instead of GET for requests.


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

Branch: refs/heads/ignite-5757
Commit: abc6e46fb9ec1c5ee228c01943c516ba0f602456
Parents: 95f4abc
Author: Andrey Novikov <an...@gridgain.com>
Authored: Mon Jul 24 10:54:01 2017 +0700
Committer: Andrey Novikov <an...@gridgain.com>
Committed: Mon Jul 24 10:54:01 2017 +0700

----------------------------------------------------------------------
 modules/web-console/backend/app/agentSocket.js  |  4 +-
 .../web-console/backend/app/browsersHandler.js  |  2 +-
 .../console/agent/handlers/RestListener.java    |  7 +--
 .../ignite/console/agent/rest/RestExecutor.java | 49 +++++++-------------
 4 files changed, 22 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/abc6e46f/modules/web-console/backend/app/agentSocket.js
----------------------------------------------------------------------
diff --git a/modules/web-console/backend/app/agentSocket.js b/modules/web-console/backend/app/agentSocket.js
index db1deaa..0853339 100644
--- a/modules/web-console/backend/app/agentSocket.js
+++ b/modules/web-console/backend/app/agentSocket.js
@@ -126,7 +126,7 @@ module.exports.factory = function(_) {
          * Send event to agent.
          *
          * @param {String} event - Event name.
-         * @param {Array.<Object>?} args - Transmitted arguments.
+         * @param {Object?} args - Transmitted arguments.
          * @returns {Promise}
          */
         emitEvent(event, ...args) {
@@ -202,7 +202,7 @@ module.exports.factory = function(_) {
                 params[`p${idx + 1}`] = args[idx];
             });
 
-            return this.emitEvent('node:rest', {uri: 'ignite', demo, params, method: 'GET'})
+            return this.emitEvent('node:rest', {uri: 'ignite', demo, params})
                 .then(this.restResultParse);
         }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/abc6e46f/modules/web-console/backend/app/browsersHandler.js
----------------------------------------------------------------------
diff --git a/modules/web-console/backend/app/browsersHandler.js b/modules/web-console/backend/app/browsersHandler.js
index c4ea532..4fb5088 100644
--- a/modules/web-console/backend/app/browsersHandler.js
+++ b/modules/web-console/backend/app/browsersHandler.js
@@ -179,7 +179,7 @@ module.exports.factory = (_, socketio, configure, errors, mongo) => {
          */
         executeOnNode(agent, demo, params) {
             return agent
-                .then((agentSock) => agentSock.emitEvent('node:rest', {uri: 'ignite', demo, params, method: 'GET'}))
+                .then((agentSock) => agentSock.emitEvent('node:rest', {uri: 'ignite', demo, params}))
                 .then((res) => {
                     if (res.status === 0)
                         return JSON.parse(res.data);

http://git-wip-us.apache.org/repos/asf/ignite/blob/abc6e46f/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/handlers/RestListener.java
----------------------------------------------------------------------
diff --git a/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/handlers/RestListener.java b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/handlers/RestListener.java
index c70514d..8855060 100644
--- a/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/handlers/RestListener.java
+++ b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/handlers/RestListener.java
@@ -61,11 +61,6 @@ public class RestListener extends AbstractListener {
 
         boolean demo = (boolean)args.get("demo");
 
-        if (!args.containsKey("method"))
-            throw new IllegalArgumentException("Missing method in arguments: " + args);
-
-        String mtd = args.get("method").toString();
-
         Map<String, Object> headers = null;
 
         if (args.containsKey("headers"))
@@ -76,6 +71,6 @@ public class RestListener extends AbstractListener {
         if (args.containsKey("body"))
             body = args.get("body").toString();
 
-        return restExecutor.execute(demo, path, params, mtd, headers, body);
+        return restExecutor.execute(demo, path, params, headers, body);
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/abc6e46f/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/rest/RestExecutor.java
----------------------------------------------------------------------
diff --git a/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/rest/RestExecutor.java b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/rest/RestExecutor.java
index 3936374..03eca4e 100644
--- a/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/rest/RestExecutor.java
+++ b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/rest/RestExecutor.java
@@ -90,7 +90,7 @@ public class RestExecutor {
 
     /** */
     private RestResult sendRequest(boolean demo, String path, Map<String, Object> params,
-        String mtd, Map<String, Object> headers, String body) throws IOException {
+        Map<String, Object> headers, String body) throws IOException {
         if (demo && AgentClusterDemo.getDemoUrl() == null) {
             try {
                 AgentClusterDemo.tryStart().await();
@@ -120,36 +120,24 @@ public class RestExecutor {
                     reqBuilder.addHeader(entry.getKey(), entry.getValue().toString());
         }
 
-        if ("GET".equalsIgnoreCase(mtd)) {
+        if (body != null) {
+            MediaType contentType = MediaType.parse("text/plain");
+
+            reqBuilder.post(RequestBody.create(contentType, body));
+        }
+        else {
+            FormBody.Builder formBody = new FormBody.Builder();
+
             if (params != null) {
                 for (Map.Entry<String, Object> entry : params.entrySet()) {
                     if (entry.getValue() != null)
-                        urlBuilder.addQueryParameter(entry.getKey(), entry.getValue().toString());
+                        formBody.add(entry.getKey(), entry.getValue().toString());
                 }
             }
-        }
-        else if ("POST".equalsIgnoreCase(mtd)) {
-            if (body != null) {
-                MediaType contentType = MediaType.parse("text/plain");
-
-                reqBuilder.post(RequestBody.create(contentType, body));
-            }
-            else {
-                FormBody.Builder formBody = new FormBody.Builder();
-
-                if (params != null) {
-                    for (Map.Entry<String, Object> entry : params.entrySet()) {
-                        if (entry.getValue() != null)
-                            formBody.add(entry.getKey(), entry.getValue().toString());
-                    }
-                }
 
-                reqBuilder.post(formBody.build());
-            }
+            reqBuilder.post(formBody.build());
         }
-        else
-            throw new IllegalArgumentException("Unknown HTTP-method: " + mtd);
-
+        
         reqBuilder.url(urlBuilder.build());
 
         try (Response resp = httpClient.newCall(reqBuilder.build()).execute()) {
@@ -180,7 +168,7 @@ public class RestExecutor {
                 "Please ensure that nodes have [ignite-rest-http] module in classpath " +
                 "(was copied from libs/optional to libs folder).");
 
-            throw new ConnectException("Failed connect to node and execute REST command [url=" + urlBuilder + "]");
+            throw new ConnectException("Failed connect to node and execute REST command [url=" + urlBuilder + ", parameters=" + params + "]");
         }
     }
 
@@ -188,21 +176,20 @@ public class RestExecutor {
      * @param demo Is demo node request.
      * @param path Path segment.
      * @param params Params.
-     * @param mtd Method.
      * @param headers Headers.
      * @param body Body.
      */
     public RestResult execute(boolean demo, String path, Map<String, Object> params,
-        String mtd, Map<String, Object> headers, String body) {
+        Map<String, Object> headers, String body) {
         if (log.isDebugEnabled())
-            log.debug("Start execute REST command [method=" + mtd + ", uri=/" + (path == null ? "" : path) +
+            log.debug("Start execute REST command [uri=/" + (path == null ? "" : path) +
                 ", parameters=" + params + "]");
 
         try {
-            return sendRequest(demo, path, params, mtd, headers, body);
+            return sendRequest(demo, path, params, headers, body);
         }
         catch (Exception e) {
-            U.error(log, "Failed to execute REST command [method=" + mtd + ", uri=/" + (path == null ? "" : path) +
+            U.error(log, "Failed to execute REST command [uri=/" + (path == null ? "" : path) +
                 ", parameters=" + params + "]", e);
 
             return RestResult.fail(404, e.getMessage());
@@ -219,6 +206,6 @@ public class RestExecutor {
         params.put("attr", true);
         params.put("mtr", full);
 
-        return sendRequest(demo, "ignite", params, "GET", null, null);
+        return sendRequest(demo, "ignite", params, null, null);
     }
 }


[20/40] ignite git commit: IGNITE-5820 Web Console: Adjust modals height.

Posted by ag...@apache.org.
IGNITE-5820 Web Console: Adjust modals height.


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

Branch: refs/heads/ignite-5757
Commit: 2005eec081add6906fa204c4db0cfcc4a4907292
Parents: f277530
Author: Andrey Novikov <an...@gridgain.com>
Authored: Tue Jul 25 15:49:21 2017 +0700
Committer: Andrey Novikov <an...@gridgain.com>
Committed: Tue Jul 25 15:49:21 2017 +0700

----------------------------------------------------------------------
 .../web-console/frontend/app/primitives/modal/index.scss    | 9 +++++++++
 1 file changed, 9 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/2005eec0/modules/web-console/frontend/app/primitives/modal/index.scss
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/primitives/modal/index.scss b/modules/web-console/frontend/app/primitives/modal/index.scss
index 87d8dc3..fcf9885 100644
--- a/modules/web-console/frontend/app/primitives/modal/index.scss
+++ b/modules/web-console/frontend/app/primitives/modal/index.scss
@@ -57,6 +57,15 @@
     transform: translateZ(1px);
 }
 
+.modal .modal-dialog--adjust-height {
+    margin-top: 0;
+    margin-bottom: 0;
+
+    .modal-body {
+        max-height: calc(100vh - 150px);
+    }
+}
+
 .modal .modal-content {
     background-color: $gray-lighter;