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 2015/10/22 12:47:13 UTC

[01/50] [abbrv] ignite git commit: Fix REST authentication.

Repository: ignite
Updated Branches:
  refs/heads/ignite-1016 8f5a4c9de -> 4f2b22bca


Fix REST authentication.


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

Branch: refs/heads/ignite-1016
Commit: f025714ef0d21ffff7ebf6088c254f26dd9aa3fc
Parents: f60cba7
Author: ashutak <as...@gridgain.com>
Authored: Wed Oct 7 16:11:18 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Wed Oct 7 16:11:18 2015 +0300

----------------------------------------------------------------------
 .../JettyRestProcessorAbstractSelfTest.java     |  27 +-
 .../apache/ignite/IgniteSystemProperties.java   |   3 +
 .../processors/rest/GridRestProcessor.java      | 356 +++++++++++++++++--
 .../handlers/cache/GridCacheCommandHandler.java |   2 +-
 .../ignite/internal/util/IgniteUtils.java       |   2 +-
 5 files changed, 341 insertions(+), 49 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/f025714e/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 8db4cd7..ac0edff 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
@@ -84,6 +84,13 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
     protected abstract int restPort();
 
     /**
+     * @return Security enabled flag. Should be the same with {@code ctx.security().enabled()}.
+     */
+    protected boolean securityEnabled() {
+        return false;
+    }
+
+    /**
      * @param params Command parameters.
      * @return Returned content.
      * @throws Exception If failed.
@@ -133,7 +140,7 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
         return "\\{\\\"affinityNodeId\\\":\\\"\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12}\\\"\\," +
             "\\\"error\\\":\\\"\\\"\\," +
             "\\\"response\\\":\\\"" + res + "\\\"\\," +
-            "\\\"sessionToken\\\":\\\"\\\"," +
+            "\\\"sessionToken\\\":\\\"" + (securityEnabled() && success ? ".+" : "") + "\\\"," +
             "\\\"successStatus\\\":" + (success ? 0 : 1) + "\\}";
     }
 
@@ -157,7 +164,7 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
     private String integerPattern(int res, boolean success) {
         return "\\{\\\"error\\\":\\\"\\\"\\," +
             "\\\"response\\\":" + res + "\\," +
-            "\\\"sessionToken\\\":\\\"\\\"," +
+            "\\\"sessionToken\\\":\\\"" + (securityEnabled() && success ? ".+" : "") + "\\\"," +
             "\\\"successStatus\\\":" + (success ? 0 : 1) + "\\}";
     }
 
@@ -170,7 +177,7 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
         return "\\{\\\"affinityNodeId\\\":\\\"\\\"\\," +
             "\\\"error\\\":\\\"\\\"\\," +
             "\\\"response\\\":" + res + "\\," +
-            "\\\"sessionToken\\\":\\\"\\\"," +
+            "\\\"sessionToken\\\":\\\"" + (securityEnabled() && success ? ".+" : "") + "\\\"," +
             "\\\"successStatus\\\":" + (success ? 0 : 1) + "\\}";
     }
 
@@ -183,7 +190,7 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
         return "\\{\\\"affinityNodeId\\\":\\\"\\\"\\," +
             "\\\"error\\\":\\\"\\\"\\," +
             "\\\"response\\\":" + res + "\\," +
-            "\\\"sessionToken\\\":\\\"\\\"," +
+            "\\\"sessionToken\\\":\\\"" + (securityEnabled() && success ? ".+" : "") + "\\\"," +
             "\\\"successStatus\\\":" + (success ? 0 : 1) + "\\}";
     }
 
@@ -196,7 +203,7 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
         return "\\{\\\"affinityNodeId\\\":\\\"\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12}\\\"\\," +
             "\\\"error\\\":\\\"\\\"\\," +
             "\\\"response\\\":" + res + "\\," +
-            "\\\"sessionToken\\\":\\\"\\\"," +
+            "\\\"sessionToken\\\":\\\"" + (securityEnabled() && success ? ".+" : "") + "\\\"," +
             "\\\"successStatus\\\":" + (success ? 0 : 1) + "\\}";
     }
 
@@ -209,7 +216,7 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
         return "\\{\\\"affinityNodeId\\\":\\\"\\\"\\," +
             "\\\"error\\\":\\\"\\\"\\," +
             "\\\"response\\\":" + res + "\\," +
-            "\\\"sessionToken\\\":\\\"\\\"," +
+            "\\\"sessionToken\\\":\\\"" + (securityEnabled() && success ? ".+" : "") + "\\\"," +
             "\\\"successStatus\\\":" + (success ? 0 : 1) + "\\}";
     }
 
@@ -222,7 +229,7 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
         return "\\{\\\"affinityNodeId\\\":\\\"(\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12})?\\\"\\," +
             "\\\"error\\\":\\\"\\\"\\," +
             "\\\"response\\\":" + res + "\\," +
-            "\\\"sessionToken\\\":\\\"\\\"," +
+            "\\\"sessionToken\\\":\\\"" + (securityEnabled() && success ? ".+" : "") + "\\\"," +
             "\\\"successStatus\\\":" + (success ? 0 : 1) + "\\}";
     }
 
@@ -234,7 +241,7 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
     private String pattern(String res, boolean success) {
         return "\\{\\\"error\\\":\\\"" + (!success ? ".+" : "") + "\\\"\\," +
             "\\\"response\\\":" + res + "\\," +
-            "\\\"sessionToken\\\":\\\"\\\"," +
+            "\\\"sessionToken\\\":\\\"" + (securityEnabled() && success ? ".+" : "") + "\\\"," +
             "\\\"successStatus\\\":" + (success ? 0 : 1) + "\\}";
     }
 
@@ -246,7 +253,7 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
     private String stringPattern(String res, boolean success) {
         return "\\{\\\"error\\\":\\\"" + (!success ? ".+" : "") + "\\\"\\," +
             "\\\"response\\\":\\\"" + res + "\\\"\\," +
-            "\\\"sessionToken\\\":\\\"\\\"," +
+            "\\\"sessionToken\\\":\\\"" + (securityEnabled() && success ? ".+" : "") + "\\\"," +
             "\\\"successStatus\\\":" + (success ? 0 : 1) + "\\}";
     }
 
@@ -1316,4 +1323,4 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
             return id;
         }
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f025714e/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 1e4c8b7..5d3b08b 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
@@ -96,6 +96,9 @@ public final class IgniteSystemProperties {
      */
     public static final String IGNITE_JETTY_LOG_NO_OVERRIDE = "IGNITE_JETTY_LOG_NO_OVERRIDE";
 
+    /** This property allow rewriting default ({@code 30}) rest session expire time (in seconds). */
+    public static final String IGNITE_REST_SESSION_TIMEOUT = "IGNITE_REST_SESSION_TIMEOUT";
+
     /**
      * This property allows to override maximum count of task results stored on one node
      * in REST processor.

http://git-wip-us.apache.org/repos/asf/ignite/blob/f025714e/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
index d606ba4..d54c8bb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.processors.rest;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.EnumMap;
 import java.util.HashMap;
@@ -30,7 +31,9 @@ import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.RejectedExecutionException;
+import java.util.concurrent.atomic.AtomicLong;
 import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteSystemProperties;
 import org.apache.ignite.configuration.ConnectorConfiguration;
 import org.apache.ignite.configuration.ConnectorMessageInterceptor;
 import org.apache.ignite.internal.GridKernalContext;
@@ -53,8 +56,10 @@ import org.apache.ignite.internal.processors.security.SecurityContext;
 import org.apache.ignite.internal.util.GridSpinReadWriteLock;
 import org.apache.ignite.internal.util.future.GridFinishedFuture;
 import org.apache.ignite.internal.util.typedef.C1;
+import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.X;
 import org.apache.ignite.internal.util.typedef.internal.LT;
+import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.internal.util.worker.GridWorker;
 import org.apache.ignite.internal.util.worker.GridWorkerFuture;
@@ -65,6 +70,7 @@ import org.apache.ignite.plugin.security.AuthenticationContext;
 import org.apache.ignite.plugin.security.SecurityCredentials;
 import org.apache.ignite.plugin.security.SecurityException;
 import org.apache.ignite.plugin.security.SecurityPermission;
+import org.apache.ignite.thread.IgniteThread;
 import org.jsr166.LongAdder8;
 
 import static org.apache.ignite.internal.processors.rest.GridRestResponse.STATUS_AUTH_FAILED;
@@ -80,8 +86,11 @@ public class GridRestProcessor extends GridProcessorAdapter {
     private static final String HTTP_PROTO_CLS =
         "org.apache.ignite.internal.processors.rest.protocols.http.jetty.GridJettyRestProtocol";
 
-    /** */
-    public static final byte[] ZERO_BYTES = new byte[0];
+    /** Delay between sessions timeout checks. */
+    private static final int SES_TIMEOUT_CHECK_DELAY = 1_000;
+
+    /** Default session timout. */
+    private static final int DEFAULT_SES_TIMEOUT = 30_000;
 
     /** Protocols. */
     private final Collection<GridRestProtocol> protos = new ArrayList<>();
@@ -98,8 +107,14 @@ public class GridRestProcessor extends GridProcessorAdapter {
     /** Workers count. */
     private final LongAdder8 workersCnt = new LongAdder8();
 
-    /** SecurityContext map. */
-    private ConcurrentMap<UUID, SecurityContext> sesMap = new ConcurrentHashMap<>();
+    /** ClientId-SessionId map. */
+    private final ConcurrentMap<UUID, UUID> clientId2SesId = new ConcurrentHashMap<>();
+
+    /** SessionId-Session map. */
+    private final ConcurrentMap<UUID, Session> sesId2Ses = new ConcurrentHashMap<>();
+
+    /** */
+    private final Thread sesTimeoutCheckerThread;
 
     /** Protocol handler. */
     private final GridRestProtocolHandler protoHnd = new GridRestProtocolHandler() {
@@ -112,6 +127,9 @@ public class GridRestProcessor extends GridProcessorAdapter {
         }
     };
 
+    /** Session time to live. */
+    private final long sesTtl;
+
     /**
      * @param req Request.
      * @return Future.
@@ -195,22 +213,40 @@ public class GridRestProcessor extends GridProcessorAdapter {
         if (log.isDebugEnabled())
             log.debug("Received request from client: " + req);
 
-        SecurityContext subjCtx = null;
-
         if (ctx.security().enabled()) {
+            Session ses;
+
             try {
-                subjCtx = authenticate(req);
+                ses = session(req);
+            }
+            catch (IgniteCheckedException e) {
+                GridRestResponse res = new GridRestResponse(STATUS_FAILED, e.getMessage());
 
-                authorize(req, subjCtx);
+                return new GridFinishedFuture<>(res);
+            }
+
+            assert ses != null;
+
+            req.clientId(ses.clientId);
+            req.sessionToken(U.uuidToBytes(ses.sesId));
+
+            if (log.isDebugEnabled())
+                log.debug("Next clientId and sessionToken were extracted according to request: " +
+                    "[clientId="+req.clientId()+", sesTok="+Arrays.toString(req.sessionToken())+"]");
+
+            SecurityContext secCtx0 = ses.secCtx;
+
+            try {
+                if (secCtx0 == null)
+                    ses.secCtx = secCtx0 = authenticate(req);
+
+                authorize(req, secCtx0);
             }
             catch (SecurityException e) {
-                assert subjCtx != null;
+                assert secCtx0 != null;
 
                 GridRestResponse res = new GridRestResponse(STATUS_SECURITY_CHECK_FAILED, e.getMessage());
 
-                updateSession(req, subjCtx);
-                res.sessionTokenBytes(ZERO_BYTES);
-
                 return new GridFinishedFuture<>(res);
             }
             catch (IgniteCheckedException e) {
@@ -228,16 +264,18 @@ public class GridRestProcessor extends GridProcessorAdapter {
             return new GridFinishedFuture<>(
                 new IgniteCheckedException("Failed to find registered handler for command: " + req.command()));
 
-        final SecurityContext subjCtx0 = subjCtx;
-
         return res.chain(new C1<IgniteInternalFuture<GridRestResponse>, GridRestResponse>() {
             @Override public GridRestResponse apply(IgniteInternalFuture<GridRestResponse> f) {
                 GridRestResponse res;
 
+                boolean failed = false;
+
                 try {
                     res = f.get();
                 }
                 catch (Exception e) {
+                    failed = true;
+
                     if (!X.hasCause(e, VisorClusterGroupEmptyException.class))
                         LT.error(log, e, "Failed to handle request: " + req.command());
 
@@ -249,10 +287,8 @@ public class GridRestProcessor extends GridProcessorAdapter {
 
                 assert res != null;
 
-                if (ctx.security().enabled()) {
-                    updateSession(req, subjCtx0);
-                    res.sessionTokenBytes(ZERO_BYTES);
-                }
+                if (ctx.security().enabled() && !failed)
+                    res.sessionTokenBytes(req.sessionToken());
 
                 interceptResponse(res, req);
 
@@ -262,10 +298,137 @@ public class GridRestProcessor extends GridProcessorAdapter {
     }
 
     /**
+     * @param req Request.
+     * @return Not null session.
+     * @throws IgniteCheckedException If failed.
+     */
+    private Session session(final GridRestRequest req) throws IgniteCheckedException {
+        final UUID clientId = req.clientId();
+        final byte[] sesTok = req.sessionToken();
+
+        while (true) {
+            if (F.isEmpty(sesTok) && clientId == null) {
+                Session ses = Session.random();
+
+                UUID oldSesId = clientId2SesId.put(ses.clientId, ses.sesId);
+
+                assert oldSesId == null : "Got an illegal state for request: " + req;
+
+                Session oldSes = sesId2Ses.put(ses.sesId, ses);
+
+                assert oldSes == null : "Got an illegal state for request: " + req;
+
+                return ses;
+            }
+
+            if (F.isEmpty(sesTok) && clientId != null) {
+                UUID sesId = clientId2SesId.get(clientId);
+
+                if (sesId == null) {
+                    Session ses = Session.fromClientId(clientId);
+
+                    if (clientId2SesId.putIfAbsent(ses.clientId, ses.sesId) != null)
+                        continue; // Another thread already register session with the clientId.
+
+                    Session prevSes = sesId2Ses.put(ses.sesId, ses);
+
+                    assert prevSes == null : "Got an illegal state for request: " + req;
+
+                    return ses;
+                }
+                else {
+                    Session ses = sesId2Ses.get(sesId);
+
+                    if (ses == null || !ses.touch())
+                        continue; // Need to wait while timeout thread complete removing of timed out sessions.
+
+                    return ses;
+                }
+            }
+
+            if (!F.isEmpty(sesTok) && clientId == null) {
+                UUID sesId = U.bytesToUuid(sesTok, 0);
+
+                Session ses = sesId2Ses.get(sesId);
+
+                if (ses == null)
+                    throw new IgniteCheckedException("Failed to handle request - unknown session token " +
+                        "(maybe expired session) [sesTok=" + U.byteArray2HexString(sesTok) + "]");
+
+                if (!ses.touch())
+                    continue; // Need to wait while timeout thread complete removing of timed out sessions.
+
+                return ses;
+            }
+
+            if (!F.isEmpty(sesTok) && clientId != null) {
+                UUID sesId = clientId2SesId.get(clientId);
+
+                if (sesId == null || !sesId.equals(U.bytesToUuid(sesTok, 0)))
+                    throw new IgniteCheckedException("Failed to handle request - unsupported case (misamatched " +
+                        "clientId and session token) [clientId=" + clientId + ", sesTok=" +
+                        U.byteArray2HexString(sesTok) + "]");
+
+                Session ses = sesId2Ses.get(sesId);
+
+                if (ses == null)
+                    throw new IgniteCheckedException("Failed to handle request - unknown session token " +
+                        "(maybe expired session) [sesTok=" + U.byteArray2HexString(sesTok) + "]");
+
+                if (!ses.touch())
+                    continue; // Need to wait while timeout thread complete removing of timed out sessions.
+
+                return ses;
+            }
+
+            assert false : "Got an unreachable state.";
+        }
+    }
+
+    /**
      * @param ctx Context.
      */
     public GridRestProcessor(GridKernalContext ctx) {
         super(ctx);
+
+        long sesExpTime0;
+        String sesExpTime = null;
+
+        try {
+            sesExpTime = System.getProperty(IgniteSystemProperties.IGNITE_REST_SESSION_TIMEOUT);
+
+            if (sesExpTime != null)
+                sesExpTime0 = Long.valueOf(sesExpTime) * 1000;
+            else
+                sesExpTime0 = DEFAULT_SES_TIMEOUT;
+        }
+        catch (NumberFormatException ignore) {
+            U.warn(log, "Failed parsing IGNITE_REST_SESSION_TIMEOUT system variable [IGNITE_REST_SESSION_TIMEOUT="
+                + sesExpTime + "]");
+
+            sesExpTime0 = DEFAULT_SES_TIMEOUT;
+        }
+
+        sesTtl = sesExpTime0;
+
+        sesTimeoutCheckerThread = new IgniteThread(ctx.gridName(), "session-timeout-worker",
+            new GridWorker(ctx.gridName(), "session-timeout-worker", log) {
+                @Override protected void body() throws InterruptedException {
+                    while (!isCancelled()) {
+                        Thread.sleep(SES_TIMEOUT_CHECK_DELAY);
+
+                        for (Map.Entry<UUID, Session> e : sesId2Ses.entrySet()) {
+                            Session ses = e.getValue();
+
+                            if (ses.isTimedOut(sesTtl)) {
+                                sesId2Ses.remove(ses.sesId, ses);
+
+                                clientId2SesId.remove(ses.clientId, ses.sesId);
+                            }
+                        }
+                    }
+                }
+            });
     }
 
     /** {@inheritDoc} */
@@ -310,6 +473,10 @@ public class GridRestProcessor extends GridProcessorAdapter {
             for (GridRestProtocol proto : protos)
                 proto.onKernalStart();
 
+            sesTimeoutCheckerThread.setDaemon(true);
+
+            sesTimeoutCheckerThread.start();
+
             startLatch.countDown();
 
             if (log.isDebugEnabled())
@@ -334,6 +501,8 @@ public class GridRestProcessor extends GridProcessorAdapter {
                 }
             }
 
+            U.interrupt(sesTimeoutCheckerThread);
+
             if (interrupted)
                 Thread.currentThread().interrupt();
 
@@ -483,13 +652,8 @@ public class GridRestProcessor extends GridProcessorAdapter {
      * @throws IgniteCheckedException If authentication failed.
      */
     private SecurityContext authenticate(GridRestRequest req) throws IgniteCheckedException {
-        UUID clientId = req.clientId();
-        SecurityContext secCtx = clientId == null ? null : sesMap.get(clientId);
+        assert req.clientId() != null;
 
-        if (secCtx != null)
-            return secCtx;
-
-        // Authenticate client if invalid session.
         AuthenticationContext authCtx = new AuthenticationContext();
 
         authCtx.subjectType(REMOTE_CLIENT);
@@ -531,18 +695,6 @@ public class GridRestProcessor extends GridProcessorAdapter {
     }
 
     /**
-     * Update session.
-     * @param req REST request.
-     * @param sCtx Security context.
-     */
-    private void updateSession(GridRestRequest req, SecurityContext sCtx) {
-        if (sCtx != null) {
-            UUID id = req.clientId();
-            sesMap.put(id, sCtx);
-        }
-    }
-
-    /**
      * @param req REST request.
      * @param sCtx Security context.
      * @throws SecurityException If authorization failed.
@@ -719,4 +871,134 @@ public class GridRestProcessor extends GridProcessorAdapter {
         X.println(">>>   protosSize: " + protos.size());
         X.println(">>>   handlersSize: " + handlers.size());
     }
-}
\ No newline at end of file
+
+    /**
+     * Session.
+     */
+    private static class Session {
+        /** Expiration flag. It's a final state of lastToucnTime. */
+        private static final Long TIMEDOUT_FLAG = 0L;
+
+        /** Client id. */
+        private final UUID clientId;
+
+        /** Session token id. */
+        private final UUID sesId;
+
+        /** Security context. */
+        private volatile SecurityContext secCtx;
+
+        /**
+         * Time when session is used last time.
+         * If this time was set at TIMEDOUT_FLAG, then it should never be changed.
+         */
+        private final AtomicLong lastTouchTime = new AtomicLong(U.currentTimeMillis());
+
+        /**
+         * @param clientId Client ID.
+         * @param sesId session ID.
+         */
+        private Session(UUID clientId, UUID sesId) {
+            this.clientId = clientId;
+            this.sesId = sesId;
+        }
+
+        /**
+         * Static constructor.
+         *
+         * @return New session instance with random client ID and random session ID.
+         */
+        static Session random() {
+            return new Session(UUID.randomUUID(), UUID.randomUUID());
+        }
+
+        /**
+         * Static constructor.
+         *
+         * @param clientId Client ID.
+         * @return New session instance with given client ID and random session ID.
+         */
+        static Session fromClientId(UUID clientId) {
+            return new Session(clientId, UUID.randomUUID());
+        }
+
+        /**
+         * Static constructor.
+         *
+         * @param sesTokId Session token ID.
+         * @return New session instance with random client ID and given session ID.
+         */
+        static Session fromSessionToken(UUID sesTokId) {
+            return new Session(UUID.randomUUID(), sesTokId);
+        }
+
+        /**
+         * Checks expiration of session and if expired then sets TIMEDOUT_FLAG.
+         *
+         * @param sesTimeout Session timeout.
+         * @return <code>True</code> if expired.
+         * @see #touch()
+         */
+        boolean isTimedOut(long sesTimeout) {
+            long time0 = lastTouchTime.get();
+
+            if (time0 == TIMEDOUT_FLAG)
+                return true;
+
+            return U.currentTimeMillis() - time0 > sesTimeout && lastTouchTime.compareAndSet(time0, TIMEDOUT_FLAG);
+        }
+
+        /**
+         * Checks whether session at expired state (EPIRATION_FLAG) or not, if not then tries to update last touch time.
+         *
+         * @return {@code False} if session timed out (not successfully touched).
+         * @see #isTimedOut(long)
+         */
+        boolean touch() {
+            while (true) {
+                long time0 = lastTouchTime.get();
+
+                if (time0 == TIMEDOUT_FLAG)
+                    return false;
+
+                boolean success = lastTouchTime.compareAndSet(time0, U.currentTimeMillis());
+
+                if (success)
+                    return true;
+            }
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean equals(Object o) {
+            if (this == o)
+                return true;
+
+            if (!(o instanceof Session))
+                return false;
+
+            Session ses = (Session)o;
+
+            if (clientId != null ? !clientId.equals(ses.clientId) : ses.clientId != null)
+                return false;
+
+            if (sesId != null ? !sesId.equals(ses.sesId) : ses.sesId != null)
+                return false;
+
+            return true;
+        }
+
+        /** {@inheritDoc} */
+        @Override public int hashCode() {
+            int res = clientId != null ? clientId.hashCode() : 0;
+
+            res = 31 * res + (sesId != null ? sesId.hashCode() : 0);
+
+            return res;
+        }
+
+        /** {@inheritDoc} */
+        @Override public String toString() {
+            return S.toString(Session.class, this);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f025714e/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandler.java
index b3af2f2..9d32c17 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandler.java
@@ -1391,4 +1391,4 @@ public class GridCacheCommandHandler extends GridRestCommandHandlerAdapter {
             return c.sizeAsync(new CachePeekMode[]{CachePeekMode.PRIMARY});
         }
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f025714e/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 e5090cb..3c1913a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
@@ -9302,4 +9302,4 @@ public abstract class IgniteUtils {
             throw new IgniteInterruptedCheckedException(e);
         }
     }
-}
\ No newline at end of file
+}


[28/50] [abbrv] ignite git commit: Merge remote-tracking branch 'origin/master'

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


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

Branch: refs/heads/ignite-1016
Commit: f4d8ea914e61981ff33e41aee498168b56063834
Parents: c4b0877 077af17
Author: Anton Vinogradov <av...@apache.org>
Authored: Thu Oct 15 17:00:01 2015 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Thu Oct 15 17:00:01 2015 +0300

----------------------------------------------------------------------
 .../CacheAbstractRestartSelfTest.java           | 247 +++++++++++++++++++
 ...NearDisabledAtomicInvokeRestartSelfTest.java | 179 ++++++++++++++
 ...abledTransactionalInvokeRestartSelfTest.java | 173 +++++++++++++
 ...edTransactionalWriteReadRestartSelfTest.java | 124 ++++++++++
 .../IgniteCacheLoadConsistencyTestSuite.java    |  42 ++++
 5 files changed, 765 insertions(+)
----------------------------------------------------------------------



[36/50] [abbrv] ignite git commit: IGNITE-1653 fixes

Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/ComputeScheduleExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/ComputeScheduleExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/ComputeScheduleExample.java
deleted file mode 100644
index 8c85a3e..0000000
--- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/ComputeScheduleExample.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-
-package org.apache.ignite.examples.java8.misc.schedule;
-
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.scheduler.SchedulerFuture;
-
-/**
- * Demonstrates a cron-based {@link Runnable} execution scheduling.
- * Test runnable object broadcasts a phrase to all cluster nodes every minute
- * three times with initial scheduling delay equal to five seconds.
- * <p>
- * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
- * with {@code examples/config/example-ignite.xml} configuration.
- */
-public class ComputeScheduleExample {
-    /**
-     * Executes example.
-     *
-     * @param args Command line arguments, none required.
-     * @throws IgniteException If example execution failed.
-     */
-    public static void main(String[] args) throws IgniteException {
-        try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
-            System.out.println();
-            System.out.println("Compute schedule example started.");
-
-            // Schedule output message every minute.
-            SchedulerFuture<?> fut = ignite.scheduler().scheduleLocal(() ->
-                ignite.compute().broadcast(() -> {
-                    System.out.println();
-                    System.out.println("Howdy! :)");
-
-                    return "Howdy! :)";
-                }),
-                "{5, 3} * * * * *" // Cron expression.
-            );
-
-            while (!fut.isDone())
-                System.out.println(">>> Invocation result: " + fut.get());
-
-            System.out.println();
-            System.out.println(">>> Schedule future is done and has been unscheduled.");
-            System.out.println(">>> Check all nodes for hello message output.");
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/package-info.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/package-info.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/package-info.java
deleted file mode 100644
index 42132f1..0000000
--- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-
-/**
- * <!-- Package description. -->
- * Demonstrates usage of cron-based scheduler.
- */
-package org.apache.ignite.examples.java8.misc.schedule;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamTransformerExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamTransformerExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamTransformerExample.java
deleted file mode 100644
index 538c4eb..0000000
--- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamTransformerExample.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-
-package org.apache.ignite.examples.java8.streaming;
-
-import java.util.List;
-import java.util.Random;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteDataStreamer;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.query.SqlFieldsQuery;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.examples.ExamplesUtils;
-import org.apache.ignite.stream.StreamTransformer;
-
-/**
- * Stream random numbers into the streaming cache.
- * To start the example, you should:
- * <ul>
- *     <li>Start a few nodes using {@link ExampleNodeStartup} or by starting remote nodes as specified below.</li>
- *     <li>Start streaming using {@link StreamTransformerExample}.</li>
- * </ul>
- * <p>
- * You should start remote nodes by running {@link ExampleNodeStartup} in another JVM.
- */
-public class StreamTransformerExample {
-    /** Random number generator. */
-    private static final Random RAND = new Random();
-
-    /** Range within which to generate numbers. */
-    private static final int RANGE = 1000;
-
-    public static void main(String[] args) throws Exception {
-        // Mark this cluster member as client.
-        Ignition.setClientMode(true);
-
-        try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
-            if (!ExamplesUtils.hasServerNodes(ignite))
-                return;
-
-            CacheConfiguration<Integer, Long> cfg = new CacheConfiguration<>("randomNumbers");
-
-            // Index key and value.
-            cfg.setIndexedTypes(Integer.class, Long.class);
-
-            // Auto-close cache at the end of the example.
-            try (IgniteCache<Integer, Long> stmCache = ignite.getOrCreateCache(cfg)) {
-                try (IgniteDataStreamer<Integer, Long> stmr = ignite.dataStreamer(stmCache.getName())) {
-                    // Allow data updates.
-                    stmr.allowOverwrite(true);
-
-                    // Configure data transformation to count random numbers added to the stream.
-                    stmr.receiver(StreamTransformer.from((e, arg) -> {
-                        // Get current count.
-                        Long val = e.getValue();
-
-                        // Increment count by 1.
-                        e.setValue(val == null ? 1L : val + 1);
-
-                        return null;
-                    }));
-
-                    // Stream 10 million of random numbers into the streamer cache.
-                    for (int i = 1; i <= 10_000_000; i++) {
-                        stmr.addData(RAND.nextInt(RANGE), 1L);
-
-                        if (i % 500_000 == 0)
-                            System.out.println("Number of tuples streamed into Ignite: " + i);
-                    }
-                }
-
-                // Query top 10 most popular numbers every.
-                SqlFieldsQuery top10Qry = new SqlFieldsQuery("select _key, _val from Long order by _val desc limit 10");
-
-                // Execute queries.
-                List<List<?>> top10 = stmCache.query(top10Qry).getAll();
-
-                System.out.println("Top 10 most popular numbers:");
-
-                // Print top 10 words.
-                ExamplesUtils.printQueryResults(top10);
-            }
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamVisitorExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamVisitorExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamVisitorExample.java
deleted file mode 100644
index cef9f2f..0000000
--- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamVisitorExample.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-
-package org.apache.ignite.examples.java8.streaming;
-
-import java.io.Serializable;
-import java.util.List;
-import java.util.Random;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteDataStreamer;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.query.SqlFieldsQuery;
-import org.apache.ignite.cache.query.annotations.QuerySqlField;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.examples.ExamplesUtils;
-import org.apache.ignite.stream.StreamVisitor;
-
-/**
- * Stream random numbers into the streaming cache.
- * To start the example, you should:
- * <ul>
- *     <li>Start a few nodes using {@link ExampleNodeStartup} or by starting remote nodes as specified below.</li>
- *     <li>Start streaming using {@link StreamVisitorExample}.</li>
- * </ul>
- * <p>
- * You should start remote nodes by running {@link ExampleNodeStartup} in another JVM.
- */
-public class StreamVisitorExample {
-    /** Random number generator. */
-    private static final Random RAND = new Random();
-
-    /** The list of instruments. */
-    private static final String[] INSTRUMENTS = {"IBM", "GOOG", "MSFT", "GE", "EBAY", "YHOO", "ORCL", "CSCO", "AMZN", "RHT"};
-
-    /** The list of initial instrument prices. */
-    private static final double[] INITIAL_PRICES = {194.9, 893.49, 34.21, 23.24, 57.93, 45.03, 44.41, 28.44, 378.49, 69.50};
-
-    public static void main(String[] args) throws Exception {
-        // Mark this cluster member as client.
-        Ignition.setClientMode(true);
-
-        try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
-            if (!ExamplesUtils.hasServerNodes(ignite))
-                return;
-
-            // Market data cache with default configuration.
-            CacheConfiguration<String, Double> mktDataCfg = new CacheConfiguration<>("marketTicks");
-
-            // Financial instrument cache configuration.
-            CacheConfiguration<String, Instrument> instCfg = new CacheConfiguration<>("instCache");
-
-            // Index key and value for querying financial instruments.
-            // Note that Instrument class has @QuerySqlField annotation for secondary field indexing.
-            instCfg.setIndexedTypes(String.class, Instrument.class);
-
-            // Auto-close caches at the end of the example.
-            try (
-                IgniteCache<String, Double> mktCache = ignite.getOrCreateCache(mktDataCfg);
-                IgniteCache<String, Instrument> instCache = ignite.getOrCreateCache(instCfg)
-            ) {
-                try (IgniteDataStreamer<String, Double> mktStmr = ignite.dataStreamer(mktCache.getName())) {
-                    // Note that we receive market data, but do not populate 'mktCache' (it remains empty).
-                    // Instead we update the instruments in the 'instCache'.
-                    // Since both, 'instCache' and 'mktCache' use the same key, updates are collocated.
-                    mktStmr.receiver(StreamVisitor.from((cache, e) -> {
-                        String symbol = e.getKey();
-                        Double tick = e.getValue();
-
-                        Instrument inst = instCache.get(symbol);
-
-                        if (inst == null)
-                            inst = new Instrument(symbol);
-
-                        // Don't populate market cache, as we don't use it for querying.
-                        // Update cached instrument based on the latest market tick.
-                        inst.update(tick);
-
-                        instCache.put(symbol, inst);
-                    }));
-
-                    // Stream 10 million market data ticks into the system.
-                    for (int i = 1; i <= 10_000_000; i++) {
-                        int idx = RAND.nextInt(INSTRUMENTS.length);
-
-                        // Use gaussian distribution to ensure that
-                        // numbers closer to 0 have higher probability.
-                        double price = round2(INITIAL_PRICES[idx] + RAND.nextGaussian());
-
-                        mktStmr.addData(INSTRUMENTS[idx], price);
-
-                        if (i % 500_000 == 0)
-                            System.out.println("Number of tuples streamed into Ignite: " + i);
-                    }
-                }
-
-                // Select top 3 best performing instruments.
-                SqlFieldsQuery top3qry = new SqlFieldsQuery(
-                    "select symbol, (latest - open) from Instrument order by (latest - open) desc limit 3");
-
-                // Execute queries.
-                List<List<?>> top3 = instCache.query(top3qry).getAll();
-
-                System.out.println("Top performing financial instruments: ");
-
-                // Print top 10 words.
-                ExamplesUtils.printQueryResults(top3);
-            }
-        }
-    }
-
-    /**
-     * Rounds double value to two significant signs.
-     *
-     * @param val value to be rounded.
-     * @return rounded double value.
-     */
-    private static double round2(double val) {
-        return Math.floor(100 * val + 0.5) / 100;
-    }
-
-    /**
-     * Financial instrument.
-     */
-    public static class Instrument implements Serializable {
-        /** Instrument symbol. */
-        @QuerySqlField(index = true)
-        private final String symbol;
-
-        /** Open price. */
-        @QuerySqlField(index = true)
-        private double open;
-
-        /** Close price. */
-        @QuerySqlField(index = true)
-        private double latest;
-
-        /**
-         * @param symbol Symbol.
-         */
-        public Instrument(String symbol) {
-            this.symbol = symbol;
-        }
-
-        /**
-         * Updates this instrument based on the latest market tick price.
-         *
-         * @param price Latest price.
-         */
-        public void update(double price) {
-            if (open == 0)
-                open = price;
-
-            this.latest = price;
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/package-info.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/package-info.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/package-info.java
deleted file mode 100644
index d215d2f..0000000
--- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-
-/**
- * <!-- Package description. -->
- * Demonstrates usage of data streamer.
- */
-package org.apache.ignite.examples.java8.streaming;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples/config/hibernate/README.txt
----------------------------------------------------------------------
diff --git a/examples/config/hibernate/README.txt b/examples/config/hibernate/README.txt
deleted file mode 100644
index 5b7ab29..0000000
--- a/examples/config/hibernate/README.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-Hibernate L2 Cache Configuration Example
-----------------------------------------
-
-This folder contains example-hibernate-L2-cache.xml file that demonstrates
-how to configure Hibernate to use Apache Ignite cache as an L2 cache provider.
-
-This file is also used in Hibernate example located in org.apache.ignite.examples.datagrid.hibernate
-package.

http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples/config/hibernate/example-hibernate-L2-cache.xml
----------------------------------------------------------------------
diff --git a/examples/config/hibernate/example-hibernate-L2-cache.xml b/examples/config/hibernate/example-hibernate-L2-cache.xml
deleted file mode 100644
index 3248946..0000000
--- a/examples/config/hibernate/example-hibernate-L2-cache.xml
+++ /dev/null
@@ -1,64 +0,0 @@
-<?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.
--->
-
-
-<!DOCTYPE hibernate-configuration PUBLIC
-    "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
-    "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
-
-<!--
-    Configuration file for HibernateL2CacheExample.
--->
-
-<hibernate-configuration>
-    <session-factory>
-        <!-- Database connection settings -->
-        <property name="connection.url">jdbc:h2:mem:example;DB_CLOSE_DELAY=-1</property>
-
-        <!-- Drop and re-create the database schema on startup. -->
-        <property name="hbm2ddl.auto">create</property>
-
-        <!-- Enable L2 cache. -->
-        <property name="cache.use_second_level_cache">true</property>
-
-        <!-- Enable query cache. -->
-        <property name="cache.use_query_cache">true</property>
-
-        <!-- Generate L2 cache statistics. -->
-        <property name="generate_statistics">true</property>
-
-        <!-- Specify Ignite as L2 cache provider. -->
-        <property name="cache.region.factory_class">org.apache.ignite.cache.hibernate.HibernateRegionFactory</property>
-
-        <!-- Specify connection release mode. -->
-        <property name="connection.release_mode">on_close</property>
-
-        <!-- Set default L2 cache access type. -->
-        <property name="org.apache.ignite.hibernate.default_access_type">READ_ONLY</property>
-
-        <!-- Specify the entity classes for mapping. -->
-        <mapping class="org.apache.ignite.examples.datagrid.hibernate.User"/>
-        <mapping class="org.apache.ignite.examples.datagrid.hibernate.Post"/>
-
-        <!-- Per-class L2 cache settings. -->
-        <class-cache class="org.apache.ignite.examples.datagrid.hibernate.User" usage="read-only"/>
-        <class-cache class="org.apache.ignite.examples.datagrid.hibernate.Post" usage="read-only"/>
-        <collection-cache collection="org.apache.ignite.examples.datagrid.hibernate.User.posts" usage="read-only"/>
-    </session-factory>
-</hibernate-configuration>

http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 7b8763f..6eeb006 100644
--- a/pom.xml
+++ b/pom.xml
@@ -147,6 +147,72 @@
         </profile>
 
         <profile>
+            <id>lgpl</id>
+            <modules>
+                <module>modules/hibernate</module>
+                <module>modules/geospatial</module>
+                <module>modules/schedule</module>
+            </modules>
+
+            <build>
+                <plugins>
+                    <plugin>
+                        <artifactId>maven-assembly-plugin</artifactId>
+                        <dependencies>
+                            <dependency>
+                                <groupId>org.apache.apache.resources</groupId>
+                                <artifactId>apache-source-release-assembly-descriptor</artifactId>
+                                <version>1.0.4</version>
+                            </dependency>
+                        </dependencies>
+                        <executions>
+                            <execution>
+                                <id>release-lgpl</id>
+                                <phase>prepare-package</phase>
+                                <goals>
+                                    <goal>single</goal>
+                                </goals>
+                                <configuration>
+                                    <descriptors>
+                                        <descriptor>assembly/release-${ignite.edition}-lgpl.xml</descriptor>
+                                    </descriptors>
+                                    <finalName>release-package</finalName>
+                                    <appendAssemblyId>false</appendAssemblyId>
+                                </configuration>
+                            </execution>
+                        </executions>
+                    </plugin>
+
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-antrun-plugin</artifactId>
+                        <version>1.7</version>
+                        <inherited>false</inherited>
+                        <executions>
+                            <execution>
+                                <id>release-postprocessing-lgpl</id>
+                                <goals>
+                                    <goal>run</goal>
+                                </goals>
+                                <phase>package</phase>
+                                <configuration>
+                                    <target>
+                                        <replaceregexp file="${basedir}/target/release-package/examples-lgpl/pom.xml"
+                                                       byline="true">
+                                            <regexp pattern="to_be_replaced_by_ignite_version"/>
+                                            <substitution expression="${project.version}"/>
+                                        </replaceregexp>
+                                    </target>
+                                </configuration>
+                            </execution>
+                        </executions>
+                    </plugin>
+
+                </plugins>
+            </build>
+        </profile>
+
+        <profile>
             <id>release</id>
             <activation>
                 <activeByDefault>true</activeByDefault>
@@ -459,72 +525,6 @@
         </profile>
 
         <profile>
-            <id>lgpl</id>
-            <modules>
-                <module>modules/hibernate</module>
-                <module>modules/geospatial</module>
-                <module>modules/schedule</module>
-            </modules>
-
-            <build>
-                <plugins>
-                    <plugin>
-                        <artifactId>maven-assembly-plugin</artifactId>
-                        <dependencies>
-                            <dependency>
-                                <groupId>org.apache.apache.resources</groupId>
-                                <artifactId>apache-source-release-assembly-descriptor</artifactId>
-                                <version>1.0.4</version>
-                            </dependency>
-                        </dependencies>
-                        <executions>
-                            <execution>
-                                <id>release-lgpl</id>
-                                <phase>prepare-package</phase>
-                                <goals>
-                                    <goal>single</goal>
-                                </goals>
-                                <configuration>
-                                    <descriptors>
-                                        <descriptor>assembly/release-${ignite.edition}-lgpl.xml</descriptor>
-                                    </descriptors>
-                                    <finalName>release-package</finalName>
-                                    <appendAssemblyId>false</appendAssemblyId>
-                                </configuration>
-                            </execution>
-                        </executions>
-                    </plugin>
-
-                    <plugin>
-                        <groupId>org.apache.maven.plugins</groupId>
-                        <artifactId>maven-antrun-plugin</artifactId>
-                        <version>1.7</version>
-                        <inherited>false</inherited>
-                        <executions>
-                            <execution>
-                                <id>release-postprocessing-lgpl</id>
-                                <goals>
-                                    <goal>run</goal>
-                                </goals>
-                                <phase>package</phase>
-                                <configuration>
-                                    <target>
-                                        <replaceregexp file="${basedir}/target/release-package/examples-lgpl/pom.xml"
-                                                       byline="true">
-                                            <regexp pattern="to_be_replaced_by_ignite_version"/>
-                                            <substitution expression="${project.version}"/>
-                                        </replaceregexp>
-                                    </target>
-                                </configuration>
-                            </execution>
-                        </executions>
-                    </plugin>
-
-                </plugins>
-            </build>
-        </profile>
-
-        <profile>
             <id>examples</id>
             <modules>
                 <module>examples</module>


[37/50] [abbrv] ignite git commit: IGNITE-1653 fixes

Posted by ag...@apache.org.
IGNITE-1653 fixes


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

Branch: refs/heads/ignite-1016
Commit: 50cf42a3137fe31c00177042eb65001253aad518
Parents: bc6bf5f
Author: Anton Vinogradov <av...@apache.org>
Authored: Mon Oct 19 11:54:49 2015 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Mon Oct 19 11:54:49 2015 +0300

----------------------------------------------------------------------
 examples-lgpl/config/filesystem/README.txt      |   8 -
 examples-lgpl/config/filesystem/core-site.xml   |  42 -----
 .../config/filesystem/example-igfs.xml          | 151 ----------------
 examples-lgpl/config/servlet/README.txt         |   8 -
 examples-lgpl/config/servlet/WEB-INF/web.xml    |  36 ----
 .../java8/cluster/ClusterGroupExample.java      |  86 ----------
 .../examples/java8/cluster/package-info.java    |  22 ---
 .../java8/computegrid/ComputeAsyncExample.java  |  75 --------
 .../computegrid/ComputeBroadcastExample.java    | 102 -----------
 .../computegrid/ComputeCallableExample.java     |  75 --------
 .../computegrid/ComputeClosureExample.java      |  71 --------
 .../computegrid/ComputeRunnableExample.java     |  64 -------
 .../java8/computegrid/package-info.java         |  22 ---
 .../java8/datagrid/CacheAffinityExample.java    | 137 ---------------
 .../java8/datagrid/CacheApiExample.java         | 105 -----------
 .../java8/datagrid/CacheAsyncApiExample.java    |  85 ---------
 .../examples/java8/datagrid/package-info.java   |  22 ---
 .../IgniteExecutorServiceExample.java           |  70 --------
 .../java8/datastructures/package-info.java      |  22 ---
 .../examples/java8/events/EventsExample.java    | 135 ---------------
 .../examples/java8/events/package-info.java     |  22 ---
 .../java8/messaging/MessagingExample.java       | 166 ------------------
 .../messaging/MessagingPingPongExample.java     | 113 ------------
 .../examples/java8/messaging/package-info.java  |  22 ---
 .../misc/schedule/ComputeScheduleExample.java   |  68 --------
 .../java8/misc/schedule/package-info.java       |  22 ---
 .../streaming/StreamTransformerExample.java     | 101 -----------
 .../java8/streaming/StreamVisitorExample.java   | 172 -------------------
 .../examples/java8/streaming/package-info.java  |  22 ---
 examples/config/hibernate/README.txt            |   8 -
 .../hibernate/example-hibernate-L2-cache.xml    |  64 -------
 pom.xml                                         | 132 +++++++-------
 32 files changed, 66 insertions(+), 2184 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/config/filesystem/README.txt
----------------------------------------------------------------------
diff --git a/examples-lgpl/config/filesystem/README.txt b/examples-lgpl/config/filesystem/README.txt
deleted file mode 100644
index 4f6ae88..0000000
--- a/examples-lgpl/config/filesystem/README.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-FileSystem Configuration Example
---------------------------------
-
-This folder contains configuration files for IgniteFs examples located in
-org.apache.ignite.examples.igfs package.
-
-- example-igfs.xml file is used to start Apache Ignite nodes with IgniteFS configured
-- core-site.xml file is used to run Hadoop FS driver over IgniteFs

http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/config/filesystem/core-site.xml
----------------------------------------------------------------------
diff --git a/examples-lgpl/config/filesystem/core-site.xml b/examples-lgpl/config/filesystem/core-site.xml
deleted file mode 100644
index a7a027c..0000000
--- a/examples-lgpl/config/filesystem/core-site.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<?xml version="1.0"?>
-<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
-
-<!--
-  ~  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.
-  -->
-
-<!--
-    Example configuration of the Hadoop FS driver over Ignite FS API.
-    Copy this file into '$HADOOP_HOME/conf/core-site.xml'.
--->
-<configuration>
-    <property>
-        <name>fs.default.name</name>
-        <value>igfs:///</value>
-    </property>
-
-    <property>
-        <!-- FS driver class for the 'igfs://' URIs. -->
-        <name>fs.igfs.impl</name>
-        <value>org.apache.ignite.hadoop.fs.v1.IgniteHadoopFileSystem</value>
-    </property>
-
-    <property>
-        <!-- FS driver class for the 'igfs://' URIs in Hadoop2.x -->
-        <name>fs.AbstractFileSystem.igfs.impl</name>
-        <value>org.apache.ignite.hadoop.fs.v2.IgniteHadoopFileSystem</value>
-    </property>
-</configuration>

http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/config/filesystem/example-igfs.xml
----------------------------------------------------------------------
diff --git a/examples-lgpl/config/filesystem/example-igfs.xml b/examples-lgpl/config/filesystem/example-igfs.xml
deleted file mode 100644
index d009d46..0000000
--- a/examples-lgpl/config/filesystem/example-igfs.xml
+++ /dev/null
@@ -1,151 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-  ~  Licensed to the Apache Software Foundation (ASF) under one or more
-  ~  contributor license agreements.  See the NOTICE file distributed with
-  ~  this work for additional information regarding copyright ownership.
-  ~  The ASF licenses this file to You under the Apache License, Version 2.0
-  ~  (the "License"); you may not use this file except in compliance with
-  ~  the License.  You may obtain a copy of the License at
-  ~
-  ~       http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~  Unless required by applicable law or agreed to in writing, software
-  ~  distributed under the License is distributed on an "AS IS" BASIS,
-  ~  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  ~  See the License for the specific language governing permissions and
-  ~  limitations under the License.
-  -->
-
-<!--
-    Ignite Spring configuration file to startup ignite cache.
-
-    When starting a standalone node, you need to execute the following command:
-    {IGNITE_HOME}/bin/ignite.{bat|sh} examples/config/filesystem/example-igfs.xml
-
-    When starting Ignite from Java IDE, pass path to this file into Ignition:
-    Ignition.start("examples/config/filesystem/example-igfs.xml");
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-       xsi:schemaLocation="http://www.springframework.org/schema/beans
-       http://www.springframework.org/schema/beans/spring-beans.xsd">
-
-    <!--
-        Optional description.
-    -->
-    <description>
-        Spring file for ignite configuration with client available endpoints.
-    </description>
-
-    <!--
-        Initialize property configurer so we can reference environment variables.
-    -->
-    <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
-        <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_FALLBACK"/>
-        <property name="searchSystemEnvironment" value="true"/>
-    </bean>
-
-    <!--
-        Configuration below demonstrates how to setup a IgniteFs node with file data.
-    -->
-    <bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
-        <!-- Set to true to enable cluster-aware class loading for examples, default is false. -->
-        <property name="peerClassLoadingEnabled" value="true"/>
-
-        <property name="marshaller">
-            <bean class="org.apache.ignite.marshaller.optimized.OptimizedMarshaller">
-                <!-- Set to false to allow non-serializable objects in examples, default is true. -->
-                <property name="requireSerializable" value="false"/>
-            </bean>
-        </property>
-
-        <property name="fileSystemConfiguration">
-            <list>
-                <bean class="org.apache.ignite.configuration.FileSystemConfiguration">
-                    <property name="name" value="igfs"/>
-                    <property name="metaCacheName" value="igfs-meta"/>
-                    <property name="dataCacheName" value="igfs-data"/>
-
-                    <!-- Must correlate with cache affinity mapper. -->
-                    <property name="blockSize" value="#{128 * 1024}"/>
-                    <property name="perNodeBatchSize" value="512"/>
-                    <property name="perNodeParallelBatchCount" value="16"/>
-
-                    <!-- Set number of prefetch blocks. -->
-                    <property name="prefetchBlocks" value="32"/>
-
-                    <!--
-                        Example of configured IPC loopback endpoint.
-                    -->
-                    <!--
-                    <property name="ipcEndpointConfiguration">
-                        <bean class="org.apache.ignite.igfs.IgfsIpcEndpointConfiguration">
-                            <property name="type" value="TCP" />
-                        </bean>
-                    </property>
-                    -->
-
-                    <!--
-                        Example of configured shared memory endpoint.
-                    -->
-                    <!--
-                    <property name="ipcEndpointConfiguration">
-                        <bean class="org.apache.ignite.igfs.IgfsIpcEndpointConfiguration">
-                            <property name="type" value="SHMEM" />
-                        </bean>
-                    </property>
-                    -->
-                </bean>
-            </list>
-        </property>
-
-        <property name="cacheConfiguration">
-            <list>
-                <bean class="org.apache.ignite.configuration.CacheConfiguration">
-                    <property name="name" value="igfs-data"/>
-                    <property name="cacheMode" value="PARTITIONED"/>
-                    <property name="atomicityMode" value="TRANSACTIONAL"/>
-                    <property name="writeSynchronizationMode" value="FULL_SYNC"/>
-                    <property name="backups" value="0"/>
-                    <property name="affinityMapper">
-                        <bean class="org.apache.ignite.igfs.IgfsGroupDataBlocksKeyMapper">
-                            <!-- Haw many blocks in row will be stored on the same node. -->
-                            <constructor-arg value="512"/>
-                        </bean>
-                    </property>
-                </bean>
-
-                <bean class="org.apache.ignite.configuration.CacheConfiguration">
-                    <property name="name" value="igfs-meta"/>
-                    <property name="cacheMode" value="REPLICATED"/>
-                    <property name="atomicityMode" value="TRANSACTIONAL"/>
-                    <property name="writeSynchronizationMode" value="FULL_SYNC"/>
-                </bean>
-            </list>
-        </property>
-
-        <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
-        <property name="discoverySpi">
-            <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
-                <property name="ipFinder">
-                    <!--
-                        Ignition provides several options for automatic discovery that can be used
-                        instead os static IP based discovery. For information on all options refer
-                        to our documentation: http://apacheignite.readme.io/docs/cluster-config
-                    -->
-                    <!-- Uncomment static IP finder to enable static-based discovery of initial nodes. -->
-                    <!--<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">-->
-                    <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
-                        <property name="addresses">
-                            <list>
-                                <!-- In distributed environment, replace with actual host IP address. -->
-                                <value>127.0.0.1:47500..47509</value>
-                            </list>
-                        </property>
-                    </bean>
-                </property>
-            </bean>
-        </property>
-    </bean>
-</beans>

http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/config/servlet/README.txt
----------------------------------------------------------------------
diff --git a/examples-lgpl/config/servlet/README.txt b/examples-lgpl/config/servlet/README.txt
deleted file mode 100644
index 20d4b90..0000000
--- a/examples-lgpl/config/servlet/README.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-Servlet Configuration Example
------------------------------
-
-This folder contains web.xml file that demonstrates how to configure any servlet container
-to start a Apache Ignite node inside a Web application.
-
-For more information on available configuration properties, etc. refer to our documentation:
-http://apacheignite.readme.io/docs/web-session-clustering

http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/config/servlet/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/examples-lgpl/config/servlet/WEB-INF/web.xml b/examples-lgpl/config/servlet/WEB-INF/web.xml
deleted file mode 100644
index de4b3a0..0000000
--- a/examples-lgpl/config/servlet/WEB-INF/web.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<?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.
-  -->
-
-<!--
-    Example web.xml to startup Ignite from Servlet container, like Tomcat.
--->
-<web-app xmlns="http://java.sun.com/xml/ns/javaee"
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
-                             http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
-         version="3.0">
-    <context-param>
-        <param-name>IgniteConfigurationFilePath</param-name>
-        <param-value>config/default-config.xml</param-value>
-    </context-param>
-
-    <listener>
-        <listener-class>org.apache.ignite.startup.servlet.ServletContextListenerStartup</listener-class>
-    </listener>
-</web-app>

http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/cluster/ClusterGroupExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/cluster/ClusterGroupExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/cluster/ClusterGroupExample.java
deleted file mode 100644
index caea8a7..0000000
--- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/cluster/ClusterGroupExample.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-
-package org.apache.ignite.examples.java8.cluster;
-
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCluster;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cluster.ClusterGroup;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.examples.ExamplesUtils;
-
-/**
- * Demonstrates new functional APIs.
- * <p>
- * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
- * with {@code examples/config/example-ignite.xml} configuration.
- */
-public class ClusterGroupExample {
-    /**
-     * Executes example.
-     *
-     * @param args Command line arguments, none required.
-     * @throws IgniteException If example execution failed.
-     */
-    public static void main(String[] args) throws IgniteException {
-        try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
-            if (!ExamplesUtils.checkMinTopologySize(ignite.cluster(), 2))
-                return;
-
-            System.out.println();
-            System.out.println("Compute example started.");
-
-            IgniteCluster cluster = ignite.cluster();
-
-            // Say hello to all nodes in the cluster, including local node.
-            sayHello(ignite, cluster);
-
-            // Say hello to all remote nodes.
-            sayHello(ignite, cluster.forRemotes());
-
-            // Pick random node out of remote nodes.
-            ClusterGroup randomNode = cluster.forRemotes().forRandom();
-
-            // Say hello to a random node.
-            sayHello(ignite, randomNode);
-
-            // Say hello to all nodes residing on the same host with random node.
-            sayHello(ignite, cluster.forHost(randomNode.node()));
-
-            // Say hello to all nodes that have current CPU load less than 50%.
-            sayHello(ignite, cluster.forPredicate(n -> n.metrics().getCurrentCpuLoad() < 0.5));
-        }
-    }
-
-    /**
-     * Print 'Hello' message on remote nodes.
-     *
-     * @param ignite Ignite.
-     * @param grp Cluster group.
-     * @throws IgniteException If failed.
-     */
-    private static void sayHello(Ignite ignite, final ClusterGroup grp) throws IgniteException {
-        // Print out hello message on all cluster nodes.
-        ignite.compute(grp).broadcast(
-            () -> System.out.println(">>> Hello Node: " + grp.ignite().cluster().localNode().id()));
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/cluster/package-info.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/cluster/package-info.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/cluster/package-info.java
deleted file mode 100644
index b96e98a..0000000
--- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/cluster/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-
-/**
- * <!-- Package description. -->
- * Cluster group example.
- */
-package org.apache.ignite.examples.java8.cluster;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeAsyncExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeAsyncExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeAsyncExample.java
deleted file mode 100644
index 8d9cc64..0000000
--- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeAsyncExample.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-
-package org.apache.ignite.examples.java8.computegrid;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCompute;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.lang.IgniteFuture;
-import org.apache.ignite.lang.IgniteRunnable;
-
-/**
- * Demonstrates a simple use of {@link IgniteRunnable}.
- * <p>
- * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
- * with {@code examples/config/example-ignite.xml} configuration.
- */
-public class ComputeAsyncExample {
-    /**
-     * Executes example.
-     *
-     * @param args Command line arguments, none required.
-     * @throws IgniteException If example execution failed.
-     */
-    public static void main(String[] args) throws IgniteException {
-        try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
-            System.out.println();
-            System.out.println("Compute asynchronous example started.");
-
-            // Enable asynchronous mode.
-            IgniteCompute compute = ignite.compute().withAsync();
-
-            Collection<IgniteFuture<?>> futs = new ArrayList<>();
-
-            // Iterate through all words in the sentence and create runnable jobs.
-            for (final String word : "Print words using runnable".split(" ")) {
-                // Execute runnable on some node.
-                compute.run(() -> {
-                    System.out.println();
-                    System.out.println(">>> Printing '" + word + "' on this node from ignite job.");
-                });
-
-                futs.add(compute.future());
-            }
-
-            // Wait for completion of all futures.
-            futs.forEach(IgniteFuture::get);
-
-            System.out.println();
-            System.out.println(">>> Finished printing words using runnable execution.");
-            System.out.println(">>> Check all nodes for output (this node is also part of the cluster).");
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeBroadcastExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeBroadcastExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeBroadcastExample.java
deleted file mode 100644
index 1aed33b..0000000
--- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeBroadcastExample.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-
-package org.apache.ignite.examples.java8.computegrid;
-
-import java.util.Collection;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ExampleNodeStartup;
-
-/**
- * Demonstrates broadcasting computations within cluster.
- * <p>
- * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
- * with {@code examples/config/example-ignite.xml} configuration.
- */
-public class ComputeBroadcastExample {
-    /**
-     * Executes example.
-     *
-     * @param args Command line arguments, none required.
-     * @throws IgniteException If example execution failed.
-     */
-    public static void main(String[] args) throws IgniteException {
-        try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
-            System.out.println();
-            System.out.println(">>> Compute broadcast example started.");
-
-            // Print hello message on all nodes.
-            hello(ignite);
-
-            // Gather system info from all nodes.
-            gatherSystemInfo(ignite);
-       }
-    }
-
-    /**
-     * Print 'Hello' message on all nodes.
-     *
-     * @param ignite Ignite instance.
-     * @throws IgniteException If failed.
-     */
-    private static void hello(Ignite ignite) throws IgniteException {
-        // Print out hello message on all nodes.
-        ignite.compute().broadcast(() -> {
-            System.out.println();
-            System.out.println(">>> Hello Node! :)");
-        });
-
-        System.out.println();
-        System.out.println(">>> Check all nodes for hello message output.");
-    }
-
-    /**
-     * Gather system info from all nodes and print it out.
-     *
-     * @param ignite Ignite instance.
-     * @throws IgniteException if failed.
-     */
-    private static void gatherSystemInfo(Ignite ignite) throws IgniteException {
-        // Gather system info from all nodes.
-        Collection<String> res = ignite.compute().broadcast(() -> {
-            System.out.println();
-            System.out.println("Executing task on node: " + ignite.cluster().localNode().id());
-
-            return "Node ID: " + ignite.cluster().localNode().id() + "\n" +
-                "OS: " + System.getProperty("os.name") + " " + System.getProperty("os.version") + " " +
-                System.getProperty("os.arch") + "\n" +
-                "User: " + System.getProperty("user.name") + "\n" +
-                "JRE: " + System.getProperty("java.runtime.name") + " " +
-                System.getProperty("java.runtime.version");
-        });
-
-        // Print result.
-        System.out.println();
-        System.out.println("Nodes system information:");
-        System.out.println();
-
-        res.forEach(r -> {
-            System.out.println(r);
-            System.out.println();
-        });
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeCallableExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeCallableExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeCallableExample.java
deleted file mode 100644
index cadb447..0000000
--- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeCallableExample.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-
-package org.apache.ignite.examples.java8.computegrid;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.lang.IgniteCallable;
-
-/**
- * Demonstrates using of {@link IgniteCallable} job execution on the cluster.
- * <p>
- * This example takes a sentence composed of multiple words and counts number of non-space
- * characters in the sentence by having each compute job count characters in each individual
- * word.
- * <p>
- * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
- * with {@code examples/config/example-ignite.xml} configuration.
- */
-public class ComputeCallableExample {
-    /**
-     * Executes example.
-     *
-     * @param args Command line arguments, none required.
-     * @throws IgniteException If example execution failed.
-     */
-    public static void main(String[] args) throws IgniteException {
-        try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
-            System.out.println();
-            System.out.println(">>> Compute callable example started.");
-
-            Collection<IgniteCallable<Integer>> calls = new ArrayList<>();
-
-            // Iterate through all words in the sentence and create callable jobs.
-            for (String word : "Count characters using callable".split(" ")) {
-                calls.add(() -> {
-                    System.out.println();
-                    System.out.println(">>> Printing '" + word + "' on this node from ignite job.");
-
-                    return word.length();
-                });
-            }
-
-            // Execute collection of callables on the ignite.
-            Collection<Integer> res = ignite.compute().call(calls);
-
-            int sum = res.stream().mapToInt(i -> i).sum();
-
-            System.out.println();
-            System.out.println(">>> Total number of characters in the phrase is '" + sum + "'.");
-            System.out.println(">>> Check all nodes for output (this node is also part of the cluster).");
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeClosureExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeClosureExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeClosureExample.java
deleted file mode 100644
index c4d3c94..0000000
--- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeClosureExample.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-
-package org.apache.ignite.examples.java8.computegrid;
-
-import java.util.Arrays;
-import java.util.Collection;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ExampleNodeStartup;
-
-/**
- * Demonstrates a simple use of Ignite with reduce closure.
- * <p>
- * This example splits a phrase into collection of words, computes their length on different
- * nodes and then computes total amount of non-whitespaces characters in the phrase.
- * <p>
- * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
- * with {@code examples/config/example-ignite.xml} configuration.
- */
-public class ComputeClosureExample {
-    /**
-     * Executes example.
-     *
-     * @param args Command line arguments, none required.
-     * @throws IgniteException If example execution failed.
-     */
-    public static void main(String[] args) throws IgniteException {
-        try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
-            System.out.println();
-            System.out.println(">>> Compute closure example started.");
-
-            // Execute closure on all cluster nodes.
-            Collection<Integer> res = ignite.compute().apply(
-                (String word) -> {
-                    System.out.println();
-                    System.out.println(">>> Printing '" + word + "' on this node from ignite job.");
-
-                    // Return number of letters in the word.
-                    return word.length();
-                },
-                // Job parameters. Ignite will create as many jobs as there are parameters.
-                Arrays.asList("Count characters using closure".split(" "))
-            );
-
-            int sum = res.stream().mapToInt(i -> i).sum();
-
-            System.out.println();
-            System.out.println(">>> Total number of characters in the phrase is '" + sum + "'.");
-            System.out.println(">>> Check all nodes for output (this node is also part of the cluster).");
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeRunnableExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeRunnableExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeRunnableExample.java
deleted file mode 100644
index acb9893..0000000
--- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeRunnableExample.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-
-package org.apache.ignite.examples.java8.computegrid;
-
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCompute;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.lang.IgniteRunnable;
-
-/**
- * Demonstrates a simple use of {@link IgniteRunnable}.
- * <p>
- * Remote nodes should always be 0started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
- * with {@code examples/config/example-ignite.xml} configuration.
- */
-public class ComputeRunnableExample {
-    /**
-     * Executes example.
-     *
-     * @param args Command line arguments, none required.
-     * @throws IgniteException If example execution failed.
-     */
-    public static void main(String[] args) throws IgniteException {
-        try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
-            System.out.println();
-            System.out.println("Compute runnable example started.");
-
-            IgniteCompute compute = ignite.compute();
-
-            // Iterate through all words in the sentence and create runnable jobs.
-            for (final String word : "Print words using runnable".split(" ")) {
-                // Execute runnable on some node.
-                compute.run(() -> {
-                    System.out.println();
-                    System.out.println(">>> Printing '" + word + "' on this node from ignite job.");
-                });
-            }
-
-            System.out.println();
-            System.out.println(">>> Finished printing words using runnable execution.");
-            System.out.println(">>> Check all nodes for output (this node is also part of the cluster).");
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/package-info.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/package-info.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/package-info.java
deleted file mode 100644
index cda49ef..0000000
--- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-
-/**
- * <!-- Package description. -->
- * Basic examples for computational ignite functionality.
- */
-package org.apache.ignite.examples.java8.computegrid;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAffinityExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAffinityExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAffinityExample.java
deleted file mode 100644
index f4a3b03..0000000
--- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAffinityExample.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-
-package org.apache.ignite.examples.java8.datagrid;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Map;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteCluster;
-import org.apache.ignite.IgniteCompute;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.CacheMode;
-import org.apache.ignite.cluster.ClusterNode;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.lang.IgniteRunnable;
-
-/**
- * This example demonstrates the simplest code that populates the distributed cache
- * and co-locates simple closure execution with each key. The goal of this particular
- * example is to provide the simplest code example of this logic.
- * <p>
- * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will
- * start node with {@code examples/config/example-ignite.xml} configuration.
- */
-public final class CacheAffinityExample {
-    /** Cache name. */
-    private static final String CACHE_NAME = CacheAffinityExample.class.getSimpleName();
-
-    /** Number of keys. */
-    private static final int KEY_CNT = 20;
-
-    /**
-     * Executes example.
-     *
-     * @param args Command line arguments, none required.
-     * @throws IgniteException If example execution failed.
-     */
-    public static void main(String[] args) throws IgniteException {
-        try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
-            System.out.println();
-            System.out.println(">>> Cache affinity example started.");
-
-            CacheConfiguration<Integer, String> cfg = new CacheConfiguration<>();
-
-            cfg.setCacheMode(CacheMode.PARTITIONED);
-            cfg.setName(CACHE_NAME);
-
-            try (IgniteCache<Integer, String> cache = ignite.getOrCreateCache(cfg)) {
-                for (int i = 0; i < KEY_CNT; i++)
-                    cache.put(i, Integer.toString(i));
-
-                // Co-locates jobs with data using IgniteCompute.affinityRun(...) method.
-                visitUsingAffinityRun();
-
-                // Co-locates jobs with data using IgniteCluster.mapKeysToNodes(...) method.
-                visitUsingMapKeysToNodes();
-            }
-        }
-    }
-
-    /**
-     * Collocates jobs with keys they need to work on using
-     * {@link IgniteCompute#affinityRun(String, Object, IgniteRunnable)} method.
-     */
-    private static void visitUsingAffinityRun() {
-        Ignite ignite = Ignition.ignite();
-
-        final IgniteCache<Integer, String> cache = ignite.cache(CACHE_NAME);
-
-        for (int i = 0; i < KEY_CNT; i++) {
-            int key = i;
-
-            // This runnable will execute on the remote node where
-            // data with the given key is located. Since it will be co-located
-            // we can use local 'peek' operation safely.
-            ignite.compute().affinityRun(CACHE_NAME, key,
-                () -> System.out.println("Co-located using affinityRun [key= " + key + ", value=" + cache.localPeek(key) + ']'));
-        }
-    }
-
-    /**
-     * Collocates jobs with keys they need to work on using {@link IgniteCluster#mapKeysToNodes(String, Collection)}
-     * method. The difference from {@code affinityRun(...)} method is that here we process multiple keys
-     * in a single job.
-     */
-    private static void visitUsingMapKeysToNodes() {
-        final Ignite ignite = Ignition.ignite();
-
-        Collection<Integer> keys = new ArrayList<>(KEY_CNT);
-
-        for (int i = 0; i < KEY_CNT; i++)
-            keys.add(i);
-
-        // Map all keys to nodes.
-        Map<ClusterNode, Collection<Integer>> mappings = ignite.cluster().mapKeysToNodes(CACHE_NAME, keys);
-
-        for (Map.Entry<ClusterNode, Collection<Integer>> mapping : mappings.entrySet()) {
-            ClusterNode node = mapping.getKey();
-
-            final Collection<Integer> mappedKeys = mapping.getValue();
-
-            if (node != null) {
-                // Bring computations to the nodes where the data resides (i.e. collocation).
-                ignite.compute(ignite.cluster().forNode(node)).run(() -> {
-                    IgniteCache<Integer, String> cache = ignite.cache(CACHE_NAME);
-
-                    // Peek is a local memory lookup, however, value should never be 'null'
-                    // as we are co-located with node that has a given key.
-                    for (Integer key : mappedKeys)
-                        System.out.println("Co-located using mapKeysToNodes [key= " + key +
-                            ", value=" + cache.localPeek(key) + ']');
-                });
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheApiExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheApiExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheApiExample.java
deleted file mode 100644
index 1891a35..0000000
--- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheApiExample.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-
-package org.apache.ignite.examples.java8.datagrid;
-
-import java.util.concurrent.ConcurrentMap;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.CacheMode;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.examples.ExampleNodeStartup;
-
-/**
- * This example demonstrates some of the cache rich API capabilities.
- * <p>
- * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will
- * start node with {@code examples/config/example-ignite.xml} configuration.
- */
-public class CacheApiExample {
-    /** Cache name. */
-    private static final String CACHE_NAME = CacheApiExample.class.getSimpleName();
-
-    /**
-     * Executes example.
-     *
-     * @param args Command line arguments, none required.
-     * @throws IgniteException If example execution failed.
-     */
-    public static void main(String[] args) throws IgniteException {
-        try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
-            System.out.println();
-            System.out.println(">>> Cache API example started.");
-
-            CacheConfiguration<Integer, String> cfg = new CacheConfiguration<>();
-
-            cfg.setCacheMode(CacheMode.PARTITIONED);
-            cfg.setName(CACHE_NAME);
-
-            try (IgniteCache<Integer, String> cache = ignite.getOrCreateCache(cfg)) {
-                // Demonstrate atomic map operations.
-                atomicMapOperations(cache);
-            }
-        }
-    }
-
-    /**
-     * Demonstrates cache operations similar to {@link ConcurrentMap} API. Note that
-     * cache API is a lot richer than the JDK {@link ConcurrentMap}.
-     *
-     * @throws IgniteException If failed.
-     */
-    private static void atomicMapOperations(final IgniteCache<Integer, String> cache) throws IgniteException {
-        System.out.println();
-        System.out.println(">>> Cache atomic map operation examples.");
-
-        // Put and return previous value.
-        String v = cache.getAndPut(1, "1");
-        assert v == null;
-
-        // Put and do not return previous value (all methods ending with 'x' return boolean).
-        // Performs better when previous value is not needed.
-        cache.put(2, "2");
-
-        // Put-if-absent.
-        boolean b1 = cache.putIfAbsent(4, "4");
-        boolean b2 = cache.putIfAbsent(4, "44");
-        assert b1 && !b2;
-
-        // Invoke - assign new value based on previous value.
-        cache.put(6, "6");
-
-        cache.invoke(6, (entry, args) -> {
-            String val = entry.getValue();
-
-            entry.setValue(val + "6"); // Set new value based on previous value.
-
-            return null;
-        });
-
-        // Replace.
-        cache.put(7, "7");
-        b1 = cache.replace(7, "7", "77");
-        b2 = cache.replace(7, "7", "777");
-        assert b1 & !b2;
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAsyncApiExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAsyncApiExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAsyncApiExample.java
deleted file mode 100644
index b457b27..0000000
--- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAsyncApiExample.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-
-package org.apache.ignite.examples.java8.datagrid;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.CacheMode;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.lang.IgniteFuture;
-
-/**
- * This example demonstrates some of the cache rich API capabilities.
- * <p>
- * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will
- * start node with {@code examples/config/example-ignite.xml} configuration.
- */
-public class CacheAsyncApiExample {
-    /** Cache name. */
-    private static final String CACHE_NAME = CacheAsyncApiExample.class.getSimpleName();
-
-    /**
-     * Executes example.
-     *
-     * @param args Command line arguments, none required.
-     * @throws IgniteException If example execution failed.
-     */
-    public static void main(String[] args) throws IgniteException {
-        try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
-            System.out.println();
-            System.out.println(">>> Cache asynchronous API example started.");
-
-            CacheConfiguration<Integer, String> cfg = new CacheConfiguration<>();
-
-            cfg.setCacheMode(CacheMode.PARTITIONED);
-            cfg.setName(CACHE_NAME);
-
-            try (IgniteCache<Integer, String> cache = ignite.getOrCreateCache(cfg)) {
-                // Enable asynchronous mode.
-                IgniteCache<Integer, String> asyncCache = cache.withAsync();
-
-                Collection<IgniteFuture<?>> futs = new ArrayList<>();
-
-                // Execute several puts asynchronously.
-                for (int i = 0; i < 10; i++) {
-                    asyncCache.put(i, String.valueOf(i));
-
-                    futs.add(asyncCache.future());
-                }
-
-                // Wait for completion of all futures.
-                futs.forEach(IgniteFuture::get);
-
-                // Execute get operation asynchronously.
-                asyncCache.get(1);
-
-                // Asynchronously wait for result.
-                asyncCache.<String>future().listen(fut ->
-                    System.out.println("Get operation completed [value=" + fut.get() + ']'));
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/package-info.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/package-info.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/package-info.java
deleted file mode 100644
index 0bd86a0..0000000
--- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-
-/**
- * <!-- Package description. -->
- * Demonstrates data ignite cache usage.
- */
-package org.apache.ignite.examples.java8.datagrid;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datastructures/IgniteExecutorServiceExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datastructures/IgniteExecutorServiceExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datastructures/IgniteExecutorServiceExample.java
deleted file mode 100644
index 0155144..0000000
--- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datastructures/IgniteExecutorServiceExample.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-
-package org.apache.ignite.examples.java8.datastructures;
-
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.TimeUnit;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.lang.IgniteRunnable;
-
-/**
- * Simple example to demonstrate usage of distributed executor service provided by Ignite.
- * <p>
- * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
- * with {@code examples/config/example-ignite.xml} configuration.
- */
-public final class IgniteExecutorServiceExample {
-    /**
-     * Executes example.
-     *
-     * @param args Command line arguments, none required.
-     * @throws Exception If example execution failed.
-     */
-    @SuppressWarnings({"TooBroadScope"})
-    public static void main(String[] args) throws Exception {
-        try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
-            System.out.println();
-            System.out.println(">>> Compute executor service example started.");
-
-            // Get ignite-enabled executor service.
-            ExecutorService exec = ignite.executorService();
-
-            // Iterate through all words in the sentence and create callable jobs.
-            for (final String word : "Print words using runnable".split(" ")) {
-                // Execute runnable on some node.
-                exec.submit((IgniteRunnable)() -> {
-                    System.out.println();
-                    System.out.println(">>> Printing '" + word + "' on this node from ignite job.");
-                });
-            }
-
-            exec.shutdown();
-
-            // Wait for all jobs to complete (0 means no limit).
-            exec.awaitTermination(0, TimeUnit.MILLISECONDS);
-
-            System.out.println();
-            System.out.println(">>> Check all nodes for output (this node is also part of the cluster).");
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datastructures/package-info.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datastructures/package-info.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datastructures/package-info.java
deleted file mode 100644
index 86f3423..0000000
--- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datastructures/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-
-/**
- * <!-- Package description. -->
- * Demonstrates using of blocking and non-blocking queues and atomic data structures.
- */
-package org.apache.ignite.examples.java8.datastructures;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/events/EventsExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/events/EventsExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/events/EventsExample.java
deleted file mode 100644
index df2d52b..0000000
--- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/events/EventsExample.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-
-package org.apache.ignite.examples.java8.events;
-
-import java.util.UUID;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.compute.ComputeTaskSession;
-import org.apache.ignite.events.TaskEvent;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.lang.IgniteBiPredicate;
-import org.apache.ignite.lang.IgnitePredicate;
-import org.apache.ignite.lang.IgniteRunnable;
-import org.apache.ignite.resources.TaskSessionResource;
-
-import static org.apache.ignite.events.EventType.EVTS_TASK_EXECUTION;
-
-/**
- * Demonstrates event consume API that allows to register event listeners on remote nodes.
- * Note that ignite events are disabled by default and must be specifically enabled,
- * just like in {@code examples/config/example-ignite.xml} file.
- * <p>
- * Remote nodes should always be started with configuration: {@code 'ignite.sh examples/config/example-ignite.xml'}.
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start
- * node with {@code examples/config/example-ignite.xml} configuration.
- */
-public class EventsExample {
-    /**
-     * Executes example.
-     *
-     * @param args Command line arguments, none required.
-     * @throws Exception If example execution failed.
-     */
-    public static void main(String[] args) throws Exception {
-        try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
-            System.out.println();
-            System.out.println(">>> Events API example started.");
-
-            // Listen to events happening on local node.
-            localListen();
-
-            // Listen to events happening on all cluster nodes.
-            remoteListen();
-
-            // Wait for a while while callback is notified about remaining puts.
-            Thread.sleep(1000);
-        }
-    }
-
-    /**
-     * Listen to events that happen only on local node.
-     *
-     * @throws IgniteException If failed.
-     */
-    private static void localListen() throws IgniteException {
-        System.out.println();
-        System.out.println(">>> Local event listener example.");
-
-        Ignite ignite = Ignition.ignite();
-
-        IgnitePredicate<TaskEvent> lsnr = evt -> {
-            System.out.println("Received task event [evt=" + evt.name() + ", taskName=" + evt.taskName() + ']');
-
-            return true; // Return true to continue listening.
-        };
-
-        // Register event listener for all local task execution events.
-        ignite.events().localListen(lsnr, EVTS_TASK_EXECUTION);
-
-        // Generate task events.
-        ignite.compute().withName("example-event-task").run(() -> System.out.println("Executing sample job."));
-
-        // Unsubscribe local task event listener.
-        ignite.events().stopLocalListen(lsnr);
-    }
-
-    /**
-     * Listen to events coming from all cluster nodes.
-     *
-     * @throws IgniteException If failed.
-     */
-    private static void remoteListen() throws IgniteException {
-        System.out.println();
-        System.out.println(">>> Remote event listener example.");
-
-        // This optional local callback is called for each event notification
-        // that passed remote predicate listener.
-        IgniteBiPredicate<UUID, TaskEvent> locLsnr = (nodeId, evt) -> {
-            // Remote filter only accepts tasks whose name being with "good-task" prefix.
-            assert evt.taskName().startsWith("good-task");
-
-            System.out.println("Received task event [evt=" + evt.name() + ", taskName=" + evt.taskName());
-
-            return true; // Return true to continue listening.
-        };
-
-        // Remote filter which only accepts tasks whose name begins with "good-task" prefix.
-        IgnitePredicate<TaskEvent> rmtLsnr = evt -> evt.taskName().startsWith("good-task");
-
-        Ignite ignite = Ignition.ignite();
-
-        // Register event listeners on all nodes to listen for task events.
-        ignite.events().remoteListen(locLsnr, rmtLsnr, EVTS_TASK_EXECUTION);
-
-        // Generate task events.
-        for (int i = 0; i < 10; i++) {
-            ignite.compute().withName(i < 5 ? "good-task-" + i : "bad-task-" + i).run(new IgniteRunnable() {
-                // Auto-inject task session.
-                @TaskSessionResource
-                private ComputeTaskSession ses;
-
-                @Override public void run() {
-                    System.out.println("Executing sample job for task: " + ses.getTaskName());
-                }
-            });
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/events/package-info.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/events/package-info.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/events/package-info.java
deleted file mode 100644
index b402e78..0000000
--- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/events/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-
-/**
- * <!-- Package description. -->
- * Demonstrates events management API.
- */
-package org.apache.ignite.examples.java8.events;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingExample.java
deleted file mode 100644
index 8b88708..0000000
--- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingExample.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-
-package org.apache.ignite.examples.java8.messaging;
-
-import java.util.concurrent.CountDownLatch;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.IgniteMessaging;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cluster.ClusterGroup;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.examples.ExamplesUtils;
-
-/**
- * Example that demonstrates how to exchange messages between nodes. Use such
- * functionality for cases when you need to communicate to other nodes outside
- * of ignite task.
- * <p>
- * To run this example you must have at least one remote node started.
- * <p>
- * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
- * with {@code examples/config/example-ignite.xml} configuration.
- */
-public final class MessagingExample {
-    /** Number of messages. */
-    private static final int MESSAGES_NUM = 10;
-
-    /** Message topics. */
-    private enum TOPIC { ORDERED, UNORDERED }
-
-    /**
-     * Executes example.
-     *
-     * @param args Command line arguments, none required.
-     * @throws IgniteException If example execution failed.
-     */
-    public static void main(String[] args) throws Exception {
-        try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
-            if (!ExamplesUtils.checkMinTopologySize(ignite.cluster(), 2)) {
-                System.out.println();
-                System.out.println(">>> Please start at least 2 cluster nodes to run example.");
-                System.out.println();
-
-                return;
-            }
-
-            System.out.println();
-            System.out.println(">>> Messaging example started.");
-
-            // Group for remote nodes.
-            ClusterGroup rmtGrp = ignite.cluster().forRemotes();
-
-            // Listen for messages from remote nodes to make sure that they received all the messages.
-            int msgCnt = rmtGrp.nodes().size() * MESSAGES_NUM;
-
-            CountDownLatch orderedLatch = new CountDownLatch(msgCnt);
-            CountDownLatch unorderedLatch = new CountDownLatch(msgCnt);
-
-            localListen(ignite.message(ignite.cluster().forLocal()), orderedLatch, unorderedLatch);
-
-            // Register listeners on all cluster nodes.
-            startListening(ignite, ignite.message(rmtGrp));
-
-            // Send unordered messages to all remote nodes.
-            for (int i = 0; i < MESSAGES_NUM; i++)
-                ignite.message(rmtGrp).send(TOPIC.UNORDERED, Integer.toString(i));
-
-            System.out.println(">>> Finished sending unordered messages.");
-
-            // Send ordered messages to all remote nodes.
-            for (int i = 0; i < MESSAGES_NUM; i++)
-                ignite.message(rmtGrp).sendOrdered(TOPIC.ORDERED, Integer.toString(i), 0);
-
-            System.out.println(">>> Finished sending ordered messages.");
-            System.out.println(">>> Check output on all nodes for message printouts.");
-            System.out.println(">>> Will wait for messages acknowledgements from all remote nodes.");
-
-            orderedLatch.await();
-            unorderedLatch.await();
-
-            System.out.println(">>> Messaging example finished.");
-        }
-    }
-
-    /**
-     * Start listening to messages on remote cluster nodes.
-     *
-     * @param ignite Ignite.
-     * @param imsg Ignite messaging.
-     * @throws IgniteException If failed.
-     */
-    private static void startListening(final Ignite ignite, IgniteMessaging imsg) throws IgniteException {
-        // Add ordered message listener.
-        imsg.remoteListen(TOPIC.ORDERED, (nodeId, msg) -> {
-            System.out.println("Received ordered message [msg=" + msg + ", fromNodeId=" + nodeId + ']');
-
-            try {
-                ignite.message(ignite.cluster().forNodeId(nodeId)).send(TOPIC.ORDERED, msg);
-            }
-            catch (IgniteException e) {
-                e.printStackTrace();
-            }
-
-            return true; // Return true to continue listening.
-        });
-
-        // Add unordered message listener.
-        imsg.remoteListen(TOPIC.UNORDERED, (nodeId, msg) -> {
-            System.out.println("Received unordered message [msg=" + msg + ", fromNodeId=" + nodeId + ']');
-
-            try {
-                ignite.message(ignite.cluster().forNodeId(nodeId)).send(TOPIC.UNORDERED, msg);
-            }
-            catch (IgniteException e) {
-                e.printStackTrace();
-            }
-
-            return true; // Return true to continue listening.
-        });
-    }
-
-    /**
-     * Listen for messages from remote nodes.
-     *
-     * @param imsg Ignite messaging.
-     * @param orderedLatch Latch for ordered messages acks.
-     * @param unorderedLatch Latch for unordered messages acks.
-     */
-    private static void localListen(
-        IgniteMessaging imsg,
-        final CountDownLatch orderedLatch,
-        final CountDownLatch unorderedLatch
-    ) {
-        imsg.localListen(TOPIC.ORDERED, (nodeId, msg) -> {
-            orderedLatch.countDown();
-
-            // Return true to continue listening, false to stop.
-            return orderedLatch.getCount() > 0;
-        });
-
-        imsg.localListen(TOPIC.UNORDERED, (nodeId, msg) -> {
-            unorderedLatch.countDown();
-
-            // Return true to continue listening, false to stop.
-            return unorderedLatch.getCount() > 0;
-        });
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingPingPongExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingPingPongExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingPingPongExample.java
deleted file mode 100644
index b19b476..0000000
--- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingPingPongExample.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-
-package org.apache.ignite.examples.java8.messaging;
-
-import java.util.concurrent.CountDownLatch;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cluster.ClusterGroup;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.examples.ExamplesUtils;
-
-/**
- * Demonstrates simple message exchange between local and remote nodes.
- * <p>
- * To run this example you must have at least one remote node started.
- * <p>
- * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
- * with {@code examples/config/example-ignite.xml} configuration.
- */
-public class MessagingPingPongExample {
-    /**
-     * Executes example.
-     *
-     * @param args Command line arguments, none required.
-     * @throws Exception If example execution failed.
-     */
-    public static void main(String[] args) throws Exception {
-        // Game is played over the default ignite.
-        try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
-            if (!ExamplesUtils.checkMinTopologySize(ignite.cluster(), 2))
-                return;
-
-            System.out.println();
-            System.out.println(">>> Messaging ping-pong example started.");
-
-            // Pick random remote node as a partner.
-            ClusterGroup nodeB = ignite.cluster().forRemotes().forRandom();
-
-            // Note that both nodeA and nodeB will always point to
-            // same nodes regardless of whether they were implicitly
-            // serialized and deserialized on another node as part of
-            // anonymous closure's state during its remote execution.
-
-            // Set up remote player.
-            ignite.message(nodeB).remoteListen(null, (nodeId, rcvMsg) -> {
-                System.out.println("Received message [msg=" + rcvMsg + ", sender=" + nodeId + ']');
-
-                if ("PING".equals(rcvMsg)) {
-                    ignite.message(ignite.cluster().forNodeId(nodeId)).send(null, "PONG");
-
-                    return true; // Continue listening.
-                }
-
-                return false; // Unsubscribe.
-            });
-
-            int MAX_PLAYS = 10;
-
-            final CountDownLatch cnt = new CountDownLatch(MAX_PLAYS);
-
-            // Set up local player.
-            ignite.message().localListen(null, (nodeId, rcvMsg) -> {
-                System.out.println("Received message [msg=" + rcvMsg + ", sender=" + nodeId + ']');
-
-                if (cnt.getCount() == 1) {
-                    ignite.message(ignite.cluster().forNodeId(nodeId)).send(null, "STOP");
-
-                    cnt.countDown();
-
-                    return false; // Stop listening.
-                }
-                else if ("PONG".equals(rcvMsg))
-                    ignite.message(ignite.cluster().forNodeId(nodeId)).send(null, "PING");
-                else
-                    throw new IgniteException("Received unexpected message: " + rcvMsg);
-
-                cnt.countDown();
-
-                return true; // Continue listening.
-            });
-
-            // Serve!
-            ignite.message(nodeB).send(null, "PING");
-
-            // Wait til the game is over.
-            try {
-                cnt.await();
-            }
-            catch (InterruptedException e) {
-                System.err.println("Hm... let us finish the game!\n" + e);
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/50cf42a3/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/messaging/package-info.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/messaging/package-info.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/messaging/package-info.java
deleted file mode 100644
index 75180cf..0000000
--- a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/messaging/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-
-/**
- * <!-- Package description. -->
- * Demonstrates how to exchange messages between nodes.
- */
-package org.apache.ignite.examples.java8.messaging;
\ No newline at end of file


[27/50] [abbrv] ignite git commit: IGNITE-1653

Posted by ag...@apache.org.
IGNITE-1653


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

Branch: refs/heads/ignite-1016
Commit: c4b0877f29c6e35c57491324837849c420f2b884
Parents: 3a29b97
Author: Anton Vinogradov <av...@apache.org>
Authored: Thu Oct 15 16:59:02 2015 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Thu Oct 15 16:59:02 2015 +0300

----------------------------------------------------------------------
 assembly/release-fabric-lgpl.xml                |  63 +++++
 assembly/release-hadoop-lgpl.xml                |  39 +++
 examples-lgpl/README.txt                        |  27 ++
 examples-lgpl/config/example-cache.xml          |  73 ++++++
 examples-lgpl/config/example-ignite.xml         |  83 +++++++
 examples-lgpl/config/filesystem/README.txt      |   8 +
 examples-lgpl/config/filesystem/core-site.xml   |  42 ++++
 .../config/filesystem/example-igfs.xml          | 151 ++++++++++++
 examples-lgpl/config/hibernate/README.txt       |   8 +
 .../hibernate/example-hibernate-L2-cache.xml    |  64 +++++
 examples-lgpl/config/servlet/README.txt         |   8 +
 examples-lgpl/config/servlet/WEB-INF/web.xml    |  36 +++
 examples-lgpl/pom-standalone.xml                | 141 +++++++++++
 examples-lgpl/pom.xml                           | 128 ++++++++++
 .../hibernate/HibernateL2CacheExample.java      | 245 +++++++++++++++++++
 .../examples/datagrid/hibernate/Post.java       | 130 ++++++++++
 .../examples/datagrid/hibernate/User.java       | 154 ++++++++++++
 .../datagrid/hibernate/package-info.java        |  22 ++
 .../hibernate/CacheHibernatePersonStore.java    | 122 +++++++++
 .../hibernate/CacheHibernateStoreExample.java   | 151 ++++++++++++
 .../datagrid/store/hibernate/Person.hbm.xml     |  34 +++
 .../datagrid/store/hibernate/hibernate.cfg.xml  |  41 ++++
 .../datagrid/store/hibernate/package-info.java  |  22 ++
 .../java8/cluster/ClusterGroupExample.java      |  86 +++++++
 .../examples/java8/cluster/package-info.java    |  22 ++
 .../java8/computegrid/ComputeAsyncExample.java  |  75 ++++++
 .../computegrid/ComputeBroadcastExample.java    | 102 ++++++++
 .../computegrid/ComputeCallableExample.java     |  75 ++++++
 .../computegrid/ComputeClosureExample.java      |  71 ++++++
 .../computegrid/ComputeRunnableExample.java     |  64 +++++
 .../java8/computegrid/package-info.java         |  22 ++
 .../java8/datagrid/CacheAffinityExample.java    | 137 +++++++++++
 .../java8/datagrid/CacheApiExample.java         | 105 ++++++++
 .../java8/datagrid/CacheAsyncApiExample.java    |  85 +++++++
 .../examples/java8/datagrid/package-info.java   |  22 ++
 .../IgniteExecutorServiceExample.java           |  70 ++++++
 .../java8/datastructures/package-info.java      |  22 ++
 .../examples/java8/events/EventsExample.java    | 135 ++++++++++
 .../examples/java8/events/package-info.java     |  22 ++
 .../java8/messaging/MessagingExample.java       | 166 +++++++++++++
 .../messaging/MessagingPingPongExample.java     | 113 +++++++++
 .../examples/java8/messaging/package-info.java  |  22 ++
 .../misc/schedule/ComputeScheduleExample.java   |  68 +++++
 .../java8/misc/schedule/package-info.java       |  22 ++
 .../ignite/examples/java8/package-info.java     |  23 ++
 .../streaming/StreamTransformerExample.java     | 101 ++++++++
 .../java8/streaming/StreamVisitorExample.java   | 172 +++++++++++++
 .../examples/java8/streaming/package-info.java  |  22 ++
 ...ibernateL2CacheExampleMultiNodeSelfTest.java |  31 +++
 .../HibernateL2CacheExampleSelfTest.java        |  33 +++
 .../IgniteLgplExamplesSelfTestSuite.java        |  48 ++++
 ...ibernateL2CacheExampleMultiNodeSelfTest.java |  29 +++
 .../HibernateL2CacheExampleSelfTest.java        |  37 +++
 .../IgniteLgplExamplesJ8SelfTestSuite.java      |  46 ++++
 examples/pom-standalone.xml                     |  12 -
 examples/pom.xml                                |  12 -
 .../hibernate/HibernateL2CacheExample.java      | 245 -------------------
 .../examples/datagrid/hibernate/Post.java       | 130 ----------
 .../examples/datagrid/hibernate/User.java       | 154 ------------
 .../datagrid/hibernate/package-info.java        |  22 --
 .../hibernate/CacheHibernatePersonStore.java    | 122 ---------
 .../hibernate/CacheHibernateStoreExample.java   | 151 ------------
 .../datagrid/store/hibernate/Person.hbm.xml     |  34 ---
 .../datagrid/store/hibernate/hibernate.cfg.xml  |  41 ----
 .../datagrid/store/hibernate/package-info.java  |  22 --
 ...ibernateL2CacheExampleMultiNodeSelfTest.java |  31 ---
 .../HibernateL2CacheExampleSelfTest.java        |  33 ---
 .../testsuites/IgniteExamplesSelfTestSuite.java |   4 -
 ...ibernateL2CacheExampleMultiNodeSelfTest.java |  29 ---
 .../HibernateL2CacheExampleSelfTest.java        |  37 ---
 pom.xml                                         |  65 ++++-
 71 files changed, 3904 insertions(+), 1080 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/assembly/release-fabric-lgpl.xml
----------------------------------------------------------------------
diff --git a/assembly/release-fabric-lgpl.xml b/assembly/release-fabric-lgpl.xml
new file mode 100644
index 0000000..b8757db
--- /dev/null
+++ b/assembly/release-fabric-lgpl.xml
@@ -0,0 +1,63 @@
+<?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.
+-->
+
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
+          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+          xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2
+          http://maven.apache.org/xsd/assembly-1.1.2.xsd">
+    <id>fabric</id>
+
+    <includeBaseDirectory>false</includeBaseDirectory>
+
+    <formats>
+        <format>dir</format>
+    </formats>
+
+    <files>
+        <file>
+            <source>examples-lgpl/pom-standalone.xml</source>
+            <outputDirectory>/examples-lgpl</outputDirectory>
+            <destName>pom.xml</destName>
+        </file>
+    </files>
+
+    <fileSets>
+        <fileSet>
+            <directory>examples-lgpl</directory>
+            <outputDirectory>/examples-lgpl</outputDirectory>
+            <includes>
+                <include>README.txt</include>
+            </includes>
+        </fileSet>
+
+        <fileSet>
+            <directory>examples-lgpl</directory>
+            <outputDirectory>/examples-lgpl</outputDirectory>
+            <includes>
+                <include>config/**</include>
+                <include>src/**</include>
+            </includes>
+            <excludes>
+                <exclude>**/package.html</exclude>
+                <exclude>pom-standalone.xml</exclude>
+                <exclude>src/test/**</exclude>
+            </excludes>
+        </fileSet>
+    </fileSets>
+</assembly>

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/assembly/release-hadoop-lgpl.xml
----------------------------------------------------------------------
diff --git a/assembly/release-hadoop-lgpl.xml b/assembly/release-hadoop-lgpl.xml
new file mode 100644
index 0000000..ac2fc31
--- /dev/null
+++ b/assembly/release-hadoop-lgpl.xml
@@ -0,0 +1,39 @@
+<?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.
+-->
+
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
+          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+          xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2
+          http://maven.apache.org/xsd/assembly-1.1.2.xsd">
+    <id>fabric</id>
+
+    <includeBaseDirectory>false</includeBaseDirectory>
+
+    <formats>
+        <format>dir</format>
+    </formats>
+
+    <files>
+        <file>
+            <source>assembly/LICENSE_HADOOP</source><!--assembly should contain at least one file. copied from release-hadoop.xml -->
+            <destName>LICENSE</destName>
+            <outputDirectory>/</outputDirectory>
+        </file>
+    </files>
+</assembly>

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/README.txt
----------------------------------------------------------------------
diff --git a/examples-lgpl/README.txt b/examples-lgpl/README.txt
new file mode 100644
index 0000000..8c8982e
--- /dev/null
+++ b/examples-lgpl/README.txt
@@ -0,0 +1,27 @@
+Apache Ignite LGPL Examples
+======================
+
+This folder contains code examples for various Apache Ignite functionality.
+
+Examples are shipped as a separate Maven project, so to start running you simply need
+to import provided `pom.xml` file into your favourite IDE.
+
+The examples folder contains he following subfolders:
+
+- `config` - contains Ignite configuration files needed for examples.
+- `src/main/java` - contains Java examples for different Ignite modules and features.
+- `src/main/java8` - contains additional set of Java examples utilizing Java 8 lambdas. These examples
+  are excluded by default, enable `java8-examples` Maven profile to include them (JDK8 is required).
+
+
+Starting Remote Nodes
+=====================
+
+Remote nodes for examples should always be started with special configuration file which enables P2P
+class loading: `examples/config/example-ignite.xml`. To run a remote node in IDE use `ExampleNodeStartup` class.
+
+
+Java7 vs Java8
+===============
+Some examples (not all) which can benefit from Java8 Lambda support were re-written with Java8 lambdas.
+For full set of examples, look at both Java7 and Java8 packages.

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/config/example-cache.xml
----------------------------------------------------------------------
diff --git a/examples-lgpl/config/example-cache.xml b/examples-lgpl/config/example-cache.xml
new file mode 100644
index 0000000..dcb8e75
--- /dev/null
+++ b/examples-lgpl/config/example-cache.xml
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  ~  Licensed to the Apache Software Foundation (ASF) under one or more
+  ~  contributor license agreements.  See the NOTICE file distributed with
+  ~  this work for additional information regarding copyright ownership.
+  ~  The ASF licenses this file to You under the Apache License, Version 2.0
+  ~  (the "License"); you may not use this file except in compliance with
+  ~  the License.  You may obtain a copy of the License at
+  ~
+  ~       http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~  Unless required by applicable law or agreed to in writing, software
+  ~  distributed under the License is distributed on an "AS IS" BASIS,
+  ~  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~  See the License for the specific language governing permissions and
+  ~  limitations under the License.
+  -->
+
+<!--
+    Ignite Spring configuration file to startup Ignite cache.
+
+    This file demonstrates how to configure cache using Spring. Provided cache
+    will be created on node startup.
+
+    Use this configuration file when running HTTP REST examples (see 'examples/rest' folder).
+
+    When starting a standalone node, you need to execute the following command:
+    {IGNITE_HOME}/bin/ignite.{bat|sh} examples/config/example-cache.xml
+
+    When starting Ignite from Java IDE, pass path to this file to Ignition:
+    Ignition.start("examples/config/example-cache.xml");
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="
+        http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans.xsd">
+    <bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+        <property name="cacheConfiguration">
+            <list>
+                <!-- Partitioned cache example configuration (Atomic mode). -->
+                <bean class="org.apache.ignite.configuration.CacheConfiguration">
+                    <property name="atomicityMode" value="ATOMIC"/>
+                    <property name="backups" value="1"/>
+                </bean>
+            </list>
+        </property>
+
+        <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
+        <property name="discoverySpi">
+            <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+                <property name="ipFinder">
+                    <!--
+                        Ignite provides several options for automatic discovery that can be used
+                        instead os static IP based discovery. For information on all options refer
+                        to our documentation: http://apacheignite.readme.io/docs/cluster-config
+                    -->
+                    <!-- Uncomment static IP finder to enable static-based discovery of initial nodes. -->
+                    <!--<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">-->
+                    <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
+                        <property name="addresses">
+                            <list>
+                                <!-- In distributed environment, replace with actual host IP address. -->
+                                <value>127.0.0.1:47500..47509</value>
+                            </list>
+                        </property>
+                    </bean>
+                </property>
+            </bean>
+        </property>
+    </bean>
+</beans>

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/config/example-ignite.xml
----------------------------------------------------------------------
diff --git a/examples-lgpl/config/example-ignite.xml b/examples-lgpl/config/example-ignite.xml
new file mode 100644
index 0000000..e870106
--- /dev/null
+++ b/examples-lgpl/config/example-ignite.xml
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  ~  Licensed to the Apache Software Foundation (ASF) under one or more
+  ~  contributor license agreements.  See the NOTICE file distributed with
+  ~  this work for additional information regarding copyright ownership.
+  ~  The ASF licenses this file to You under the Apache License, Version 2.0
+  ~  (the "License"); you may not use this file except in compliance with
+  ~  the License.  You may obtain a copy of the License at
+  ~
+  ~       http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~  Unless required by applicable law or agreed to in writing, software
+  ~  distributed under the License is distributed on an "AS IS" BASIS,
+  ~  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~  See the License for the specific language governing permissions and
+  ~  limitations under the License.
+  -->
+
+<!--
+    Ignite configuration with all defaults and enabled p2p deployment and enabled events.
+-->
+<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="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+        <!-- Set to true to enable distributed class loading for examples, default is false. -->
+        <property name="peerClassLoadingEnabled" value="true"/>
+
+        <property name="marshaller">
+            <bean class="org.apache.ignite.marshaller.optimized.OptimizedMarshaller">
+                <!-- Set to false to allow non-serializable objects in examples, default is true. -->
+                <property name="requireSerializable" value="false"/>
+            </bean>
+        </property>
+
+        <!-- Enable task execution events for examples. -->
+        <property name="includeEventTypes">
+            <list>
+                <!--Task execution events-->
+                <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_STARTED"/>
+                <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FINISHED"/>
+                <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FAILED"/>
+                <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_TIMEDOUT"/>
+                <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_SESSION_ATTR_SET"/>
+                <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_REDUCED"/>
+
+                <!--Cache events-->
+                <util:constant static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_PUT"/>
+                <util:constant static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_READ"/>
+                <util:constant static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_REMOVED"/>
+            </list>
+        </property>
+
+        <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
+        <property name="discoverySpi">
+            <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+                <property name="ipFinder">
+                    <!--
+                        Ignite provides several options for automatic discovery that can be used
+                        instead os static IP based discovery. For information on all options refer
+                        to our documentation: http://apacheignite.readme.io/docs/cluster-config
+                    -->
+                    <!-- Uncomment static IP finder to enable static-based discovery of initial nodes. -->
+                    <!--<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">-->
+                    <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
+                        <property name="addresses">
+                            <list>
+                                <!-- In distributed environment, replace with actual host IP address. -->
+                                <value>127.0.0.1:47500..47509</value>
+                            </list>
+                        </property>
+                    </bean>
+                </property>
+            </bean>
+        </property>
+    </bean>
+</beans>

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/config/filesystem/README.txt
----------------------------------------------------------------------
diff --git a/examples-lgpl/config/filesystem/README.txt b/examples-lgpl/config/filesystem/README.txt
new file mode 100644
index 0000000..4f6ae88
--- /dev/null
+++ b/examples-lgpl/config/filesystem/README.txt
@@ -0,0 +1,8 @@
+FileSystem Configuration Example
+--------------------------------
+
+This folder contains configuration files for IgniteFs examples located in
+org.apache.ignite.examples.igfs package.
+
+- example-igfs.xml file is used to start Apache Ignite nodes with IgniteFS configured
+- core-site.xml file is used to run Hadoop FS driver over IgniteFs

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/config/filesystem/core-site.xml
----------------------------------------------------------------------
diff --git a/examples-lgpl/config/filesystem/core-site.xml b/examples-lgpl/config/filesystem/core-site.xml
new file mode 100644
index 0000000..a7a027c
--- /dev/null
+++ b/examples-lgpl/config/filesystem/core-site.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
+
+<!--
+  ~  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.
+  -->
+
+<!--
+    Example configuration of the Hadoop FS driver over Ignite FS API.
+    Copy this file into '$HADOOP_HOME/conf/core-site.xml'.
+-->
+<configuration>
+    <property>
+        <name>fs.default.name</name>
+        <value>igfs:///</value>
+    </property>
+
+    <property>
+        <!-- FS driver class for the 'igfs://' URIs. -->
+        <name>fs.igfs.impl</name>
+        <value>org.apache.ignite.hadoop.fs.v1.IgniteHadoopFileSystem</value>
+    </property>
+
+    <property>
+        <!-- FS driver class for the 'igfs://' URIs in Hadoop2.x -->
+        <name>fs.AbstractFileSystem.igfs.impl</name>
+        <value>org.apache.ignite.hadoop.fs.v2.IgniteHadoopFileSystem</value>
+    </property>
+</configuration>

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/config/filesystem/example-igfs.xml
----------------------------------------------------------------------
diff --git a/examples-lgpl/config/filesystem/example-igfs.xml b/examples-lgpl/config/filesystem/example-igfs.xml
new file mode 100644
index 0000000..d009d46
--- /dev/null
+++ b/examples-lgpl/config/filesystem/example-igfs.xml
@@ -0,0 +1,151 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  ~  Licensed to the Apache Software Foundation (ASF) under one or more
+  ~  contributor license agreements.  See the NOTICE file distributed with
+  ~  this work for additional information regarding copyright ownership.
+  ~  The ASF licenses this file to You under the Apache License, Version 2.0
+  ~  (the "License"); you may not use this file except in compliance with
+  ~  the License.  You may obtain a copy of the License at
+  ~
+  ~       http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~  Unless required by applicable law or agreed to in writing, software
+  ~  distributed under the License is distributed on an "AS IS" BASIS,
+  ~  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~  See the License for the specific language governing permissions and
+  ~  limitations under the License.
+  -->
+
+<!--
+    Ignite Spring configuration file to startup ignite cache.
+
+    When starting a standalone node, you need to execute the following command:
+    {IGNITE_HOME}/bin/ignite.{bat|sh} examples/config/filesystem/example-igfs.xml
+
+    When starting Ignite from Java IDE, pass path to this file into Ignition:
+    Ignition.start("examples/config/filesystem/example-igfs.xml");
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans
+       http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+    <!--
+        Optional description.
+    -->
+    <description>
+        Spring file for ignite configuration with client available endpoints.
+    </description>
+
+    <!--
+        Initialize property configurer so we can reference environment variables.
+    -->
+    <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
+        <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_FALLBACK"/>
+        <property name="searchSystemEnvironment" value="true"/>
+    </bean>
+
+    <!--
+        Configuration below demonstrates how to setup a IgniteFs node with file data.
+    -->
+    <bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+        <!-- Set to true to enable cluster-aware class loading for examples, default is false. -->
+        <property name="peerClassLoadingEnabled" value="true"/>
+
+        <property name="marshaller">
+            <bean class="org.apache.ignite.marshaller.optimized.OptimizedMarshaller">
+                <!-- Set to false to allow non-serializable objects in examples, default is true. -->
+                <property name="requireSerializable" value="false"/>
+            </bean>
+        </property>
+
+        <property name="fileSystemConfiguration">
+            <list>
+                <bean class="org.apache.ignite.configuration.FileSystemConfiguration">
+                    <property name="name" value="igfs"/>
+                    <property name="metaCacheName" value="igfs-meta"/>
+                    <property name="dataCacheName" value="igfs-data"/>
+
+                    <!-- Must correlate with cache affinity mapper. -->
+                    <property name="blockSize" value="#{128 * 1024}"/>
+                    <property name="perNodeBatchSize" value="512"/>
+                    <property name="perNodeParallelBatchCount" value="16"/>
+
+                    <!-- Set number of prefetch blocks. -->
+                    <property name="prefetchBlocks" value="32"/>
+
+                    <!--
+                        Example of configured IPC loopback endpoint.
+                    -->
+                    <!--
+                    <property name="ipcEndpointConfiguration">
+                        <bean class="org.apache.ignite.igfs.IgfsIpcEndpointConfiguration">
+                            <property name="type" value="TCP" />
+                        </bean>
+                    </property>
+                    -->
+
+                    <!--
+                        Example of configured shared memory endpoint.
+                    -->
+                    <!--
+                    <property name="ipcEndpointConfiguration">
+                        <bean class="org.apache.ignite.igfs.IgfsIpcEndpointConfiguration">
+                            <property name="type" value="SHMEM" />
+                        </bean>
+                    </property>
+                    -->
+                </bean>
+            </list>
+        </property>
+
+        <property name="cacheConfiguration">
+            <list>
+                <bean class="org.apache.ignite.configuration.CacheConfiguration">
+                    <property name="name" value="igfs-data"/>
+                    <property name="cacheMode" value="PARTITIONED"/>
+                    <property name="atomicityMode" value="TRANSACTIONAL"/>
+                    <property name="writeSynchronizationMode" value="FULL_SYNC"/>
+                    <property name="backups" value="0"/>
+                    <property name="affinityMapper">
+                        <bean class="org.apache.ignite.igfs.IgfsGroupDataBlocksKeyMapper">
+                            <!-- Haw many blocks in row will be stored on the same node. -->
+                            <constructor-arg value="512"/>
+                        </bean>
+                    </property>
+                </bean>
+
+                <bean class="org.apache.ignite.configuration.CacheConfiguration">
+                    <property name="name" value="igfs-meta"/>
+                    <property name="cacheMode" value="REPLICATED"/>
+                    <property name="atomicityMode" value="TRANSACTIONAL"/>
+                    <property name="writeSynchronizationMode" value="FULL_SYNC"/>
+                </bean>
+            </list>
+        </property>
+
+        <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
+        <property name="discoverySpi">
+            <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+                <property name="ipFinder">
+                    <!--
+                        Ignition provides several options for automatic discovery that can be used
+                        instead os static IP based discovery. For information on all options refer
+                        to our documentation: http://apacheignite.readme.io/docs/cluster-config
+                    -->
+                    <!-- Uncomment static IP finder to enable static-based discovery of initial nodes. -->
+                    <!--<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">-->
+                    <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
+                        <property name="addresses">
+                            <list>
+                                <!-- In distributed environment, replace with actual host IP address. -->
+                                <value>127.0.0.1:47500..47509</value>
+                            </list>
+                        </property>
+                    </bean>
+                </property>
+            </bean>
+        </property>
+    </bean>
+</beans>

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/config/hibernate/README.txt
----------------------------------------------------------------------
diff --git a/examples-lgpl/config/hibernate/README.txt b/examples-lgpl/config/hibernate/README.txt
new file mode 100644
index 0000000..5b7ab29
--- /dev/null
+++ b/examples-lgpl/config/hibernate/README.txt
@@ -0,0 +1,8 @@
+Hibernate L2 Cache Configuration Example
+----------------------------------------
+
+This folder contains example-hibernate-L2-cache.xml file that demonstrates
+how to configure Hibernate to use Apache Ignite cache as an L2 cache provider.
+
+This file is also used in Hibernate example located in org.apache.ignite.examples.datagrid.hibernate
+package.

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/config/hibernate/example-hibernate-L2-cache.xml
----------------------------------------------------------------------
diff --git a/examples-lgpl/config/hibernate/example-hibernate-L2-cache.xml b/examples-lgpl/config/hibernate/example-hibernate-L2-cache.xml
new file mode 100644
index 0000000..a2f7e89
--- /dev/null
+++ b/examples-lgpl/config/hibernate/example-hibernate-L2-cache.xml
@@ -0,0 +1,64 @@
+<?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.
+  -->
+
+
+<!DOCTYPE hibernate-configuration PUBLIC
+    "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
+    "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
+
+<!--
+    Configuration file for HibernateL2CacheExample.
+-->
+
+<hibernate-configuration>
+    <session-factory>
+        <!-- Database connection settings -->
+        <property name="connection.url">jdbc:h2:mem:example;DB_CLOSE_DELAY=-1</property>
+
+        <!-- Drop and re-create the database schema on startup. -->
+        <property name="hbm2ddl.auto">create</property>
+
+        <!-- Enable L2 cache. -->
+        <property name="cache.use_second_level_cache">true</property>
+
+        <!-- Enable query cache. -->
+        <property name="cache.use_query_cache">true</property>
+
+        <!-- Generate L2 cache statistics. -->
+        <property name="generate_statistics">true</property>
+
+        <!-- Specify Ignite as L2 cache provider. -->
+        <property name="cache.region.factory_class">org.apache.ignite.cache.hibernate.HibernateRegionFactory</property>
+
+        <!-- Specify connection release mode. -->
+        <property name="connection.release_mode">on_close</property>
+
+        <!-- Set default L2 cache access type. -->
+        <property name="org.apache.ignite.hibernate.default_access_type">READ_ONLY</property>
+
+        <!-- Specify the entity classes for mapping. -->
+        <mapping class="org.apache.ignite.examples.datagrid.hibernate.User"/>
+        <mapping class="org.apache.ignite.examples.datagrid.hibernate.Post"/>
+
+        <!-- Per-class L2 cache settings. -->
+        <class-cache class="org.apache.ignite.examples.datagrid.hibernate.User" usage="read-only"/>
+        <class-cache class="org.apache.ignite.examples.datagrid.hibernate.Post" usage="read-only"/>
+        <collection-cache collection="org.apache.ignite.examples.datagrid.hibernate.User.posts" usage="read-only"/>
+    </session-factory>
+</hibernate-configuration>

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/config/servlet/README.txt
----------------------------------------------------------------------
diff --git a/examples-lgpl/config/servlet/README.txt b/examples-lgpl/config/servlet/README.txt
new file mode 100644
index 0000000..20d4b90
--- /dev/null
+++ b/examples-lgpl/config/servlet/README.txt
@@ -0,0 +1,8 @@
+Servlet Configuration Example
+-----------------------------
+
+This folder contains web.xml file that demonstrates how to configure any servlet container
+to start a Apache Ignite node inside a Web application.
+
+For more information on available configuration properties, etc. refer to our documentation:
+http://apacheignite.readme.io/docs/web-session-clustering

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/config/servlet/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/examples-lgpl/config/servlet/WEB-INF/web.xml b/examples-lgpl/config/servlet/WEB-INF/web.xml
new file mode 100644
index 0000000..de4b3a0
--- /dev/null
+++ b/examples-lgpl/config/servlet/WEB-INF/web.xml
@@ -0,0 +1,36 @@
+<?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.
+  -->
+
+<!--
+    Example web.xml to startup Ignite from Servlet container, like Tomcat.
+-->
+<web-app xmlns="http://java.sun.com/xml/ns/javaee"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+                             http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+         version="3.0">
+    <context-param>
+        <param-name>IgniteConfigurationFilePath</param-name>
+        <param-value>config/default-config.xml</param-value>
+    </context-param>
+
+    <listener>
+        <listener-class>org.apache.ignite.startup.servlet.ServletContextListenerStartup</listener-class>
+    </listener>
+</web-app>

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/pom-standalone.xml
----------------------------------------------------------------------
diff --git a/examples-lgpl/pom-standalone.xml b/examples-lgpl/pom-standalone.xml
new file mode 100644
index 0000000..d2a00d1
--- /dev/null
+++ b/examples-lgpl/pom-standalone.xml
@@ -0,0 +1,141 @@
+<?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.
+-->
+
+<!--
+    POM file.
+-->
+<project
+    xmlns="http://maven.apache.org/POM/4.0.0"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+
+    <groupId>org.apache.ignite</groupId>
+    <artifactId>ignite-examples-lgpl</artifactId>
+    <version>to_be_replaced_by_ignite_version</version>
+    <packaging>pom</packaging>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.ignite</groupId>
+            <artifactId>ignite-examples</artifactId>
+            <version>to_be_replaced_by_ignite_version</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.ignite</groupId>
+            <artifactId>ignite-hibernate</artifactId>
+            <version>to_be_replaced_by_ignite_version</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.ignite</groupId>
+            <artifactId>ignite-schedule</artifactId>
+            <version>to_be_replaced_by_ignite_version</version>
+        </dependency>
+    </dependencies>
+
+    <modules>
+        <module>../examples</module>
+    </modules>
+
+    <build>
+        <resources>
+            <resource>
+                <directory>src/main/java</directory>
+                <excludes>
+                    <exclude>**/*.java</exclude>
+                </excludes>
+            </resource>
+            <resource>
+                <directory>config</directory>
+            </resource>
+        </resources>
+
+        <plugins>
+            <plugin>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.1</version>
+                <configuration>
+                    <source>1.7</source>
+                    <target>1.7</target>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+    <profiles>
+        <profile>
+            <id>java8-examples</id>
+
+            <activation>
+                <jdk>[1.8,)</jdk>
+            </activation>
+
+            <build>
+                <plugins>
+                    <plugin>
+                        <artifactId>maven-compiler-plugin</artifactId>
+                        <version>3.1</version>
+                        <configuration>
+                            <source>1.8</source>
+                            <target>1.8</target>
+                        </configuration>
+                    </plugin>
+
+                    <plugin>
+                        <groupId>org.codehaus.mojo</groupId>
+                        <artifactId>build-helper-maven-plugin</artifactId>
+                        <version>1.9.1</version>
+                        <executions>
+                            <execution>
+                                <id>add-sources</id>
+                                <phase>generate-sources</phase>
+                                <goals>
+                                    <goal>add-source</goal>
+                                </goals>
+                                <configuration>
+                                    <sources>
+                                        <source>src/main/java8</source>
+                                    </sources>
+                                </configuration>
+                            </execution>
+                            <execution>
+                                <id>add-tests</id>
+                                <phase>generate-test-sources</phase>
+                                <goals>
+                                    <goal>add-test-source</goal>
+                                </goals>
+                                <configuration>
+                                    <sources>
+                                        <source>src/test/java8</source>
+                                    </sources>
+                                </configuration>
+                            </execution>
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
+</project>

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/pom.xml
----------------------------------------------------------------------
diff --git a/examples-lgpl/pom.xml b/examples-lgpl/pom.xml
new file mode 100644
index 0000000..019dc23
--- /dev/null
+++ b/examples-lgpl/pom.xml
@@ -0,0 +1,128 @@
+<?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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.ignite</groupId>
+        <artifactId>ignite-parent</artifactId>
+        <version>1</version>
+        <relativePath>../parent</relativePath>
+    </parent>
+
+    <artifactId>ignite-examples-lgpl</artifactId>
+    <version>1.5.0-SNAPSHOT</version>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.ignite</groupId>
+            <artifactId>ignite-hibernate</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.ignite</groupId>
+            <artifactId>ignite-schedule</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.ignite</groupId>
+            <artifactId>ignite-examples</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.ignite</groupId>
+            <artifactId>ignite-core</artifactId>
+            <version>${project.version}</version>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <resources>
+            <resource>
+                <directory>src/main/java</directory>
+                <excludes>
+                    <exclude>**/*.java</exclude>
+                </excludes>
+            </resource>
+            <resource>
+                <directory>config</directory>
+            </resource>
+        </resources>
+    </build>
+
+    <profiles>
+        <profile>
+            <id>java8-examples</id>
+
+            <activation>
+                <jdk>[1.8,)</jdk>
+            </activation>
+
+            <build>
+                <plugins>
+                    <plugin>
+                        <artifactId>maven-compiler-plugin</artifactId>
+                        <configuration>
+                            <source>1.8</source>
+                            <target>1.8</target>
+                        </configuration>
+                    </plugin>
+
+                    <plugin>
+                        <groupId>org.codehaus.mojo</groupId>
+                        <artifactId>build-helper-maven-plugin</artifactId>
+                        <version>1.9.1</version>
+                        <executions>
+                            <execution>
+                                <id>add-sources</id>
+                                <phase>generate-sources</phase>
+                                <goals>
+                                    <goal>add-source</goal>
+                                </goals>
+                                <configuration>
+                                    <sources>
+                                        <source>src/main/java8</source>
+                                    </sources>
+                                </configuration>
+                            </execution>
+                            <execution>
+                                <id>add-tests</id>
+                                <phase>generate-test-sources</phase>
+                                <goals>
+                                    <goal>add-test-source</goal>
+                                </goals>
+                                <configuration>
+                                    <sources>
+                                        <source>src/test/java8</source>
+                                    </sources>
+                                </configuration>
+                            </execution>
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
+</project>

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/hibernate/HibernateL2CacheExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/hibernate/HibernateL2CacheExample.java b/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/hibernate/HibernateL2CacheExample.java
new file mode 100644
index 0000000..2f271c8
--- /dev/null
+++ b/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/hibernate/HibernateL2CacheExample.java
@@ -0,0 +1,245 @@
+/*
+ * 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.examples.datagrid.hibernate;
+
+import java.net.URL;
+import java.util.Arrays;
+import java.util.List;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.examples.ExampleNodeStartup;
+import org.apache.ignite.examples.ExamplesUtils;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.Transaction;
+import org.hibernate.cache.spi.access.AccessType;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.service.ServiceRegistryBuilder;
+import org.hibernate.stat.SecondLevelCacheStatistics;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
+
+/**
+ * This example demonstrates the use of Ignite In-Memory Data Ignite cluster as a Hibernate
+ * Second-Level cache provider.
+ * <p>
+ * The Hibernate Second-Level cache (or "L2 cache" shortly) lets you significantly
+ * reduce the number of requests to the underlying SQL database. Because database
+ * access is known to be an expansive operation, using L2 cache may improve
+ * performance dramatically.
+ * <p>
+ * This example defines 2 entity classes: {@link User} and {@link Post}, with
+ * 1 <-> N relation, and marks them with appropriate annotations for Hibernate
+ * object-relational mapping to SQL tables of an underlying H2 in-memory database.
+ * The example launches node in the same JVM and registers it in
+ * Hibernate configuration as an L2 cache implementation. It then stores and
+ * queries instances of the entity classes to and from the database, having
+ * Hibernate SQL output, L2 cache statistics output, and Ignite cache metrics
+ * output enabled.
+ * <p>
+ * When running example, it's easy to notice that when an object is first
+ * put into a database, the L2 cache is not used and it's contents is empty.
+ * However, when an object is first read from the database, it is immediately
+ * stored in L2 cache (which is Ignite In-Memory Data Ignite cluster in fact), which can
+ * be seen in stats output. Further requests of the same object only read the data
+ * from L2 cache and do not hit the database.
+ * <p>
+ * In this example, the Hibernate query cache is also enabled. Query cache lets you
+ * avoid hitting the database in case of repetitive queries with the same parameter
+ * values. You may notice that when the example runs the same query repeatedly in
+ * loop, only the first query hits the database and the successive requests take the
+ * data from L2 cache.
+ * <p>
+ * Note: this example uses {@link AccessType#READ_ONLY} L2 cache access type, but you
+ * can experiment with other access types by modifying the Hibernate configuration file
+ * {@code IGNITE_HOME/examples/config/hibernate/example-hibernate-L2-cache.xml}, used by the example.
+ * <p>
+ * Remote nodes should always be started with special configuration file which
+ * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
+ * <p>
+ * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will
+ * start node with {@code examples/config/example-ignite.xml} configuration.
+ */
+public class HibernateL2CacheExample {
+    /** JDBC URL for backing database (an H2 in-memory database is used). */
+    private static final String JDBC_URL = "jdbc:h2:mem:example;DB_CLOSE_DELAY=-1";
+
+    /** Path to hibernate configuration file (will be resolved from application {@code CLASSPATH}). */
+    private static final String HIBERNATE_CFG = "hibernate/example-hibernate-L2-cache.xml";
+
+    /** Entity names for stats output. */
+    private static final List<String> ENTITY_NAMES =
+        Arrays.asList(User.class.getName(), Post.class.getName(), User.class.getName() + ".posts");
+
+    /**
+     * Executes example.
+     *
+     * @param args Command line arguments, none required.
+     * @throws IgniteException If example execution failed.
+     */
+    public static void main(String[] args) throws IgniteException {
+        // Start the node, run the example, and stop the node when finished.
+        try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+            // We use a single session factory, but create a dedicated session
+            // for each transaction or query. This way we ensure that L1 cache
+            // is not used (L1 cache has per-session scope only).
+            System.out.println();
+            System.out.println(">>> Hibernate L2 cache example started.");
+
+            try (
+                // Create all required caches.
+                IgniteCache c1 = createCache("org.hibernate.cache.spi.UpdateTimestampsCache", ATOMIC);
+                IgniteCache c2 = createCache("org.hibernate.cache.internal.StandardQueryCache", ATOMIC);
+                IgniteCache c3 = createCache("org.apache.ignite.examples.datagrid.hibernate.User", TRANSACTIONAL);
+                IgniteCache c4 = createCache("org.apache.ignite.examples.datagrid.hibernate.User.posts", TRANSACTIONAL);
+                IgniteCache c5 = createCache("org.apache.ignite.examples.datagrid.hibernate.Post", TRANSACTIONAL)
+            ) {
+                URL hibernateCfg = ExamplesUtils.url(HIBERNATE_CFG);
+
+                SessionFactory sesFactory = createHibernateSessionFactory(hibernateCfg);
+
+                System.out.println();
+                System.out.println(">>> Creating objects.");
+
+                final long userId;
+
+                Session ses = sesFactory.openSession();
+
+                try {
+                    Transaction tx = ses.beginTransaction();
+
+                    User user = new User("jedi", "Luke", "Skywalker");
+
+                    user.getPosts().add(new Post(user, "Let the Force be with you."));
+
+                    ses.save(user);
+
+                    tx.commit();
+
+                    // Create a user object, store it in DB, and save the database-generated
+                    // object ID. You may try adding more objects in a similar way.
+                    userId = user.getId();
+                }
+                finally {
+                    ses.close();
+                }
+
+                // Output L2 cache and Ignite cache stats. You may notice that
+                // at this point the object is not yet stored in L2 cache, because
+                // the read was not yet performed.
+                printStats(sesFactory);
+
+                System.out.println();
+                System.out.println(">>> Querying object by ID.");
+
+                // Query user by ID several times. First time we get an L2 cache
+                // miss, and the data is queried from DB, but it is then stored
+                // in cache and successive queries hit the cache and return
+                // immediately, no SQL query is made.
+                for (int i = 0; i < 3; i++) {
+                    ses = sesFactory.openSession();
+
+                    try {
+                        Transaction tx = ses.beginTransaction();
+
+                        User user = (User)ses.get(User.class, userId);
+
+                        System.out.println("User: " + user);
+
+                        for (Post post : user.getPosts())
+                            System.out.println("\tPost: " + post);
+
+                        tx.commit();
+                    }
+                    finally {
+                        ses.close();
+                    }
+                }
+
+                // Output the stats. We should see 1 miss and 2 hits for
+                // User and Collection object (stored separately in L2 cache).
+                // The Post is loaded with the collection, so it won't imply
+                // a miss.
+                printStats(sesFactory);
+            }
+        }
+    }
+
+    /**
+     * Creates cache.
+     *
+     * @param name Cache name.
+     * @param atomicityMode Atomicity mode.
+     * @return Cache configuration.
+     */
+    private static IgniteCache createCache(String name, CacheAtomicityMode atomicityMode) {
+        CacheConfiguration ccfg = new CacheConfiguration(name);
+
+        ccfg.setAtomicityMode(atomicityMode);
+        ccfg.setWriteSynchronizationMode(FULL_SYNC);
+
+        return Ignition.ignite().getOrCreateCache(ccfg);
+    }
+
+    /**
+     * Creates a new Hibernate {@link SessionFactory} using a programmatic
+     * configuration.
+     *
+     * @param hibernateCfg Hibernate configuration file.
+     * @return New Hibernate {@link SessionFactory}.
+     */
+    private static SessionFactory createHibernateSessionFactory(URL hibernateCfg) {
+        ServiceRegistryBuilder builder = new ServiceRegistryBuilder();
+
+        builder.applySetting("hibernate.connection.url", JDBC_URL);
+        builder.applySetting("hibernate.show_sql", true);
+
+        return new Configuration()
+            .configure(hibernateCfg)
+            .buildSessionFactory(builder.buildServiceRegistry());
+    }
+
+    /**
+     * Prints Hibernate L2 cache statistics to standard output.
+     *
+     * @param sesFactory Hibernate {@link SessionFactory}, for which to print
+     *                   statistics.
+     */
+    private static void printStats(SessionFactory sesFactory) {
+        System.out.println("=== Hibernate L2 cache statistics ===");
+
+        for (String entityName : ENTITY_NAMES) {
+            System.out.println("\tEntity: " + entityName);
+
+            SecondLevelCacheStatistics stats =
+                sesFactory.getStatistics().getSecondLevelCacheStatistics(entityName);
+
+            System.out.println("\t\tL2 cache entries: " + stats.getEntries());
+            System.out.println("\t\tHits: " + stats.getHitCount());
+            System.out.println("\t\tMisses: " + stats.getMissCount());
+        }
+
+        System.out.println("=====================================");
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/hibernate/Post.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/hibernate/Post.java b/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/hibernate/Post.java
new file mode 100644
index 0000000..8e98835
--- /dev/null
+++ b/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/hibernate/Post.java
@@ -0,0 +1,130 @@
+/*
+ * 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.examples.datagrid.hibernate;
+
+import java.util.Date;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.ManyToOne;
+
+/**
+ * An entity class representing a post, that a
+ * {@link User} has made on some public service.
+ */
+@Entity
+class Post {
+    /** ID. */
+    @Id
+    @GeneratedValue(strategy=GenerationType.AUTO)
+    private long id;
+
+    /** Author. */
+    @ManyToOne
+    private User author;
+
+    /** Text. */
+    private String text;
+
+    /** Created timestamp. */
+    private Date created;
+
+    /**
+     * Default constructor (required by Hibernate).
+     */
+    Post() {
+        // No-op.
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param author Author.
+     * @param text Text.
+     */
+    Post(User author, String text) {
+        this.author = author;
+        this.text = text;
+        created = new Date();
+    }
+
+    /**
+     * @return ID.
+     */
+    public long getId() {
+        return id;
+    }
+
+    /**
+     * @param id New ID.
+     */
+    public void setId(long id) {
+        this.id = id;
+    }
+
+    /**
+     * @return Author.
+     */
+    public User getAuthor() {
+        return author;
+    }
+
+    /**
+     * @param author New author.
+     */
+    public void setAuthor(User author) {
+        this.author = author;
+    }
+
+    /**
+     * @return Text.
+     */
+    public String getText() {
+        return text;
+    }
+
+    /**
+     * @param text New text.
+     */
+    public void setText(String text) {
+        this.text = text;
+    }
+
+    /**
+     * @return Created timestamp.
+     */
+    public Date getCreated() {
+        return (Date)created.clone();
+    }
+
+    /**
+     * @param created New created timestamp.
+     */
+    public void setCreated(Date created) {
+        this.created = (Date)created.clone();
+    }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return "Post [id=" + id +
+            ", text=" + text +
+            ", created=" + created +
+            ']';
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/hibernate/User.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/hibernate/User.java b/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/hibernate/User.java
new file mode 100644
index 0000000..d0486f5
--- /dev/null
+++ b/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/hibernate/User.java
@@ -0,0 +1,154 @@
+/*
+ * 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.examples.datagrid.hibernate;
+
+import java.util.HashSet;
+import java.util.Set;
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+import org.hibernate.annotations.NaturalId;
+
+/**
+ * A user entity class. Represents a user of some public service,
+ * having a number of personal information fields as well as a
+ * number of posts written.
+ */
+@Entity
+class User {
+    /** ID. */
+    @Id
+    @GeneratedValue(strategy=GenerationType.AUTO)
+    private long id;
+
+    /** Login. */
+    @NaturalId
+    private String login;
+
+    /** First name. */
+    private String firstName;
+
+    /** Last name. */
+    private String lastName;
+
+    /** Posts. */
+    @OneToMany(mappedBy = "author", cascade = CascadeType.ALL)
+    private Set<Post> posts = new HashSet<>();
+
+    /**
+     * Default constructor (required by Hibernate).
+     */
+    User() {
+        // No-op.
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param login Login.
+     * @param firstName First name.
+     * @param lastName Last name.
+     */
+    User(String login, String firstName, String lastName) {
+        this.login = login;
+        this.firstName = firstName;
+        this.lastName = lastName;
+    }
+
+    /**
+     * @return ID.
+     */
+    public long getId() {
+        return id;
+    }
+
+    /**
+     * @param id New ID.
+     */
+    public void setId(long id) {
+        this.id = id;
+    }
+
+    /**
+     * @return Login.
+     */
+    public String getLogin() {
+        return login;
+    }
+
+    /**
+     * @param login New login.
+     */
+    public void setLogin(String login) {
+        this.login = login;
+    }
+
+    /**
+     * @return First name.
+     */
+    public String getFirstName() {
+        return firstName;
+    }
+
+    /**
+     * @param firstName New first name.
+     */
+    public void setFirstName(String firstName) {
+        this.firstName = firstName;
+    }
+
+    /**
+     * @return Last name.
+     */
+    public String getLastName() {
+        return lastName;
+    }
+
+    /**
+     * @param lastName New last name.
+     */
+    public void setLastName(String lastName) {
+        this.lastName = lastName;
+    }
+
+    /**
+     * @return Posts.
+     */
+    public Set<Post> getPosts() {
+        return posts;
+    }
+
+    /**
+     * @param posts New posts.
+     */
+    public void setPosts(Set<Post> posts) {
+        this.posts = posts;
+    }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return "User [id=" + id +
+            ", login=" + login +
+            ", firstName=" + firstName +
+            ", lastName=" + lastName +
+            ']';
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/hibernate/package-info.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/hibernate/package-info.java b/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/hibernate/package-info.java
new file mode 100644
index 0000000..7bddaaf
--- /dev/null
+++ b/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/hibernate/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * <!-- Package description. -->
+ * Hibernate example.
+ */
+package org.apache.ignite.examples.datagrid.hibernate;

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernatePersonStore.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernatePersonStore.java b/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernatePersonStore.java
new file mode 100644
index 0000000..d040b88
--- /dev/null
+++ b/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernatePersonStore.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.examples.datagrid.store.hibernate;
+
+import java.util.List;
+import java.util.UUID;
+import javax.cache.integration.CacheLoaderException;
+import javax.cache.integration.CacheWriterException;
+import org.apache.ignite.cache.store.CacheStore;
+import org.apache.ignite.cache.store.CacheStoreAdapter;
+import org.apache.ignite.cache.store.CacheStoreSession;
+import org.apache.ignite.examples.datagrid.store.Person;
+import org.apache.ignite.lang.IgniteBiInClosure;
+import org.apache.ignite.resources.CacheStoreSessionResource;
+import org.hibernate.HibernateException;
+import org.hibernate.Session;
+
+/**
+ * Example of {@link CacheStore} implementation that uses Hibernate
+ * and deals with maps {@link UUID} to {@link Person}.
+ */
+public class CacheHibernatePersonStore extends CacheStoreAdapter<Long, Person> {
+    /** Auto-injected store session. */
+    @CacheStoreSessionResource
+    private CacheStoreSession ses;
+
+    /** {@inheritDoc} */
+    @Override public Person load(Long key) {
+        System.out.println(">>> Store load [key=" + key + ']');
+
+        Session hibSes = ses.attachment();
+
+        try {
+            return (Person)hibSes.get(Person.class, key);
+        }
+        catch (HibernateException e) {
+            throw new CacheLoaderException("Failed to load value from cache store [key=" + key + ']', e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public void write(javax.cache.Cache.Entry<? extends Long, ? extends Person> entry) {
+        Long key = entry.getKey();
+        Person val = entry.getValue();
+
+        System.out.println(">>> Store write [key=" + key + ", val=" + val + ']');
+
+        Session hibSes = ses.attachment();
+
+        try {
+            hibSes.saveOrUpdate(val);
+        }
+        catch (HibernateException e) {
+            throw new CacheWriterException("Failed to put value to cache store [key=" + key + ", val" + val + "]", e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @SuppressWarnings({"JpaQueryApiInspection"})
+    @Override public void delete(Object key) {
+        System.out.println(">>> Store delete [key=" + key + ']');
+
+        Session hibSes = ses.attachment();
+
+        try {
+            hibSes.createQuery("delete " + Person.class.getSimpleName() + " where key = :key").
+                setParameter("key", key).
+                executeUpdate();
+        }
+        catch (HibernateException e) {
+            throw new CacheWriterException("Failed to remove value from cache store [key=" + key + ']', e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public void loadCache(IgniteBiInClosure<Long, Person> clo, Object... args) {
+        if (args == null || args.length == 0 || args[0] == null)
+            throw new CacheLoaderException("Expected entry count parameter is not provided.");
+
+        final int entryCnt = (Integer)args[0];
+
+        Session hibSes = ses.attachment();
+
+        try {
+            int cnt = 0;
+
+            List list = hibSes.createCriteria(Person.class).
+                setMaxResults(entryCnt).
+                list();
+
+            if (list != null) {
+                for (Object obj : list) {
+                    Person person = (Person)obj;
+
+                    clo.apply(person.getId(), person);
+
+                    cnt++;
+                }
+            }
+
+            System.out.println(">>> Loaded " + cnt + " values into cache.");
+        }
+        catch (HibernateException e) {
+            throw new CacheLoaderException("Failed to load values from cache store.", e);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernateStoreExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernateStoreExample.java b/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernateStoreExample.java
new file mode 100644
index 0000000..f993d81
--- /dev/null
+++ b/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernateStoreExample.java
@@ -0,0 +1,151 @@
+/*
+ * 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.examples.datagrid.store.hibernate;
+
+import java.util.UUID;
+import javax.cache.configuration.Factory;
+import javax.cache.configuration.FactoryBuilder;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.store.CacheStoreSessionListener;
+import org.apache.ignite.cache.store.hibernate.CacheHibernateStoreSessionListener;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.examples.ExampleNodeStartup;
+import org.apache.ignite.examples.ExamplesUtils;
+import org.apache.ignite.examples.datagrid.store.Person;
+import org.apache.ignite.transactions.Transaction;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+
+/**
+ * Demonstrates usage of cache with underlying persistent store configured.
+ * <p>
+ * This example uses {@link CacheHibernatePersonStore} as a persistent store.
+ * <p>
+ * Remote nodes can be started with {@link ExampleNodeStartup} in another JVM which will
+ * start node with {@code examples/config/example-ignite.xml} configuration.
+ */
+public class CacheHibernateStoreExample {
+    /** Hibernate configuration resource path. */
+    private static final String HIBERNATE_CFG =
+        "/org/apache/ignite/examples/datagrid/store/hibernate/hibernate.cfg.xml";
+
+    /** Cache name. */
+    private static final String CACHE_NAME = CacheHibernateStoreExample.class.getSimpleName();
+
+    /** Heap size required to run this example. */
+    public static final int MIN_MEMORY = 1024 * 1024 * 1024;
+
+    /** Number of entries to load. */
+    private static final int ENTRY_COUNT = 100_000;
+
+    /** Global person ID to use across entire example. */
+    private static final Long id = Math.abs(UUID.randomUUID().getLeastSignificantBits());
+
+    /**
+     * Executes example.
+     *
+     * @param args Command line arguments, none required.
+     * @throws IgniteException If example execution failed.
+     */
+    public static void main(String[] args) throws IgniteException {
+        ExamplesUtils.checkMinMemory(MIN_MEMORY);
+
+        // To start ignite with desired configuration uncomment the appropriate line.
+        try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+            System.out.println();
+            System.out.println(">>> Cache store example started.");
+
+            CacheConfiguration<Long, Person> cacheCfg = new CacheConfiguration<>(CACHE_NAME);
+
+            // Set atomicity as transaction, since we are showing transactions in example.
+            cacheCfg.setAtomicityMode(TRANSACTIONAL);
+
+            // Configure Hibernate store.
+            cacheCfg.setCacheStoreFactory(FactoryBuilder.factoryOf(CacheHibernatePersonStore.class));
+
+            // Configure Hibernate session listener.
+            cacheCfg.setCacheStoreSessionListenerFactories(new Factory<CacheStoreSessionListener>() {
+                @Override public CacheStoreSessionListener create() {
+                    CacheHibernateStoreSessionListener lsnr = new CacheHibernateStoreSessionListener();
+
+                    lsnr.setHibernateConfigurationPath(HIBERNATE_CFG);
+
+                    return lsnr;
+                }
+            });
+
+            cacheCfg.setReadThrough(true);
+            cacheCfg.setWriteThrough(true);
+
+            try (IgniteCache<Long, Person> cache = ignite.getOrCreateCache(cacheCfg)) {
+                // Make initial cache loading from persistent store. This is a
+                // distributed operation and will call CacheStore.loadCache(...)
+                // method on all nodes in topology.
+                loadCache(cache);
+
+                // Start transaction and execute several cache operations with
+                // read/write-through to persistent store.
+                executeTransaction(cache);
+            }
+        }
+    }
+
+    /**
+     * Makes initial cache loading.
+     *
+     * @param cache Cache to load.
+     */
+    private static void loadCache(IgniteCache<Long, Person> cache) {
+        long start = System.currentTimeMillis();
+
+        // Start loading cache from persistent store on all caching nodes.
+        cache.loadCache(null, ENTRY_COUNT);
+
+        long end = System.currentTimeMillis();
+
+        System.out.println(">>> Loaded " + cache.size() + " keys with backups in " + (end - start) + "ms.");
+    }
+
+    /**
+     * Executes transaction with read/write-through to persistent store.
+     *
+     * @param cache Cache to execute transaction on.
+     */
+    private static void executeTransaction(IgniteCache<Long, Person> cache) {
+        try (Transaction tx = Ignition.ignite().transactions().txStart()) {
+            Person val = cache.get(id);
+
+            System.out.println("Read value: " + val);
+
+            val = cache.getAndPut(id, new Person(id, "Isaac", "Newton"));
+
+            System.out.println("Overwrote old value: " + val);
+
+            val = cache.get(id);
+
+            System.out.println("Read value: " + val);
+
+            tx.commit();
+        }
+
+        System.out.println("Read value after commit: " + cache.get(id));
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/Person.hbm.xml
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/Person.hbm.xml b/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/Person.hbm.xml
new file mode 100644
index 0000000..035ab98
--- /dev/null
+++ b/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/Person.hbm.xml
@@ -0,0 +1,34 @@
+<?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.
+-->
+
+
+<!DOCTYPE hibernate-mapping PUBLIC
+        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+        "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping default-access="field">
+    <class name="org.apache.ignite.examples.datagrid.store.Person" table="PERSONS">
+        <!-- ID. -->
+        <id name="id"/>
+
+        <!-- We only map data we are interested in. -->
+        <property name="firstName"/>
+        <property name="lastName"/>
+    </class>
+</hibernate-mapping>

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/hibernate.cfg.xml
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/hibernate.cfg.xml b/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/hibernate.cfg.xml
new file mode 100644
index 0000000..80a43e7
--- /dev/null
+++ b/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/hibernate.cfg.xml
@@ -0,0 +1,41 @@
+<?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.
+-->
+
+<!DOCTYPE hibernate-configuration PUBLIC
+        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
+        "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
+
+<!--
+    Hibernate configuration.
+-->
+<hibernate-configuration>
+    <session-factory>
+        <!-- Database connection settings (private in-memory database). -->
+        <property name="connection.url">jdbc:h2:mem:example;DB_CLOSE_DELAY=-1</property>
+
+        <!-- Only validate the database schema on startup in production mode. -->
+        <property name="hbm2ddl.auto">update</property>
+
+        <!-- Do not output SQL. -->
+        <property name="show_sql">false</property>
+
+        <!-- Mappings. -->
+        <mapping resource="org/apache/ignite/examples/datagrid/store/hibernate/Person.hbm.xml"/>
+    </session-factory>
+</hibernate-configuration>

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/package-info.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/package-info.java b/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/package-info.java
new file mode 100644
index 0000000..7210b49
--- /dev/null
+++ b/examples-lgpl/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * <!-- Package description. -->
+ * Contains Hibernate-based cache store implementation.
+ */
+package org.apache.ignite.examples.datagrid.store.hibernate;


[11/50] [abbrv] ignite git commit: Merge branch master into ignite-1.4.2

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


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

Branch: refs/heads/ignite-1016
Commit: 4ee154c808ac0d7384cdfc0dfc5c1ef5733e7e1b
Parents: 6afc2fc 1223525
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Mon Oct 12 12:28:00 2015 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Mon Oct 12 12:28:00 2015 +0300

----------------------------------------------------------------------
 examples/pom.xml                                |   2 +-
 examples/schema-import/pom.xml                  |   5 +-
 .../computegrid/ComputeClosureExample.java      |   2 +-
 .../socket/WordsSocketStreamerServer.java       |   5 +-
 modules/aop/pom.xml                             |   2 +-
 modules/apache-license-gen/README.txt           |  33 +
 modules/apache-license-gen/pom.xml              |   2 +-
 modules/aws/pom.xml                             |   2 +-
 modules/clients/pom.xml                         |   2 +-
 .../JettyRestProcessorAbstractSelfTest.java     | 252 ++++-
 modules/cloud/pom.xml                           |   2 +-
 .../TcpDiscoveryCloudIpFinderSelfTest.java      |   2 +
 modules/codegen/pom.xml                         |   2 +-
 modules/core/pom.xml                            |   2 +-
 .../org/apache/ignite/IgniteAtomicLong.java     |  15 +-
 .../apache/ignite/IgniteAtomicReference.java    |   9 +-
 .../org/apache/ignite/IgniteAtomicSequence.java |   9 +-
 .../org/apache/ignite/IgniteAtomicStamped.java  |  13 +-
 .../org/apache/ignite/IgniteFileSystem.java     |   4 +-
 .../apache/ignite/IgniteSystemProperties.java   |   3 +
 .../configuration/CacheConfiguration.java       |   2 +-
 .../ignite/configuration/TopologyValidator.java |  38 +-
 .../java/org/apache/ignite/igfs/IgfsPath.java   |   2 +-
 .../apache/ignite/internal/IgniteKernal.java    |  70 +-
 .../managers/discovery/CustomEventListener.java |   4 +-
 .../discovery/GridDiscoveryManager.java         | 541 ++++++++++-
 .../cache/DynamicCacheChangeRequest.java        |  19 +
 .../cache/DynamicCacheDescriptor.java           |  36 +
 .../processors/cache/GridCacheContext.java      |   2 +-
 .../processors/cache/GridCacheEventManager.java |  12 +-
 .../cache/GridCacheExplicitLockSpan.java        |  13 +-
 .../processors/cache/GridCacheIoManager.java    |  76 +-
 .../processors/cache/GridCacheMessage.java      |   7 -
 .../cache/GridCacheMvccCandidate.java           |   5 +-
 .../processors/cache/GridCacheMvccManager.java  |  67 +-
 .../GridCachePartitionExchangeManager.java      |  92 +-
 .../processors/cache/GridCacheProcessor.java    | 157 ++-
 .../cache/GridCacheSharedContext.java           |  32 -
 .../processors/cache/GridCacheSwapManager.java  |   4 +-
 .../processors/cache/GridCacheUtils.java        |   8 -
 .../distributed/GridDistributedCacheEntry.java  |   2 +-
 .../dht/GridDhtAffinityAssignmentRequest.java   |   5 -
 .../dht/GridDhtAffinityAssignmentResponse.java  |   5 -
 .../cache/distributed/dht/GridDhtGetFuture.java |   4 +-
 .../distributed/dht/GridDhtLockRequest.java     |  10 +-
 .../distributed/dht/GridDhtTxFinishRequest.java |   5 -
 .../distributed/dht/GridDhtTxPrepareFuture.java |   6 +-
 .../dht/GridDhtTxPrepareRequest.java            |   7 +-
 .../dht/GridPartitionedGetFuture.java           |   5 +-
 .../dht/atomic/GridDhtAtomicUpdateFuture.java   |   5 +
 .../dht/atomic/GridNearAtomicUpdateFuture.java  |  17 +-
 .../dht/colocated/GridDhtColocatedCache.java    |  12 +-
 .../colocated/GridDhtColocatedLockFuture.java   |  27 +-
 .../dht/preloader/GridDhtForceKeysRequest.java  |   5 -
 .../dht/preloader/GridDhtForceKeysResponse.java |   5 -
 .../GridDhtPartitionDemandMessage.java          |   5 -
 .../GridDhtPartitionSupplyMessage.java          |   5 -
 .../GridDhtPartitionsAbstractMessage.java       |   5 -
 .../dht/preloader/GridDhtPreloader.java         |   8 +-
 .../distributed/near/GridNearGetFuture.java     |   2 +
 .../distributed/near/GridNearLockFuture.java    |  11 +-
 .../near/GridNearOptimisticTxPrepareFuture.java |  24 +-
 .../near/GridNearTxFinishFuture.java            |   4 +-
 .../cache/distributed/near/GridNearTxLocal.java |  21 +-
 .../cache/local/GridLocalCacheEntry.java        |   2 +-
 .../cache/query/GridCacheQueryManager.java      |  74 +-
 .../cache/query/GridCacheSqlIndexMetadata.java  |   7 +-
 .../cache/query/GridCacheSqlMetadata.java       |  22 +-
 .../continuous/CacheContinuousQueryHandler.java |  10 +-
 .../transactions/IgniteTxLocalAdapter.java      |  35 +-
 .../continuous/GridContinuousProcessor.java     |  17 +-
 .../datastructures/DataStructuresProcessor.java |  54 +-
 .../internal/processors/igfs/IgfsFileInfo.java  |  15 +-
 .../internal/processors/igfs/IgfsImpl.java      | 208 +---
 .../processors/igfs/IgfsMetaManager.java        | 594 ++++++++++--
 .../processors/rest/GridRestCommand.java        |   8 +-
 .../processors/rest/GridRestProcessor.java      | 411 +++++++-
 .../handlers/cache/GridCacheCommandHandler.java | 364 +++----
 .../handlers/query/QueryCommandHandler.java     | 195 ++--
 .../top/GridTopologyCommandHandler.java         | 160 ++-
 .../rest/request/RestQueryRequest.java          | 175 ++++
 .../rest/request/RestSqlQueryRequest.java       | 125 ---
 .../ignite/internal/util/GridArgumentCheck.java |   5 +-
 .../ignite/internal/util/IgniteUtils.java       |   2 +-
 .../util/nio/GridNioRecoveryDescriptor.java     |   4 +-
 .../org/apache/ignite/stream/StreamAdapter.java | 104 +-
 .../stream/StreamMultipleTupleExtractor.java    |  38 +
 .../stream/StreamSingleTupleExtractor.java      |  40 +
 .../ignite/stream/StreamTupleExtractor.java     |  20 +-
 .../ignite/stream/socket/SocketStreamer.java    |   3 +-
 .../core/src/main/resources/ignite.properties   |   2 +-
 .../ignite/igfs/IgfsFragmentizerSelfTest.java   |   2 +-
 .../internal/GridUpdateNotifierSelfTest.java    |   1 +
 .../IgniteClientReconnectAbstractTest.java      |  35 +-
 .../IgniteClientReconnectCacheTest.java         | 154 +++
 .../GridDiscoveryManagerAliveCacheSelfTest.java |   2 +
 .../processors/cache/CrossCacheLockTest.java    | 142 +++
 .../GridCacheAbstractFailoverSelfTest.java      |   3 +
 .../GridCacheAbstractRemoveFailureTest.java     |   3 +
 .../GridCacheDeploymentOffHeapSelfTest.java     |  15 +
 .../GridCacheFinishPartitionsSelfTest.java      |   5 +-
 .../GridCacheVariableTopologySelfTest.java      |   3 +-
 ...IgniteCacheAtomicPutAllFailoverSelfTest.java |   4 +
 .../cache/IgniteCacheCreateRestartSelfTest.java |   3 +
 .../cache/IgniteCacheEntryListenerTxTest.java   |   4 +
 .../IgniteCacheP2pUnmarshallingErrorTest.java   |   7 +
 ...CacheP2pUnmarshallingRebalanceErrorTest.java |  12 +-
 .../cache/IgniteCachePutAllRestartTest.java     |   4 +-
 .../cache/IgniteDynamicCacheFilterTest.java     | 150 +++
 .../IgniteTxExceptionAbstractSelfTest.java      |   3 +
 ...omicOffheapQueueCreateMultiNodeSelfTest.java |   5 -
 ...ionedAtomicQueueCreateMultiNodeSelfTest.java |   9 +-
 ...artitionedOffHeapValuesQueueApiSelfTest.java |   4 +
 ...PartitionedQueueCreateMultiNodeSelfTest.java |  16 +-
 ...nedQueueFailoverDataConsistencySelfTest.java |   5 -
 ...GridCachePartitionedSetFailoverSelfTest.java |   4 +
 ...acheAsyncOperationsFailoverAbstractTest.java |  11 +
 .../CacheGetFutureHangsSelfTest.java            | 159 ++-
 .../CachePutAllFailoverAbstractTest.java        |  11 +
 .../IgniteCacheAtomicNodeRestartTest.java       |   8 +
 ...niteCacheClientNodeChangingTopologyTest.java |   6 +-
 .../IgniteCacheCreatePutMultiNodeSelfTest.java  | 151 +++
 .../distributed/IgniteCacheCreatePutTest.java   | 125 +++
 .../IgniteCachePutGetRestartAbstractTest.java   |   3 +
 .../IgniteCacheSizeFailoverTest.java            |   3 +
 .../IgniteTxPreloadAbstractTest.java            |  43 +-
 .../GridCacheColocatedTxExceptionSelfTest.java  |   5 -
 .../dht/GridNearCacheTxNodeFailureSelfTest.java |   4 +
 ...gniteAtomicLongChangingTopologySelfTest.java | 186 +++-
 .../IgniteCacheCrossCacheTxFailoverTest.java    |   3 +
 .../IgniteCrossCacheTxNearEnabledSelfTest.java  |  28 +
 .../dht/IgniteCrossCacheTxSelfTest.java         | 213 ++++
 ...ledFairAffinityMultiNodeFullApiSelfTest.java |   4 +
 .../near/GridCacheNearTxExceptionSelfTest.java  |   9 +-
 .../near/NearCacheMultithreadedUpdateTest.java  | 217 +++++
 .../GridCacheReplicatedInvalidateSelfTest.java  | 249 -----
 .../GridCacheReplicatedTxExceptionSelfTest.java |   5 -
 .../replicated/GridReplicatedTxPreloadTest.java |   2 -
 ...eCacheExpiryPolicyWithStoreAbstractTest.java |   5 +-
 .../GridCacheLocalTxExceptionSelfTest.java      |   5 -
 ...bledFairAffinityMultiJvmFullApiSelfTest.java |   5 +
 ...tomicNearEnabledMultiJvmFullApiSelfTest.java |   5 +
 .../DataStreamerMultiThreadedSelfTest.java      |   4 +-
 .../DataStreamerMultinodeCreateCacheTest.java   |   2 +
 .../processors/igfs/IgfsAbstractSelfTest.java   | 378 ++++++--
 .../igfs/IgfsClientCacheSelfTest.java           |  15 +-
 .../igfs/IgfsMetaManagerSelfTest.java           | 100 +-
 .../processors/igfs/IgfsMetricsSelfTest.java    |   2 +-
 .../processors/igfs/IgfsProcessorSelfTest.java  |  29 +-
 .../igfs/UniversalFileSystemAdapter.java        |   1 -
 .../tcp/TcpClientDiscoverySpiSelfTest.java      |   2 +
 .../stream/socket/SocketStreamerSelfTest.java   | 112 ++-
 .../multijvm/IgniteCacheProcessProxy.java       | 965 +++++++++++++++++++
 .../IgniteCacheFailoverTestSuite.java           |   4 -
 .../IgniteCacheFailoverTestSuite3.java          |  28 +-
 .../testsuites/IgniteCacheTestSuite3.java       |   2 -
 .../testsuites/IgniteCacheTestSuite4.java       |  22 +
 modules/extdata/p2p/pom.xml                     |   2 +-
 .../extdata/uri/modules/uri-dependency/pom.xml  |   2 +-
 modules/extdata/uri/pom.xml                     |   2 +-
 modules/gce/pom.xml                             |   2 +-
 modules/geospatial/pom.xml                      |   2 +-
 modules/hadoop/pom.xml                          |   2 +-
 .../processors/hadoop/igfs/HadoopIgfsUtils.java |  36 +
 .../ignite/igfs/Hadoop1DualAbstractTest.java    |   5 +
 ...oopFileSystemUniversalFileSystemAdapter.java |   4 +-
 .../HadoopIgfs20FileSystemAbstractSelfTest.java |   7 +-
 .../IgniteHadoopFileSystemAbstractSelfTest.java |   5 +-
 .../testsuites/IgniteHadoopTestSuite.java       |  19 +-
 modules/hibernate/pom.xml                       |   2 +-
 modules/indexing/pom.xml                        |   2 +-
 .../processors/query/h2/sql/GridSqlArray.java   |  52 +
 .../processors/query/h2/sql/GridSqlElement.java |   2 +-
 .../query/h2/sql/GridSqlFunction.java           |  60 +-
 .../query/h2/sql/GridSqlFunctionType.java       |   3 +
 .../query/h2/sql/GridSqlPlaceholder.java        |   7 +-
 .../query/h2/sql/GridSqlQueryParser.java        |  84 +-
 .../processors/query/h2/sql/GridSqlType.java    |  29 +-
 .../query/h2/sql/GridQueryParsingTest.java      |  27 +
 modules/jcl/pom.xml                             |   2 +-
 modules/jms11/pom.xml                           |   2 +-
 modules/jta/pom.xml                             |   2 +-
 modules/kafka/pom.xml                           |   2 +-
 modules/log4j/pom.xml                           |   2 +-
 modules/log4j2/pom.xml                          |   2 +-
 modules/mesos/pom.xml                           |   2 +-
 modules/mqtt/pom.xml                            | 114 +++
 .../apache/ignite/stream/mqtt/MqttStreamer.java | 611 ++++++++++++
 .../stream/mqtt/IgniteMqttStreamerTest.java     | 553 +++++++++++
 .../mqtt/IgniteMqttStreamerTestSuite.java       |  34 +
 modules/platform/pom.xml                        |   2 +-
 .../platform/src/main/cpp/common/configure.ac   |   2 +-
 .../src/main/cpp/core-test/configure.ac         |   2 +-
 modules/platform/src/main/cpp/core/configure.ac |   2 +-
 .../Properties/AssemblyInfo.cs                  |   6 +-
 .../Apache.Ignite/Properties/AssemblyInfo.cs    |   6 +-
 .../Properties/AssemblyInfo.cs                  |   6 +-
 .../Properties/AssemblyInfo.cs                  |   6 +-
 modules/rest-http/pom.xml                       |   2 +-
 .../http/jetty/GridJettyJsonConfig.java         | 158 ++-
 .../http/jetty/GridJettyRestHandler.java        | 186 ++--
 modules/scalar-2.10/pom.xml                     |   2 +-
 modules/scalar/pom.xml                          |   2 +-
 modules/schedule/pom.xml                        |   2 +-
 modules/schema-import/pom.xml                   |   2 +-
 modules/slf4j/pom.xml                           |   2 +-
 modules/spark-2.10/pom.xml                      |   2 +-
 modules/spark/pom.xml                           |   2 +-
 modules/spring/pom.xml                          |   2 +-
 modules/ssh/pom.xml                             |   2 +-
 modules/tools/pom.xml                           |   2 +-
 modules/urideploy/pom.xml                       |   2 +-
 modules/visor-console-2.10/pom.xml              |   2 +-
 modules/visor-console/pom.xml                   |   2 +-
 .../visor/commands/kill/VisorKillCommand.scala  |   2 +-
 .../scala/org/apache/ignite/visor/visor.scala   |   1 -
 modules/visor-plugins/pom.xml                   |   2 +-
 modules/web/pom.xml                             |   2 +-
 .../config/benchmark-put-indexed-val.properties |   2 +-
 modules/yardstick/pom.xml                       |  12 +-
 modules/yarn/pom.xml                            |   2 +-
 modules/zookeeper/pom.xml                       |   2 +-
 pom.xml                                         |   3 +-
 223 files changed, 8182 insertions(+), 2112 deletions(-)
----------------------------------------------------------------------


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

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

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

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

http://git-wip-us.apache.org/repos/asf/ignite/blob/4ee154c8/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
----------------------------------------------------------------------
diff --cc modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
index 02c6a26,d89e397..ddce314
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
@@@ -426,963 -427,963 +427,1927 @@@ public class IgniteCacheProcessProxy<K
       *
       */
      private static class GetConfigurationTask<K, V, C extends Configuration<K, V>> extends CacheTaskAdapter<K, V, C> {
+         /** Clazz. */
+         private final Class<C> clazz;
+ 
+         /**
+          * @param cacheName Cache name.
+          * @param async Async.
+          * @param clazz Clazz.
+          */
+         public GetConfigurationTask(String cacheName, boolean async, Class<C> clazz) {
+             super(cacheName, async);
+             this.clazz = clazz;
+         }
+ 
+         /** {@inheritDoc} */
+         @Override public C call() throws Exception {
+             return cache().getConfiguration(clazz);
+         }
+     }
+ 
+     /**
+      *
+      */
+     private static class LocalLoadCacheTask<K, V> extends CacheTaskAdapter<K, V, Void> {
+         /** Predicate. */
+         private final IgniteBiPredicate<K, V> p;
+ 
+         /** Args. */
+         private final Object[] args;
+ 
+         /**
+          * @param cacheName Cache name.
+          * @param async Async.
+          * @param p P.
+          * @param args Args.
+          */
+         public LocalLoadCacheTask(String cacheName, boolean async, IgniteBiPredicate<K, V> p, Object[] args) {
+             super(cacheName, async);
+             this.p = p;
+             this.args = args;
+         }
+ 
+         /** {@inheritDoc} */
+         @Override public Void call() {
+             cache().localLoadCache(p, args);
+ 
+             return null;
+         }
+     }
+ 
+     /**
+      *
+      */
+     private static class GetAndPutIfAbsentTask<K, V> extends CacheTaskAdapter<K, V, V> {
+         /** Key. */
+         private final K key;
+ 
+         /** Value. */
+         private final V val;
+ 
+         /**
+          * @param cacheName Cache name.
+          * @param async Async.
+          * @param key Key.
+          * @param val Value.
+          */
+         public GetAndPutIfAbsentTask(String cacheName, boolean async, K key, V val) {
+             super(cacheName, async);
+             this.key = key;
+             this.val = val;
+         }
+ 
+         /** {@inheritDoc} */
+         @Override public V call() throws Exception {
+             return cache().getAndPutIfAbsent(key, val);
+         }
+     }
+ 
+     /**
+      *
+      */
+     private static class IsLocalLockedTask<K> extends CacheTaskAdapter<K, Void, Boolean> {
+         /** Key. */
+         private final K key;
+ 
+         /** By current thread. */
+         private final boolean byCurrThread;
+ 
+         /**
+          * @param cacheName Cache name.
+          * @param async Async.
+          * @param key Key.
+          * @param byCurrThread By current thread.
+          */
+         public IsLocalLockedTask(String cacheName, boolean async, K key, boolean byCurrThread) {
+             super(cacheName, async);
+             this.key = key;
+             this.byCurrThread = byCurrThread;
+         }
+ 
+         /** {@inheritDoc} */
+         @Override public Boolean call() throws Exception {
+             return cache().isLocalLocked(key, byCurrThread);
+         }
+     }
+ 
+     /**
+      *
+      */
+     private static class LocalEntriesTask<K, V> extends CacheTaskAdapter<K, V, Iterable<Entry<K, V>>> {
+         /** Peek modes. */
+         private final CachePeekMode[] peekModes;
+ 
+         /**
+          * @param cacheName Cache name.
+          * @param async Async.
+          * @param peekModes Peek modes.
+          */
+         public LocalEntriesTask(String cacheName, boolean async, CachePeekMode[] peekModes) {
+             super(cacheName, async);
+             this.peekModes = peekModes;
+         }
+ 
+         /** {@inheritDoc} */
+         @Override public Iterable<Entry<K, V>> call() throws Exception {
+             Collection<Entry<K, V>> res = new ArrayList<>();
+ 
+             for (Entry<K, V> e : cache().localEntries(peekModes))
+                 res.add(new CacheEntryImpl<>(e.getKey(), e.getValue()));
+ 
+             return res;
+         }
+     }
+ 
+     /**
+      *
+      */
+     private static class LocalEvictTask<K> extends CacheTaskAdapter<K, Void, Void> {
+         /** Keys. */
+         private final Collection<? extends K> keys;
+ 
+         /**
+          * @param cacheName Cache name.
+          * @param async Async.
+          * @param keys Keys.
+          */
+         public LocalEvictTask(String cacheName, boolean async, Collection<? extends K> keys) {
+             super(cacheName, async);
+             this.keys = keys;
+         }
+ 
+         /** {@inheritDoc} */
+         @Override public Void call() {
+             cache().localEvict(keys);
+ 
+             return null;
+         }
+     }
+ 
+     /**
+      *
+      */
+     private static class LocalPeekTask<K, V> extends CacheTaskAdapter<K, V, V> {
+         /** Key. */
+         private final K key;
+ 
+         /** Peek modes. */
+         private final CachePeekMode[] peekModes;
+ 
+         /**
+          * @param cacheName Cache name.
+          * @param async Async.
+          * @param key Key.
+          * @param peekModes Peek modes.
+          */
+         public LocalPeekTask(String cacheName, boolean async, K key, CachePeekMode[] peekModes) {
+             super(cacheName, async);
+             this.key = key;
+             this.peekModes = peekModes;
+         }
+ 
+         /** {@inheritDoc} */
+         @Override public V call() throws Exception {
+             return cache().localPeek(key, peekModes);
+         }
+     }
+ 
+     /**
+      *
+      */
+     private static class SizeTask extends CacheTaskAdapter<Void, Void, Integer> {
+         /** Peek modes. */
+         private final CachePeekMode[] peekModes;
+ 
+         /** Local. */
+         private final boolean loc;
+ 
+         /**
+          * @param cacheName Cache name.
+          * @param async Async.
+          * @param peekModes Peek modes.
+          * @param loc Local.
+          */
+         public SizeTask(String cacheName, boolean async, CachePeekMode[] peekModes, boolean loc) {
+             super(cacheName, async);
+             this.loc = loc;
+             this.peekModes = peekModes;
+         }
+ 
+         /** {@inheritDoc} */
+         @Override public Integer call() throws Exception {
+             return loc ? cache().localSize(peekModes) : cache().size(peekModes);
+         }
+     }
+ 
+     /**
+      *
+      */
+     private static class GetTask<K, V> extends CacheTaskAdapter<K, V, V> {
+         /** Key. */
+         private final K key;
+ 
+         /**
+          * @param cacheName Cache name.
+          * @param async Async.
+          * @param key Key.
+          */
+         public GetTask(String cacheName, boolean async, K key) {
+             super(cacheName, async);
+             this.key = key;
+         }
+ 
+         /** {@inheritDoc} */
+         @Override public V call() throws Exception {
+             return cache().get(key);
+         }
+     }
+ 
+     /**
+      *
+      */
+     private static class RemoveAllTask<K, V> extends CacheTaskAdapter<K, V, Void> {
+         /**
+          * @param cacheName Cache name.
+          * @param async Async.
+          */
+         public RemoveAllTask(String cacheName, boolean async) {
+             super(cacheName, async);
+         }
+ 
+         /** {@inheritDoc} */
+         @Override public Void call() {
+             IgniteCache<K, V> cache = cache();
+ 
+             cache.removeAll();
+ 
+             if (async)
+                 cache.future().get();
+ 
+             return null;
+         }
+     }
+ 
+     /**
+      *
+      */
+     private static class PutTask<K, V> extends CacheTaskAdapter<K, V, Void> {
+         /** Key. */
+         private final K key;
+ 
+         /** Value. */
+         private final V val;
+ 
+         /**
+          * @param cacheName Cache name.
+          * @param async Async.
+          * @param key Key.
+          * @param val Value.
+          */
+         public PutTask(String cacheName, boolean async, K key, V val) {
+             super(cacheName, async);
+             this.key = key;
+             this.val = val;
+         }
+ 
+         /** {@inheritDoc} */
+         @Override public Void call() {
+             cache().put(key, val);
+ 
+             return null;
+         }
+     }
+ 
+     /**
+      *
+      */
+     private static class ContainsKeyTask<K> extends CacheTaskAdapter<K, Object, Boolean> {
+         /** Key. */
+         private final K key;
+ 
+         /**
+          * @param cacheName Cache name.
+          * @param async Async.
+          * @param key Key.
+          */
+         public ContainsKeyTask(String cacheName, boolean async, K key) {
+             super(cacheName, async);
+             this.key = key;
+         }
+ 
+         /** {@inheritDoc} */
+         @Override public Boolean call() throws Exception {
+             return cache().containsKey(key);
+         }
+     }
+ 
+     /**
+      *
+      */
+     private static class ClearTask extends CacheTaskAdapter<Object, Object, Void> {
+         /**
+          * @param cacheName Cache name.
+          * @param async Async.
+          */
+         public ClearTask(String cacheName, boolean async) {
+             super(cacheName, async);
+         }
+ 
+         /** {@inheritDoc} */
+         @Override public Void call() {
+             cache().clear();
+ 
+             return null;
+         }
+     }
+ 
+     /**
+      *
+      */
+     private static class IteratorTask<K, V> extends CacheTaskAdapter<K, V, Collection<Entry<K, V>>> {
+         /**
+          * @param cacheName Cache name.
+          * @param async Async.
+          */
+         public IteratorTask(String cacheName, boolean async) {
+             super(cacheName, async);
+         }
+ 
+         /** {@inheritDoc} */
+         @Override public Collection<Entry<K, V>> call() throws Exception {
+             Collection<Entry<K, V>> res = new ArrayList<>();
+ 
+             for (Entry<K, V> o : cache())
+                 res.add(o);
+ 
+             return res;
+         }
+     }
+ 
+     /**
+      *
+      */
+     private static class ReplaceTask<K, V> extends CacheTaskAdapter<K, V, Boolean> {
+         /** Key. */
+         private final K key;
+ 
+         /** Value. */
+         private final V val;
+ 
+         /**
+          * @param cacheName Cache name.
+          * @param async Async.
+          * @param key Key.
+          * @param val Value.
+          */
+         public ReplaceTask(String cacheName, boolean async, K key, V val) {
+             super(cacheName, async);
+             this.key = key;
+             this.val = val;
+         }
+ 
+         /** {@inheritDoc} */
+         @Override public Boolean call() throws Exception {
+             return cache().replace(key, val);
+         }
+     }
+ 
+     /**
+      *
+      */
+     private static class GetNameTask extends CacheTaskAdapter<Void, Void, String> {
+         /**
+          * @param cacheName Cache name.
+          * @param async Async.
+          */
+         public GetNameTask(String cacheName, boolean async) {
+             super(cacheName, async);
+         }
+ 
+         /** {@inheritDoc} */
+         @Override public String call() throws Exception {
+             return cache().getName();
+         }
+     }
+ 
+     /**
+      *
+      */
+     private static class RemoveTask<K> extends CacheTaskAdapter<K, Void, Boolean> {
+         /** Key. */
+         private final K key;
+ 
+         /**
+          * @param cacheName Cache name.
+          * @param async Async.
+          * @param key Key.
+          */
+         public RemoveTask(String cacheName, boolean async, K key) {
+             super(cacheName, async);
+             this.key = key;
+         }
+ 
+         /** {@inheritDoc} */
+         @Override public Boolean call() throws Exception {
+             return cache().remove(key);
+         }
+     }
+ 
+     /**
+      *
+      */
+     private static class PutAllTask<K, V> extends CacheTaskAdapter<K, V, Void> {
+         /** Map. */
+         private final Map<? extends K, ? extends V> map;
+ 
+         /**
+          * @param cacheName Cache name.
+          * @param async Async.
+          * @param map Map.
+          */
+         public PutAllTask(String cacheName, boolean async, Map<? extends K, ? extends V> map) {
+             super(cacheName, async);
+             this.map = map;
+         }
+ 
+         /** {@inheritDoc} */
+         @Override public Void call() {
+             cache().putAll(map);
+ 
+             return null;
+         }
+     }
+ 
+     /**
+      *
+      */
+     private static class RemoveAllKeysTask<K> extends CacheTaskAdapter<K, Void, Void> {
+         /** Keys. */
+         private final Set<? extends K> keys;
+ 
+         /**
+          * @param cacheName Cache name.
+          * @param async Async.
+          * @param keys Keys.
+          */
+         public RemoveAllKeysTask(String cacheName, boolean async, Set<? extends K> keys) {
+             super(cacheName, async);
+             this.keys = keys;
+         }
+ 
+         /** {@inheritDoc} */
+         @Override public Void call() {
+             cache().removeAll(keys);
+ 
+             return null;
+         }
+     }
+ 
+     /**
+      *
+      */
+     private static class GetAllTask<K, V> extends CacheTaskAdapter<K, V, Map<K, V>> {
+         /** Keys. */
+         private final Set<? extends K> keys;
+ 
+         /**
+          * @param cacheName Cache name.
+          * @param async Async.
+          * @param keys Keys.
+          */
+         public GetAllTask(String cacheName, boolean async, Set<? extends K> keys) {
+             super(cacheName, async);
+             this.keys = keys;
+         }
+ 
+         /** {@inheritDoc} */
+         @Override public Map<K, V> call() throws Exception {
+             return cache().getAll(keys);
+         }
+     }
+ 
+     /**
+      *
+      */
+     private static class GetAllOutTxTask<K, V> extends CacheTaskAdapter<K, V, Map<K, V>> {
+         /** Keys. */
+         private final Set<? extends K> keys;
+ 
+         /**
+          * @param cacheName Cache name.
+          * @param async Async.
+          * @param keys Keys.
+          */
+         public GetAllOutTxTask(String cacheName, boolean async, Set<? extends K> keys) {
+             super(cacheName, async);
+             this.keys = keys;
+         }
+ 
+         /** {@inheritDoc} */
+         @Override public Map<K, V> call() throws Exception {
+             return cache().getAllOutTx(keys);
+         }
+     }
+ 
+     /**
+      *
+      */
+     private static class ContainsKeysTask<K, V> extends CacheTaskAdapter<K, V, Boolean> {
+         /** Keys. */
+         private final Set<? extends K> keys;
+ 
+         /**
+          * @param cacheName Cache name.
+          * @param async Async.
+          * @param keys Keys.
+          */
+         public ContainsKeysTask(String cacheName, boolean async, Set<? extends K> keys) {
+             super(cacheName, async);
+             this.keys = keys;
+         }
+ 
+         /** {@inheritDoc} */
+         @Override public Boolean call() throws Exception {
+             return cache().containsKeys(keys);
+         }
+     }
+ 
+     /**
+      *
+      */
+     private static class GetAndPutTask<K, V> extends CacheTaskAdapter<K, V, V> {
+         /** Key. */
+         private final K key;
+ 
+         /** Value. */
+         private final V val;
+ 
+         /**
+          * @param cacheName Cache name.
+          * @param async Async.
+          * @param key Key.
+          * @param val Value.
+          */
+         public GetAndPutTask(String cacheName, boolean async, K key, V val) {
+             super(cacheName, async);
+             this.key = key;
+             this.val = val;
+         }
+ 
+         /** {@inheritDoc} */
+         @Override public V call() throws Exception {
+             return cache().getAndPut(key, val);
+         }
+     }
+ 
+     /**
+      *
+      */
+     private static class PutIfAbsentTask<K, V> extends CacheTaskAdapter<K, V, Boolean> {
+         /** Key. */
+         private final K key;
+ 
+         /** Value. */
+         private final V val;
+ 
+         /**
+          * @param cacheName Cache name.
+          * @param async Async.
+          * @param key Key.
+          * @param val Value.
+          */
+         public PutIfAbsentTask(String cacheName, boolean async, K key, V val) {
+             super(cacheName, async);
+             this.key = key;
+             this.val = val;
+         }
+ 
+         /** {@inheritDoc} */
+         @Override public Boolean call() throws Exception {
+             return cache().putIfAbsent(key, val);
+         }
+     }
+ 
+     /**
+      *
+      */
+     private static class RemoveIfExistsTask<K, V> extends CacheTaskAdapter<K, V, Boolean> {
+         /** Key. */
+         private final K key;
+ 
+         /** Old value. */
+         private final V oldVal;
+ 
+         /**
+          * @param cacheName Cache name.
+          * @param async Async.
+          * @param key Key.
+          * @param oldVal Old value.
+          */
+         public RemoveIfExistsTask(String cacheName, boolean async, K key, V oldVal) {
+             super(cacheName, async);
+             this.key = key;
+             this.oldVal = oldVal;
+         }
+ 
+         /** {@inheritDoc} */
+         @Override public Boolean call() throws Exception {
+             return cache().remove(key, oldVal);
+         }
+     }
+ 
+     /**
+      *
+      */
+     private static class GetAndRemoveTask<K, V> extends CacheTaskAdapter<K, V, V> {
+         /** Key. */
+         private final K key;
+ 
+         /**
+          * @param cacheName Cache name.
+          * @param async Async.
+          * @param key Key.
+          */
+         public GetAndRemoveTask(String cacheName, boolean async, K key) {
+             super(cacheName, async);
+             this.key = key;
+         }
+ 
+         /** {@inheritDoc} */
+         @Override public V call() throws Exception {
+             return cache().getAndRemove(key);
+         }
+     }
+ 
+     /**
+      *
+      */
+     private static class ReplaceIfExistsTask<K, V> extends CacheTaskAdapter<K, V, Boolean> {
+         /** Key. */
+         private final K key;
+ 
+         /** Old value. */
+         private final V oldVal;
+ 
+         /** New value. */
+         private final V newVal;
+ 
+         /**
+          * @param cacheName Cache name.
+          * @param async Async.
+          * @param key Key.
+          * @param oldVal Old value.
+          * @param newVal New value.
+          */
+         public ReplaceIfExistsTask(String cacheName, boolean async, K key, V oldVal, V newVal) {
+             super(cacheName, async);
+             this.key = key;
+             this.oldVal = oldVal;
+             this.newVal = newVal;
+         }
+ 
+         /** {@inheritDoc} */
+         @Override public Boolean call() throws Exception {
+             return cache().replace(key, oldVal, newVal);
+         }
+     }
+ 
+     /**
+      *
+      */
+     private static class GetAndReplaceTask<K, V> extends CacheTaskAdapter<K, V, V> {
+         /** Key. */
+         private final K key;
+ 
+         /** Value. */
+         private final V val;
+ 
+         /**
+          * @param cacheName Cache name.
+          * @param async Async.
+          * @param key Key.
+          * @param val Value.
+          */
+         public GetAndReplaceTask(String cacheName, boolean async, K key, V val) {
+             super(cacheName, async);
+             this.key = key;
+             this.val = val;
+         }
+ 
+         /** {@inheritDoc} */
+         @Override public V call() throws Exception {
+             return cache().getAndReplace(key, val);
+         }
+     }
+ 
+     /**
+      *
+      */
+     private static class ClearKeyTask<K> extends CacheTaskAdapter<K, Void, Void> {
+         /** Key. */
+         private final K key;
+ 
+         /** Local. */
+         private final boolean loc;
+ 
+         /**
+          * @param cacheName Cache name.
+          * @param async Async.
+          * @param key Key.
+          */
+         public ClearKeyTask(String cacheName, boolean async, boolean loc, K key) {
+             super(cacheName, async);
+             this.key = key;
+             this.loc = loc;
+         }
+ 
+         /** {@inheritDoc} */
+         @Override public Void call() {
+             if (loc)
+                 cache().localClear(key);
+             else
+                 cache().clear(key);
+ 
+             return null;
+         }
+     }
+ 
+     /**
+      *
+      */
+     private static class ClearAllKeys<K> extends CacheTaskAdapter<K, Void, Void> {
+         /** Keys. */
+         private final Set<? extends K> keys;
+ 
+         /** Local. */
+         private final boolean loc;
+ 
+         /**
+          * @param cacheName Cache name.
+          * @param async Async.
+          * @param keys Keys.
+          */
+         public ClearAllKeys(String cacheName, boolean async, boolean loc, Set<? extends K> keys) {
+             super(cacheName, async);
+             this.keys = keys;
+             this.loc = loc;
+         }
+ 
+         /** {@inheritDoc} */
+         @Override public Void call() {
+             if (loc)
+                 cache().localClearAll(keys);
+             else
+                 cache().clearAll(keys);
+ 
+             return null;
+         }
+     }
+ 
+     /**
+      *
+      */
+     private static class InvokeTask<K, V, R> extends CacheTaskAdapter<K, V, R> {
+         /** Key. */
+         private final K key;
+ 
+         /** Processor. */
+         private final EntryProcessor<K, V, R> processor;
+ 
+         /** Args. */
+         private final Object[] args;
+ 
+         /**
+          * @param cacheName Cache name.
+          * @param async Async.
+          * @param key Key.
+          * @param processor Processor.
+          * @param args Args.
+          */
+         public InvokeTask(String cacheName, boolean async, K key, EntryProcessor<K, V, R> processor,
+             Object[] args) {
+             super(cacheName, async);
+             this.args = args;
+             this.key = key;
+             this.processor = processor;
+         }
+ 
+         /** {@inheritDoc} */
+         @Override public R call() throws Exception {
+             return cache().invoke(key, processor, args);
+         }
+     }
+ 
+     /**
+      *
+      */
+     private static class InvokeAllTask<K, V, T> extends CacheTaskAdapter<K, V, Map<K, EntryProcessorResult<T>>> {
+         /** Keys. */
+         private final Set<? extends K> keys;
+ 
+         /** Processor. */
+         private final EntryProcessor<K, V, T> processor;
+ 
+         /** Args. */
+         private final Object[] args;
+ 
+         /**
+          * @param cacheName Cache name.
+          * @param async Async.
+          * @param keys Keys.
+          * @param processor Processor.
+          * @param args Args.
+          */
+         public InvokeAllTask(String cacheName, boolean async, Set<? extends K> keys,
+             EntryProcessor<K, V, T> processor, Object[] args) {
+             super(cacheName, async);
+             this.args = args;
+             this.keys = keys;
+             this.processor = processor;
+         }
+ 
+         /** {@inheritDoc} */
+         @Override public Map<K, EntryProcessorResult<T>> call() throws Exception {
+             return cache().invokeAll(keys, processor, args);
+         }
+     }
+ 
+     /**
+      *
+      */
+     private static class CloseTask extends CacheTaskAdapter<Void, Void, Void> {
+         /**
+          * @param cacheName Cache name.
+          * @param async Async.
+          */
+         public CloseTask(String cacheName, boolean async) {
+             super(cacheName, async);
+         }
+ 
+         /** {@inheritDoc} */
+         @Override public Void call() {
+             cache().close();
+ 
+             return null;
+         }
+     }
+ 
+     /**
+      *
+      */
+     private static class DestroyTask extends CacheTaskAdapter<Void, Void, Void> {
+         /**
+          * @param cacheName Cache name.
+          * @param async Async.
+          */
+         public DestroyTask(String cacheName, boolean async) {
+             super(cacheName, async);
+         }
+ 
+         /** {@inheritDoc} */
+         @Override public Void call() {
+             cache().destroy();
+ 
+             return null;
+         }
+     }
+ 
+     /**
+      *
+      */
+     private static class IsClosedTask extends CacheTaskAdapter<Void, Void, Boolean> {
+         /**
+          * @param cacheName Cache name.
+          * @param async Async.
+          */
+         public IsClosedTask(String cacheName, boolean async) {
+             super(cacheName, async);
+         }
+ 
+         /** {@inheritDoc} */
+         @Override public Boolean call() throws Exception {
+             return cache().isClosed();
+         }
+     }
+ 
+     /**
+      *
+      */
+     private static class UnwrapTask<R> extends CacheTaskAdapter<Void, Void, R> {
+         /** Clazz. */
+         private final Class<R> clazz;
+ 
+         /**
+          * @param cacheName Cache name.
+          * @param async Async.
+          * @param clazz Clazz.
+          */
+         public UnwrapTask(String cacheName, boolean async, Class<R> clazz) {
+             super(cacheName, async);
+             this.clazz = clazz;
+         }
+ 
+         /** {@inheritDoc} */
+         @Override public R call() throws Exception {
+             return cache().unwrap(clazz);
+         }
+     }
+ 
+     /**
+      *
+      */
+     private static abstract class CacheTaskAdapter<K, V, R> implements IgniteCallable<R> {
+         /** Ignite. */
+         @IgniteInstanceResource
+         protected Ignite ignite;
+ 
+         /** Cache name. */
+         protected final String cacheName;
+ 
+         /** Async. */
+         protected final boolean async;
+ 
+         /**
+          * @param cacheName Cache name.
+          * @param async Async.
+          */
+         public CacheTaskAdapter(String cacheName, boolean async) {
+             this.async = async;
+             this.cacheName = cacheName;
+         }
+ 
+         /**
+          * Returns cache instance.
+          */
+         protected IgniteCache<K, V> cache() {
+             IgniteCache<K, V> cache = ignite.cache(cacheName);
+ 
+             return async ? cache.withAsync() : cache;
+         }
+     }
 -}
++
++    /**
++     *
++     */
++    private static class GetConfigurationTask<K, V, C extends Configuration<K, V>> extends CacheTaskAdapter<K, V, C> {
 +        /** Clazz. */
 +        private final Class<C> clazz;
 +
 +        /**
 +         * @param cacheName Cache name.
 +         * @param async Async.
 +         * @param clazz Clazz.
 +         */
 +        public GetConfigurationTask(String cacheName, boolean async, Class<C> clazz) {
 +            super(cacheName, async);
 +            this.clazz = clazz;
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public C call() throws Exception {
 +            return cache().getConfiguration(clazz);
 +        }
 +    }
 +
 +    /**
 +     *
 +     */
 +    private static class LocalLoadCacheTask<K, V> extends CacheTaskAdapter<K, V, Void> {
 +        /** Predicate. */
 +        private final IgniteBiPredicate<K, V> p;
 +
 +        /** Args. */
 +        private final Object[] args;
 +
 +        /**
 +         * @param cacheName Cache name.
 +         * @param async Async.
 +         * @param p P.
 +         * @param args Args.
 +         */
 +        public LocalLoadCacheTask(String cacheName, boolean async, IgniteBiPredicate<K, V> p, Object[] args) {
 +            super(cacheName, async);
 +            this.p = p;
 +            this.args = args;
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public Void call() {
 +            cache().localLoadCache(p, args);
 +
 +            return null;
 +        }
 +    }
 +
 +    /**
 +     *
 +     */
 +    private static class GetAndPutIfAbsentTask<K, V> extends CacheTaskAdapter<K, V, V> {
 +        /** Key. */
 +        private final K key;
 +
 +        /** Value. */
 +        private final V val;
 +
 +        /**
 +         * @param cacheName Cache name.
 +         * @param async Async.
 +         * @param key Key.
 +         * @param val Value.
 +         */
 +        public GetAndPutIfAbsentTask(String cacheName, boolean async, K key, V val) {
 +            super(cacheName, async);
 +            this.key = key;
 +            this.val = val;
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public V call() throws Exception {
 +            return cache().getAndPutIfAbsent(key, val);
 +        }
 +    }
 +
 +    /**
 +     *
 +     */
 +    private static class IsLocalLockedTask<K> extends CacheTaskAdapter<K, Void, Boolean> {
 +        /** Key. */
 +        private final K key;
 +
 +        /** By current thread. */
 +        private final boolean byCurrThread;
 +
 +        /**
 +         * @param cacheName Cache name.
 +         * @param async Async.
 +         * @param key Key.
 +         * @param byCurrThread By current thread.
 +         */
 +        public IsLocalLockedTask(String cacheName, boolean async, K key, boolean byCurrThread) {
 +            super(cacheName, async);
 +            this.key = key;
 +            this.byCurrThread = byCurrThread;
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public Boolean call() throws Exception {
 +            return cache().isLocalLocked(key, byCurrThread);
 +        }
 +    }
 +
 +    /**
 +     *
 +     */
 +    private static class LocalEntriesTask<K, V> extends CacheTaskAdapter<K, V, Iterable<Entry<K, V>>> {
 +        /** Peek modes. */
 +        private final CachePeekMode[] peekModes;
 +
 +        /**
 +         * @param cacheName Cache name.
 +         * @param async Async.
 +         * @param peekModes Peek modes.
 +         */
 +        public LocalEntriesTask(String cacheName, boolean async, CachePeekMode[] peekModes) {
 +            super(cacheName, async);
 +            this.peekModes = peekModes;
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public Iterable<Entry<K, V>> call() throws Exception {
 +            Collection<Entry<K, V>> res = new ArrayList<>();
 +
 +            for (Entry<K, V> e : cache().localEntries(peekModes))
 +                res.add(e);
 +
 +            return res;
 +        }
 +    }
 +
 +    /**
 +     *
 +     */
 +    private static class LocalEvictTask<K> extends CacheTaskAdapter<K, Void, Void> {
 +        /** Keys. */
 +        private final Collection<? extends K> keys;
 +
 +        /**
 +         * @param cacheName Cache name.
 +         * @param async Async.
 +         * @param keys Keys.
 +         */
 +        public LocalEvictTask(String cacheName, boolean async, Collection<? extends K> keys) {
 +            super(cacheName, async);
 +            this.keys = keys;
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public Void call() {
 +            cache().localEvict(keys);
 +
 +            return null;
 +        }
 +    }
 +
 +    /**
 +     *
 +     */
 +    private static class LocalPeekTask<K, V> extends CacheTaskAdapter<K, V, V> {
 +        /** Key. */
 +        private final K key;
 +
 +        /** Peek modes. */
 +        private final CachePeekMode[] peekModes;
 +
 +        /**
 +         * @param cacheName Cache name.
 +         * @param async Async.
 +         * @param key Key.
 +         * @param peekModes Peek modes.
 +         */
 +        public LocalPeekTask(String cacheName, boolean async, K key, CachePeekMode[] peekModes) {
 +            super(cacheName, async);
 +            this.key = key;
 +            this.peekModes = peekModes;
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public V call() throws Exception {
 +            return cache().localPeek(key, peekModes);
 +        }
 +    }
 +
 +    /**
 +     *
 +     */
 +    private static class SizeTask extends CacheTaskAdapter<Void, Void, Integer> {
 +        /** Peek modes. */
 +        private final CachePeekMode[] peekModes;
 +
 +        /** Local. */
 +        private final boolean loc;
 +
 +        /**
 +         * @param cacheName Cache name.
 +         * @param async Async.
 +         * @param peekModes Peek modes.
 +         * @param loc Local.
 +         */
 +        public SizeTask(String cacheName, boolean async, CachePeekMode[] peekModes, boolean loc) {
 +            super(cacheName, async);
 +            this.loc = loc;
 +            this.peekModes = peekModes;
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public Integer call() throws Exception {
 +            return loc ? cache().localSize(peekModes) : cache().size(peekModes);
 +        }
 +    }
 +
 +    /**
 +     *
 +     */
 +    private static class GetTask<K, V> extends CacheTaskAdapter<K, V, V> {
 +        /** Key. */
 +        private final K key;
 +
 +        /**
 +         * @param cacheName Cache name.
 +         * @param async Async.
 +         * @param key Key.
 +         */
 +        public GetTask(String cacheName, boolean async, K key) {
 +            super(cacheName, async);
 +            this.key = key;
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public V call() throws Exception {
 +            return cache().get(key);
 +        }
 +    }
 +
 +    /**
 +     *
 +     */
 +    private static class RemoveAllTask<K, V> extends CacheTaskAdapter<K, V, Void> {
 +        /**
 +         * @param cacheName Cache name.
 +         * @param async Async.
 +         */
 +        public RemoveAllTask(String cacheName, boolean async) {
 +            super(cacheName, async);
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public Void call() {
 +            IgniteCache<K, V> cache = cache();
 +
 +            cache.removeAll();
 +
 +            if (async)
 +                cache.future().get();
 +
 +            return null;
 +        }
 +    }
 +
 +    /**
 +     *
 +     */
 +    private static class PutTask<K, V> extends CacheTaskAdapter<K, V, Void> {
 +        /** Key. */
 +        private final K key;
 +
 +        /** Value. */
 +        private final V val;
 +
 +        /**
 +         * @param cacheName Cache name.
 +         * @param async Async.
 +         * @param key Key.
 +         * @param val Value.
 +         */
 +        public PutTask(String cacheName, boolean async, K key, V val) {
 +            super(cacheName, async);
 +            this.key = key;
 +            this.val = val;
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public Void call() {
 +            cache().put(key, val);
 +
 +            return null;
 +        }
 +    }
 +
 +    /**
 +     *
 +     */
 +    private static class ContainsKeyTask<K> extends CacheTaskAdapter<K, Object, Boolean> {
 +        /** Key. */
 +        private final K key;
 +
 +        /**
 +         * @param cacheName Cache name.
 +         * @param async Async.
 +         * @param key Key.
 +         */
 +        public ContainsKeyTask(String cacheName, boolean async, K key) {
 +            super(cacheName, async);
 +            this.key = key;
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public Boolean call() throws Exception {
 +            return cache().containsKey(key);
 +        }
 +    }
 +
 +    /**
 +     *
 +     */
 +    private static class ClearTask extends CacheTaskAdapter<Object, Object, Void> {
 +        /**
 +         * @param cacheName Cache name.
 +         * @param async Async.
 +         */
 +        public ClearTask(String cacheName, boolean async) {
 +            super(cacheName, async);
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public Void call() {
 +            cache().clear();
 +
 +            return null;
 +        }
 +    }
 +
 +    /**
 +     *
 +     */
 +    private static class IteratorTask<K, V> extends CacheTaskAdapter<K, V, Collection<Entry<K, V>>> {
 +        /**
 +         * @param cacheName Cache name.
 +         * @param async Async.
 +         */
 +        public IteratorTask(String cacheName, boolean async) {
 +            super(cacheName, async);
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public Collection<Entry<K, V>> call() throws Exception {
 +            Collection<Entry<K, V>> res = new ArrayList<>();
 +
 +            for (Entry<K, V> o : cache())
 +                res.add(o);
 +
 +            return res;
 +        }
 +    }
 +
 +    /**
 +     *
 +     */
 +    private static class ReplaceTask<K, V> extends CacheTaskAdapter<K, V, Boolean> {
 +        /** Key. */
 +        private final K key;
 +
 +        /** Value. */
 +        private final V val;
 +
 +        /**
 +         * @param cacheName Cache name.
 +         * @param async Async.
 +         * @param key Key.
 +         * @param val Value.
 +         */
 +        public ReplaceTask(String cacheName, boolean async, K key, V val) {
 +            super(cacheName, async);
 +            this.key = key;
 +            this.val = val;
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public Boolean call() throws Exception {
 +            return cache().replace(key, val);
 +        }
 +    }
 +
 +    /**
 +     *
 +     */
 +    private static class GetNameTask extends CacheTaskAdapter<Void, Void, String> {
 +        /**
 +         * @param cacheName Cache name.
 +         * @param async Async.
 +         */
 +        public GetNameTask(String cacheName, boolean async) {
 +            super(cacheName, async);
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public String call() throws Exception {
 +            return cache().getName();
 +        }
 +    }
 +
 +    /**
 +     *
 +     */
 +    private static class RemoveTask<K> extends CacheTaskAdapter<K, Void, Boolean> {
 +        /** Key. */
 +        private final K key;
 +
 +        /**
 +         * @param cacheName Cache name.
 +         * @param async Async.
 +         * @param key Key.
 +         */
 +        public RemoveTask(String cacheName, boolean async, K key) {
 +            super(cacheName, async);
 +            this.key = key;
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public Boolean call() throws Exception {
 +            return cache().remove(key);
 +        }
 +    }
 +
 +    /**
 +     *
 +     */
 +    private static class PutAllTask<K, V> extends CacheTaskAdapter<K, V, Void> {
 +        /** Map. */
 +        private final Map<? extends K, ? extends V> map;
 +
 +        /**
 +         * @param cacheName Cache name.
 +         * @param async Async.
 +         * @param map Map.
 +         */
 +        public PutAllTask(String cacheName, boolean async, Map<? extends K, ? extends V> map) {
 +            super(cacheName, async);
 +            this.map = map;
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public Void call() {
 +            cache().putAll(map);
 +
 +            return null;
 +        }
 +    }
 +
 +    /**
 +     *
 +     */
 +    private static class RemoveAllKeysTask<K> extends CacheTaskAdapter<K, Void, Void> {
 +        /** Keys. */
 +        private final Set<? extends K> keys;
 +
 +        /**
 +         * @param cacheName Cache name.
 +         * @param async Async.
 +         * @param keys Keys.
 +         */
 +        public RemoveAllKeysTask(String cacheName, boolean async, Set<? extends K> keys) {
 +            super(cacheName, async);
 +            this.keys = keys;
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public Void call() {
 +            cache().removeAll(keys);
 +
 +            return null;
 +        }
 +    }
 +
 +    /**
 +     *
 +     */
 +    private static class GetAllTask<K, V> extends CacheTaskAdapter<K, V, Map<K, V>> {
 +        /** Keys. */
 +        private final Set<? extends K> keys;
 +
 +        /**
 +         * @param cacheName Cache name.
 +         * @param async Async.
 +         * @param keys Keys.
 +         */
 +        public GetAllTask(String cacheName, boolean async, Set<? extends K> keys) {
 +            super(cacheName, async);
 +            this.keys = keys;
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public Map<K, V> call() throws Exception {
 +            return cache().getAll(keys);
 +        }
 +    }
 +
 +    /**
 +     *
 +     */
 +    private static class GetAllOutTxTask<K, V> extends CacheTaskAdapter<K, V, Map<K, V>> {
 +        /** Keys. */
 +        private final Set<? extends K> keys;
 +
 +        /**
 +         * @param cacheName Cache name.
 +         * @param async Async.
 +         * @param keys Keys.
 +         */
 +        public GetAllOutTxTask(String cacheName, boolean async, Set<? extends K> keys) {
 +            super(cacheName, async);
 +            this.keys = keys;
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public Map<K, V> call() throws Exception {
 +            return cache().getAllOutTx(keys);
 +        }
 +    }
 +
 +    /**
 +     *
 +     */
 +    private static class ContainsKeysTask<K, V> extends CacheTaskAdapter<K, V, Boolean> {
 +        /** Keys. */
 +        private final Set<? extends K> keys;
 +
 +        /**
 +         * @param cacheName Cache name.
 +         * @param async Async.
 +         * @param keys Keys.
 +         */
 +        public ContainsKeysTask(String cacheName, boolean async, Set<? extends K> keys) {
 +            super(cacheName, async);
 +            this.keys = keys;
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public Boolean call() throws Exception {
 +            return cache().containsKeys(keys);
 +        }
 +    }
 +
 +    /**
 +     *
 +     */
 +    private static class GetAndPutTask<K, V> extends CacheTaskAdapter<K, V, V> {
 +        /** Key. */
 +        private final K key;
 +
 +        /** Value. */
 +        private final V val;
 +
 +        /**
 +         * @param cacheName Cache name.
 +         * @param async Async.
 +         * @param key Key.
 +         * @param val Value.
 +         */
 +        public GetAndPutTask(String cacheName, boolean async, K key, V val) {
 +            super(cacheName, async);
 +            this.key = key;
 +            this.val = val;
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public V call() throws Exception {
 +            return cache().getAndPut(key, val);
 +        }
 +    }
 +
 +    /**
 +     *
 +     */
 +    private static class PutIfAbsentTask<K, V> extends CacheTaskAdapter<K, V, Boolean> {
 +        /** Key. */
 +        private final K key;
 +
 +        /** Value. */
 +        private final V val;
 +
 +        /**
 +         * @param cacheName Cache name.
 +         * @param async Async.
 +         * @param key Key.
 +         * @param val Value.
 +         */
 +        public PutIfAbsentTask(String cacheName, boolean async, K key, V val) {
 +            super(cacheName, async);
 +            this.key = key;
 +            this.val = val;
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public Boolean call() throws Exception {
 +            return cache().putIfAbsent(key, val);
 +        }
 +    }
 +
 +    /**
 +     *
 +     */
 +    private static class RemoveIfExistsTask<K, V> extends CacheTaskAdapter<K, V, Boolean> {
 +        /** Key. */
 +        private final K key;
 +
 +        /** Old value. */
 +        private final V oldVal;
 +
 +        /**
 +         * @param cacheName Cache name.
 +         * @param async Async.
 +         * @param key Key.
 +         * @param oldVal Old value.
 +         */
 +        public RemoveIfExistsTask(String cacheName, boolean async, K key, V oldVal) {
 +            super(cacheName, async);
 +            this.key = key;
 +            this.oldVal = oldVal;
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public Boolean call() throws Exception {
 +            return cache().remove(key, oldVal);
 +        }
 +    }
 +
 +    /**
 +     *
 +     */
 +    private static class GetAndRemoveTask<K, V> extends CacheTaskAdapter<K, V, V> {
 +        /** Key. */
 +        private final K key;
 +
 +        /**
 +         * @param cacheName Cache name.
 +         * @param async Async.
 +         * @param key Key.
 +         */
 +        public GetAndRemoveTask(String cacheName, boolean async, K key) {
 +            super(cacheName, async);
 +            this.key = key;
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public V call() throws Exception {
 +            return cache().getAndRemove(key);
 +        }
 +    }
 +
 +    /**
 +     *
 +     */
 +    private static class ReplaceIfExistsTask<K, V> extends CacheTaskAdapter<K, V, Boolean> {
 +        /** Key. */
 +        private final K key;
 +
 +        /** Old value. */
 +        private final V oldVal;
 +
 +        /** New value. */
 +        private final V newVal;
 +
 +        /**
 +         * @param cacheName Cache name.
 +         * @param async Async.
 +         * @param key Key.
 +         * @param oldVal Old value.
 +         * @param newVal New value.
 +         */
 +        public ReplaceIfExistsTask(String cacheName, boolean async, K key, V oldVal, V newVal) {
 +            super(cacheName, async);
 +            this.key = key;
 +            this.oldVal = oldVal;
 +            this.newVal = newVal;
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public Boolean call() throws Exception {
 +            return cache().replace(key, oldVal, newVal);
 +        }
 +    }
 +
 +    /**
 +     *
 +     */
 +    private static class GetAndReplaceTask<K, V> extends CacheTaskAdapter<K, V, V> {
 +        /** Key. */
 +        private final K key;
 +
 +        /** Value. */
 +        private final V val;
 +
 +        /**
 +         * @param cacheName Cache name.
 +         * @param async Async.
 +         * @param key Key.
 +         * @param val Value.
 +         */
 +        public GetAndReplaceTask(String cacheName, boolean async, K key, V val) {
 +            super(cacheName, async);
 +            this.key = key;
 +            this.val = val;
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public V call() throws Exception {
 +            return cache().getAndReplace(key, val);
 +        }
 +    }
 +
 +    /**
 +     *
 +     */
 +    private static class ClearKeyTask<K> extends CacheTaskAdapter<K, Void, Void> {
 +        /** Key. */
 +        private final K key;
 +
 +        /** Local. */
 +        private final boolean loc;
 +
 +        /**
 +         * @param cacheName Cache name.
 +         * @param async Async.
 +         * @param key Key.
 +         */
 +        public ClearKeyTask(String cacheName, boolean async, boolean loc, K key) {
 +            super(cacheName, async);
 +            this.key = key;
 +            this.loc = loc;
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public Void call() {
 +            if (loc)
 +                cache().localClear(key);
 +            else
 +                cache().clear(key);
 +
 +            return null;
 +        }
 +    }
 +
 +    /**
 +     *
 +     */
 +    private static class ClearAllKeys<K> extends CacheTaskAdapter<K, Void, Void> {
 +        /** Keys. */
 +        private final Set<? extends K> keys;
 +
 +        /** Local. */
 +        private final boolean loc;
 +
 +        /**
 +         * @param cacheName Cache name.
 +         * @param async Async.
 +         * @param keys Keys.
 +         */
 +        public ClearAllKeys(String cacheName, boolean async, boolean loc, Set<? extends K> keys) {
 +            super(cacheName, async);
 +            this.keys = keys;
 +            this.loc = loc;
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public Void call() {
 +            if (loc)
 +                cache().localClearAll(keys);
 +            else
 +                cache().clearAll(keys);
 +
 +            return null;
 +        }
 +    }
 +
 +    /**
 +     *
 +     */
 +    private static class InvokeTask<K, V, R> extends CacheTaskAdapter<K, V, R> {
 +        /** Key. */
 +        private final K key;
 +
 +        /** Processor. */
 +        private final EntryProcessor<K, V, R> processor;
 +
 +        /** Args. */
 +        private final Object[] args;
 +
 +        /**
 +         * @param cacheName Cache name.
 +         * @param async Async.
 +         * @param key Key.
 +         * @param processor Processor.
 +         * @param args Args.
 +         */
 +        public InvokeTask(String cacheName, boolean async, K key, EntryProcessor<K, V, R> processor,
 +            Object[] args) {
 +            super(cacheName, async);
 +            this.args = args;
 +            this.key = key;
 +            this.processor = processor;
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public R call() throws Exception {
 +            return cache().invoke(key, processor, args);
 +        }
 +    }
 +
 +    /**
 +     *
 +     */
 +    private static class InvokeAllTask<K, V, T> extends CacheTaskAdapter<K, V, Map<K, EntryProcessorResult<T>>> {
 +        /** Keys. */
 +        private final Set<? extends K> keys;
 +
 +        /** Processor. */
 +        private final EntryProcessor<K, V, T> processor;
 +
 +        /** Args. */
 +        private final Object[] args;
 +
 +        /**
 +         * @param cacheName Cache name.
 +         * @param async Async.
 +         * @param keys Keys.
 +         * @param processor Processor.
 +         * @param args Args.
 +         */
 +        public InvokeAllTask(String cacheName, boolean async, Set<? extends K> keys,
 +            EntryProcessor<K, V, T> processor, Object[] args) {
 +            super(cacheName, async);
 +            this.args = args;
 +            this.keys = keys;
 +            this.processor = processor;
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public Map<K, EntryProcessorResult<T>> call() throws Exception {
 +            return cache().invokeAll(keys, processor, args);
 +        }
 +    }
 +
 +    /**
 +     *
 +     */
 +    private static class CloseTask extends CacheTaskAdapter<Void, Void, Void> {
 +        /**
 +         * @param cacheName Cache name.
 +         * @param async Async.
 +         */
 +        public CloseTask(String cacheName, boolean async) {
 +            super(cacheName, async);
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public Void call() {
 +            cache().close();
 +
 +            return null;
 +        }
 +    }
 +
 +    /**
 +     *
 +     */
 +    private static class DestroyTask extends CacheTaskAdapter<Void, Void, Void> {
 +        /**
 +         * @param cacheName Cache name.
 +         * @param async Async.
 +         */
 +        public DestroyTask(String cacheName, boolean async) {
 +            super(cacheName, async);
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public Void call() {
 +            cache().destroy();
 +
 +            return null;
 +        }
 +    }
 +
 +    /**
 +     *
 +     */
 +    private static class IsClosedTask extends CacheTaskAdapter<Void, Void, Boolean> {
 +        /**
 +         * @param cacheName Cache name.
 +         * @param async Async.
 +         */
 +        public IsClosedTask(String cacheName, boolean async) {
 +            super(cacheName, async);
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public Boolean call() throws Exception {
 +            return cache().isClosed();
 +        }
 +    }
 +
 +    /**
 +     *
 +     */
 +    private static class UnwrapTask<R> extends CacheTaskAdapter<Void, Void, R> {
 +        /** Clazz. */
 +        private final Class<R> clazz;
 +
 +        /**
 +         * @param cacheName Cache name.
 +         * @param async Async.
 +         * @param clazz Clazz.
 +         */
 +        public UnwrapTask(String cacheName, boolean async, Class<R> clazz) {
 +            super(cacheName, async);
 +            this.clazz = clazz;
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public R call() throws Exception {
 +            return cache().unwrap(clazz);
 +        }
 +    }
 +
 +    /**
 +     *
 +     */
 +    private static abstract class CacheTaskAdapter<K, V, R> implements IgniteCallable<R> {
 +        /** Ignite. */
 +        @IgniteInstanceResource
 +        protected Ignite ignite;
 +
 +        /** Cache name. */
 +        protected final String cacheName;
 +
 +        /** Async. */
 +        protected final boolean async;
 +
 +        /**
 +         * @param cacheName Cache name.
 +         * @param async Async.
 +         */
 +        public CacheTaskAdapter(String cacheName, boolean async) {
 +            this.async = async;
 +            this.cacheName = cacheName;
 +        }
 +
 +        /**
 +         * Returns cache instance.
 +         */
 +        protected IgniteCache<K, V> cache() {
 +            IgniteCache<K, V> cache = ignite.cache(cacheName);
 +
 +            return async ? cache.withAsync() : cache;
 +        }
 +    }
 +}

http://git-wip-us.apache.org/repos/asf/ignite/blob/4ee154c8/modules/platform/src/main/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --cc modules/platform/src/main/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs
index 8e653e3,1876e24..7425cb6
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs
+++ b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs
@@@ -1,4 -1,4 +1,4 @@@
--/*
++/*
   * 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.

http://git-wip-us.apache.org/repos/asf/ignite/blob/4ee154c8/modules/platform/src/main/dotnet/Apache.Ignite/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --cc modules/platform/src/main/dotnet/Apache.Ignite/Properties/AssemblyInfo.cs
index 7cf47c3,03f7fb9..198cfa6
--- a/modules/platform/src/main/dotnet/Apache.Ignite/Properties/AssemblyInfo.cs
+++ b/modules/platform/src/main/dotnet/Apache.Ignite/Properties/AssemblyInfo.cs
@@@ -1,4 -1,4 +1,4 @@@
--/*
++/*
   * 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.

http://git-wip-us.apache.org/repos/asf/ignite/blob/4ee154c8/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests.TestDll/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --cc modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests.TestDll/Properties/AssemblyInfo.cs
index ba4b794,22d74c9..a45f421
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests.TestDll/Properties/AssemblyInfo.cs
+++ b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests.TestDll/Properties/AssemblyInfo.cs
@@@ -1,4 -1,4 +1,4 @@@
--/*
++/*
   * 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.

http://git-wip-us.apache.org/repos/asf/ignite/blob/4ee154c8/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --cc modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Properties/AssemblyInfo.cs
index f474b03,1ebcf24..db88e3b
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Properties/AssemblyInfo.cs
+++ b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Properties/AssemblyInfo.cs
@@@ -1,4 -1,4 +1,4 @@@
--/*
++/*
   * 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.


[31/50] [abbrv] ignite git commit: IGNITE-1555. Combine ignite-hadoop and ignite-spark into signle assembly for downstream consumption.

Posted by ag...@apache.org.
IGNITE-1555. Combine ignite-hadoop and ignite-spark into signle assembly for downstream consumption.


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

Branch: refs/heads/ignite-1016
Commit: c9eb539b565bf0a49dbe8dc936c1b2f165946805
Parents: 8217be6
Author: Konstantin Boudnik <co...@wandisco.com>
Authored: Fri Oct 9 20:54:30 2015 -0700
Committer: Konstantin Boudnik <co...@wandisco.com>
Committed: Thu Oct 15 14:01:50 2015 -0700

----------------------------------------------------------------------
 DEVNOTES.txt                     | 3 ++-
 assembly/dependencies-hadoop.xml | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/c9eb539b/DEVNOTES.txt
----------------------------------------------------------------------
diff --git a/DEVNOTES.txt b/DEVNOTES.txt
index a46b73d..a6c45f0 100644
--- a/DEVNOTES.txt
+++ b/DEVNOTES.txt
@@ -23,7 +23,8 @@ mvn clean package -DskipTests -Dignite.edition=hadoop [-Dhadoop.version=X.X.X]
 
 Use 'hadoop.version' parameter to build Ignite against a specific Hadoop version.
 
-Look for apache-ignite-hadoop-<version>-bin.zip in ./target/bin directory.
+Look for apache-ignite-hadoop-<version>-bin.zip in ./target/bin directory. Resulting binary
+assembly will also include integration module for Apache Spark.
 
 NOTE: JDK version should be 1.7.0-* or >= 1.8.0-u40.
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/c9eb539b/assembly/dependencies-hadoop.xml
----------------------------------------------------------------------
diff --git a/assembly/dependencies-hadoop.xml b/assembly/dependencies-hadoop.xml
index 0e282a4..38646ba 100644
--- a/assembly/dependencies-hadoop.xml
+++ b/assembly/dependencies-hadoop.xml
@@ -32,6 +32,7 @@
     <moduleSets>
         <moduleSet>
             <includes>
+                <include>org.apache.ignite:ignite-spark</include>
                 <include>org.apache.ignite:ignite-spring</include>
                 <include>org.apache.ignite:ignite-log4j</include>
                 <include>org.apache.ignite:ignite-indexing</include>


[39/50] [abbrv] ignite git commit: IGNITE-1733

Posted by ag...@apache.org.
IGNITE-1733


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

Branch: refs/heads/ignite-1016
Commit: 10cf673ce288229d5ff346f95542e0b8d4a9fea0
Parents: 9527933
Author: Anton Vinogradov <av...@apache.org>
Authored: Mon Oct 19 18:23:47 2015 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Mon Oct 19 18:23:47 2015 +0300

----------------------------------------------------------------------
 .../misc/schedule/ComputeScheduleExample.java   | 82 ++++++++++++++++++++
 .../examples/misc/schedule/package-info.java    | 22 ++++++
 .../misc/schedule/ComputeScheduleExample.java   | 68 ++++++++++++++++
 .../java8/misc/schedule/package-info.java       | 22 ++++++
 .../misc/schedule/ComputeScheduleExample.java   | 82 --------------------
 .../examples/misc/schedule/package-info.java    | 22 ------
 .../misc/schedule/ComputeScheduleExample.java   | 68 ----------------
 .../java8/misc/schedule/package-info.java       | 22 ------
 8 files changed, 194 insertions(+), 194 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/10cf673c/examples-lgpl/src/main/java/org/apache/ignite/examples/misc/schedule/ComputeScheduleExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java/org/apache/ignite/examples/misc/schedule/ComputeScheduleExample.java b/examples-lgpl/src/main/java/org/apache/ignite/examples/misc/schedule/ComputeScheduleExample.java
new file mode 100644
index 0000000..f8d0660
--- /dev/null
+++ b/examples-lgpl/src/main/java/org/apache/ignite/examples/misc/schedule/ComputeScheduleExample.java
@@ -0,0 +1,82 @@
+/*
+ * 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.examples.misc.schedule;
+
+import java.util.concurrent.Callable;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.examples.ExampleNodeStartup;
+import org.apache.ignite.lang.IgniteRunnable;
+import org.apache.ignite.scheduler.SchedulerFuture;
+
+/**
+ * Demonstrates a cron-based {@link Runnable} execution scheduling.
+ * Test runnable object broadcasts a phrase to all cluster nodes every minute
+ * three times with initial scheduling delay equal to five seconds.
+ * <p>
+ * Remote nodes should always be started with special configuration file which
+ * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
+ * <p>
+ * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
+ * with {@code examples/config/example-ignite.xml} configuration.
+ */
+public class ComputeScheduleExample {
+    /**
+     * Executes example.
+     *
+     * @param args Command line arguments, none required.
+     * @throws IgniteException If example execution failed.
+     */
+    public static void main(String[] args) throws IgniteException {
+        try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+            System.out.println();
+            System.out.println("Compute schedule example started.");
+
+            // Schedule output message every minute.
+            SchedulerFuture<?> fut = ignite.scheduler().scheduleLocal(
+                new Callable<Integer>() {
+                    private int invocations;
+
+                    @Override public Integer call() {
+                        invocations++;
+
+                        ignite.compute().broadcast(
+                            new IgniteRunnable() {
+                                @Override public void run() {
+                                    System.out.println();
+                                    System.out.println("Howdy! :)");
+                                }
+                            }
+                        );
+
+                        return invocations;
+                    }
+                },
+                "{5, 3} * * * * *" // Cron expression.
+            );
+
+            while (!fut.isDone())
+                System.out.println(">>> Invocation #: " + fut.get());
+
+            System.out.println();
+            System.out.println(">>> Schedule future is done and has been unscheduled.");
+            System.out.println(">>> Check all nodes for hello message output.");
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/10cf673c/examples-lgpl/src/main/java/org/apache/ignite/examples/misc/schedule/package-info.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java/org/apache/ignite/examples/misc/schedule/package-info.java b/examples-lgpl/src/main/java/org/apache/ignite/examples/misc/schedule/package-info.java
new file mode 100644
index 0000000..6602a6e
--- /dev/null
+++ b/examples-lgpl/src/main/java/org/apache/ignite/examples/misc/schedule/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * <!-- Package description. -->
+ * Demonstrates usage of cron-based scheduler.
+ */
+package org.apache.ignite.examples.misc.schedule;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/10cf673c/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/ComputeScheduleExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/ComputeScheduleExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/ComputeScheduleExample.java
new file mode 100644
index 0000000..c250638
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/ComputeScheduleExample.java
@@ -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.
+ */
+
+package org.apache.ignite.examples.java8.misc.schedule;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.examples.ExampleNodeStartup;
+import org.apache.ignite.scheduler.SchedulerFuture;
+
+/**
+ * Demonstrates a cron-based {@link Runnable} execution scheduling.
+ * Test runnable object broadcasts a phrase to all cluster nodes every minute
+ * three times with initial scheduling delay equal to five seconds.
+ * <p>
+ * Remote nodes should always be started with special configuration file which
+ * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
+ * <p>
+ * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
+ * with {@code examples/config/example-ignite.xml} configuration.
+ */
+public class ComputeScheduleExample {
+    /**
+     * Executes example.
+     *
+     * @param args Command line arguments, none required.
+     * @throws IgniteException If example execution failed.
+     */
+    public static void main(String[] args) throws IgniteException {
+        try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+            System.out.println();
+            System.out.println("Compute schedule example started.");
+
+            // Schedule output message every minute.
+            SchedulerFuture<?> fut = ignite.scheduler().scheduleLocal(() ->
+                ignite.compute().broadcast(() -> {
+                    System.out.println();
+                    System.out.println("Howdy! :)");
+
+                    return "Howdy! :)";
+                }),
+                "{5, 3} * * * * *" // Cron expression.
+            );
+
+            while (!fut.isDone())
+                System.out.println(">>> Invocation result: " + fut.get());
+
+            System.out.println();
+            System.out.println(">>> Schedule future is done and has been unscheduled.");
+            System.out.println(">>> Check all nodes for hello message output.");
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/10cf673c/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/package-info.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/package-info.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/package-info.java
new file mode 100644
index 0000000..5855994
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * <!-- Package description. -->
+ * Demonstrates usage of cron-based scheduler.
+ */
+package org.apache.ignite.examples.java8.misc.schedule;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/10cf673c/examples/src/main/java/org/apache/ignite/examples/misc/schedule/ComputeScheduleExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/misc/schedule/ComputeScheduleExample.java b/examples/src/main/java/org/apache/ignite/examples/misc/schedule/ComputeScheduleExample.java
deleted file mode 100644
index f8d0660..0000000
--- a/examples/src/main/java/org/apache/ignite/examples/misc/schedule/ComputeScheduleExample.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.examples.misc.schedule;
-
-import java.util.concurrent.Callable;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.lang.IgniteRunnable;
-import org.apache.ignite.scheduler.SchedulerFuture;
-
-/**
- * Demonstrates a cron-based {@link Runnable} execution scheduling.
- * Test runnable object broadcasts a phrase to all cluster nodes every minute
- * three times with initial scheduling delay equal to five seconds.
- * <p>
- * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
- * with {@code examples/config/example-ignite.xml} configuration.
- */
-public class ComputeScheduleExample {
-    /**
-     * Executes example.
-     *
-     * @param args Command line arguments, none required.
-     * @throws IgniteException If example execution failed.
-     */
-    public static void main(String[] args) throws IgniteException {
-        try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
-            System.out.println();
-            System.out.println("Compute schedule example started.");
-
-            // Schedule output message every minute.
-            SchedulerFuture<?> fut = ignite.scheduler().scheduleLocal(
-                new Callable<Integer>() {
-                    private int invocations;
-
-                    @Override public Integer call() {
-                        invocations++;
-
-                        ignite.compute().broadcast(
-                            new IgniteRunnable() {
-                                @Override public void run() {
-                                    System.out.println();
-                                    System.out.println("Howdy! :)");
-                                }
-                            }
-                        );
-
-                        return invocations;
-                    }
-                },
-                "{5, 3} * * * * *" // Cron expression.
-            );
-
-            while (!fut.isDone())
-                System.out.println(">>> Invocation #: " + fut.get());
-
-            System.out.println();
-            System.out.println(">>> Schedule future is done and has been unscheduled.");
-            System.out.println(">>> Check all nodes for hello message output.");
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/10cf673c/examples/src/main/java/org/apache/ignite/examples/misc/schedule/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/misc/schedule/package-info.java b/examples/src/main/java/org/apache/ignite/examples/misc/schedule/package-info.java
deleted file mode 100644
index 6602a6e..0000000
--- a/examples/src/main/java/org/apache/ignite/examples/misc/schedule/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * <!-- Package description. -->
- * Demonstrates usage of cron-based scheduler.
- */
-package org.apache.ignite.examples.misc.schedule;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/10cf673c/examples/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/ComputeScheduleExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/ComputeScheduleExample.java b/examples/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/ComputeScheduleExample.java
deleted file mode 100644
index c250638..0000000
--- a/examples/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/ComputeScheduleExample.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.examples.java8.misc.schedule;
-
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.scheduler.SchedulerFuture;
-
-/**
- * Demonstrates a cron-based {@link Runnable} execution scheduling.
- * Test runnable object broadcasts a phrase to all cluster nodes every minute
- * three times with initial scheduling delay equal to five seconds.
- * <p>
- * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
- * with {@code examples/config/example-ignite.xml} configuration.
- */
-public class ComputeScheduleExample {
-    /**
-     * Executes example.
-     *
-     * @param args Command line arguments, none required.
-     * @throws IgniteException If example execution failed.
-     */
-    public static void main(String[] args) throws IgniteException {
-        try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
-            System.out.println();
-            System.out.println("Compute schedule example started.");
-
-            // Schedule output message every minute.
-            SchedulerFuture<?> fut = ignite.scheduler().scheduleLocal(() ->
-                ignite.compute().broadcast(() -> {
-                    System.out.println();
-                    System.out.println("Howdy! :)");
-
-                    return "Howdy! :)";
-                }),
-                "{5, 3} * * * * *" // Cron expression.
-            );
-
-            while (!fut.isDone())
-                System.out.println(">>> Invocation result: " + fut.get());
-
-            System.out.println();
-            System.out.println(">>> Schedule future is done and has been unscheduled.");
-            System.out.println(">>> Check all nodes for hello message output.");
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/10cf673c/examples/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/package-info.java b/examples/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/package-info.java
deleted file mode 100644
index 5855994..0000000
--- a/examples/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * <!-- Package description. -->
- * Demonstrates usage of cron-based scheduler.
- */
-package org.apache.ignite.examples.java8.misc.schedule;
\ No newline at end of file


[35/50] [abbrv] ignite git commit: ignite-1698 - test

Posted by ag...@apache.org.
ignite-1698 - test


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

Branch: refs/heads/ignite-1016
Commit: bc6bf5fcd2c6fd996c3f3d2b1731afed26338091
Parents: 7d3621b
Author: S.Vladykin <sv...@gridgain.com>
Authored: Sat Oct 17 18:53:16 2015 +0300
Committer: S.Vladykin <sv...@gridgain.com>
Committed: Sat Oct 17 18:53:16 2015 +0300

----------------------------------------------------------------------
 .../ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java | 4 ++++
 .../apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java  | 2 ++
 2 files changed, 6 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/bc6bf5fc/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java
index 7b1c87c..a8c8388 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java
@@ -21,6 +21,7 @@ import java.io.Serializable;
 import java.util.Collections;
 import java.util.List;
 import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheMode;
 import org.apache.ignite.cache.query.QueryCursor;
 import org.apache.ignite.cache.query.SqlFieldsQuery;
 import org.apache.ignite.cache.query.annotations.QuerySqlField;
@@ -102,6 +103,9 @@ public class SqlFieldsQuerySelfTest extends GridCommonAbstractTest {
     private IgniteCache<Integer, Person> createAndFillCache() {
         CacheConfiguration<Integer, Person> cacheConf = new CacheConfiguration<>();
 
+        cacheConf.setCacheMode(CacheMode.PARTITIONED);
+        cacheConf.setBackups(0);
+
         cacheConf.setIndexedTypes(Integer.class, Person.class);
 
         cacheConf.setName("person");

http://git-wip-us.apache.org/repos/asf/ignite/blob/bc6bf5fc/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
index fe54b63..6cb1a52 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
@@ -45,6 +45,7 @@ import org.apache.ignite.internal.processors.cache.IgniteCacheQueryMultiThreaded
 import org.apache.ignite.internal.processors.cache.IgniteCacheQueryOffheapEvictsMultiThreadedSelfTest;
 import org.apache.ignite.internal.processors.cache.IgniteCacheQueryOffheapMultiThreadedSelfTest;
 import org.apache.ignite.internal.processors.cache.IgniteCacheSqlQueryMultiThreadedSelfTest;
+import org.apache.ignite.internal.processors.cache.SqlFieldsQuerySelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheAtomicFieldsQuerySelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheAtomicNearEnabledFieldsQuerySelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheAtomicNearEnabledQuerySelfTest;
@@ -137,6 +138,7 @@ public class IgniteCacheQuerySelfTestSuite extends TestSuite {
         suite.addTestSuite(CacheScanPartitionQueryFallbackSelfTest.class);
 
         // Fields queries.
+        suite.addTestSuite(SqlFieldsQuerySelfTest.class);
         suite.addTestSuite(IgniteCacheLocalFieldsQuerySelfTest.class);
         suite.addTestSuite(IgniteCacheReplicatedFieldsQuerySelfTest.class);
         suite.addTestSuite(IgniteCacheReplicatedFieldsQueryP2PEnabledSelfTest.class);


[23/50] [abbrv] ignite git commit: IGNITE-1168 Fixed typo.

Posted by ag...@apache.org.
IGNITE-1168 Fixed typo.


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

Branch: refs/heads/ignite-1016
Commit: 3a29b97371946e50da8d6352e39428673e9c74ca
Parents: 541ba40
Author: Andrey <an...@gridgain.com>
Authored: Thu Oct 15 17:53:16 2015 +0700
Committer: Andrey <an...@gridgain.com>
Committed: Thu Oct 15 17:53:16 2015 +0700

----------------------------------------------------------------------
 .../processors/rest/JettyRestProcessorAbstractSelfTest.java      | 4 ++--
 .../rest/protocols/http/jetty/GridJettyRestHandler.java          | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/3a29b973/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 bb6e67e..c413bbd 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
@@ -1212,7 +1212,7 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
         params.put("cmd", GridRestCommand.EXECUTE_SCAN_QUERY.key());
         params.put("pageSize", "10");
         params.put("cacheName", "person");
-        params.put("classname", ScanFilter.class.getName());
+        params.put("className", ScanFilter.class.getName());
 
         String ret = content(params);
 
@@ -1236,7 +1236,7 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
         params.put("cmd", GridRestCommand.EXECUTE_SCAN_QUERY.key());
         params.put("pageSize", "10");
         params.put("cacheName", "person");
-        params.put("classname", ScanFilter.class.getName() + 1);
+        params.put("className", ScanFilter.class.getName() + 1);
 
         String ret = content(params);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/3a29b973/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java
----------------------------------------------------------------------
diff --git a/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java
index 48a60a9..5f2c4ba 100644
--- a/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java
+++ b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java
@@ -600,7 +600,7 @@ public class GridJettyRestHandler extends AbstractHandler {
 
                 restReq0.cacheName((String)params.get("cacheName"));
 
-                restReq0.className((String)params.get("classname"));
+                restReq0.className((String)params.get("className"));
 
                 restReq0.queryType(RestQueryRequest.QueryType.SCAN);
 


[49/50] [abbrv] ignite git commit: ignite-1718: proper type name extraction in portable context for classes that ends on '$' sign

Posted by ag...@apache.org.
ignite-1718: proper type name extraction in portable context for classes that ends on '$' sign


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

Branch: refs/heads/ignite-1016
Commit: e9524cea121ce70338bb9bf1a5f622acc445d5f0
Parents: 91e31e9
Author: Andrey Gura <ag...@gridgain.com>
Authored: Thu Oct 22 11:05:02 2015 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Thu Oct 22 11:05:02 2015 +0300

----------------------------------------------------------------------
 .../ignite/internal/portable/PortableContext.java       | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/e9524cea/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
index 1ad42ab..e9cccf0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
@@ -547,7 +547,6 @@ public class PortableContext implements Externalizable {
 
         try {
             registered = marshCtx.registerClass(typeId, cls);
-
         }
         catch (IgniteCheckedException e) {
             throw new PortableException("Failed to register class.", e);
@@ -891,10 +890,11 @@ public class PortableContext implements Externalizable {
 
         int idx = clsName.lastIndexOf('$');
 
-        String typeName;
-
-        if (idx >= 0) {
-            typeName = clsName.substring(idx + 1);
+        if (idx == clsName.length() - 1)
+            // This is a regular (not inner) class name that ends with '$'. Common use case for Scala classes.
+            idx = -1;
+        else if (idx >= 0) {
+            String typeName = clsName.substring(idx + 1);
 
             try {
                 Integer.parseInt(typeName);
@@ -1147,4 +1147,4 @@ public class PortableContext implements Externalizable {
             return registered;
         }
     }
-}
\ No newline at end of file
+}


[18/50] [abbrv] ignite git commit: IGNITE-1590: Reworked create and append operations to match overall design.

Posted by ag...@apache.org.
IGNITE-1590: Reworked create and append operations to match overall design.


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

Branch: refs/heads/ignite-1016
Commit: 962fcce3acbecd028c4787a6255fedcdcbdf9db1
Parents: 6844370
Author: iveselovskiy <iv...@gridgain.com>
Authored: Wed Oct 14 15:59:57 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Oct 14 15:59:57 2015 +0300

----------------------------------------------------------------------
 .../processors/igfs/IgfsDataManager.java        |   2 -
 .../processors/igfs/IgfsDeleteWorker.java       | 102 ++-
 .../internal/processors/igfs/IgfsImpl.java      | 164 +---
 .../processors/igfs/IgfsMetaManager.java        | 897 ++++++++++++-------
 .../processors/igfs/IgfsOutputStreamImpl.java   |   2 +
 .../internal/processors/igfs/IgfsUtils.java     |  23 +
 .../ignite/igfs/IgfsEventsAbstractSelfTest.java |   6 +-
 .../processors/igfs/IgfsAbstractSelfTest.java   | 639 ++++++++++---
 .../igfs/IgfsDataManagerSelfTest.java           |  13 +-
 .../igfs/IgfsMetaManagerSelfTest.java           | 170 ++--
 .../processors/igfs/IgfsProcessorSelfTest.java  |  12 +-
 .../ignite/testsuites/IgniteIgfsTestSuite.java  |   6 +
 .../ignite/igfs/Hadoop1DualAbstractTest.java    |   5 -
 .../HadoopIgfs20FileSystemAbstractSelfTest.java |   5 +-
 .../IgniteHadoopFileSystemAbstractSelfTest.java |   2 +-
 15 files changed, 1289 insertions(+), 759 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/962fcce3/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
index b1b51f9..125d728 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
@@ -580,8 +580,6 @@ public class IgfsDataManager extends IgfsManager {
      * @return Delete future that will be completed when file is actually erased.
      */
     public IgniteInternalFuture<Object> delete(IgfsFileInfo fileInfo) {
-        //assert validTxState(any); // Allow this method call for any transaction state.
-
         if (!fileInfo.isFile()) {
             if (log.isDebugEnabled())
                 log.debug("Cannot delete content of not-data file: " + fileInfo);

http://git-wip-us.apache.org/repos/asf/ignite/blob/962fcce3/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteWorker.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteWorker.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteWorker.java
index 98672e8..95a6a5d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteWorker.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteWorker.java
@@ -27,12 +27,10 @@ import java.util.concurrent.locks.ReentrantLock;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteLogger;
 import org.apache.ignite.cluster.ClusterNode;
-import org.apache.ignite.events.IgfsEvent;
 import org.apache.ignite.internal.IgniteFutureCancelledCheckedException;
 import org.apache.ignite.internal.IgniteInterruptedCheckedException;
 import org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException;
 import org.apache.ignite.internal.managers.communication.GridIoPolicy;
-import org.apache.ignite.internal.managers.eventstorage.GridEventStorageManager;
 import org.apache.ignite.internal.util.future.GridCompoundFuture;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.internal.LT;
@@ -62,9 +60,6 @@ public class IgfsDeleteWorker extends IgfsThread {
     /** Data manager. */
     private final IgfsDataManager data;
 
-    /** Event manager. */
-    private final GridEventStorageManager evts;
-
     /** Logger. */
     private final IgniteLogger log;
 
@@ -96,8 +91,6 @@ public class IgfsDeleteWorker extends IgfsThread {
         meta = igfsCtx.meta();
         data = igfsCtx.data();
 
-        evts = igfsCtx.kernalContext().event();
-
         String igfsName = igfsCtx.igfs().name();
 
         topic = F.isEmpty(igfsName) ? TOPIC_IGFS : TOPIC_IGFS.topic(igfsName);
@@ -147,6 +140,9 @@ public class IgfsDeleteWorker extends IgfsThread {
         }
     }
 
+    /**
+     * Cancels the worker.
+     */
     void cancel() {
         cancelled = true;
 
@@ -218,7 +214,8 @@ public class IgfsDeleteWorker extends IgfsThread {
 
             if (info != null) {
                 if (info.isDirectory()) {
-                    deleteDirectory(TRASH_ID, id);
+                    if (!deleteDirectoryContents(TRASH_ID, id))
+                        return false;
 
                     if (meta.delete(TRASH_ID, name, id))
                         return true;
@@ -226,19 +223,22 @@ public class IgfsDeleteWorker extends IgfsThread {
                 else {
                     assert info.isFile();
 
+                    // Lock the file with special lock Id to prevent concurrent writing:
+                    IgfsFileInfo lockedInfo = meta.lock(id, true);
+
+                    if (lockedInfo == null)
+                        return false; // File is locked, we cannot delete it.
+
+                    assert id.equals(lockedInfo.id());
+
                     // Delete file content first.
                     // In case this node crashes, other node will re-delete the file.
-                    data.delete(info).get();
+                    data.delete(lockedInfo).get();
 
                     boolean ret = meta.delete(TRASH_ID, name, id);
 
-                    if (evts.isRecordable(EVT_IGFS_FILE_PURGED)) {
-                        if (info.path() != null)
-                            evts.record(new IgfsEvent(info.path(),
-                                igfsCtx.kernalContext().discovery().localNode(), EVT_IGFS_FILE_PURGED));
-                        else
-                            LT.warn(log, null, "Removing file without path info: " + info);
-                    }
+                    if (info.path() != null)
+                        IgfsUtils.sendEvents(igfsCtx.kernalContext(), info.path(), EVT_IGFS_FILE_PURGED);
 
                     return ret;
                 }
@@ -253,9 +253,10 @@ public class IgfsDeleteWorker extends IgfsThread {
      *
      * @param parentId Parent ID.
      * @param id Entry id.
+     * @return true iff all the items in the directory were deleted (directory is seen to be empty).
      * @throws IgniteCheckedException If delete failed for some reason.
      */
-    private void deleteDirectory(IgniteUuid parentId, IgniteUuid id) throws IgniteCheckedException {
+    private boolean deleteDirectoryContents(IgniteUuid parentId, final IgniteUuid id) throws IgniteCheckedException {
         assert parentId != null;
         assert id != null;
 
@@ -265,47 +266,50 @@ public class IgfsDeleteWorker extends IgfsThread {
             if (info != null) {
                 assert info.isDirectory();
 
-                Map<String, IgfsListingEntry> listing = info.listing();
+                final Map<String, IgfsListingEntry> listing = info.listing();
 
                 if (listing.isEmpty())
-                    return; // Directory is empty.
+                    return true; // Directory is empty.
 
-                Map<String, IgfsListingEntry> delListing;
+                final Map<String, IgfsListingEntry> delListing = new HashMap<>(MAX_DELETE_BATCH, 1.0f);
 
-                if (listing.size() <= MAX_DELETE_BATCH)
-                    delListing = listing;
-                else {
-                    delListing = new HashMap<>(MAX_DELETE_BATCH, 1.0f);
+                final GridCompoundFuture<Object, ?> fut = new GridCompoundFuture<>();
 
-                    int i = 0;
+                int failedFiles = 0;
 
-                    for (Map.Entry<String, IgfsListingEntry> entry : listing.entrySet()) {
-                        delListing.put(entry.getKey(), entry.getValue());
+                for (final Map.Entry<String, IgfsListingEntry> entry : listing.entrySet()) {
+                    if (cancelled)
+                        return false;
 
-                        if (++i == MAX_DELETE_BATCH)
-                            break;
+                    if (entry.getValue().isDirectory()) {
+                        if (deleteDirectoryContents(id, entry.getValue().fileId())) // *** Recursive call.
+                            delListing.put(entry.getKey(), entry.getValue());
+                        else
+                            failedFiles++;
                     }
-                }
+                    else {
+                        IgfsFileInfo fileInfo = meta.info(entry.getValue().fileId());
 
-                GridCompoundFuture<Object, ?> fut = new GridCompoundFuture<>();
+                        if (fileInfo != null) {
+                            assert fileInfo.isFile();
 
-                // Delegate to child folders.
-                for (IgfsListingEntry entry : delListing.values()) {
-                    if (!cancelled) {
-                        if (entry.isDirectory())
-                            deleteDirectory(id, entry.fileId());
-                        else {
-                            IgfsFileInfo fileInfo = meta.info(entry.fileId());
+                            IgfsFileInfo lockedInfo = meta.lock(fileInfo.id(), true);
+
+                            if (lockedInfo == null)
+                                // File is already locked:
+                                failedFiles++;
+                            else {
+                                assert IgfsMetaManager.DELETE_LOCK_ID.equals(lockedInfo.lockId());
 
-                            if (fileInfo != null) {
-                                assert fileInfo.isFile();
+                                fut.add(data.delete(lockedInfo));
 
-                                fut.add(data.delete(fileInfo));
+                                delListing.put(entry.getKey(), entry.getValue());
                             }
                         }
                     }
-                    else
-                        return;
+
+                    if (delListing.size() == MAX_DELETE_BATCH)
+                        break;
                 }
 
                 fut.markInitialized();
@@ -318,17 +322,21 @@ public class IgfsDeleteWorker extends IgfsThread {
                     // This future can be cancelled only due to IGFS shutdown.
                     cancelled = true;
 
-                    return;
+                    return false;
                 }
 
                 // Actual delete of folder content.
                 Collection<IgniteUuid> delIds = meta.delete(id, delListing);
 
-                if (delListing == listing && delListing.size() == delIds.size())
-                    break; // All entries were deleted.
+                if (listing.size() == delIds.size())
+                    return true; // All entries were deleted.
+
+                if (listing.size() == delListing.size() + failedFiles)
+                    // All the files were tried, no reason to continue the loop:
+                    return false;
             }
             else
-                break; // Entry was deleted concurrently.
+                return true; // Directory entry was deleted concurrently.
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/962fcce3/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsImpl.java
index fa3a955..0d5cda3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsImpl.java
@@ -60,7 +60,6 @@ import org.apache.ignite.igfs.IgfsMetrics;
 import org.apache.ignite.igfs.IgfsMode;
 import org.apache.ignite.igfs.IgfsOutputStream;
 import org.apache.ignite.igfs.IgfsPath;
-import org.apache.ignite.igfs.IgfsPathAlreadyExistsException;
 import org.apache.ignite.igfs.IgfsPathIsDirectoryException;
 import org.apache.ignite.igfs.IgfsPathNotFoundException;
 import org.apache.ignite.igfs.IgfsPathSummary;
@@ -97,7 +96,6 @@ import static org.apache.ignite.events.EventType.EVT_IGFS_DIR_DELETED;
 import static org.apache.ignite.events.EventType.EVT_IGFS_DIR_RENAMED;
 import static org.apache.ignite.events.EventType.EVT_IGFS_FILE_CLOSED_READ;
 import static org.apache.ignite.events.EventType.EVT_IGFS_FILE_CLOSED_WRITE;
-import static org.apache.ignite.events.EventType.EVT_IGFS_FILE_CREATED;
 import static org.apache.ignite.events.EventType.EVT_IGFS_FILE_DELETED;
 import static org.apache.ignite.events.EventType.EVT_IGFS_FILE_OPENED_READ;
 import static org.apache.ignite.events.EventType.EVT_IGFS_FILE_OPENED_WRITE;
@@ -112,7 +110,6 @@ import static org.apache.ignite.igfs.IgfsMode.PROXY;
 import static org.apache.ignite.internal.GridTopic.TOPIC_IGFS;
 import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_IGFS;
 import static org.apache.ignite.internal.processors.igfs.IgfsFileInfo.ROOT_ID;
-import static org.apache.ignite.internal.processors.igfs.IgfsFileInfo.TRASH_ID;
 
 /**
  * Cache-based IGFS implementation.
@@ -122,7 +119,7 @@ public final class IgfsImpl implements IgfsEx {
     private static final String PERMISSION_DFLT_VAL = "0777";
 
     /** Default directory metadata. */
-    private static final Map<String, String> DFLT_DIR_META = F.asMap(PROP_PERMISSION, PERMISSION_DFLT_VAL);
+    static final Map<String, String> DFLT_DIR_META = F.asMap(PROP_PERMISSION, PERMISSION_DFLT_VAL);
 
     /** Handshake message. */
     private final IgfsPaths secondaryPaths;
@@ -740,14 +737,9 @@ public final class IgfsImpl implements IgfsEx {
                 }
 
                 // Record event if needed.
-                if (res && desc != null) {
-                    if (desc.isFile) {
-                        if (evts.isRecordable(EVT_IGFS_FILE_DELETED))
-                            evts.record(new IgfsEvent(path, localNode(), EVT_IGFS_FILE_DELETED));
-                    }
-                    else if (evts.isRecordable(EVT_IGFS_DIR_DELETED))
-                        evts.record(new IgfsEvent(path, localNode(), EVT_IGFS_DIR_DELETED));
-                }
+                if (res && desc != null)
+                    IgfsUtils.sendEvents(igfsCtx.kernalContext(), path,
+                            desc.isFile ? EVT_IGFS_FILE_DELETED : EVT_IGFS_DIR_DELETED);
 
                 return res;
             }
@@ -928,8 +920,7 @@ public final class IgfsImpl implements IgfsEx {
                     IgfsEventAwareInputStream os = new IgfsEventAwareInputStream(igfsCtx, path, desc.info(),
                         cfg.getPrefetchBlocks(), seqReadsBeforePrefetch, desc.reader(), metrics);
 
-                    if (evts.isRecordable(EVT_IGFS_FILE_OPENED_READ))
-                        evts.record(new IgfsEvent(path, localNode(), EVT_IGFS_FILE_OPENED_READ));
+                    IgfsUtils.sendEvents(igfsCtx.kernalContext(), path, EVT_IGFS_FILE_OPENED_READ);
 
                     return os;
                 }
@@ -949,8 +940,7 @@ public final class IgfsImpl implements IgfsEx {
                 IgfsEventAwareInputStream os = new IgfsEventAwareInputStream(igfsCtx, path, info,
                     cfg.getPrefetchBlocks(), seqReadsBeforePrefetch, null, metrics);
 
-                if (evts.isRecordable(EVT_IGFS_FILE_OPENED_READ))
-                    evts.record(new IgfsEvent(path, localNode(), EVT_IGFS_FILE_OPENED_READ));
+                IgfsUtils.sendEvents(igfsCtx.kernalContext(), path, EVT_IGFS_FILE_OPENED_READ);
 
                 return os;
             }
@@ -1004,7 +994,7 @@ public final class IgfsImpl implements IgfsEx {
                     log.debug("Open file for writing [path=" + path + ", bufSize=" + bufSize + ", overwrite=" +
                         overwrite + ", props=" + props + ']');
 
-                IgfsMode mode = resolveMode(path);
+                final IgfsMode mode = resolveMode(path);
 
                 IgfsFileWorkerBatch batch;
 
@@ -1021,71 +1011,28 @@ public final class IgfsImpl implements IgfsEx {
                     IgfsEventAwareOutputStream os = new IgfsEventAwareOutputStream(path, desc.info(), desc.parentId(),
                         bufSize == 0 ? cfg.getStreamBufferSize() : bufSize, mode, batch);
 
-                    if (evts.isRecordable(EVT_IGFS_FILE_OPENED_WRITE))
-                        evts.record(new IgfsEvent(path, localNode(), EVT_IGFS_FILE_OPENED_WRITE));
+                    IgfsUtils.sendEvents(igfsCtx.kernalContext(), path, EVT_IGFS_FILE_OPENED_WRITE);
 
                     return os;
                 }
 
-                // Re-create parents when working in PRIMARY mode. In DUAL mode this is done by MetaManager.
-                IgfsPath parent = path.parent();
-
-                // Create missing parent directories if necessary.
-                if (parent != null)
-                    mkdirs(parent, props);
-
-                List<IgniteUuid> ids = meta.fileIds(path);
-
-                // Resolve parent ID for file.
-                IgniteUuid parentId = ids.size() >= 2 ? ids.get(ids.size() - 2) : null;
-
-                if (parentId == null)
-                    throw new IgfsPathNotFoundException("Failed to resolve parent directory: " + parent);
-
-                String fileName = path.name();
-
-                // Constructs new file info.
-                IgfsFileInfo info = new IgfsFileInfo(cfg.getBlockSize(), affKey, evictExclude(path, true), props);
-
-                // Add new file into tree structure.
-                while (true) {
-                    IgniteUuid oldId = meta.putIfAbsent(parentId, fileName, info);
-
-                    if (oldId == null)
-                        break;
-
-                    if (!overwrite)
-                        throw new IgfsPathAlreadyExistsException("Failed to create file (file already exists): " +
-                            path);
-
-                    IgfsFileInfo oldInfo = meta.info(oldId);
-
-                    assert oldInfo != null;
-
-                    if (oldInfo.isDirectory())
-                        throw new IgfsPathAlreadyExistsException("Failed to create file (path points to a " +
-                            "directory): " + path);
+                final Map<String, String> dirProps, fileProps;
 
-                    // Remove old file from the tree.
-                    // Only one file is deleted, so we use internal data streamer.
-                    deleteFile(path, new FileDescriptor(parentId, fileName, oldId, oldInfo.isFile()), false);
+                if (props == null) {
+                    dirProps = DFLT_DIR_META;
 
-                    if (evts.isRecordable(EVT_IGFS_FILE_DELETED))
-                        evts.record(new IgfsEvent(path, localNode(), EVT_IGFS_FILE_DELETED));
+                    fileProps = null;
                 }
+                else
+                    dirProps = fileProps = new HashMap<>(props);
 
-                if (evts.isRecordable(EVT_IGFS_FILE_CREATED))
-                    evts.record(new IgfsEvent(path, localNode(), EVT_IGFS_FILE_CREATED));
+                IgniteBiTuple<IgfsFileInfo, IgniteUuid> t2 = meta.create(path, false/*append*/, overwrite, dirProps,
+                    cfg.getBlockSize(), affKey, evictExclude(path, true), fileProps);
 
-                info = meta.lock(info.id());
+                assert t2 != null;
 
-                IgfsEventAwareOutputStream os = new IgfsEventAwareOutputStream(path, info, parentId,
+                return new IgfsEventAwareOutputStream(path, t2.get1(), t2.get2(),
                     bufSize == 0 ? cfg.getStreamBufferSize() : bufSize, mode, null);
-
-                if (evts.isRecordable(EVT_IGFS_FILE_OPENED_WRITE))
-                    evts.record(new IgfsEvent(path, localNode(), EVT_IGFS_FILE_OPENED_WRITE));
-
-                return os;
             }
         });
     }
@@ -1107,7 +1054,7 @@ public final class IgfsImpl implements IgfsEx {
                     log.debug("Open file for appending [path=" + path + ", bufSize=" + bufSize + ", create=" + create +
                         ", props=" + props + ']');
 
-                IgfsMode mode = resolveMode(path);
+                final IgfsMode mode = resolveMode(path);
 
                 IgfsFileWorkerBatch batch;
 
@@ -1124,46 +1071,39 @@ public final class IgfsImpl implements IgfsEx {
                         bufSize == 0 ? cfg.getStreamBufferSize() : bufSize, mode, batch);
                 }
 
-                List<IgniteUuid> ids = meta.fileIds(path);
+                final List<IgniteUuid> ids = meta.fileIds(path);
 
-                IgfsFileInfo info = meta.info(ids.get(ids.size() - 1));
+                final IgniteUuid id = ids.get(ids.size() - 1);
 
-                // Resolve parent ID for the file.
-                IgniteUuid parentId = ids.size() >= 2 ? ids.get(ids.size() - 2) : null;
-
-                if (info == null) {
+                if (id == null) {
                     if (!create) {
                         checkConflictWithPrimary(path);
 
                         throw new IgfsPathNotFoundException("File not found: " + path);
                     }
+                }
 
-                    if (parentId == null)
-                        throw new IgfsPathNotFoundException("Failed to resolve parent directory: " + path.parent());
-
-                    info = new IgfsFileInfo(cfg.getBlockSize(), /**affinity key*/null, evictExclude(path, true), props);
+                // Prevent attempt to append to ROOT in early stage:
+                if (ids.size() == 1)
+                    throw new IgfsPathIsDirectoryException("Failed to open file (not a file): " + path);
 
-                    IgniteUuid oldId = meta.putIfAbsent(parentId, path.name(), info);
+                final Map<String, String> dirProps, fileProps;
 
-                    if (oldId != null)
-                        info = meta.info(oldId);
+                if (props == null) {
+                    dirProps = DFLT_DIR_META;
 
-                    if (evts.isRecordable(EVT_IGFS_FILE_CREATED))
-                        evts.record(new IgfsEvent(path, localNode(), EVT_IGFS_FILE_CREATED));
+                    fileProps = null;
                 }
+                else
+                    dirProps = fileProps = new HashMap<>(props);
 
-                assert info != null;
-
-                if (!info.isFile())
-                    throw new IgfsPathIsDirectoryException("Failed to open file (not a file): " + path);
-
-                info = meta.lock(info.id());
+                IgniteBiTuple<IgfsFileInfo, IgniteUuid> t2 = meta.create(path, true/*append*/, false/*overwrite*/,
+                    dirProps, cfg.getBlockSize(), null/*affKey*/, evictExclude(path, true), fileProps);
 
-                if (evts.isRecordable(EVT_IGFS_FILE_OPENED_WRITE))
-                    evts.record(new IgfsEvent(path, localNode(), EVT_IGFS_FILE_OPENED_WRITE));
+                assert t2 != null;
 
-                return new IgfsEventAwareOutputStream(path, info, parentId, bufSize == 0 ?
-                    cfg.getStreamBufferSize() : bufSize, mode, null);
+                return new IgfsEventAwareOutputStream(path, t2.get1(), t2.get2(),
+                        bufSize == 0 ? cfg.getStreamBufferSize() : bufSize, mode, null);
             }
         });
     }
@@ -1451,30 +1391,6 @@ public final class IgfsImpl implements IgfsEx {
     }
 
     /**
-     * Remove file from the file system (structure and data).
-     *
-     * @param path Path of the deleted file.
-     * @param desc Detailed file descriptor to remove.
-     * @param rmvLocked Whether to remove this entry in case it is has explicit lock.
-     * @throws IgniteCheckedException If failed.
-     */
-    private void deleteFile(IgfsPath path, FileDescriptor desc, boolean rmvLocked) throws IgniteCheckedException {
-        IgniteUuid parentId = desc.parentId;
-        IgniteUuid fileId = desc.fileId;
-
-        if (parentId == null || ROOT_ID.equals(fileId)) {
-            assert parentId == null && ROOT_ID.equals(fileId) : "Invalid file descriptor: " + desc;
-
-            return; // Never remove the root directory!
-        }
-
-        if (TRASH_ID.equals(fileId))
-            return; // Never remove trash directory.
-
-        meta.removeIfEmpty(parentId, desc.fileName, fileId, path, rmvLocked);
-    }
-
-    /**
      * Check whether IGFS with the same name exists among provided attributes.
      *
      * @param attrs Attributes.
@@ -2005,13 +1921,13 @@ public final class IgfsImpl implements IgfsEx {
     /**
      * Perform IGFS operation in safe context.
      *
-     * @param action Action.
+     * @param act Action.
      * @return Result.
      */
-    private <T> T safeOp(Callable<T> action) {
+    private <T> T safeOp(Callable<T> act) {
         if (enterBusy()) {
             try {
-                return action.call();
+                return act.call();
             }
             catch (Exception e) {
                 throw IgfsUtils.toIgfsException(e);

http://git-wip-us.apache.org/repos/asf/ignite/blob/962fcce3/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
index 927067a..c016e46 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
@@ -37,8 +37,11 @@ import java.util.Set;
 import java.util.SortedSet;
 import java.util.TreeMap;
 import java.util.TreeSet;
+import java.util.UUID;
 import java.util.concurrent.CountDownLatch;
 import javax.cache.processor.EntryProcessor;
+import javax.cache.processor.EntryProcessorException;
+import javax.cache.processor.EntryProcessorResult;
 import javax.cache.processor.MutableEntry;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
@@ -46,6 +49,7 @@ import org.apache.ignite.IgniteInterruptedException;
 import org.apache.ignite.IgniteLogger;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.configuration.FileSystemConfiguration;
+import org.apache.ignite.events.EventType;
 import org.apache.ignite.events.IgfsEvent;
 import org.apache.ignite.igfs.IgfsConcurrentModificationException;
 import org.apache.ignite.igfs.IgfsDirectoryNotEmptyException;
@@ -73,9 +77,10 @@ import org.apache.ignite.internal.util.lang.GridClosureException;
 import org.apache.ignite.internal.util.lang.IgniteOutClosureX;
 import org.apache.ignite.internal.util.typedef.CI1;
 import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.internal.util.typedef.internal.LT;
+import org.apache.ignite.internal.util.typedef.T2;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteBiTuple;
 import org.apache.ignite.lang.IgniteClosure;
 import org.apache.ignite.lang.IgniteUuid;
 import org.jetbrains.annotations.Nullable;
@@ -83,9 +88,8 @@ import org.jetbrains.annotations.Nullable;
 import static org.apache.ignite.events.EventType.EVT_IGFS_DIR_CREATED;
 import static org.apache.ignite.events.EventType.EVT_IGFS_DIR_RENAMED;
 import static org.apache.ignite.events.EventType.EVT_IGFS_FILE_CREATED;
-import static org.apache.ignite.events.EventType.EVT_IGFS_FILE_DELETED;
-import static org.apache.ignite.events.EventType.EVT_IGFS_FILE_PURGED;
 import static org.apache.ignite.events.EventType.EVT_IGFS_FILE_RENAMED;
+import static org.apache.ignite.events.EventType.EVT_IGFS_FILE_OPENED_WRITE;
 import static org.apache.ignite.internal.processors.igfs.IgfsFileInfo.ROOT_ID;
 import static org.apache.ignite.internal.processors.igfs.IgfsFileInfo.TRASH_ID;
 import static org.apache.ignite.internal.processors.igfs.IgfsFileInfo.builder;
@@ -97,6 +101,9 @@ import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_REA
  */
 @SuppressWarnings("all")
 public class IgfsMetaManager extends IgfsManager {
+    /** Lock Id used to lock files being deleted from TRASH. This is a global constant. */
+    static final IgniteUuid DELETE_LOCK_ID = new IgniteUuid(new UUID(0L, 0L), 0L);
+
     /** Comparator for Id sorting. */
     private static final Comparator<IgniteUuid> PATH_ID_SORTING_COMPARATOR
             = new Comparator<IgniteUuid>() {
@@ -295,7 +302,8 @@ public class IgfsMetaManager extends IgfsManager {
      * @return File ID.
      * @throws IgniteCheckedException If failed.
      */
-    @Nullable private IgniteUuid fileId(IgniteUuid parentId, String fileName, boolean skipTx) throws IgniteCheckedException {
+    @Nullable private IgniteUuid fileId(IgniteUuid parentId, String fileName, boolean skipTx)
+        throws IgniteCheckedException {
         IgfsListingEntry entry = directoryListing(parentId, skipTx).get(fileName);
 
         if (entry == null) {
@@ -464,9 +472,9 @@ public class IgfsMetaManager extends IgfsManager {
      *
      * @param fileId File ID to lock.
      * @return Locked file info or {@code null} if file cannot be locked or doesn't exist.
-     * @throws IgniteCheckedException If failed.
+     * @throws IgniteCheckedException If the file with such id does not exist, or on another failure.
      */
-    public IgfsFileInfo lock(IgniteUuid fileId) throws IgniteCheckedException {
+    public @Nullable IgfsFileInfo lock(IgniteUuid fileId, boolean isDeleteLock) throws IgniteCheckedException {
         if (busyLock.enterBusy()) {
             try {
                 assert validTxState(false);
@@ -479,14 +487,19 @@ public class IgfsMetaManager extends IgfsManager {
                     IgfsFileInfo oldInfo = info(fileId);
 
                     if (oldInfo == null)
-                        throw new IgniteCheckedException("Failed to lock file (file not found): " + fileId);
+                        return null;
 
-                    IgfsFileInfo newInfo = lockInfo(oldInfo);
+                    if (oldInfo.lockId() != null)
+                        return null; // The file is already locked, we cannot lock it.
 
-                    boolean put = metaCache.put(fileId, newInfo);
+                    IgfsFileInfo newInfo = lockInfo(oldInfo, isDeleteLock);
+
+                    boolean put = metaCache.replace(fileId, oldInfo, newInfo);
 
                     assert put : "Value was not stored in cache [fileId=" + fileId + ", newInfo=" + newInfo + ']';
 
+                    assert newInfo.id().equals(oldInfo.id()); // Same id.
+
                     tx.commit();
 
                     return newInfo;
@@ -510,26 +523,26 @@ public class IgfsMetaManager extends IgfsManager {
      * Set lock on file info.
      *
      * @param info File info.
-     * @return New file info with lock set.
+     * @return New file info with lock set, or null if the info passed in is already locked.
      * @throws IgniteCheckedException In case lock is already set on that file.
      */
-    public IgfsFileInfo lockInfo(IgfsFileInfo info) throws IgniteCheckedException {
-        if (busyLock.enterBusy()) {
-            try {
-                assert info != null;
+    private static @Nullable IgfsFileInfo lockInfo(IgfsFileInfo info, boolean isDeleteLock) {
+         assert info != null;
 
-                if (info.lockId() != null)
-                    throw new IgniteCheckedException("Failed to lock file (file is being concurrently written) [fileId=" +
-                        info.id() + ", lockId=" + info.lockId() + ']');
+         if (info.lockId() != null)
+             return null; // Null return value indicates that the file is already locked.
 
-                return new IgfsFileInfo(info, IgniteUuid.randomUuid(), info.modificationTime());
-            }
-            finally {
-                busyLock.leaveBusy();
-            }
-        }
-        else
-            throw new IllegalStateException("Failed to get lock info because Grid is stopping: " + info);
+         return new IgfsFileInfo(info, composeLockId(isDeleteLock), info.modificationTime());
+    }
+
+    /**
+     * Gets a new lock id.
+     *
+     * @param isDeleteLock if this is special delete lock.
+     * @return The new lock id.
+     */
+    private static IgniteUuid composeLockId(boolean isDeleteLock) {
+        return isDeleteLock ? DELETE_LOCK_ID : IgniteUuid.randomUuid();
     }
 
     /**
@@ -556,23 +569,28 @@ public class IgfsMetaManager extends IgfsManager {
                 try {
                     IgfsUtils.doInTransactionWithRetries(metaCache, new IgniteOutClosureX<Void>() {
                         @Override public Void applyx() throws IgniteCheckedException {
+                            assert validTxState(true);
+
                             IgniteUuid fileId = info.id();
 
                             // Lock file ID for this transaction.
                             IgfsFileInfo oldInfo = info(fileId);
 
                             if (oldInfo == null)
-                                throw fsException(new IgfsPathNotFoundException("Failed to unlock file (file not found): " + fileId));
+                                throw fsException(new IgfsPathNotFoundException("Failed to unlock file (file not " +
+                                    "found): " + fileId));
 
                             if (!info.lockId().equals(oldInfo.lockId()))
-                                throw new IgniteCheckedException("Failed to unlock file (inconsistent file lock ID) [fileId=" + fileId +
-                                    ", lockId=" + info.lockId() + ", actualLockId=" + oldInfo.lockId() + ']');
+                                throw new IgniteCheckedException("Failed to unlock file (inconsistent file lock ID) " +
+                                    "[fileId=" + fileId + ", lockId=" + info.lockId() + ", actualLockId=" +
+                                    oldInfo.lockId() + ']');
 
                             IgfsFileInfo newInfo = new IgfsFileInfo(oldInfo, null, modificationTime);
 
                             boolean put = metaCache.put(fileId, newInfo);
 
-                            assert put : "Value was not stored in cache [fileId=" + fileId + ", newInfo=" + newInfo + ']';
+                            assert put : "Value was not stored in cache [fileId=" + fileId + ", newInfo=" + newInfo
+                                    + ']';
 
                             return null;
                         }
@@ -668,7 +686,8 @@ public class IgfsMetaManager extends IgfsManager {
      * @param id The id to check.
      * @throws IgniteCheckedException On error.
      */
-    private void addInfoIfNeeded(Collection<IgniteUuid> fileIds, Map<IgniteUuid, IgfsFileInfo> map, IgniteUuid id) throws IgniteCheckedException {
+    private void addInfoIfNeeded(Collection<IgniteUuid> fileIds, Map<IgniteUuid, IgfsFileInfo> map, IgniteUuid id)
+        throws IgniteCheckedException {
         assert validTxState(true);
 
         if (fileIds.contains(id) && !map.containsKey(id)) {
@@ -773,7 +792,8 @@ public class IgfsMetaManager extends IgfsManager {
      * @return Directory listing for the specified file.*
      * @throws IgniteCheckedException If failed.
      */
-    private Map<String, IgfsListingEntry> directoryListing(IgniteUuid fileId, boolean skipTx) throws IgniteCheckedException {
+    private Map<String, IgfsListingEntry> directoryListing(IgniteUuid fileId, boolean skipTx)
+        throws IgniteCheckedException {
         assert fileId != null;
 
         IgfsFileInfo info = skipTx ? id2InfoPrj.getAllOutTx(Collections.singleton(fileId)).get(fileId) :
@@ -783,48 +803,6 @@ public class IgfsMetaManager extends IgfsManager {
     }
 
     /**
-     * Add file into file system structure.
-     *
-     * @param parentId Parent file ID.
-     * @param fileName File name in the parent's listing.
-     * @param newFileInfo File info to store in the parent's listing.
-     * @return File id already stored in meta cache or {@code null} if passed file info was stored.
-     * @throws IgniteCheckedException If failed.
-     */
-    public IgniteUuid putIfAbsent(IgniteUuid parentId, String fileName, IgfsFileInfo newFileInfo)
-        throws IgniteCheckedException {
-        if (busyLock.enterBusy()) {
-            try {
-                assert validTxState(false);
-                assert parentId != null;
-                assert fileName != null;
-                assert newFileInfo != null;
-
-                IgniteUuid res = null;
-
-                IgniteInternalTx tx = metaCache.txStartEx(PESSIMISTIC, REPEATABLE_READ);
-
-                try {
-                    res = putIfAbsentNonTx(parentId, fileName, newFileInfo);
-
-                    tx.commit();
-                }
-                finally {
-                    tx.close();
-                }
-
-                return res;
-            }
-            finally {
-                busyLock.leaveBusy();
-            }
-        }
-        else
-            throw new IllegalStateException("Failed to put file because Grid is stopping [parentId=" + parentId +
-                ", fileName=" + fileName + ", newFileInfo=" + newFileInfo + ']');
-    }
-
-    /**
      * Add file into file system structure. Do not create new transaction expecting that the one already exists.
      *
      * @param parentId Parent file ID.
@@ -845,7 +823,8 @@ public class IgfsMetaManager extends IgfsManager {
         IgfsFileInfo parentInfo = info(parentId);
 
         if (parentInfo == null)
-            throw fsException(new IgfsPathNotFoundException("Failed to lock parent directory (not found): " + parentId));
+            throw fsException(new IgfsPathNotFoundException("Failed to lock parent directory (not found): " +
+                parentId));
 
         if (!parentInfo.isDirectory())
             throw fsException(new IgfsPathIsNotDirectoryException("Parent file is not a directory: " + parentInfo));
@@ -1122,124 +1101,6 @@ public class IgfsMetaManager extends IgfsManager {
     }
 
     /**
-     * Remove file from the file system structure.
-     *
-     * @param parentId Parent file ID.
-     * @param fileName New file name in the parent's listing.
-     * @param fileId File ID to remove.
-     * @param path Path of the deleted file.
-     * @param rmvLocked Whether to remove this entry in case it is has explicit lock.
-     * @return The last actual file info or {@code null} if such file no more exist.
-     * @throws IgniteCheckedException If failed.
-     */
-    @Nullable public IgfsFileInfo removeIfEmpty(IgniteUuid parentId, String fileName, IgniteUuid fileId,
-        IgfsPath path, boolean rmvLocked)
-        throws IgniteCheckedException {
-        if (busyLock.enterBusy()) {
-            try {
-                assert validTxState(false);
-
-                IgniteInternalTx tx = metaCache.txStartEx(PESSIMISTIC, REPEATABLE_READ);
-
-                try {
-                    if (parentId != null)
-                        lockIds(parentId, fileId, TRASH_ID);
-                    else
-                        lockIds(fileId, TRASH_ID);
-
-                    IgfsFileInfo fileInfo = removeIfEmptyNonTx(parentId, fileName, fileId, path, rmvLocked);
-
-                    tx.commit();
-
-                    delWorker.signal();
-
-                    return fileInfo;
-                }
-                finally {
-                    tx.close();
-                }
-            }
-            finally {
-                busyLock.leaveBusy();
-            }
-        }
-        else
-            throw new IllegalStateException("Failed to remove file system entry because Grid is stopping [parentId=" +
-                parentId + ", fileName=" + fileName + ", fileId=" + fileId + ", path=" + path + ']');
-    }
-
-    /**
-     * Remove file from the file system structure in existing transaction.
-     *
-     * @param parentId Parent file ID.
-     * @param fileName New file name in the parent's listing.
-     * @param fileId File ID to remove.
-     * @param path Path of the deleted file.
-     * @param rmvLocked Whether to remove this entry in case it has explicit lock.
-     * @return The last actual file info or {@code null} if such file no more exist.
-     * @throws IgniteCheckedException If failed.
-     */
-    @Nullable private IgfsFileInfo removeIfEmptyNonTx(@Nullable IgniteUuid parentId, String fileName, IgniteUuid fileId,
-        IgfsPath path, boolean rmvLocked)
-        throws IgniteCheckedException {
-        assert validTxState(true);
-        assert parentId != null;
-        assert fileName != null;
-        assert fileId != null;
-        assert !ROOT_ID.equals(fileId);
-
-        if (log.isDebugEnabled())
-            log.debug("Remove file: [parentId=" + parentId + ", fileName= " + fileName + ", fileId=" + fileId + ']');
-
-        // Safe gets because locks are obtained in removeIfEmpty.
-        IgfsFileInfo fileInfo = id2InfoPrj.get(fileId);
-        IgfsFileInfo parentInfo = id2InfoPrj.get(parentId);
-
-        if (fileInfo == null || parentInfo == null) {
-            if (parentInfo != null) { // fileInfo == null
-                IgfsListingEntry entry = parentInfo.listing().get(fileName);
-
-                // If file info does not exists but listing entry exists, throw inconsistent exception.
-                if (entry != null && entry.fileId().equals(fileId))
-                    throw new IgniteCheckedException("Failed to remove file (file system is in inconsistent state) " +
-                        "[fileInfo=" + fileInfo + ", fileName=" + fileName + ", fileId=" + fileId + ']');
-            }
-
-            return null; // Parent directory or removed file cannot be locked (not found?).
-        }
-
-        assert parentInfo.isDirectory();
-
-        if (!rmvLocked && fileInfo.lockId() != null)
-            throw fsException("Failed to remove file (file is opened for writing) [fileName=" +
-                fileName + ", fileId=" + fileId + ", lockId=" + fileInfo.lockId() + ']');
-
-        // Validate own directory listing.
-        if (fileInfo.isDirectory()) {
-            Map<String, IgfsListingEntry> listing = fileInfo.listing();
-
-            if (!F.isEmpty(listing))
-                throw fsException(new IgfsDirectoryNotEmptyException("Failed to remove file (directory is not empty)" +
-                    " [fileId=" + fileId + ", listing=" + listing + ']'));
-        }
-
-        // Validate file in the parent listing.
-        IgfsListingEntry listingEntry = parentInfo.listing().get(fileName);
-
-        if (listingEntry == null || !listingEntry.fileId().equals(fileId))
-            return null;
-
-        // Actual remove.
-        softDeleteNonTx(parentId, fileName, fileId);
-
-        // Update a file info of the removed file with a file path,
-        // which will be used by delete worker for event notifications.
-        id2InfoPrj.invoke(fileId, new UpdatePath(path));
-
-        return builder(fileInfo).path(path).build();
-    }
-
-    /**
      * Deletes (moves to TRASH) all elements under the root folder.
      *
      * @return The new Id if the artificially created folder containing all former root
@@ -1528,6 +1389,9 @@ public class IgfsMetaManager extends IgfsManager {
                             IgfsFileInfo entryInfo = locks.get(entryId);
 
                             if (entryInfo != null) {
+                                // File must be locked for deletion:
+                                assert entryInfo.isDirectory() || DELETE_LOCK_ID.equals(entryInfo.lockId());
+
                                 // Delete only files or empty folders.
                                 if (entryInfo.isFile() || entryInfo.isDirectory() && entryInfo.listing().isEmpty()) {
                                     id2InfoPrj.getAndRemove(entryId);
@@ -1588,6 +1452,14 @@ public class IgfsMetaManager extends IgfsManager {
 
                     Map<IgniteUuid, IgfsFileInfo> infos = lockIds(parentId, id);
 
+                    IgfsFileInfo victim = infos.get(id);
+
+                    if (victim == null)
+                        return res;
+
+                    assert victim.isDirectory() || DELETE_LOCK_ID.equals(victim.lockId()) :
+                            " isDir: " + victim.isDirectory() + ", lockId: " + victim.lockId();
+
                     // Proceed only in case both parent and child exist.
                     if (infos.containsKey(parentId) && infos.containsKey(id)) {
                         IgfsFileInfo parentInfo = infos.get(parentId);
@@ -1599,7 +1471,9 @@ public class IgfsMetaManager extends IgfsManager {
                         if (listingEntry != null)
                             id2InfoPrj.invoke(parentId, new UpdateListing(name, listingEntry, true));
 
-                        id2InfoPrj.getAndRemove(id);
+                        IgfsFileInfo deleted = id2InfoPrj.getAndRemove(id);
+
+                        assert victim.id().equals(deleted.id());
 
                         res = true;
                     }
@@ -1885,66 +1759,34 @@ public class IgfsMetaManager extends IgfsManager {
         assert props != null;
         assert validTxState(false);
 
-        List<String> components;
-        SortedSet<IgniteUuid> idSet;
-        IgfsPath existingPath;
+        DirectoryChainBuilder b = null;
 
         while (true) {
             if (busyLock.enterBusy()) {
                 try {
-                    // Take the ids in *path* order out of transaction:
-                    final List<IgniteUuid> idList = fileIds(path);
-
-                    idSet = new TreeSet<IgniteUuid>(PATH_ID_SORTING_COMPARATOR);
-
-                    idSet.add(ROOT_ID);
-
-                    components = path.components();
-
-                    // Store all the non-null ids in the set & construct existing path in one loop:
-                    existingPath = path.root();
-
-                    assert idList.size() == components.size() + 1;
-
-                    // Find the lowermost existing id:
-                    IgniteUuid parentId = ROOT_ID;
-
-                    for (int i = 1; i < idList.size(); i++) {
-                        IgniteUuid id = idList.get(i);
-
-                        if (id == null)
-                            break;
-
-                        parentId = id;
-
-                        boolean added = idSet.add(id);
-
-                        assert added;
-
-                        existingPath = new IgfsPath(existingPath, components.get(i - 1));
-                    }
+                    b = new DirectoryChainBuilder(path, props, props);
 
                     // Start TX.
                     IgniteInternalTx tx = metaCache.txStartEx(PESSIMISTIC, REPEATABLE_READ);
 
                     try {
-                        final Map<IgniteUuid, IgfsFileInfo> lockedInfos = lockIds(idSet);
+                        final Map<IgniteUuid, IgfsFileInfo> lockedInfos = lockIds(b.idSet);
 
                         // If the path was changed, we close the current Tx and repeat the procedure again
                         // starting from taking the path ids.
-                        if (verifyPathIntegrity(existingPath, idList, lockedInfos)) {
+                        if (verifyPathIntegrity(b.existingPath, b.idList, lockedInfos)) {
                             // Locked path okay, trying to proceed with the remainder creation.
-                            IgfsFileInfo parentInfo = lockedInfos.get(parentId);
+                            IgfsFileInfo lowermostExistingInfo = lockedInfos.get(b.lowermostExistingId);
 
                             // Check only the lowermost directory in the existing directory chain
                             // because others are already checked in #verifyPathIntegrity() above.
-                            if (!parentInfo.isDirectory())
+                            if (!lowermostExistingInfo.isDirectory())
                                 throw new IgfsParentNotDirectoryException("Failed to create directory (parent " +
                                     "element is not a directory)");
 
-                            if (idSet.size() == components.size() + 1) {
-                                assert existingPath.equals(path);
-                                assert lockedInfos.size() == idSet.size();
+                            if (b.existingIdCnt == b.components.size() + 1) {
+                                assert b.existingPath.equals(path);
+                                assert lockedInfos.size() == b.existingIdCnt;
 
                                 // The target directory already exists, nothing to do.
                                 // (The fact that all the path consisns of directories is already checked above).
@@ -1952,48 +1794,15 @@ public class IgfsMetaManager extends IgfsManager {
                                 return false;
                             }
 
-                            Map<String, IgfsListingEntry> parentListing = parentInfo.listing();
+                            Map<String, IgfsListingEntry> parentListing = lowermostExistingInfo.listing();
 
-                            String shortName = components.get(idSet.size() - 1);
+                            String shortName = b.components.get(b.existingIdCnt - 1);
 
                             IgfsListingEntry entry = parentListing.get(shortName);
 
                             if (entry == null) {
-                                IgfsFileInfo childInfo = null;
-
-                                String childName = null;
-
-                                IgfsFileInfo newDirInfo;
-
-                                // This loop creates the missing directory chain from the bottom to the top:
-                                for (int i = components.size() - 1; i >= idSet.size() - 1; i--) {
-                                    // Required entry does not exist.
-                                    // Create new directory info:
-                                    if (childName == null) {
-                                        assert childInfo == null;
-
-                                        newDirInfo = new IgfsFileInfo(true, props);
-                                    }
-                                    else {
-                                        assert childInfo != null;
-
-                                        newDirInfo = new IgfsFileInfo(Collections.singletonMap(childName,
-                                            new IgfsListingEntry(childInfo)), props);
-                                    }
-
-                                    boolean put = id2InfoPrj.putIfAbsent(newDirInfo.id(), newDirInfo);
-
-                                    assert put; // Because we used a new id that should be unique.
+                                b.doBuild();
 
-                                    childInfo = newDirInfo;
-                                    childName = components.get(i);
-                                }
-
-                                // Now link the newly created directory chain to the lowermost existing parent:
-                                id2InfoPrj.invoke(parentId,
-                                    new UpdateListing(childName, new IgfsListingEntry(childInfo), false));
-
-                                // We're close to finish:
                                 tx.commit();
 
                                 break;
@@ -2022,17 +1831,11 @@ public class IgfsMetaManager extends IgfsManager {
             }
             else
                 throw new IllegalStateException("Failed to mkdir because Grid is stopping. [path=" + path + ']');
-        } // retry loop
-
-        if (evts.isRecordable(EVT_IGFS_DIR_CREATED)) {
-            IgfsPath createdPath = existingPath;
+        }
 
-            for (int i = idSet.size() - 1; i < components.size(); i++) {
-                createdPath = new IgfsPath(createdPath, components.get(i));
+        assert b != null;
 
-                evts.record(new IgfsEvent(createdPath, locNode, EVT_IGFS_DIR_CREATED));
-            }
-        }
+        b.sendEvents();
 
         return true;
     }
@@ -2135,6 +1938,8 @@ public class IgfsMetaManager extends IgfsManager {
 
                         @Override public IgfsSecondaryOutputStreamDescriptor onSuccess(Map<IgfsPath,
                             IgfsFileInfo> infos) throws Exception {
+                            assert validTxState(true);
+
                             assert !infos.isEmpty();
 
                             // Determine the first existing parent.
@@ -2186,7 +1991,7 @@ public class IgfsMetaManager extends IgfsManager {
                                     "the secondary file system because the path points to a directory: " + path);
 
                             IgfsFileInfo newInfo = new IgfsFileInfo(status.blockSize(), status.length(), affKey,
-                                IgniteUuid.randomUuid(), igfsCtx.igfs().evictExclude(path, false), status.properties());
+                                composeLockId(false), igfsCtx.igfs().evictExclude(path, false), status.properties());
 
                             // Add new file info to the listing optionally removing the previous one.
                             IgniteUuid oldId = putIfAbsentNonTx(parentInfo.id(), path.name(), newInfo);
@@ -2194,6 +1999,13 @@ public class IgfsMetaManager extends IgfsManager {
                             if (oldId != null) {
                                 IgfsFileInfo oldInfo = info(oldId);
 
+                                assert oldInfo != null; // Otherwise cache is in inconsistent state.
+
+                                // The contact is that we cannot overwrite a file locked for writing:
+                                if (oldInfo.lockId() != null)
+                                    throw fsException("Failed to overwrite file (file is opened for writing) [path=" +
+                                        path + ", fileId=" + oldId + ", lockId=" + oldInfo.lockId() + ']');
+
                                 id2InfoPrj.remove(oldId); // Remove the old one.
                                 id2InfoPrj.put(newInfo.id(), newInfo); // Put the new one.
 
@@ -2203,29 +2015,6 @@ public class IgfsMetaManager extends IgfsManager {
                                     new UpdateListing(path.name(), new IgfsListingEntry(newInfo), false));
 
                                 IgniteInternalFuture<?> delFut = igfsCtx.data().delete(oldInfo);
-
-                                // Record PURGE event if needed.
-                                if (evts.isRecordable(EVT_IGFS_FILE_PURGED)) {
-                                    delFut.listen(new CI1<IgniteInternalFuture<?>>() {
-                                        @Override public void apply(IgniteInternalFuture<?> t) {
-                                            try {
-                                                t.get(); // Ensure delete succeeded.
-
-                                                evts.record(new IgfsEvent(path, locNode, EVT_IGFS_FILE_PURGED));
-                                            }
-                                            catch (IgniteCheckedException e) {
-                                                LT.warn(log, e, "Old file deletion failed in DUAL mode [path=" + path +
-                                                    ", simpleCreate=" + simpleCreate + ", props=" + props +
-                                                    ", overwrite=" + overwrite + ", bufferSize=" + bufSize +
-                                                    ", replication=" + replication + ", blockSize=" + blockSize + ']');
-                                            }
-                                        }
-                                    });
-                                }
-
-                                // Record DELETE event if needed.
-                                if (evts.isRecordable(EVT_IGFS_FILE_DELETED))
-                                    pendingEvts.add(new IgfsEvent(path, locNode, EVT_IGFS_FILE_DELETED));
                             }
 
                             // Record CREATE event if needed.
@@ -2287,7 +2076,9 @@ public class IgfsMetaManager extends IgfsManager {
 
                         @Override public IgfsSecondaryOutputStreamDescriptor onSuccess(Map<IgfsPath,
                             IgfsFileInfo> infos) throws Exception {
-                            IgfsFileInfo info = infos.get(path);
+                            assert validTxState(true);
+
+                            final IgfsFileInfo info = infos.get(path);
 
                             if (info.isDirectory())
                                 throw fsException("Failed to open output stream to the file in the " +
@@ -2314,12 +2105,22 @@ public class IgfsMetaManager extends IgfsManager {
                                 }
                             }
 
+                            if (info.lockId() != null) {
+                                throw fsException("Failed to open file (file is opened for writing) [path=" +
+                                    path + ", fileId=" + info.id() + ", lockId=" + info.lockId() + ']');
+                            }
+
                             // Set lock and return.
-                            info = lockInfo(info);
+                            IgfsFileInfo lockedInfo = lockInfo(info, false);
+
+                            assert lockedInfo != null; // We checked the lock above.
 
-                            metaCache.put(info.id(), info);
+                            boolean put = metaCache.put(info.id(), lockedInfo);
 
-                            return new IgfsSecondaryOutputStreamDescriptor(infos.get(path.parent()).id(), info, out);
+                            assert put;
+
+                            return new IgfsSecondaryOutputStreamDescriptor(infos.get(path.parent()).id(),
+                                lockedInfo, out);
                         }
 
                         @Override public IgfsSecondaryOutputStreamDescriptor onFailure(@Nullable Exception err)
@@ -2329,8 +2130,8 @@ public class IgfsMetaManager extends IgfsManager {
                             U.error(log, "File append in DUAL mode failed [path=" + path + ", bufferSize=" + bufSize +
                                 ']', err);
 
-                            throw new IgniteCheckedException("Failed to append to the file due to secondary file system " +
-                                "exception: " + path, err);
+                            throw new IgniteCheckedException("Failed to append to the file due to secondary file " +
+                                "system exception: " + path, err);
                         }
                     };
 
@@ -2438,8 +2239,8 @@ public class IgfsMetaManager extends IgfsManager {
                         }
 
                         @Override public IgfsFileInfo onFailure(@Nullable Exception err) throws IgniteCheckedException {
-                            throw new IgniteCheckedException("Failed to synchronize path due to secondary file system " +
-                                "exception: " + path, err);
+                            throw new IgniteCheckedException("Failed to synchronize path due to secondary file " +
+                                "system exception: " + path, err);
                         }
                     };
 
@@ -2517,8 +2318,8 @@ public class IgfsMetaManager extends IgfsManager {
                         U.error(log, "Directory creation in DUAL mode failed [path=" + path + ", properties=" + props +
                             ']', err);
 
-                        throw new IgniteCheckedException("Failed to create the path due to secondary file system exception: " +
-                            path, err);
+                        throw new IgniteCheckedException("Failed to create the path due to secondary file system " +
+                            "exception: " + path, err);
                     }
                 };
 
@@ -2685,8 +2486,8 @@ public class IgfsMetaManager extends IgfsManager {
                         U.error(log, "Path delete in DUAL mode failed [path=" + path + ", recursive=" + recursive + ']',
                             err);
 
-                        throw new IgniteCheckedException("Failed to delete the path due to secondary file system exception: ",
-                            err);
+                        throw new IgniteCheckedException("Failed to delete the path due to secondary file system " +
+                            "exception: ", err);
                     }
                 };
 
@@ -2713,8 +2514,8 @@ public class IgfsMetaManager extends IgfsManager {
      * @return Update file info.
      * @throws IgniteCheckedException If update failed.
      */
-    public IgfsFileInfo updateDual(final IgfsSecondaryFileSystem fs, final IgfsPath path, final Map<String, String> props)
-        throws IgniteCheckedException {
+    public IgfsFileInfo updateDual(final IgfsSecondaryFileSystem fs, final IgfsPath path,
+        final Map<String, String> props) throws IgniteCheckedException {
         assert fs != null;
         assert path != null;
         assert props != null && !props.isEmpty();
@@ -2740,8 +2541,8 @@ public class IgfsMetaManager extends IgfsManager {
                         U.error(log, "Path update in DUAL mode failed [path=" + path + ", properties=" + props + ']',
                             err);
 
-                        throw new IgniteCheckedException("Failed to update the path due to secondary file system exception: " +
-                            path, err);
+                        throw new IgniteCheckedException("Failed to update the path due to secondary file system " +
+                            "exception: " + path, err);
                     }
                 };
 
@@ -2805,8 +2606,8 @@ public class IgfsMetaManager extends IgfsManager {
 
                 if (status != null) {
                     if (!status.isDirectory() && !curPath.equals(endPath))
-                        throw new IgniteCheckedException("Failed to create path the locally because secondary file system " +
-                            "directory structure was modified concurrently and the path is not a directory as " +
+                        throw new IgniteCheckedException("Failed to create path the locally because secondary file " +
+                            "system directory structure was modified concurrently and the path is not a directory as " +
                             "expected: " + curPath);
                 }
                 else {
@@ -3084,7 +2885,8 @@ public class IgfsMetaManager extends IgfsManager {
      * @return {@code True} if value was stored in cache, {@code false} otherwise.
      * @throws IgniteCheckedException If operation failed.
      */
-    private <K, V> boolean putx(IgniteInternalCache<K, V> cache, K key, IgniteClosure<V, V> c) throws IgniteCheckedException {
+    private <K, V> boolean putx(IgniteInternalCache<K, V> cache, K key, IgniteClosure<V, V> c)
+        throws IgniteCheckedException {
         assert validTxState(true);
 
         V oldVal = cache.get(key);
@@ -3549,4 +3351,455 @@ public class IgfsMetaManager extends IgfsManager {
             return S.toString(UpdatePath.class, this);
         }
     }
+
+    /**
+     * Create a new file.
+     *
+     * @param path Path.
+     * @param bufSize Buffer size.
+     * @param overwrite Overwrite flag.
+     * @param affKey Affinity key.
+     * @param replication Replication factor.
+     * @param props Properties.
+     * @param simpleCreate Whether new file should be created in secondary FS using create(Path, boolean) method.
+     * @return Tuple containing the created file info and its parent id.
+     */
+    IgniteBiTuple<IgfsFileInfo, IgniteUuid> create(
+        final IgfsPath path,
+        final boolean append,
+        final boolean overwrite,
+        Map<String, String> dirProps,
+        final int blockSize,
+        final @Nullable IgniteUuid affKey,
+        final boolean evictExclude,
+        @Nullable Map<String, String> fileProps) throws IgniteCheckedException {
+        assert validTxState(false);
+        assert path != null;
+
+        final String name = path.name();
+
+        DirectoryChainBuilder b = null;
+
+        while (true) {
+            if (busyLock.enterBusy()) {
+                try {
+                    b = new DirectoryChainBuilder(path, dirProps, fileProps) {
+                        /** {@inheritDoc} */
+                        @Override protected IgfsFileInfo buildLeaf() {
+                            return new IgfsFileInfo(blockSize, 0L, affKey, composeLockId(false),
+                                 evictExclude, leafProps);
+                        }
+                    };
+
+                    // Start Tx:
+                    IgniteInternalTx tx = metaCache.txStartEx(PESSIMISTIC, REPEATABLE_READ);
+
+                    try {
+                        if (overwrite)
+                            // Lock also the TRASH directory because in case of overwrite we
+                            // may need to delete the old file:
+                            b.idSet.add(TRASH_ID);
+
+                        final Map<IgniteUuid, IgfsFileInfo> lockedInfos = lockIds(b.idSet);
+
+                        assert !overwrite || lockedInfos.get(TRASH_ID) != null; // TRASH must exist at this point.
+
+                        // If the path was changed, we close the current Tx and repeat the procedure again
+                        // starting from taking the path ids.
+                        if (verifyPathIntegrity(b.existingPath, b.idList, lockedInfos)) {
+                            // Locked path okay, trying to proceed with the remainder creation.
+                            final IgfsFileInfo lowermostExistingInfo = lockedInfos.get(b.lowermostExistingId);
+
+                            if (b.existingIdCnt == b.components.size() + 1) {
+                                // Full requestd path exists.
+
+                                assert b.existingPath.equals(path);
+                                assert lockedInfos.size() ==
+                                        (overwrite ? b.existingIdCnt + 1/*TRASH*/ : b.existingIdCnt);
+
+                                if (lowermostExistingInfo.isDirectory()) {
+                                    throw new IgfsPathAlreadyExistsException("Failed to "
+                                            + (append ? "open" : "create") + " file (path points to an " +
+                                        "existing directory): " + path);
+                                }
+                                else {
+                                    // This is a file.
+                                    assert lowermostExistingInfo.isFile();
+
+                                    final IgniteUuid parentId = b.idList.get(b.idList.size() - 2);
+
+                                    final IgniteUuid lockId = lowermostExistingInfo.lockId();
+
+                                    if (append) {
+                                        if (lockId != null)
+                                            throw fsException("Failed to open file (file is opened for writing) "
+                                                + "[fileName=" + name + ", fileId=" + lowermostExistingInfo.id()
+                                                + ", lockId=" + lockId + ']');
+
+                                        IgniteUuid newLockId = composeLockId(false);
+
+                                        EntryProcessorResult<IgfsFileInfo> result
+                                            = id2InfoPrj.invoke(lowermostExistingInfo.id(),
+                                                new LockFileProcessor(newLockId));
+
+                                        IgfsFileInfo lockedInfo = result.get();
+
+                                        assert lockedInfo != null; // we already checked lock above.
+                                        assert lockedInfo.lockId() != null;
+                                        assert lockedInfo.lockId().equals(newLockId);
+                                        assert lockedInfo.id().equals(lowermostExistingInfo.id());
+
+                                        IgniteBiTuple<IgfsFileInfo, IgniteUuid> t2 = new T2<>(lockedInfo, parentId);
+
+                                        tx.commit();
+
+                                        IgfsUtils.sendEvents(igfsCtx.kernalContext(), path,
+                                                EventType.EVT_IGFS_FILE_OPENED_WRITE);
+
+                                        return t2;
+                                    }
+                                    else if (overwrite) {
+                                        // Delete existing file, but fail if it is locked:
+                                        if (lockId != null)
+                                            throw fsException("Failed to overwrite file (file is opened for writing) " +
+                                                    "[fileName=" + name + ", fileId=" + lowermostExistingInfo.id()
+                                                    + ", lockId=" + lockId + ']');
+
+                                        final IgfsListingEntry deletedEntry = lockedInfos.get(parentId).listing()
+                                                .get(name);
+
+                                        assert deletedEntry != null;
+
+                                        id2InfoPrj.invoke(parentId, new UpdateListing(name, deletedEntry, true));
+
+                                        // Add listing entry into the destination parent listing.
+                                        id2InfoPrj.invoke(TRASH_ID, new UpdateListing(
+                                                lowermostExistingInfo.id().toString(), deletedEntry, false));
+
+                                        // Update a file info of the removed file with a file path,
+                                        // which will be used by delete worker for event notifications.
+                                        id2InfoPrj.invoke(lowermostExistingInfo.id(), new UpdatePath(path));
+
+                                        // Make a new locked info:
+                                        final IgfsFileInfo newFileInfo = new IgfsFileInfo(cfg.getBlockSize(), 0L,
+                                            affKey, composeLockId(false), evictExclude, fileProps);
+
+                                        assert newFileInfo.lockId() != null; // locked info should be created.
+
+                                        boolean put = id2InfoPrj.putIfAbsent(newFileInfo.id(), newFileInfo);
+
+                                        assert put;
+
+                                        id2InfoPrj.invoke(parentId,
+                                                new UpdateListing(name, new IgfsListingEntry(newFileInfo), false));
+
+                                        IgniteBiTuple<IgfsFileInfo, IgniteUuid> t2 = new T2<>(newFileInfo, parentId);
+
+                                        tx.commit();
+
+                                        delWorker.signal();
+
+                                        IgfsUtils.sendEvents(igfsCtx.kernalContext(), path, EVT_IGFS_FILE_OPENED_WRITE);
+
+                                        return t2;
+                                    }
+                                    else {
+                                        throw new IgfsPathAlreadyExistsException("Failed to create file (file " +
+                                            "already exists and overwrite flag is false): " + path);
+                                    }
+                                }
+                            }
+
+                            // The full requested path does not exist.
+
+                            // Check only the lowermost directory in the existing directory chain
+                            // because others are already checked in #verifyPathIntegrity() above.
+                            if (!lowermostExistingInfo.isDirectory())
+                                throw new IgfsParentNotDirectoryException("Failed to " + (append ? "open" : "create" )
+                                    + " file (parent element is not a directory)");
+
+                            Map<String, IgfsListingEntry> parentListing = lowermostExistingInfo.listing();
+
+                            final String uppermostFileToBeCreatedName = b.components.get(b.existingIdCnt - 1);
+
+                            final IgfsListingEntry entry = parentListing.get(uppermostFileToBeCreatedName);
+
+                            if (entry == null) {
+                                b.doBuild();
+
+                                assert b.leafInfo != null;
+                                assert b.leafParentId != null;
+
+                                IgniteBiTuple<IgfsFileInfo, IgniteUuid> t2 = new T2<>(b.leafInfo, b.leafParentId);
+
+                                tx.commit();
+
+                                b.sendEvents();
+
+                                return t2;
+                            }
+
+                            // Another thread concurrently created file or directory in the path with
+                            // the name we need.
+                        }
+                    }
+                    finally {
+                        tx.close();
+                    }
+                }
+                finally {
+                    busyLock.leaveBusy();
+                }
+            } else
+                throw new IllegalStateException("Failed to mkdir because Grid is stopping. [path=" + path + ']');
+        }
+    }
+
+    /** File chain builder. */
+    private class DirectoryChainBuilder {
+        /** The requested path to be created. */
+        protected final IgfsPath path;
+
+        /** Full path components. */
+        protected final List<String> components;
+
+        /** The list of ids. */
+        protected final List<IgniteUuid> idList;
+
+        /** The set of ids. */
+        protected final SortedSet<IgniteUuid> idSet;
+
+        /** The middle node properties. */
+        protected final Map<String, String> middleProps;
+
+        /** The leaf node properties. */
+        protected final Map<String, String> leafProps;
+
+        /** The lowermost exsiting path id. */
+        protected final IgniteUuid lowermostExistingId;
+
+        /** The existing path. */
+        protected final IgfsPath existingPath;
+
+        /** The created leaf info. */
+        protected IgfsFileInfo leafInfo;
+
+        /** The leaf parent id. */
+        protected IgniteUuid leafParentId;
+
+        /** The number of existing ids. */
+        protected final int existingIdCnt;
+
+        /**
+         * Creates the builder and performa all the initial calculations.
+         */
+        protected DirectoryChainBuilder(IgfsPath path,
+                 Map<String,String> middleProps, Map<String,String> leafProps) throws IgniteCheckedException {
+            this.path = path;
+
+            this.components = path.components();
+
+            this.idList = fileIds(path);
+
+            this.idSet = new TreeSet<IgniteUuid>(PATH_ID_SORTING_COMPARATOR);
+
+            this.middleProps = middleProps;
+
+            this.leafProps = leafProps;
+            // Store all the non-null ids in the set & construct existing path in one loop:
+            IgfsPath existingPath = path.root();
+
+            assert idList.size() == components.size() + 1;
+
+            // Find the lowermost existing id:
+            IgniteUuid lowermostExistingId = null;
+
+            int idIdx = 0;
+
+            for (IgniteUuid id: idList) {
+                if (id == null)
+                    break;
+
+                lowermostExistingId = id;
+
+                boolean added = idSet.add(id);
+
+                assert added : "Not added id = " + id;
+
+                if (idIdx >= 1) // skip root.
+                    existingPath = new IgfsPath(existingPath, components.get(idIdx - 1));
+
+                idIdx++;
+            }
+
+            assert idSet.contains(ROOT_ID);
+
+            this.lowermostExistingId = lowermostExistingId;
+
+            this.existingPath = existingPath;
+
+            this.existingIdCnt = idSet.size();
+        }
+
+        /**
+         * Builds middle nodes.
+         */
+        protected IgfsFileInfo buildMiddleNode(String childName, IgfsFileInfo childInfo) {
+            return new IgfsFileInfo(Collections.singletonMap(childName,
+                    new IgfsListingEntry(childInfo)), middleProps);
+        }
+
+        /**
+         * Builds leaf.
+         */
+        protected IgfsFileInfo buildLeaf()  {
+            return new IgfsFileInfo(true, leafProps);
+        }
+
+        /**
+         * Links newly created chain to existing parent.
+         */
+        final void linkBuiltChainToExistingParent(String childName, IgfsFileInfo childInfo)
+                throws IgniteCheckedException {
+            assert childInfo != null;
+
+            id2InfoPrj.invoke(lowermostExistingId,
+                    new UpdateListing(childName, new IgfsListingEntry(childInfo), false));
+        }
+
+        /**
+         * Does the main portion of job building the renmaining path.
+         */
+        public final void doBuild() throws IgniteCheckedException {
+            IgfsFileInfo childInfo = null;
+
+            String childName = null;
+
+            IgfsFileInfo newLeafInfo;
+            IgniteUuid parentId = null;
+
+            // This loop creates the missing directory chain from the bottom to the top:
+            for (int i = components.size() - 1; i >= existingIdCnt - 1; i--) {
+                // Required entry does not exist.
+                // Create new directory info:
+                if (childName == null) {
+                    assert childInfo == null;
+
+                    newLeafInfo = buildLeaf();
+
+                    assert newLeafInfo != null;
+
+                    leafInfo = newLeafInfo;
+                }
+                else {
+                    assert childInfo != null;
+
+                    newLeafInfo = buildMiddleNode(childName, childInfo);
+
+                    assert newLeafInfo != null;
+
+                    if (parentId == null)
+                        parentId = newLeafInfo.id();
+                }
+
+                boolean put = id2InfoPrj.putIfAbsent(newLeafInfo.id(), newLeafInfo);
+
+                assert put; // Because we used a new id that should be unique.
+
+                childInfo = newLeafInfo;
+
+                childName = components.get(i);
+            }
+
+            if (parentId == null)
+                parentId = lowermostExistingId;
+
+            leafParentId = parentId;
+
+            // Now link the newly created directory chain to the lowermost existing parent:
+            linkBuiltChainToExistingParent(childName, childInfo);
+        }
+
+        /**
+         * Sends events.
+         */
+        public final void sendEvents() {
+            if (evts.isRecordable(EVT_IGFS_DIR_CREATED)) {
+                IgfsPath createdPath = existingPath;
+
+                for (int i = existingPath.components().size(); i < components.size() - 1; i++) {
+                    createdPath = new IgfsPath(createdPath, components.get(i));
+
+                    IgfsUtils.sendEvents(igfsCtx.kernalContext(), createdPath, EVT_IGFS_DIR_CREATED);
+                }
+            }
+
+            if (leafInfo.isDirectory())
+                IgfsUtils.sendEvents(igfsCtx.kernalContext(), path, EVT_IGFS_DIR_CREATED);
+            else {
+                IgfsUtils.sendEvents(igfsCtx.kernalContext(), path, EVT_IGFS_FILE_CREATED);
+                IgfsUtils.sendEvents(igfsCtx.kernalContext(), path, EVT_IGFS_FILE_OPENED_WRITE);
+            }
+        }
+    }
+
+    /**
+     * Processor closure to locks a file for writing.
+     */
+    private static class LockFileProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, IgfsFileInfo>,
+            Externalizable {
+        /** */
+        private static final long serialVersionUID = 0L;
+
+        /** New lock id to lock the entry. */
+        private IgniteUuid newLockId;
+
+        /**
+         * Constructor.
+         */
+        public LockFileProcessor(IgniteUuid newLockId) {
+            assert newLockId != null;
+
+            this.newLockId = newLockId;
+        }
+
+        /**
+         * Empty constructor required for {@link Externalizable}.
+         */
+        public LockFileProcessor() {
+            // No-op.
+        }
+
+        /** {@inheritDoc} */
+        @Override @Nullable public IgfsFileInfo process(MutableEntry<IgniteUuid, IgfsFileInfo> entry,
+                 Object... arguments) throws EntryProcessorException {
+            final IgfsFileInfo info = entry.getValue();
+
+            assert info != null;
+
+            if (info.lockId() != null)
+                return null; // file is already locked.
+
+            IgfsFileInfo newInfo = new IgfsFileInfo(info, newLockId, info.modificationTime());
+
+            entry.setValue(newInfo);
+
+            return newInfo;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void writeExternal(ObjectOutput out) throws IOException {
+            U.writeGridUuid(out, newLockId);
+        }
+
+        /** {@inheritDoc} */
+        @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+            newLockId = U.readGridUuid(in);
+        }
+
+        /** {@inheritDoc} */
+        @Override public String toString() {
+            return S.toString(LockFileProcessor.class, this);
+        }
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/962fcce3/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsOutputStreamImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsOutputStreamImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsOutputStreamImpl.java
index c297eed..c9225ae 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsOutputStreamImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsOutputStreamImpl.java
@@ -121,6 +121,8 @@ class IgfsOutputStreamImpl extends IgfsOutputStreamAdapter {
         if (fileInfo.lockId() == null)
             throw new IgfsException("Failed to acquire file lock (concurrently modified?): " + path);
 
+        assert !IgfsMetaManager.DELETE_LOCK_ID.equals(fileInfo.lockId());
+
         this.igfsCtx = igfsCtx;
         meta = igfsCtx.meta();
         data = igfsCtx.data();

http://git-wip-us.apache.org/repos/asf/ignite/blob/962fcce3/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
index 50ebd56..07fdda4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
@@ -21,10 +21,15 @@ import java.lang.reflect.Constructor;
 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.cluster.ClusterTopologyException;
 import org.apache.ignite.configuration.FileSystemConfiguration;
+import org.apache.ignite.events.IgfsEvent;
 import org.apache.ignite.igfs.IgfsException;
+import org.apache.ignite.igfs.IgfsPath;
+import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException;
+import org.apache.ignite.internal.managers.eventstorage.GridEventStorageManager;
 import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
 import org.apache.ignite.internal.util.future.IgniteFutureImpl;
 import org.apache.ignite.internal.util.lang.IgniteOutClosureX;
@@ -158,4 +163,22 @@ public class IgfsUtils {
         throw new IgniteCheckedException("Failed to perform operation since max number of attempts " +
             "exceeded. [maxAttempts=" + MAX_CACHE_TX_RETRIES + ']');
     }
+
+
+    /**
+     * Sends a series of event.
+     *
+     * @param path The path of the created file.
+     * @param type The type of event to send.
+     */
+    public static void sendEvents(GridKernalContext kernalCtx, IgfsPath path, int type) {
+        assert kernalCtx != null;
+        assert path != null;
+
+        GridEventStorageManager evts = kernalCtx.event();
+        ClusterNode locNode = kernalCtx.discovery().localNode();
+
+        if (evts.isRecordable(type))
+            evts.record(new IgfsEvent(path, locNode, type));
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/962fcce3/modules/core/src/test/java/org/apache/ignite/igfs/IgfsEventsAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/igfs/IgfsEventsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/igfs/IgfsEventsAbstractSelfTest.java
index f0f86ec..6ca75a1 100644
--- a/modules/core/src/test/java/org/apache/ignite/igfs/IgfsEventsAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/igfs/IgfsEventsAbstractSelfTest.java
@@ -683,7 +683,7 @@ public abstract class IgfsEventsAbstractSelfTest extends GridCommonAbstractTest
     public void testSingleFileOverwrite() throws Exception {
         final List<Event> evtList = new ArrayList<>();
 
-        final int evtsCnt = 3 + 4 + 1;
+        final int evtsCnt = 1 + 4 + 1;
 
         final CountDownLatch latch = new CountDownLatch(evtsCnt);
 
@@ -703,7 +703,7 @@ public abstract class IgfsEventsAbstractSelfTest extends GridCommonAbstractTest
 
         igfs.create(file, false).close(); // Will generate create, open and close events.
 
-        igfs.create(file, true).close(); // Will generate same event set + delete and purge events.
+        igfs.create(file, true).close(); // Will generate only OPEN_WRITE & close events.
 
         try {
             igfs.create(file, false).close(); // Won't generate any event.
@@ -732,7 +732,7 @@ public abstract class IgfsEventsAbstractSelfTest extends GridCommonAbstractTest
         assertEquals(0, evt.dataSize());
 
         assertOneToOne(
-            evtList.subList(3, 8),
+            evtList.subList(3, evtsCnt),
             new P1<Event>() {
                 @Override public boolean apply(Event e) {
                     IgfsEvent e0 = (IgfsEvent)e;


[50/50] [abbrv] ignite git commit: Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/ignite into ignite-1016

Posted by ag...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/ignite into ignite-1016


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

Branch: refs/heads/ignite-1016
Commit: 4f2b22bca3d282550bca11066afb91cbae4f8de0
Parents: 8f5a4c9 e9524ce
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Thu Oct 22 13:46:38 2015 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Thu Oct 22 13:46:38 2015 +0300

----------------------------------------------------------------------
 DEVNOTES.txt                                    |    3 +-
 RELEASE_NOTES.txt                               |    2 +
 assembly/dependencies-fabric.xml                |    2 +-
 assembly/dependencies-hadoop.xml                |    1 +
 assembly/release-fabric-lgpl.xml                |   63 +
 assembly/release-fabric.xml                     |   10 +-
 assembly/release-hadoop-lgpl.xml                |   39 +
 bin/igniterouter.bat                            |    2 +-
 bin/igniterouter.sh                             |    2 +-
 examples-lgpl/README.txt                        |   27 +
 examples-lgpl/config/example-cache.xml          |   73 +
 examples-lgpl/config/example-ignite.xml         |   83 ++
 examples-lgpl/config/hibernate/README.txt       |    8 +
 .../hibernate/example-hibernate-L2-cache.xml    |   64 +
 examples-lgpl/pom-standalone.xml                |  186 +++
 examples-lgpl/pom.xml                           |  128 ++
 .../hibernate/HibernateL2CacheExample.java      |  245 ++++
 .../examples/datagrid/hibernate/Post.java       |  130 ++
 .../examples/datagrid/hibernate/User.java       |  154 ++
 .../datagrid/hibernate/package-info.java        |   22 +
 .../hibernate/CacheHibernatePersonStore.java    |  122 ++
 .../hibernate/CacheHibernateStoreExample.java   |  151 ++
 .../datagrid/store/hibernate/Person.hbm.xml     |   34 +
 .../datagrid/store/hibernate/hibernate.cfg.xml  |   41 +
 .../datagrid/store/hibernate/package-info.java  |   22 +
 .../misc/schedule/ComputeScheduleExample.java   |   82 ++
 .../examples/misc/schedule/package-info.java    |   22 +
 .../misc/schedule/ComputeScheduleExample.java   |   68 +
 .../java8/misc/schedule/package-info.java       |   22 +
 .../ignite/examples/java8/package-info.java     |   23 +
 .../scalar/examples/ScalarScheduleExample.scala |   66 +
 ...ibernateL2CacheExampleMultiNodeSelfTest.java |   31 +
 .../HibernateL2CacheExampleSelfTest.java        |   33 +
 .../IgniteLgplExamplesSelfTestSuite.java        |   48 +
 ...ibernateL2CacheExampleMultiNodeSelfTest.java |   29 +
 .../HibernateL2CacheExampleSelfTest.java        |   37 +
 .../IgniteLgplExamplesJ8SelfTestSuite.java      |   46 +
 .../ScalarLgplExamplesMultiNodeSelfTest.scala   |   33 +
 .../examples/ScalarLgplExamplesSelfTest.scala   |   36 +
 .../ScalarLgplExamplesSelfTestSuite.scala       |   37 +
 examples/config/hibernate/README.txt            |    8 -
 .../hibernate/example-hibernate-L2-cache.xml    |   64 -
 examples/pom-standalone.xml                     |   12 -
 examples/pom.xml                                |   14 +-
 examples/schema-import/pom-standalone.xml       |   90 ++
 examples/schema-import/pom.xml                  |   23 +-
 .../computegrid/ComputeClosureExample.java      |    2 +-
 .../hibernate/HibernateL2CacheExample.java      |  245 ----
 .../examples/datagrid/hibernate/Post.java       |  130 --
 .../examples/datagrid/hibernate/User.java       |  154 --
 .../datagrid/hibernate/package-info.java        |   22 -
 .../hibernate/CacheHibernatePersonStore.java    |  122 --
 .../hibernate/CacheHibernateStoreExample.java   |  151 --
 .../datagrid/store/hibernate/Person.hbm.xml     |   34 -
 .../datagrid/store/hibernate/hibernate.cfg.xml  |   41 -
 .../datagrid/store/hibernate/package-info.java  |   22 -
 .../misc/schedule/ComputeScheduleExample.java   |   82 --
 .../examples/misc/schedule/package-info.java    |   22 -
 .../socket/WordsSocketStreamerServer.java       |    5 +-
 .../misc/schedule/ComputeScheduleExample.java   |   68 -
 .../java8/misc/schedule/package-info.java       |   22 -
 .../scalar/examples/ScalarScheduleExample.scala |   66 -
 ...ibernateL2CacheExampleMultiNodeSelfTest.java |   31 -
 .../HibernateL2CacheExampleSelfTest.java        |   33 -
 .../testsuites/IgniteExamplesSelfTestSuite.java |    4 -
 ...ibernateL2CacheExampleMultiNodeSelfTest.java |   29 -
 .../HibernateL2CacheExampleSelfTest.java        |   37 -
 .../tests/examples/ScalarExamplesSelfTest.scala |    5 -
 modules/aop/pom.xml                             |    2 +-
 modules/apache-license-gen/README.txt           |   33 +
 modules/apache-license-gen/pom.xml              |    5 +-
 modules/aws/pom.xml                             |    2 +-
 modules/clients/pom.xml                         |    2 +-
 .../JettyRestProcessorAbstractSelfTest.java     |  252 +++-
 modules/cloud/pom.xml                           |    2 +-
 .../TcpDiscoveryCloudIpFinderSelfTest.java      |    2 +
 modules/codegen/pom.xml                         |    2 +-
 modules/core/pom.xml                            |    2 +-
 .../org/apache/ignite/IgniteAtomicLong.java     |   15 +-
 .../apache/ignite/IgniteAtomicReference.java    |    9 +-
 .../org/apache/ignite/IgniteAtomicSequence.java |    9 +-
 .../org/apache/ignite/IgniteAtomicStamped.java  |   13 +-
 .../org/apache/ignite/IgniteFileSystem.java     |    4 +-
 .../apache/ignite/IgniteSystemProperties.java   |    3 +
 .../org/apache/ignite/IgniteTransactions.java   |    4 -
 .../configuration/CacheConfiguration.java       |    2 +-
 .../ignite/configuration/TopologyValidator.java |   38 +-
 .../java/org/apache/ignite/igfs/IgfsPath.java   |    2 +-
 .../apache/ignite/internal/IgniteKernal.java    |   74 +-
 .../managers/discovery/CustomEventListener.java |    4 +-
 .../discovery/GridDiscoveryManager.java         |   81 +-
 .../internal/portable/PortableContext.java      |   19 +-
 .../portable/api/PortableMarshaller.java        |   14 +-
 .../cache/DynamicCacheChangeRequest.java        |   19 +
 .../cache/DynamicCacheDescriptor.java           |   36 +
 .../processors/cache/GridCacheAdapter.java      |  357 +++--
 .../cache/GridCacheClearAllRunnable.java        |   18 +-
 .../cache/GridCacheConcurrentMap.java           |    4 +-
 .../processors/cache/GridCacheContext.java      |    2 +-
 .../processors/cache/GridCacheEventManager.java |   12 +-
 .../cache/GridCacheExplicitLockSpan.java        |   13 +-
 .../processors/cache/GridCacheIoManager.java    |  105 +-
 .../processors/cache/GridCacheMessage.java      |    7 -
 .../cache/GridCacheMvccCandidate.java           |    5 +-
 .../processors/cache/GridCacheMvccManager.java  |   67 +-
 .../GridCachePartitionExchangeManager.java      |   92 +-
 .../processors/cache/GridCacheProcessor.java    |  140 +-
 .../processors/cache/GridCacheProxyImpl.java    |   14 +-
 .../cache/GridCacheSharedContext.java           |   32 -
 .../processors/cache/GridCacheSwapManager.java  |    4 +-
 .../processors/cache/GridCacheUtils.java        |    8 -
 .../processors/cache/IgniteCacheProxy.java      |    6 +-
 .../processors/cache/IgniteInternalCache.java   |   19 +-
 .../distributed/GridDistributedCacheEntry.java  |    2 +-
 .../dht/GridClientPartitionTopology.java        |   13 +-
 .../dht/GridDhtAffinityAssignmentRequest.java   |    5 -
 .../dht/GridDhtAffinityAssignmentResponse.java  |    5 -
 .../distributed/dht/GridDhtCacheAdapter.java    |    6 +-
 .../cache/distributed/dht/GridDhtGetFuture.java |    4 +-
 .../distributed/dht/GridDhtLocalPartition.java  |    3 +-
 .../distributed/dht/GridDhtLockRequest.java     |   10 +-
 .../dht/GridDhtPartitionTopologyImpl.java       |   12 +-
 .../distributed/dht/GridDhtTxFinishRequest.java |    5 -
 .../distributed/dht/GridDhtTxPrepareFuture.java |    6 +-
 .../dht/GridDhtTxPrepareRequest.java            |    7 +-
 .../dht/GridPartitionedGetFuture.java           |    5 +-
 .../dht/atomic/GridDhtAtomicUpdateFuture.java   |    5 +
 .../dht/atomic/GridNearAtomicUpdateFuture.java  |   17 +-
 .../dht/colocated/GridDhtColocatedCache.java    |   12 +-
 .../colocated/GridDhtColocatedLockFuture.java   |   27 +-
 .../dht/preloader/GridDhtForceKeysRequest.java  |    5 -
 .../dht/preloader/GridDhtForceKeysResponse.java |    5 -
 .../GridDhtPartitionDemandMessage.java          |    9 +-
 .../GridDhtPartitionSupplyMessage.java          |    8 +-
 .../GridDhtPartitionsAbstractMessage.java       |    5 -
 .../GridDhtPartitionsExchangeFuture.java        |   12 +-
 .../preloader/GridDhtPartitionsFullMessage.java |   12 +-
 .../GridDhtPartitionsSingleMessage.java         |   11 +-
 .../dht/preloader/GridDhtPreloader.java         |   26 +-
 .../distributed/near/GridNearCacheAdapter.java  |   21 +-
 .../near/GridNearCacheClearAllRunnable.java     |    9 +-
 .../distributed/near/GridNearGetFuture.java     |    2 +
 .../distributed/near/GridNearLockFuture.java    |   11 +-
 .../near/GridNearOptimisticTxPrepareFuture.java |   24 +-
 .../near/GridNearTxFinishFuture.java            |    4 +-
 .../cache/distributed/near/GridNearTxLocal.java |   21 +-
 .../cache/local/GridLocalCacheEntry.java        |    2 +-
 .../cache/query/GridCacheQueryManager.java      |   33 +-
 .../cache/query/GridCacheSqlIndexMetadata.java  |    7 +-
 .../cache/query/GridCacheSqlMetadata.java       |   22 +-
 .../continuous/CacheContinuousQueryHandler.java |   10 +-
 .../continuous/CacheContinuousQueryManager.java |   58 +-
 .../transactions/IgniteTxLocalAdapter.java      |   35 +-
 .../continuous/GridContinuousProcessor.java     |   20 +-
 .../datastructures/DataStructuresProcessor.java |   54 +-
 .../processors/igfs/IgfsDataManager.java        |    2 -
 .../processors/igfs/IgfsDeleteWorker.java       |  102 +-
 .../internal/processors/igfs/IgfsFileInfo.java  |   15 +-
 .../internal/processors/igfs/IgfsImpl.java      |  372 +----
 .../processors/igfs/IgfsMetaManager.java        | 1255 ++++++++++++----
 .../processors/igfs/IgfsOutputStreamImpl.java   |    2 +
 .../internal/processors/igfs/IgfsUtils.java     |   23 +
 .../processors/rest/GridRestCommand.java        |    8 +-
 .../processors/rest/GridRestProcessor.java      |  364 ++++-
 .../handlers/cache/GridCacheCommandHandler.java |  364 ++---
 .../handlers/query/QueryCommandHandler.java     |  195 ++-
 .../top/GridTopologyCommandHandler.java         |   31 +-
 .../rest/request/RestQueryRequest.java          |  175 +++
 .../rest/request/RestSqlQueryRequest.java       |  125 --
 .../ignite/internal/util/GridArgumentCheck.java |    5 +-
 .../ignite/internal/util/GridJavaProcess.java   |   12 +-
 .../ignite/internal/util/IgniteUtils.java       |    2 +-
 .../ignite/internal/util/lang/GridFunc.java     |   12 +
 .../util/nio/GridNioRecoveryDescriptor.java     |    4 +-
 .../apache/ignite/marshaller/Marshaller.java    |    2 +-
 .../optimized/OptimizedMarshallerUtils.java     |    6 +-
 .../org/apache/ignite/mxbean/IgniteMXBean.java  |    8 +-
 .../communication/tcp/TcpCommunicationSpi.java  |   22 +-
 .../ignite/spi/deployment/DeploymentSpi.java    |    8 +-
 .../org/apache/ignite/stream/StreamAdapter.java |  104 +-
 .../stream/StreamMultipleTupleExtractor.java    |   38 +
 .../stream/StreamSingleTupleExtractor.java      |   40 +
 .../ignite/stream/StreamTupleExtractor.java     |   20 +-
 .../ignite/stream/socket/SocketStreamer.java    |    3 +-
 .../core/src/main/resources/ignite.properties   |    2 +-
 modules/core/src/test/config/tests.properties   |    3 +
 .../ignite/igfs/IgfsEventsAbstractSelfTest.java |    6 +-
 .../ignite/igfs/IgfsFragmentizerSelfTest.java   |    2 +-
 .../internal/GridUpdateNotifierSelfTest.java    |    1 +
 .../IgniteClientReconnectAbstractTest.java      |   35 +-
 .../IgniteClientReconnectCacheTest.java         |  154 ++
 .../GridDiscoveryManagerAliveCacheSelfTest.java |    2 +
 .../cache/CacheAffinityCallSelfTest.java        |    4 +-
 .../processors/cache/CrossCacheLockTest.java    |  142 ++
 .../GridCacheAbstractFailoverSelfTest.java      |    3 +
 .../cache/GridCacheAbstractFullApiSelfTest.java |  486 ++++---
 .../GridCacheAbstractRemoveFailureTest.java     |    3 +
 .../cache/GridCacheClearSelfTest.java           |  308 ++++
 .../GridCacheDeploymentOffHeapSelfTest.java     |   15 +
 .../GridCacheFinishPartitionsSelfTest.java      |    5 +-
 .../GridCacheVariableTopologySelfTest.java      |    3 +-
 ...IgniteCacheAtomicPutAllFailoverSelfTest.java |    4 +
 .../IgniteCacheConfigurationTemplateTest.java   |   31 +
 .../cache/IgniteCacheCreateRestartSelfTest.java |    3 +
 .../cache/IgniteCacheEntryListenerTxTest.java   |    4 +
 .../IgniteCacheP2pUnmarshallingErrorTest.java   |    7 +
 ...CacheP2pUnmarshallingRebalanceErrorTest.java |   12 +-
 .../cache/IgniteCachePutAllRestartTest.java     |    4 +-
 .../cache/IgniteDynamicCacheFilterTest.java     |  150 ++
 .../IgniteTxExceptionAbstractSelfTest.java      |    3 +
 ...omicOffheapQueueCreateMultiNodeSelfTest.java |    5 -
 ...ionedAtomicQueueCreateMultiNodeSelfTest.java |    9 +-
 ...artitionedOffHeapValuesQueueApiSelfTest.java |    4 +
 ...PartitionedQueueCreateMultiNodeSelfTest.java |   16 +-
 ...nedQueueFailoverDataConsistencySelfTest.java |    5 -
 ...GridCachePartitionedSetFailoverSelfTest.java |    4 +
 .../CacheAbstractRestartSelfTest.java           |  247 ++++
 ...acheAsyncOperationsFailoverAbstractTest.java |   11 +
 .../CacheGetFutureHangsSelfTest.java            |  159 +--
 ...NearDisabledAtomicInvokeRestartSelfTest.java |  179 +++
 ...abledTransactionalInvokeRestartSelfTest.java |  173 +++
 ...edTransactionalWriteReadRestartSelfTest.java |  124 ++
 .../CacheNoValueClassOnServerNodeTest.java      |    1 +
 .../CachePutAllFailoverAbstractTest.java        |   11 +
 .../IgniteCacheAtomicNodeRestartTest.java       |    8 +
 ...niteCacheClientNodeChangingTopologyTest.java |   10 +-
 .../IgniteCacheCreatePutMultiNodeSelfTest.java  |  151 ++
 .../distributed/IgniteCacheCreatePutTest.java   |  125 ++
 .../IgniteCachePutGetRestartAbstractTest.java   |    3 +
 .../IgniteCacheSizeFailoverTest.java            |    3 +
 .../IgniteTxPreloadAbstractTest.java            |   43 +-
 .../GridCacheColocatedTxExceptionSelfTest.java  |    5 -
 .../dht/GridCacheDhtEntrySelfTest.java          |    2 +-
 .../dht/GridCacheDhtPreloadPerformanceTest.java |  133 ++
 .../dht/GridCacheTxNodeFailureSelfTest.java     |    2 +
 .../dht/GridNearCacheTxNodeFailureSelfTest.java |    4 +
 ...gniteAtomicLongChangingTopologySelfTest.java |  190 ++-
 .../IgniteCacheCrossCacheTxFailoverTest.java    |    3 +
 .../IgniteCrossCacheTxNearEnabledSelfTest.java  |   28 +
 .../dht/IgniteCrossCacheTxSelfTest.java         |  213 +++
 ...tomicClientOnlyMultiNodeFullApiSelfTest.java |   71 +-
 ...ledFairAffinityMultiNodeFullApiSelfTest.java |   12 +-
 ...icOffHeapTieredMultiNodeFullApiSelfTest.java |    7 +-
 .../near/GridCacheNearTxExceptionSelfTest.java  |    9 +-
 .../near/GridCacheNearTxForceKeyTest.java       |    2 +-
 ...achePartitionedMultiNodeFullApiSelfTest.java |  129 +-
 .../near/NearCacheMultithreadedUpdateTest.java  |  217 +++
 .../GridCacheReplicatedInvalidateSelfTest.java  |  249 ----
 .../GridCacheReplicatedTxExceptionSelfTest.java |    5 -
 .../replicated/GridReplicatedTxPreloadTest.java |    9 +-
 ...eCacheExpiryPolicyWithStoreAbstractTest.java |    5 +-
 .../GridCacheLocalTxExceptionSelfTest.java      |    5 -
 ...bledFairAffinityMultiJvmFullApiSelfTest.java |    5 +
 ...tomicNearEnabledMultiJvmFullApiSelfTest.java |    5 +
 ...ontinuousQueryReplicatedOneNodeSelfTest.java |  120 ++
 .../DataStreamerMultiThreadedSelfTest.java      |    4 +-
 .../DataStreamerMultinodeCreateCacheTest.java   |    2 +
 .../processors/igfs/IgfsAbstractSelfTest.java   |  927 +++++++++---
 .../igfs/IgfsClientCacheSelfTest.java           |   15 +-
 .../igfs/IgfsDataManagerSelfTest.java           |   13 +-
 .../igfs/IgfsMetaManagerSelfTest.java           |  258 ++--
 .../processors/igfs/IgfsMetricsSelfTest.java    |    2 +-
 .../processors/igfs/IgfsProcessorSelfTest.java  |   41 +-
 .../igfs/UniversalFileSystemAdapter.java        |    1 -
 .../tcp/TcpClientDiscoverySpiSelfTest.java      |    2 +
 .../stream/socket/SocketStreamerSelfTest.java   |  112 +-
 .../testframework/junits/GridAbstractTest.java  |  116 +-
 .../junits/IgniteTestResources.java             |    8 +-
 .../junits/common/GridCommonAbstractTest.java   |   15 +-
 .../junits/multijvm/AffinityProcessProxy.java   |  440 ++++--
 .../multijvm/IgniteCacheProcessProxy.java       | 1347 ++++++++++++++----
 .../multijvm/IgniteClusterProcessProxy.java     |  115 +-
 .../multijvm/IgniteEventsProcessProxy.java      |   50 +-
 .../junits/multijvm/IgniteNodeRunner.java       |   39 +-
 .../junits/multijvm/IgniteProcessProxy.java     |  107 +-
 .../IgniteCacheFailoverTestSuite.java           |    4 -
 .../IgniteCacheFailoverTestSuite3.java          |   28 +-
 .../IgniteCacheFullApiSelfTestSuite.java        |    8 +-
 .../IgniteCacheLoadConsistencyTestSuite.java    |   42 +
 .../testsuites/IgniteCacheTestSuite3.java       |    2 -
 .../testsuites/IgniteCacheTestSuite4.java       |   22 +
 .../ignite/testsuites/IgniteIgfsTestSuite.java  |    6 +
 modules/extdata/p2p/pom.xml                     |    2 +-
 .../extdata/uri/modules/uri-dependency/pom.xml  |    2 +-
 modules/extdata/uri/pom.xml                     |   13 +-
 modules/gce/pom.xml                             |    2 +-
 modules/geospatial/pom.xml                      |    2 +-
 modules/hadoop/pom.xml                          |    2 +-
 .../processors/hadoop/igfs/HadoopIgfsUtils.java |   36 +
 .../hadoop/igfs/HadoopIgfsWrapper.java          |   54 +-
 ...oopFileSystemUniversalFileSystemAdapter.java |    4 +-
 .../HadoopIgfs20FileSystemAbstractSelfTest.java |   34 +-
 .../IgniteHadoopFileSystemAbstractSelfTest.java |    7 +-
 .../testsuites/IgniteHadoopTestSuite.java       |   19 +-
 modules/hibernate/pom.xml                       |    2 +-
 .../CacheHibernateBlobStoreSelfTest.java        |    6 +-
 modules/indexing/pom.xml                        |    2 +-
 .../processors/query/h2/sql/GridSqlArray.java   |   52 +
 .../processors/query/h2/sql/GridSqlElement.java |    2 +-
 .../query/h2/sql/GridSqlFunction.java           |   60 +-
 .../query/h2/sql/GridSqlFunctionType.java       |    3 +
 .../query/h2/sql/GridSqlPlaceholder.java        |    7 +-
 .../query/h2/sql/GridSqlQueryParser.java        |   84 +-
 .../processors/query/h2/sql/GridSqlType.java    |   29 +-
 .../cache/CacheConfigurationP2PTest.java        |    3 +
 .../cache/SqlFieldsQuerySelfTest.java           |  172 +++
 .../query/h2/sql/GridQueryParsingTest.java      |   27 +
 .../IgniteCacheQuerySelfTestSuite.java          |    6 +-
 modules/jcl/pom.xml                             |    2 +-
 modules/jms11/pom.xml                           |    2 +-
 modules/jta/pom.xml                             |    2 +-
 modules/kafka/pom.xml                           |    2 +-
 modules/log4j/pom.xml                           |    2 +-
 modules/log4j2/pom.xml                          |    2 +-
 modules/mesos/pom.xml                           |    2 +-
 modules/mqtt/pom.xml                            |  114 ++
 .../apache/ignite/stream/mqtt/MqttStreamer.java |  611 ++++++++
 .../stream/mqtt/IgniteMqttStreamerTest.java     |  553 +++++++
 .../mqtt/IgniteMqttStreamerTestSuite.java       |   34 +
 modules/platform/pom.xml                        |    2 +-
 .../platform/src/main/cpp/common/configure.ac   |    2 +-
 .../main/cpp/common/project/vs/common.vcxproj   |    4 +-
 .../src/main/cpp/core-test/configure.ac         |    2 +-
 modules/platform/src/main/cpp/core/configure.ac |    2 +-
 .../Properties/AssemblyInfo.cs                  |    4 +-
 .../Apache.Ignite/Properties/AssemblyInfo.cs    |    4 +-
 .../Properties/AssemblyInfo.cs                  |    4 +-
 .../Properties/AssemblyInfo.cs                  |    4 +-
 modules/rest-http/pom.xml                       |    2 +-
 .../http/jetty/GridJettyJsonConfig.java         |  158 +-
 .../http/jetty/GridJettyRestHandler.java        |  186 +--
 modules/scalar-2.10/pom.xml                     |    2 +-
 modules/scalar/pom.xml                          |    2 +-
 modules/schedule/pom.xml                        |    2 +-
 modules/schema-import/pom.xml                   |    2 +-
 modules/slf4j/pom.xml                           |    2 +-
 modules/spark-2.10/pom.xml                      |    2 +-
 modules/spark/pom.xml                           |    2 +-
 modules/spring/pom.xml                          |    2 +-
 modules/ssh/pom.xml                             |    2 +-
 modules/tools/pom.xml                           |    2 +-
 modules/urideploy/pom.xml                       |    2 +-
 .../spi/deployment/uri/UriDeploymentSpi.java    |   93 +-
 .../scanners/http/UriDeploymentHttpScanner.java |   10 +-
 .../http/GridHttpDeploymentSelfTest.java        |  132 +-
 modules/visor-console-2.10/pom.xml              |    2 +-
 modules/visor-console/pom.xml                   |    2 +-
 .../visor/commands/kill/VisorKillCommand.scala  |    2 +-
 .../scala/org/apache/ignite/visor/visor.scala   |    1 -
 modules/visor-plugins/pom.xml                   |    2 +-
 modules/web/pom.xml                             |    2 +-
 .../config/benchmark-put-indexed-val.properties |    2 +-
 modules/yardstick/pom.xml                       |   12 +-
 modules/yarn/pom.xml                            |    2 +-
 modules/zookeeper/pom.xml                       |    2 +-
 pom.xml                                         |  116 +-
 356 files changed, 14454 insertions(+), 5328 deletions(-)
----------------------------------------------------------------------


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

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

http://git-wip-us.apache.org/repos/asf/ignite/blob/4f2b22bc/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFullApiSelfTestSuite.java
----------------------------------------------------------------------


[22/50] [abbrv] ignite git commit: IGNITE-1487: Exceptions on normal execution path avoided.

Posted by ag...@apache.org.
IGNITE-1487: Exceptions on normal execution path avoided.


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

Branch: refs/heads/ignite-1016
Commit: 541ba4037dbde7f93ec7951e57fca46ad1a9ec50
Parents: 52a733f
Author: iveselovskiy <iv...@gridgain.com>
Authored: Thu Oct 15 13:25:11 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Thu Oct 15 13:25:11 2015 +0300

----------------------------------------------------------------------
 .../hadoop/igfs/HadoopIgfsWrapper.java          | 54 +++++++++++---------
 1 file changed, 29 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/541ba403/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/igfs/HadoopIgfsWrapper.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/igfs/HadoopIgfsWrapper.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/igfs/HadoopIgfsWrapper.java
index 857db71..69df381 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/igfs/HadoopIgfsWrapper.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/igfs/HadoopIgfsWrapper.java
@@ -26,6 +26,10 @@ import org.apache.commons.logging.Log;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteFileSystem;
+import org.apache.ignite.IgniteIllegalStateException;
+import org.apache.ignite.IgniteState;
+import org.apache.ignite.Ignition;
 import org.apache.ignite.igfs.IgfsBlockLocation;
 import org.apache.ignite.igfs.IgfsFile;
 import org.apache.ignite.igfs.IgfsPath;
@@ -34,11 +38,11 @@ import org.apache.ignite.internal.processors.igfs.IgfsEx;
 import org.apache.ignite.internal.processors.igfs.IgfsHandshakeResponse;
 import org.apache.ignite.internal.processors.igfs.IgfsStatus;
 import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.internal.util.typedef.G;
 import org.apache.ignite.internal.util.typedef.internal.SB;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.jetbrains.annotations.Nullable;
 
+import static org.apache.ignite.IgniteState.STARTED;
 import static org.apache.ignite.internal.processors.hadoop.igfs.HadoopIgfsEndpoint.LOCALHOST;
 import static org.apache.ignite.internal.processors.hadoop.igfs.HadoopIgfsUtils.PARAM_IGFS_ENDPOINT_NO_EMBED;
 import static org.apache.ignite.internal.processors.hadoop.igfs.HadoopIgfsUtils.PARAM_IGFS_ENDPOINT_NO_LOCAL_SHMEM;
@@ -354,30 +358,7 @@ public class HadoopIgfsWrapper implements HadoopIgfs {
         boolean skipInProc = parameter(conf, PARAM_IGFS_ENDPOINT_NO_EMBED, authority, false);
 
         if (!skipInProc) {
-            IgfsEx igfs = null;
-
-            if (endpoint.grid() == null) {
-                try {
-                    Ignite ignite = G.ignite();
-
-                    igfs = (IgfsEx)ignite.fileSystem(endpoint.igfs());
-                }
-                catch (Exception ignore) {
-                    // No-op.
-                }
-            }
-            else {
-                for (Ignite ignite : G.allGrids()) {
-                    try {
-                        igfs = (IgfsEx)ignite.fileSystem(endpoint.igfs());
-
-                        break;
-                    }
-                    catch (Exception ignore) {
-                        // No-op.
-                    }
-                }
-            }
+            IgfsEx igfs = getIgfsEx(endpoint.grid(), endpoint.igfs());
 
             if (igfs != null) {
                 HadoopIgfsEx hadoop = null;
@@ -540,4 +521,27 @@ public class HadoopIgfsWrapper implements HadoopIgfs {
                 hadoop.close(force);
         }
     }
+
+    /**
+     * Helper method to find Igfs of the given name in the given Ignite instance.
+     *
+     * @param gridName The name of the grid to check.
+     * @param igfsName The name of Igfs.
+     * @return The file system instance, or null if not found.
+     */
+    private static IgfsEx getIgfsEx(@Nullable String gridName, @Nullable String igfsName) {
+        if (Ignition.state(gridName) == STARTED) {
+            try {
+                for (IgniteFileSystem fs : Ignition.ignite(gridName).fileSystems()) {
+                    if (F.eq(fs.name(), igfsName))
+                        return (IgfsEx)fs;
+                }
+            }
+            catch (IgniteIllegalStateException ignore) {
+                // May happen if the grid state has changed:
+            }
+        }
+
+        return null;
+    }
 }
\ No newline at end of file


[46/50] [abbrv] ignite git commit: Muted GridCacheAtomicOffHeapTieredMultiNodeFullApiSelfTest.testIgniteCacheIterator muted

Posted by ag...@apache.org.
Muted GridCacheAtomicOffHeapTieredMultiNodeFullApiSelfTest.testIgniteCacheIterator muted


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

Branch: refs/heads/ignite-1016
Commit: 9ffe402cf50c3b4260f132945b8d51e56f3926fd
Parents: 0acb5db
Author: ashutak <as...@gridgain.com>
Authored: Wed Oct 21 14:56:54 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Wed Oct 21 14:56:54 2015 +0300

----------------------------------------------------------------------
 .../GridCacheAtomicOffHeapTieredMultiNodeFullApiSelfTest.java | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/9ffe402c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicOffHeapTieredMultiNodeFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicOffHeapTieredMultiNodeFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicOffHeapTieredMultiNodeFullApiSelfTest.java
index 2ee9335..608729a 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicOffHeapTieredMultiNodeFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicOffHeapTieredMultiNodeFullApiSelfTest.java
@@ -30,4 +30,9 @@ public class GridCacheAtomicOffHeapTieredMultiNodeFullApiSelfTest extends
     @Override protected CacheMemoryMode memoryMode() {
         return OFFHEAP_TIERED;
     }
-}
\ No newline at end of file
+
+    /** {@inheritDoc} */
+    @Override public void testIgniteCacheIterator() throws Exception {
+        fail("https://issues.apache.org/jira/browse/IGNITE-1756");
+    }
+}


[34/50] [abbrv] ignite git commit: ignite-1698 SqlFieldsQuery works incorrectly in case of topology changes - Fixes #162.

Posted by ag...@apache.org.
ignite-1698 SqlFieldsQuery works incorrectly in case of topology changes - Fixes #162.

Signed-off-by: S.Vladykin <sv...@gridgain.com>


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

Branch: refs/heads/ignite-1016
Commit: 7d3621b6907ca4fadae6134593e6a67dd389ff54
Parents: 02b59e4
Author: agura <ag...@gridgain.com>
Authored: Sat Oct 17 18:22:55 2015 +0300
Committer: S.Vladykin <sv...@gridgain.com>
Committed: Sat Oct 17 18:22:55 2015 +0300

----------------------------------------------------------------------
 .../cache/SqlFieldsQuerySelfTest.java           | 166 +++++++++++++++++++
 1 file changed, 166 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/7d3621b6/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java
new file mode 100644
index 0000000..7b1c87c
--- /dev/null
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java
@@ -0,0 +1,166 @@
+/*
+ * 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.Serializable;
+import java.util.Collections;
+import java.util.List;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.query.QueryCursor;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.cache.query.annotations.QuerySqlField;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ *
+ */
+public class SqlFieldsQuerySelfTest extends GridCommonAbstractTest {
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        cfg.setLocalHost("127.0.0.1");
+
+        cfg.setPeerClassLoadingEnabled(true);
+
+        TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+        ipFinder.setAddresses(Collections.singletonList("127.0.0.1:47500..47509"));
+
+        TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
+        discoSpi.setIpFinder(ipFinder);
+
+        cfg.setDiscoverySpi(discoSpi);
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        stopAllGrids();
+    }
+
+    /**
+     * @throws Exception If error.
+     */
+    public void testSqlFieldsQuery() throws Exception {
+        startGrids(2);
+
+        createAndFillCache();
+
+        executeQuery();
+    }
+
+    /**
+     * @throws Exception If error.
+     */
+    public void testSqlFieldsQueryWithTopologyChanges() throws Exception {
+        startGrid(0);
+
+        createAndFillCache();
+
+        startGrid(1);
+
+        executeQuery();
+    }
+
+    /**
+     *
+     */
+    private void executeQuery() {
+        IgniteCache<?, ?> cache = grid(1).cache("person");
+
+        SqlFieldsQuery qry = new SqlFieldsQuery("select name, age from person where age > 10");
+
+        QueryCursor<List<?>> qryCursor = cache.query(qry);
+
+        assertEquals(2, qryCursor.getAll().size());
+    }
+
+
+    /**
+     *
+     */
+    private IgniteCache<Integer, Person> createAndFillCache() {
+        CacheConfiguration<Integer, Person> cacheConf = new CacheConfiguration<>();
+
+        cacheConf.setIndexedTypes(Integer.class, Person.class);
+
+        cacheConf.setName("person");
+
+        IgniteCache<Integer, Person> cache = grid(0).createCache(cacheConf);
+
+        cache.put(1, new Person("sun", 100));
+        cache.put(2, new Person("moon", 50));
+
+        return cache;
+    }
+
+    /**
+     *
+     */
+    public static class Person implements Serializable {
+        /** Name. */
+        @QuerySqlField
+        private String name;
+
+        /** Age. */
+        @QuerySqlField
+        private int age;
+
+        /**
+         * @param name Name.
+         * @param age Age.
+         */
+        public Person(String name, int age) {
+            this.name = name;
+            this.age = age;
+        }
+
+        /**
+         *
+         */
+        public String getName() {
+            return name;
+        }
+
+        /**
+         * @param name Name.
+         */
+        public void setName(String name) {
+            this.name = name;
+        }
+
+        /**
+         *
+         */
+        public int getAge() {
+            return age;
+        }
+
+        /**
+         * @param age Age.
+         */
+        public void setAge(int age) {
+            this.age = age;
+        }
+    }
+}


[16/50] [abbrv] ignite git commit: Merging fixes to master.

Posted by ag...@apache.org.
Merging fixes to master.


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

Branch: refs/heads/ignite-1016
Commit: 6844370dc16790423a59fb9e9f6ec39ca0699b9b
Parents: 075e7d0 30b731b
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Mon Oct 12 20:14:14 2015 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Mon Oct 12 20:14:14 2015 +0300

----------------------------------------------------------------------
 .../discovery/GridDiscoveryManager.java         | 479 +------------------
 .../processors/cache/GridCacheIoManager.java    |  29 +-
 .../processors/cache/GridCacheProcessor.java    |  63 +--
 .../dht/GridClientPartitionTopology.java        |  13 +-
 .../distributed/dht/GridDhtLocalPartition.java  |   3 +-
 .../dht/GridDhtPartitionTopologyImpl.java       |  12 +-
 .../GridDhtPartitionDemandMessage.java          |   4 +-
 .../GridDhtPartitionSupplyMessage.java          |   3 +-
 .../GridDhtPartitionsExchangeFuture.java        |  12 +-
 .../preloader/GridDhtPartitionsFullMessage.java |  12 +-
 .../GridDhtPartitionsSingleMessage.java         |  11 +-
 .../dht/preloader/GridDhtPreloader.java         |  18 +-
 .../cache/query/GridCacheQueryManager.java      |  41 --
 .../processors/rest/GridRestProcessor.java      |  47 --
 .../top/GridTopologyCommandHandler.java         | 129 -----
 .../communication/tcp/TcpCommunicationSpi.java  |  22 +-
 .../IgniteCacheConfigurationTemplateTest.java   |  31 ++
 .../dht/GridCacheDhtPreloadPerformanceTest.java | 133 +++++
 .../near/GridCacheNearTxForceKeyTest.java       |   2 +-
 19 files changed, 270 insertions(+), 794 deletions(-)
----------------------------------------------------------------------



[17/50] [abbrv] ignite git commit: IGNITE-1590: Reworked create and append operations to match overall design.

Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/962fcce3/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java
index cc89fd1..b290303 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java
@@ -63,7 +63,6 @@ import org.apache.ignite.igfs.IgfsPathNotFoundException;
 import org.apache.ignite.igfs.secondary.IgfsSecondaryFileSystem;
 import org.apache.ignite.internal.IgniteEx;
 import org.apache.ignite.internal.IgniteInternalFuture;
-import org.apache.ignite.internal.IgniteInterruptedCheckedException;
 import org.apache.ignite.internal.IgniteKernal;
 import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
 import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
@@ -102,10 +101,10 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
     protected static final long BLOCK_SIZE = 32 * 1024 * 1024;
 
     /** Default repeat count. */
-    protected static final int REPEAT_CNT = 10;
+    protected static final int REPEAT_CNT = 5; // Diagnostic: up to 500; Regression: 5
 
     /** Concurrent operations count. */
-    protected static final int OPS_CNT = 32;
+    protected static final int OPS_CNT = 16;
 
     /** Renames count. */
     protected static final int RENAME_CNT = OPS_CNT;
@@ -122,6 +121,9 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
     /** Create count. */
     protected static final int CREATE_CNT = OPS_CNT;
 
+    /** Time to wait until the caches get empty after format. */
+    private static final long CACHE_EMPTY_TIMEOUT = 30_000L;
+
     /** Seed to generate random numbers. */
     protected static final long SEED = System.currentTimeMillis();
 
@@ -761,6 +763,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
 
         create(igfs, null, new IgfsPath[] { new IgfsPath("/d/f") }); // "f" is a file.
         checkExist(igfs, igfsSecondary, new IgfsPath("/d/f"));
+        assertTrue(igfs.info(new IgfsPath("/d/f")).isFile());
 
         try {
             igfs.mkdirs(new IgfsPath("/d/f"), null);
@@ -770,6 +773,11 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
         catch (IgfsParentNotDirectoryException ignore) {
             // No-op.
         }
+        catch (IgfsException ignore) {
+            // Currently Ok for Hadoop fs:
+            if (!getClass().getSimpleName().startsWith("Hadoop"))
+                throw ignore;
+        }
 
         try {
             igfs.mkdirs(new IgfsPath("/d/f/something/else"), null);
@@ -779,6 +787,11 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
         catch (IgfsParentNotDirectoryException ignore) {
             // No-op.
         }
+        catch (IgfsException ignore) {
+            // Currently Ok for Hadoop fs:
+            if (!getClass().getSimpleName().startsWith("Hadoop"))
+                throw ignore;
+        }
 
         create(igfs, paths(DIR, SUBDIR), null);
 
@@ -1026,8 +1039,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
 
                 try {
                     is = igfs.open(FILE);
-                }
-                finally {
+                } finally {
                     U.closeQuiet(is);
                 }
 
@@ -1041,12 +1053,84 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
      *
      * @throws Exception If failed.
      */
+    @SuppressWarnings({"ConstantConditions", "EmptyTryBlock", "UnusedDeclaration"})
     public void testCreate() throws Exception {
         create(igfs, paths(DIR, SUBDIR), null);
 
         createFile(igfs.asSecondary(), FILE, true, chunk);
 
         checkFile(igfs, igfsSecondary, FILE, chunk);
+
+        try (IgfsOutputStream os = igfs.create(new IgfsPath("/r"), false)) {
+            checkExist(igfs, igfsSecondary, new IgfsPath("/r"));
+            assert igfs.info(new IgfsPath("/r")).isFile();
+        }
+
+        try (IgfsOutputStream os = igfs.create(new IgfsPath("/k/l"), false)) {
+            checkExist(igfs, igfsSecondary, new IgfsPath("/k/l"));
+            assert igfs.info(new IgfsPath("/k/l")).isFile();
+        }
+
+        try {
+            try (IgfsOutputStream os = igfs.create(new IgfsPath("/k/l"), false)) {}
+
+            fail("Exception expected");
+        } catch (IgniteException e) {
+            // okay
+        }
+
+        checkExist(igfs, igfsSecondary, new IgfsPath("/k/l"));
+        assert igfs.info(new IgfsPath("/k/l")).isFile();
+
+        try {
+            try (IgfsOutputStream os = igfs.create(new IgfsPath("/k/l/m"), true)) {}
+
+            fail("Exception expected");
+        } catch (IgniteException e) {
+            // okay
+        }
+        checkNotExist(igfs, igfsSecondary, new IgfsPath("/k/l/m"));
+        checkExist(igfs, igfsSecondary, new IgfsPath("/k/l"));
+        assert igfs.info(new IgfsPath("/k/l")).isFile();
+
+        try {
+            try (IgfsOutputStream os = igfs.create(new IgfsPath("/k/l/m/n/o/p"), true)) {}
+
+            fail("Exception expected");
+        } catch (IgniteException e) {
+            // okay
+        }
+        checkNotExist(igfs, igfsSecondary, new IgfsPath("/k/l/m"));
+        checkExist(igfs, igfsSecondary, new IgfsPath("/k/l"));
+        assert igfs.info(new IgfsPath("/k/l")).isFile();
+
+        igfs.mkdirs(new IgfsPath("/x/y"), null);
+        try {
+            try (IgfsOutputStream os = igfs.create(new IgfsPath("/x/y"), true)) {}
+
+            fail("Exception expected");
+        } catch (IgniteException e) {
+            // okay
+        }
+
+        checkExist(igfs, igfsSecondary, new IgfsPath("/x/y"));
+        assert igfs.info(new IgfsPath("/x/y")).isDirectory();
+
+        try (IgfsOutputStream os = igfs.create(new IgfsPath("/x/y/f"), false)) {
+            assert igfs.info(new IgfsPath("/x/y/f")).isFile();
+        }
+
+        try (IgfsOutputStream os = igfs.create(new IgfsPath("/x/y/z/f"), false)) {
+            assert igfs.info(new IgfsPath("/x/y/z/f")).isFile();
+        }
+
+        try (IgfsOutputStream os = igfs.create(new IgfsPath("/x/y/z/t/f"), false)) {
+            assert igfs.info(new IgfsPath("/x/y/z/t/f")).isFile();
+        }
+
+        try (IgfsOutputStream os = igfs.create(new IgfsPath("/x/y/z/t/t2/t3/t4/t5/f"), false)) {
+            assert igfs.info(new IgfsPath("/x/y/z/t/t2/t3/t4/t5/f")).isFile();
+        }
     }
 
     /**
@@ -1078,8 +1162,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
                 try {
                     os1 = igfs.create(FILE, true);
                     os2 = igfs.create(FILE, true);
-                }
-                finally {
+                } finally {
                     U.closeQuiet(os1);
                     U.closeQuiet(os2);
                 }
@@ -1141,26 +1224,47 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
     public void testCreateDeleteNoClose() throws Exception {
         create(igfs, paths(DIR, SUBDIR), null);
 
-        GridTestUtils.assertThrows(log, new Callable<Object>() {
-            @Override public Object call() throws Exception {
-                IgfsOutputStream os = null;
+        IgfsOutputStream os = null;
 
-                try {
-                    os = igfs.create(FILE, true);
+        IgniteUuid id = null;
+
+        try {
+            os = igfs.create(FILE, false);
+
+            id = igfs.context().meta().fileId(FILE);
+
+            assert id != null;
+
+            boolean del = igfs.delete(FILE, false);
+
+            assertTrue(del);
+            assertFalse(igfs.exists(FILE));
+            // The id still exists in meta cache since
+            // it is locked for writing and just moved to TRASH.
+            // Delete worker cannot delete it for that reason:
+            assertTrue(igfs.context().meta().exists(id));
+
+            os.write(chunk);
 
-                    igfs.format();
+            os.close();
+        }
+        finally {
+            U.closeQuiet(os);
+        }
 
-                    os.write(chunk);
+        final IgniteUuid id0 = id;
 
-                    os.close();
+        // Delete worker should delete the file once its output stream is finally closed:
+        GridTestUtils.waitForCondition(new GridAbsPredicate() {
+            @Override public boolean apply() {
+                try {
+                    return !igfs.context().meta().exists(id0);
                 }
-                finally {
-                    U.closeQuiet(os);
+                catch (IgniteCheckedException ice) {
+                    throw new IgniteException(ice);
                 }
-
-                return null;
             }
-        }, IOException.class, "File was concurrently deleted: " + FILE);
+        }, 5_000L);
     }
 
     /**
@@ -1171,29 +1275,47 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
     public void testCreateDeleteParentNoClose() throws Exception {
         create(igfs, paths(DIR, SUBDIR), null);
 
-        GridTestUtils.assertThrows(log, new Callable<Object>() {
-            @Override public Object call() throws Exception {
-                IgfsOutputStream os = null;
+        IgfsOutputStream os = null;
 
-                try {
-                    os = igfs.create(FILE, true);
+        IgniteUuid id = null;
+
+        try {
+            os = igfs.create(FILE, false);
+
+            id = igfs.context().meta().fileId(FILE);
 
-                    IgniteUuid id = igfs.context().meta().fileId(FILE);
+            assert id != null;
 
-                    igfs.delete(SUBDIR, true); // Since GG-4911 we allow deletes in this case.
+            boolean del = igfs.delete(SUBDIR, true);
 
-                    while (igfs.context().meta().exists(id))
-                        U.sleep(100);
+            assertTrue(del);
+            assertFalse(igfs.exists(FILE));
+            // The id still exists in meta cache since
+            // it is locked for writing and just moved to TRASH.
+            // Delete worker cannot delete it for that reason:
+            assertTrue(igfs.context().meta().exists(id));
 
-                    os.close();
+            os.write(chunk);
+
+            os.close();
+        }
+        finally {
+            U.closeQuiet(os);
+        }
+
+        final IgniteUuid id0 = id;
+
+        // Delete worker should delete the file once its output stream is finally closed:
+        GridTestUtils.waitForCondition(new GridAbsPredicate() {
+            @Override public boolean apply() {
+                try {
+                    return !igfs.context().meta().exists(id0);
                 }
-                finally {
-                    U.closeQuiet(os);
+                catch (IgniteCheckedException ice) {
+                    throw new IgniteException(ice);
                 }
-
-                return null;
             }
-        }, IOException.class, "File was concurrently deleted: " + FILE);
+        }, 5_000L);
     }
 
     /**
@@ -1221,6 +1343,41 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
     }
 
     /**
+     * Checks simple write.
+     *
+     * @throws Exception On error.
+     */
+    public void testSimpleWrite() throws Exception {
+        IgfsPath path = new IgfsPath("/file1");
+
+        IgfsOutputStream os = igfs.create(path, 128, true/*overwrite*/, null, 0, 256, null);
+
+        os.write(chunk);
+
+        os.close();
+
+        assert igfs.exists(path);
+        checkFileContent(igfs, path, chunk);
+
+        os = igfs.create(path, 128, true/*overwrite*/, null, 0, 256, null);
+
+        assert igfs.exists(path);
+
+        os.write(chunk);
+
+        assert igfs.exists(path);
+
+        os.write(chunk);
+
+        assert igfs.exists(path);
+
+        os.close();
+
+        assert igfs.exists(path);
+        checkFileContent(igfs, path, chunk, chunk);
+    }
+
+    /**
      * Ensure consistency of data during file creation.
      *
      * @throws Exception If failed.
@@ -1229,17 +1386,17 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
         final AtomicInteger ctr = new AtomicInteger();
         final AtomicReference<Exception> err = new AtomicReference<>();
 
-        int threadCnt = 10;
+        final int threadCnt = 10;
 
         multithreaded(new Runnable() {
             @Override public void run() {
                 int idx = ctr.incrementAndGet();
 
-                IgfsPath path = new IgfsPath("/file" + idx);
+                final IgfsPath path = new IgfsPath("/file" + idx);
 
                 try {
                     for (int i = 0; i < REPEAT_CNT; i++) {
-                        IgfsOutputStream os = igfs.create(path, 128, true, null, 0, 256, null);
+                        IgfsOutputStream os = igfs.create(path, 128, true/*overwrite*/, null, 0, 256, null);
 
                         os.write(chunk);
 
@@ -1275,11 +1432,11 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
 
         igfs.create(FILE, false).close();
 
-        int threadCnt = 5;
+        int threadCnt = 50;
 
         IgniteInternalFuture<?> fut = multithreadedAsync(new Runnable() {
             @Override public void run() {
-                while (!stop.get()) {
+                while (!stop.get() && err.get() == null) {
                     IgfsOutputStream os = null;
 
                     try {
@@ -1287,27 +1444,43 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
 
                         os.write(chunk);
 
-                        U.sleep(50);
-
                         os.close();
 
                         createCtr.incrementAndGet();
                     }
-                    catch (IgniteInterruptedCheckedException | IgniteException ignore) {
-                        try {
-                            U.sleep(10);
-                        }
-                        catch (IgniteInterruptedCheckedException ignored) {
-                            // nO-op.
+                    catch (IgniteException e) {
+                        Throwable[] chain = X.getThrowables(e);
+
+                        Throwable cause = chain[chain.length - 1];
+
+                        if (!e.getMessage().startsWith("Failed to overwrite file (file is opened for writing)")
+                                && (cause == null
+                                    || !cause.getMessage().startsWith("Failed to overwrite file (file is opened for writing)"))) {
+
+                            System.out.println("Failed due to IgniteException exception. Cause:");
+                            cause.printStackTrace(System.out);
+
+                            err.compareAndSet(null, e);
                         }
                     }
                     catch (IOException e) {
-                        // We can ignore concurrent deletion exception since we override the file.
-                        if (!e.getMessage().startsWith("File was concurrently deleted"))
-                            err.compareAndSet(null, e);
+                        err.compareAndSet(null, e);
+
+                        Throwable[] chain = X.getThrowables(e);
+
+                        Throwable cause = chain[chain.length - 1];
+
+                        System.out.println("Failed due to IOException exception. Cause:");
+                        cause.printStackTrace(System.out);
                     }
                     finally {
-                        U.closeQuiet(os);
+                        if (os != null)
+                            try {
+                                os.close();
+                            }
+                            catch (IOException ioe) {
+                                throw new IgniteException(ioe);
+                            }
                     }
                 }
             }
@@ -1315,7 +1488,9 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
 
         long startTime = U.currentTimeMillis();
 
-        while (createCtr.get() < 50 && U.currentTimeMillis() - startTime < 60 * 1000)
+        while (err.get() == null
+                && createCtr.get() < 500
+                && U.currentTimeMillis() - startTime < 60 * 1000)
             U.sleep(100);
 
         stop.set(true);
@@ -1324,8 +1499,11 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
 
         awaitFileClose(igfs.asSecondary(), FILE);
 
-        if (err.get() != null)
+        if (err.get() != null) {
+            X.println("Test failed: rethrowing first error: " + err.get());
+
             throw err.get();
+        }
 
         checkFileContent(igfs, FILE, chunk);
     }
@@ -1336,13 +1514,131 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
      * @throws Exception If failed.
      */
     public void testAppend() throws Exception {
+        if (dual)
+            fail("Test fails in DUAL modes, see https://issues.apache.org/jira/browse/IGNITE-1631");
+
         create(igfs, paths(DIR, SUBDIR), null);
 
+        assert igfs.exists(SUBDIR);
+
         createFile(igfs, FILE, true, BLOCK_SIZE, chunk);
 
+        checkFile(igfs, igfsSecondary, FILE, chunk);
+
         appendFile(igfs, FILE, chunk);
 
         checkFile(igfs, igfsSecondary, FILE, chunk, chunk);
+
+        // Test create via append:
+        IgfsPath path2 = FILE2;
+
+        IgfsOutputStream os = null;
+
+        try {
+            os = igfs.append(path2, true/*create*/);
+
+            writeFileChunks(os, chunk);
+        }
+        finally {
+            U.closeQuiet(os);
+
+            awaitFileClose(igfs.asSecondary(), path2);
+        }
+
+        try {
+            os = igfs.append(path2, false/*create*/);
+
+            writeFileChunks(os, chunk);
+        }
+        finally {
+            U.closeQuiet(os);
+
+            awaitFileClose(igfs.asSecondary(), path2);
+        }
+
+        checkFile(igfs, igfsSecondary, path2, chunk, chunk);
+
+        // Negative append (create == false):
+        try {
+            try (IgfsOutputStream os0 = igfs.append(new IgfsPath("/should-not-be-created"), false)) {}
+
+            fail("Exception expected");
+        } catch (IgniteException e) {
+            // okay
+        }
+        checkNotExist(igfs, igfsSecondary, new IgfsPath("/d1"));
+
+        // Positive mkdirs via append:
+        try (IgfsOutputStream os0 = igfs.append(new IgfsPath("/k/l"), true)) {
+            checkExist(igfs, igfsSecondary, new IgfsPath("/k/l"));
+            assert igfs.info(new IgfsPath("/k/l")).isFile();
+        }
+
+        // Negative append (file is immediate parent):
+        try {
+            try (IgfsOutputStream os0 = igfs.append(new IgfsPath("/k/l/m"), true)) {}
+
+            fail("Exception expected");
+        } catch (IgniteException e) {
+            // okay
+        }
+        checkNotExist(igfs, igfsSecondary, new IgfsPath("/k/l/m"));
+        checkExist(igfs, igfsSecondary, new IgfsPath("/k/l"));
+        assert igfs.info(new IgfsPath("/k/l")).isFile();
+
+        // Negative append (file is in the parent chain):
+        try {
+            try (IgfsOutputStream os0 = igfs.append(new IgfsPath("/k/l/m/n/o/p"), true)) {}
+
+            fail("Exception expected");
+        } catch (IgniteException e) {
+            // okay
+        }
+        checkNotExist(igfs, igfsSecondary, new IgfsPath("/k/l/m"));
+        checkExist(igfs, igfsSecondary, new IgfsPath("/k/l"));
+        assert igfs.info(new IgfsPath("/k/l")).isFile();
+
+        // Negative append (target is a directory):
+        igfs.mkdirs(new IgfsPath("/x/y"), null);
+        checkExist(igfs, igfsSecondary, new IgfsPath("/x/y"));
+        assert igfs.info(new IgfsPath("/x/y")).isDirectory();
+        try {
+            try (IgfsOutputStream os0 = igfs.append(new IgfsPath("/x/y"), true)) {}
+
+            fail("Exception expected");
+        } catch (IgniteException e) {
+            // okay
+        }
+
+        // Positive append with create
+        try (IgfsOutputStream os0 = igfs.append(new IgfsPath("/x/y/f"), true)) {
+            assert igfs.info(new IgfsPath("/x/y/f")).isFile();
+        }
+
+        // Positive append with create & 1 mkdirs:
+        try (IgfsOutputStream os0 = igfs.append(new IgfsPath("/x/y/z/f"), true)) {
+            assert igfs.info(new IgfsPath("/x/y/z/f")).isFile();
+        }
+
+        // Positive append with create & 2 mkdirs:
+        try (IgfsOutputStream os0 = igfs.append(new IgfsPath("/x/y/z/t/f"), true)) {
+            assert igfs.info(new IgfsPath("/x/y/z/t/f")).isFile();
+        }
+
+        // Positive mkdirs create & many mkdirs:
+        try (IgfsOutputStream os0 = igfs.append(new IgfsPath("/x/y/z/t/t2/t3/t4/t5/f"), true)) {
+            assert igfs.info(new IgfsPath("/x/y/z/t/t2/t3/t4/t5/f")).isFile();
+        }
+
+        // Negative mkdirs via append (create == false):
+        try {
+            try (IgfsOutputStream os0 = igfs.append(new IgfsPath("/d1/d2/d3/f"), false)) {}
+
+            fail("Exception expected");
+        } catch (IgniteException e) {
+            // okay
+        }
+        checkNotExist(igfs, igfsSecondary, new IgfsPath("/d1"));
     }
 
     /**
@@ -1447,26 +1743,44 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
 
         createFile(igfs.asSecondary(), FILE, false);
 
-        GridTestUtils.assertThrows(log, new Callable<Object>() {
-            @Override public Object call() throws Exception {
-                IgfsOutputStream os = null;
+        IgfsOutputStream os = null;
+        IgniteUuid id = null;
 
-                try {
-                    os = igfs.append(FILE, false);
+        try {
+            id = igfs.context().meta().fileId(FILE);
 
-                    igfs.format();
+            os = igfs.append(FILE, false);
 
-                    os.write(chunk);
+            boolean del = igfs.delete(FILE, false);
 
-                    os.close();
-                }
-                finally {
-                    U.closeQuiet(os);
-                }
+            assertTrue(del);
+            assertFalse(igfs.exists(FILE));
+            assertTrue(igfs.context().meta().exists(id)); // id still exists in meta cache since
+            // it is locked for writing and just moved to TRASH.
+            // Delete worker cannot delete it for that reason.
 
-                return null;
+            os.write(chunk);
+
+            os.close();
+        }
+        finally {
+            U.closeQuiet(os);
+        }
+
+        assert id != null;
+
+        final IgniteUuid id0 = id;
+
+        // Delete worker should delete the file once its output stream is finally closed:
+        GridTestUtils.waitForCondition(new GridAbsPredicate() {
+            @Override public boolean apply() {
+                try {
+                    return !igfs.context().meta().exists(id0);
+                } catch (IgniteCheckedException ice) {
+                    throw new IgniteException(ice);
+                }
             }
-        }, IOException.class, "File was concurrently deleted: " + FILE);
+        }, 5_000L);
     }
 
     /**
@@ -1479,31 +1793,44 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
 
         createFile(igfs.asSecondary(), FILE, false);
 
-        GridTestUtils.assertThrows(log, new Callable<Object>() {
-            @Override public Object call() throws Exception {
-                IgfsOutputStream os = null;
+        IgfsOutputStream os = null;
+        IgniteUuid id = null;
 
-                try {
-                    IgniteUuid id = igfs.context().meta().fileId(FILE);
+        try {
+            id = igfs.context().meta().fileId(FILE);
 
-                    os = igfs.append(FILE, false);
+            os = igfs.append(FILE, false);
 
-                    igfs.delete(SUBDIR, true); // Since GG-4911 we allow deletes in this case.
+            boolean del = igfs.delete(SUBDIR, true); // Since GG-4911 we allow deletes in this case.
 
-                    for (int i = 0; i < 100 && igfs.context().meta().exists(id); i++)
-                        U.sleep(100);
+            assertTrue(del);
+            assertFalse(igfs.exists(FILE));
+            assertTrue(igfs.context().meta().exists(id)); // id still exists in meta cache since
+            // it is locked for writing and just moved to TRASH.
+            // Delete worker cannot delete it for that reason.
 
-                    os.write(chunk);
+            os.write(chunk);
 
-                    os.close();
-                }
-                finally {
-                    U.closeQuiet(os);
-                }
+            os.close();
+        }
+        finally {
+            U.closeQuiet(os);
+        }
 
-                return null;
+        assert id != null;
+
+        final IgniteUuid id0 = id;
+
+        // Delete worker should delete the file once its output stream is finally closed:
+        GridTestUtils.waitForCondition(new GridAbsPredicate() {
+            @Override public boolean apply() {
+                try {
+                    return !igfs.context().meta().exists(id0);
+                } catch (IgniteCheckedException ice) {
+                    throw new IgniteException(ice);
+                }
             }
-        }, IOException.class, "File was concurrently deleted: " + FILE);
+        }, 5_000L);
     }
 
     /**
@@ -1594,11 +1921,11 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
 
         igfs.create(FILE, false).close();
 
-        int threadCnt = 5;
+        int threadCnt = 50;
 
         IgniteInternalFuture<?> fut = multithreadedAsync(new Runnable() {
             @Override public void run() {
-                while (!stop.get()) {
+                while (!stop.get() && err.get() == null) {
                     IgfsOutputStream os = null;
 
                     try {
@@ -1606,25 +1933,31 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
 
                         os.write(chunk);
 
-                        U.sleep(50);
-
                         os.close();
 
                         chunksCtr.incrementAndGet();
                     }
-                    catch (IgniteInterruptedCheckedException | IgniteException ignore) {
-                        try {
-                            U.sleep(10);
-                        }
-                        catch (IgniteInterruptedCheckedException ignored) {
-                            // nO-op.
-                        }
+                    catch (IgniteException e) {
+                        Throwable[] chain = X.getThrowables(e);
+
+                        Throwable cause = chain[chain.length - 1];
+
+                        if (!e.getMessage().startsWith("Failed to open file (file is opened for writing)")
+                                && (cause == null
+                                || !cause.getMessage().startsWith("Failed to open file (file is opened for writing)")))
+                            err.compareAndSet(null, e);
                     }
                     catch (IOException e) {
                         err.compareAndSet(null, e);
                     }
                     finally {
-                        U.closeQuiet(os);
+                        if (os != null)
+                            try {
+                                os.close();
+                            }
+                            catch (IOException ioe) {
+                                throw new IgniteException(ioe);
+                            }
                     }
                 }
             }
@@ -1632,7 +1965,8 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
 
         long startTime = U.currentTimeMillis();
 
-        while (chunksCtr.get() < 50 && U.currentTimeMillis() - startTime < 60 * 1000)
+        while (err.get() == null
+                && chunksCtr.get() < 50 && U.currentTimeMillis() - startTime < 60 * 1000)
             U.sleep(100);
 
         stop.set(true);
@@ -1641,8 +1975,11 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
 
         awaitFileClose(igfs.asSecondary(), FILE);
 
-        if (err.get() != null)
+        if (err.get() != null) {
+            X.println("Test failed: rethrowing first error: " + err.get());
+
             throw err.get();
+        }
 
         byte[][] data = new byte[chunksCtr.get()][];
 
@@ -2019,8 +2356,6 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
      * @throws Exception If failed.
      */
     public void testDeadlocksCreate() throws Exception {
-        assert false : "https://issues.apache.org/jira/browse/IGNITE-1590";
-
         checkDeadlocksRepeat(5, 2, 2, 2, 0, 0, 0, 0, CREATE_CNT);
     }
 
@@ -2030,8 +2365,6 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
      * @throws Exception If failed.
      */
     public void testDeadlocks() throws Exception {
-        assert false : "https://issues.apache.org/jira/browse/IGNITE-1590";
-
         checkDeadlocksRepeat(5, 2, 2, 2,  RENAME_CNT, DELETE_CNT, UPDATE_CNT, MKDIRS_CNT, CREATE_CNT);
     }
 
@@ -2057,6 +2390,9 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
             try {
                 checkDeadlocks(lvlCnt, childrenDirPerLvl, childrenFilePerLvl, primaryLvlCnt, renCnt, delCnt,
                     updateCnt, mkdirsCnt, createCnt);
+
+                if (i % 10 == 0)
+                    X.println(" - " + i);
             }
             finally {
                 clear(igfs, igfsSecondary);
@@ -2679,7 +3015,8 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
 
                     read = is.read(buf);
 
-                    assert read == chunk.length : "Chunk #" + chunkIdx + " was not read fully.";
+                    assert read == chunk.length : "Chunk #" + chunkIdx + " was not read fully:" +
+                            " read=" + read + ", expected=" + chunk.length;
                     assert Arrays.equals(chunk, buf) : "Bad chunk [igfs=" + uni.name() + ", chunkIdx=" + chunkIdx +
                         ", expected=" + Arrays.toString(chunk) + ", actual=" + Arrays.toString(buf) + ']';
 
@@ -2800,19 +3137,57 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
         // Clear igfs.
         igfs.format();
 
-        final IgniteFileSystem igfs0 = igfs;
+        int prevDifferentSize = Integer.MAX_VALUE; // Previous different size.
+        int size;
+        int constCnt = 0, totalCnt = 0;
+        final int constThreshold = 20;
+        final long sleepPeriod = 500L;
+        final long totalThreshold = CACHE_EMPTY_TIMEOUT / sleepPeriod;
 
-        if (!GridTestUtils.waitForCondition(new GridAbsPredicate() {
-            @Override public boolean apply() {
-                return isEmpty(igfs0);
+        while (true) {
+            size = sumCacheSize(igfs);
+
+            if (size <= 2)
+                return; // Caches are cleared, we're done. (2 because ROOT & TRASH always exist).
+
+            X.println("Sum size: " + size);
+
+            if (size > prevDifferentSize) {
+                X.println("Summary cache size has grown unexpectedly: size=" + size + ", prevSize=" + prevDifferentSize);
+
+                break;
             }
-        }, 10_000L)) {
-            dumpCache("MetaCache" , getMetaCache(igfs));
 
-            dumpCache("DataCache" , getDataCache(igfs));
+            if (totalCnt > totalThreshold) {
+                X.println("Timeout exceeded.");
 
-            assert false;
+                break;
+            }
+
+            if (size == prevDifferentSize) {
+                constCnt++;
+
+                if (constCnt == constThreshold) {
+                    X.println("Summary cache size stays unchanged for too long: size=" + size);
+
+                    break;
+                }
+            } else {
+                constCnt = 0;
+
+                prevDifferentSize = size; // renew;
+            }
+
+            Thread.sleep(sleepPeriod);
+
+            totalCnt++;
         }
+
+        dumpCache("MetaCache" , getMetaCache(igfs));
+
+        dumpCache("DataCache" , getDataCache(igfs));
+
+        fail("Caches are not empty.");
     }
 
     /**
@@ -2831,37 +3206,12 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
     }
 
     /**
-     * Answers if the given IGFS is empty.
-     *
-     * @param igfs IGFS to operate on.
-     * @return True if IGFS is empty.
+     * Gets summary IGFS cache size.
+     * @param igfs The IGFS to measure.
+     * @return data cache size + meta cache size.
      */
-    private static boolean isEmpty(IgniteFileSystem igfs) {
-        GridCacheAdapter dataCache = getDataCache(igfs);
-
-        assert dataCache != null;
-
-        int size1 = dataCache.size();
-
-        if (size1 > 0) {
-            X.println("Data cache size = " + size1);
-
-            return false;
-        }
-
-        GridCacheAdapter metaCache = getMetaCache(igfs);
-
-        assert metaCache != null;
-
-        int size2 = metaCache.size();
-
-        if (size2 > 2) {
-            X.println("Meta cache size = " + size2);
-
-            return false;
-        }
-
-        return true;
+    private static int sumCacheSize(IgniteFileSystem igfs) {
+        return getMetaCache(igfs).size() + getDataCache(igfs).size();
     }
 
     /**
@@ -2880,4 +3230,9 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
         // Clear the filesystem.
         uni.format();
     }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        clear(igfs, igfsSecondary);
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/962fcce3/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDataManagerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDataManagerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDataManagerSelfTest.java
index 6266ab4..84462fd 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDataManagerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDataManagerSelfTest.java
@@ -165,7 +165,9 @@ public class IgfsDataManagerSelfTest extends IgfsCommonAbstractTest {
     public void testDataStoring() throws Exception {
         for (int i = 0; i < 10; i++) {
             IgfsPath path = new IgfsPath();
-            IgfsFileInfo info = new IgfsFileInfo(200, null, false, null);
+
+            IgfsFileInfo info = new IgfsFileInfo(200, 0L, null, IgfsMetaManager.DELETE_LOCK_ID,
+                    false, null);
 
             assertNull(mgr.dataBlock(info, path, 0, null).get());
 
@@ -246,7 +248,9 @@ public class IgfsDataManagerSelfTest extends IgfsCommonAbstractTest {
 
         for (int i = 0; i < 10; i++) {
             IgfsPath path = new IgfsPath();
-            IgfsFileInfo info = new IgfsFileInfo(blockSize, null, false, null);
+
+            IgfsFileInfo info = new IgfsFileInfo(blockSize, 0L, null, IgfsMetaManager.DELETE_LOCK_ID,
+                false, null);
 
             assertNull(mgr.dataBlock(info, path, 0, null).get());
 
@@ -333,7 +337,10 @@ public class IgfsDataManagerSelfTest extends IgfsCommonAbstractTest {
 
         for (int i = 0; i < 10; i++) {
             IgfsPath path = new IgfsPath();
-            IgfsFileInfo info = new IgfsFileInfo(blockSize, null, false, null);
+
+            IgfsFileInfo info =
+                new IgfsFileInfo(blockSize, 0L, null, IgfsMetaManager.DELETE_LOCK_ID,
+                    false, null);
 
             IgfsFileAffinityRange range = new IgfsFileAffinityRange();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/962fcce3/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java
index 4072636..df519ed 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java
@@ -26,7 +26,6 @@ import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.FileSystemConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.igfs.IgfsDirectoryNotEmptyException;
 import org.apache.ignite.igfs.IgfsException;
 import org.apache.ignite.igfs.IgfsGroupDataBlocksKeyMapper;
 import org.apache.ignite.igfs.IgfsPath;
@@ -46,7 +45,6 @@ import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
 import static org.apache.ignite.internal.processors.igfs.IgfsFileInfo.ROOT_ID;
 import static org.apache.ignite.testframework.GridTestUtils.assertThrows;
 import static org.apache.ignite.testframework.GridTestUtils.assertThrowsInherited;
-import static org.apache.ignite.testframework.GridTestUtils.getFieldValue;
 
 /**
  * {@link IgfsMetaManager} test case.
@@ -143,17 +141,20 @@ public class IgfsMetaManagerSelfTest extends IgfsCommonAbstractTest {
     public void testUpdateProperties() throws Exception {
         assertEmpty(mgr.directoryListing(ROOT_ID));
 
-        IgfsFileInfo dir = new IgfsFileInfo(true, null);
-        IgfsFileInfo file = new IgfsFileInfo(new IgfsFileInfo(400, null, false, null), 1);
+        assertTrue(mgr.mkdirs(new IgfsPath("/dir"), IgfsImpl.DFLT_DIR_META));
+        assertNotNull(mgr.create(new IgfsPath("/file"), false, false, null, 400, null, false, null));
 
-        assertNull(mgr.putIfAbsent(ROOT_ID, "dir", dir));
-        assertNull(mgr.putIfAbsent(ROOT_ID, "file", file));
+        IgfsListingEntry dirEntry = mgr.directoryListing(ROOT_ID).get("dir");
+        assertNotNull(dirEntry);
+        assertTrue(dirEntry.isDirectory());
+        IgfsFileInfo dir = mgr.info(dirEntry.fileId());
 
-        assertEquals(F.asMap("dir", new IgfsListingEntry(dir), "file", new IgfsListingEntry(file)),
-            mgr.directoryListing(ROOT_ID));
+        IgfsListingEntry fileEntry = mgr.directoryListing(ROOT_ID).get("file");
+        assertNotNull(fileEntry);
+        assertTrue(!fileEntry.isDirectory());
+        IgfsFileInfo file = mgr.info(fileEntry.fileId());
 
-        assertEquals(dir, mgr.info(dir.id()));
-        assertEquals(file, mgr.info(file.id()));
+        assertEquals(2, mgr.directoryListing(ROOT_ID).size());
 
         for (IgniteBiTuple<IgniteUuid, String> tup: Arrays.asList(F.t(dir.id(), "dir"), F.t(file.id(), "file"))) {
             IgniteUuid fileId = tup.get1();
@@ -167,38 +168,63 @@ public class IgfsMetaManagerSelfTest extends IgfsCommonAbstractTest {
 
             IgfsFileInfo info = mgr.info(fileId);
 
-            assertNull("Expects empty properties are not stored: " + info, getFieldValue(info, "props"));
-            assertEquals("Expects empty properties are not stored: " + info, Collections.<String, String>emptyMap(),
-                info.properties());
+            assertNull("Unexpected stored properties: " + info, info.properties().get(key1));
+            assertNull("Unexpected stored properties: " + info, info.properties().get(key2));
 
             info = mgr.updateProperties(ROOT_ID, fileId, fileName, F.asMap(key1, "1"));
 
-            assertEquals("Unexpected stored properties: " + info, F.asMap(key1, "1"), info.properties());
+            assertEquals("Unexpected stored properties: " + info, "1", info.properties().get(key1));
 
             info = mgr.updateProperties(ROOT_ID, fileId, fileName, F.asMap(key2, "2"));
 
-            assertEquals("Unexpected stored properties: " + info, F.asMap(key1, "1", key2, "2"), info.properties());
+           // assertEquals("Unexpected stored properties: " + info, F.asMap(key1, "1", key2, "2"), info.properties());
+            assertEquals("Unexpected stored properties: " + info, "1", info.properties().get(key1));
+            assertEquals("Unexpected stored properties: " + info, "2", info.properties().get(key2));
 
             info = mgr.updateProperties(ROOT_ID, fileId, fileName, F.<String, String>asMap(key1, null));
 
-            assertEquals("Unexpected stored properties: " + info, F.asMap(key2, "2"), info.properties());
+            assertEquals("Unexpected stored properties: " + info, "2", info.properties().get(key2));
 
             info = mgr.updateProperties(ROOT_ID, fileId, fileName, F.<String, String>asMap(key2, null));
 
-            assertNull("Expects empty properties are not stored: " + info, getFieldValue(info, "props"));
-            assertEquals("Expects empty properties are not stored: " + info, Collections.<String, String>emptyMap(),
-                info.properties());
+            assertNull("Unexpected stored properties: " + info, info.properties().get(key1));
+            assertNull("Unexpected stored properties: " + info, info.properties().get(key2));
 
             assertNull(mgr.updateProperties(ROOT_ID, fileId, "not_exists", F.<String, String>asMap(key2, null)));
         }
 
-        mgr.removeIfEmpty(ROOT_ID, "dir", dir.id(), new IgfsPath("/dir"), true);
-        mgr.removeIfEmpty(ROOT_ID, "file", file.id(), new IgfsPath("/file"), true);
+        mgr.softDelete(new IgfsPath("/dir"), true);
+        mgr.softDelete(new IgfsPath("/file"), false);
 
         assertNull(mgr.updateProperties(ROOT_ID, dir.id(), "dir", F.asMap("p", "7")));
         assertNull(mgr.updateProperties(ROOT_ID, file.id(), "file", F.asMap("q", "8")));
     }
 
+    private IgfsFileInfo mkdirsAndGetInfo(String path) throws IgniteCheckedException {
+        IgfsPath p = path(path);
+
+        mgr.mkdirs(p, IgfsImpl.DFLT_DIR_META);
+
+        IgniteUuid id = mgr.fileId(p);
+
+        IgfsFileInfo info = mgr.info(id);
+
+        assert info.isDirectory();
+
+        return info;
+    }
+
+    private IgfsFileInfo createFileAndGetInfo(String path) throws IgniteCheckedException {
+        IgfsPath p = path(path);
+
+        IgniteBiTuple<IgfsFileInfo, IgniteUuid> t2 = mgr.create(p, false, false, null, 400, null, false, null);
+
+        assert t2 != null;
+        assert !t2.get1().isDirectory();
+
+        return t2.get1();
+    }
+
     /**
      * Test file system structure in meta-cache.
      *
@@ -206,31 +232,22 @@ public class IgfsMetaManagerSelfTest extends IgfsCommonAbstractTest {
      */
     public void testStructure() throws Exception {
         IgfsFileInfo rootInfo = new IgfsFileInfo();
+
         // Test empty structure.
         assertEmpty(mgr.directoryListing(ROOT_ID));
         assertEquals(rootInfo, mgr.info(ROOT_ID));
         assertEquals(F.asMap(ROOT_ID, rootInfo), mgr.infos(Arrays.asList(ROOT_ID)));
 
-        IgfsFileInfo a = new IgfsFileInfo(true, null);
-        IgfsFileInfo b = new IgfsFileInfo(true, null);
-        IgfsFileInfo k = new IgfsFileInfo(true, null);
-        IgfsFileInfo z = new IgfsFileInfo(true, null);
-
-        IgfsFileInfo f1 = new IgfsFileInfo(400, null, false, null);
-        IgfsFileInfo f2 = new IgfsFileInfo(new IgfsFileInfo(400, null, false, null), 0);
-        IgfsFileInfo f3 = new IgfsFileInfo(new IgfsFileInfo(400, null, false, null), 200000L);
+        // Directories:
+        IgfsFileInfo a = mkdirsAndGetInfo("/a");
+        IgfsFileInfo b = mkdirsAndGetInfo("/a/b");
+        IgfsFileInfo k = mkdirsAndGetInfo("/a/b/k");
+        IgfsFileInfo z = mkdirsAndGetInfo("/a/k");
 
-        // Validate 'add file' operation.
-        assertNull(mgr.putIfAbsent(ROOT_ID, "a", a));
-        assertNull(mgr.putIfAbsent(ROOT_ID, "f1", f1));
-        assertNull(mgr.putIfAbsent(a.id(), "b", b));
-        assertNull(mgr.putIfAbsent(a.id(), "k", z));
-        assertNull(mgr.putIfAbsent(b.id(), "k", k));
-        assertNull(mgr.putIfAbsent(a.id(), "f2", f2));
-        assertNull(mgr.putIfAbsent(b.id(), "f3", f3));
-
-        assertEquals(b.id(), mgr.putIfAbsent(a.id(), "b", f3));
-        expectsPutIfAbsentFail(a.id(), "c", f3, "Failed to add file details into cache");
+        // Files:
+        IgfsFileInfo f1 = createFileAndGetInfo("/f1");
+        IgfsFileInfo f2 = createFileAndGetInfo("/a/f2");
+        IgfsFileInfo f3 = createFileAndGetInfo("/a/b/f3");
 
         assertEquals(F.asMap("a", new IgfsListingEntry(a), "f1", new IgfsListingEntry(f1)),
             mgr.directoryListing(ROOT_ID));
@@ -315,25 +332,12 @@ public class IgfsMetaManagerSelfTest extends IgfsCommonAbstractTest {
 
         mgr.move(path("/a2"), path("/a"));
 
-        // Validate 'remove' operation.
-        for (int i = 0; i < 100; i++) {
-            // One of participants doesn't exist.
-            assertNull(mgr.removeIfEmpty(ROOT_ID, "a", IgniteUuid.randomUuid(), new IgfsPath("/a"), true));
-            assertNull(mgr.removeIfEmpty(IgniteUuid.randomUuid(), "a", IgniteUuid.randomUuid(),
-                new IgfsPath("/" + IgniteUuid.randomUuid() + "/a"), true));
-        }
-
-        expectsRemoveFail(ROOT_ID, "a", a.id(), new IgfsPath("/a"),
-            "Failed to remove file (directory is not empty)");
-        expectsRemoveFail(a.id(), "b", b.id(), new IgfsPath("/a/b"),
-            "Failed to remove file (directory is not empty)");
-        assertNull(mgr.removeIfEmpty(ROOT_ID, "a", f1.id(), new IgfsPath("/a"), true));
-        assertNull(mgr.removeIfEmpty(a.id(), "b", f1.id(), new IgfsPath("/a/b"), true));
+        IgniteUuid del = mgr.softDelete(path("/a/b/f3"), false);
 
-        assertEquals(f3, mgr.removeIfEmpty(b.id(), "f3", f3.id(), new IgfsPath("/a/b/f3"), true));
+        assertEquals(f3.id(), del);
 
         assertEquals(F.asMap("a", new IgfsListingEntry(a), "f1", new IgfsListingEntry(f1)),
-            mgr.directoryListing(ROOT_ID));
+                mgr.directoryListing(ROOT_ID));
 
         assertEquals(
             F.asMap("b", new IgfsListingEntry(b),
@@ -342,7 +346,9 @@ public class IgfsMetaManagerSelfTest extends IgfsCommonAbstractTest {
 
         assertEmpty(mgr.directoryListing(b.id()));
 
-        assertEquals(b, mgr.removeIfEmpty(a.id(), "b", b.id(), new IgfsPath("/a/b"), true));
+        //assertEquals(b, mgr.removeIfEmpty(a.id(), "b", b.id(), new IgfsPath("/a/b"), true));
+        del = mgr.softDelete(path("/a/b"), false);
+        assertEquals(b.id(), del);
 
         assertEquals(F.asMap("a", new IgfsListingEntry(a), "f1", new IgfsListingEntry(f1)),
             mgr.directoryListing(ROOT_ID));
@@ -362,7 +368,8 @@ public class IgfsMetaManagerSelfTest extends IgfsCommonAbstractTest {
         assertEquals(f2.id(), newF2.id());
         assertNotSame(f2, newF2);
 
-        assertEquals(newF2, mgr.removeIfEmpty(a.id(), "f2", f2.id(), new IgfsPath("/a/f2"), true));
+        del = mgr.softDelete(path("/a/f2"), false);
+        assertEquals(f2.id(), del);
 
         assertEquals(F.asMap("a", new IgfsListingEntry(a), "f1", new IgfsListingEntry(f1)),
             mgr.directoryListing(ROOT_ID));
@@ -370,14 +377,16 @@ public class IgfsMetaManagerSelfTest extends IgfsCommonAbstractTest {
         assertEmpty(mgr.directoryListing(a.id()));
         assertEmpty(mgr.directoryListing(b.id()));
 
-        assertEquals(f1, mgr.removeIfEmpty(ROOT_ID, "f1", f1.id(), new IgfsPath("/f1"), true));
+        del = mgr.softDelete(path("/f1"), false);
+        assertEquals(f1.id(), del);
 
         assertEquals(F.asMap("a", new IgfsListingEntry(a)), mgr.directoryListing(ROOT_ID));
 
         assertEmpty(mgr.directoryListing(a.id()));
         assertEmpty(mgr.directoryListing(b.id()));
 
-        assertEquals(a, mgr.removeIfEmpty(ROOT_ID, "a", a.id(), new IgfsPath("/a"), true));
+        del = mgr.softDelete(path("/a"), false);
+        assertEquals(a.id(), del);
 
         assertEmpty(mgr.directoryListing(ROOT_ID));
         assertEmpty(mgr.directoryListing(a.id()));
@@ -420,25 +429,6 @@ public class IgfsMetaManagerSelfTest extends IgfsCommonAbstractTest {
     }
 
     /**
-     * Test expected failures for 'add file' operation.
-     *
-     * @param parentId Parent file ID.
-     * @param fileName New file name in the parent's listing.
-     * @param fileInfo New file initial details.
-     * @param msg Failure message if expected exception was not thrown.
-     */
-    private void expectsPutIfAbsentFail(final IgniteUuid parentId, final String fileName, final IgfsFileInfo fileInfo,
-        @Nullable String msg) {
-        Throwable err = assertThrows(log, new Callable() {
-            @Override public Object call() throws Exception {
-                return mgr.putIfAbsent(parentId, fileName, fileInfo);
-            }
-        }, IgniteCheckedException.class, msg);
-
-        assertTrue("Unexpected cause: " + err.getCause(), err.getCause() instanceof IgfsException);
-    }
-
-    /**
      * Test expected failures for 'move file' operation.
      *
      * @param msg Failure message if expected exception was not thrown.
@@ -454,26 +444,4 @@ public class IgfsMetaManagerSelfTest extends IgfsCommonAbstractTest {
 
         assertTrue("Unexpected cause: " + err, err instanceof IgfsException);
     }
-
-    /**
-     * Test expected failures for 'remove file' operation.
-     *
-     * @param parentId Parent file ID to remove file from.
-     * @param fileName File name in the parent's listing.
-     * @param fileId File ID to remove.
-     * @param path Removed file path.
-     * @param msg Failure message if expected exception was not thrown.
-     */
-    private void expectsRemoveFail(final IgniteUuid parentId, final String fileName, final IgniteUuid fileId,
-        final IgfsPath path, @Nullable String msg) {
-        Throwable err = assertThrows(log, new Callable() {
-            @Nullable @Override public Object call() throws Exception {
-                mgr.removeIfEmpty(parentId, fileName, fileId, path, true);
-
-                return null;
-            }
-        }, IgniteCheckedException.class, msg);
-
-        assertTrue("Unexpected cause: " + err.getCause(), err.getCause() instanceof IgfsDirectoryNotEmptyException);
-    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/962fcce3/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorSelfTest.java
index 9c4d832..c6853ae 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorSelfTest.java
@@ -626,17 +626,17 @@ public class IgfsProcessorSelfTest extends IgfsCommonAbstractTest {
     /** @throws Exception If failed. */
     public void testCreateOpenAppend() throws Exception {
         // Error - path points to root directory.
-        assertCreateFails("/", false, "Failed to resolve parent directory");
+        assertCreateFails("/", false, "Failed to create file (path points to an existing directory)");
 
         // Create directories.
         igfs.mkdirs(path("/A/B1/C1"));
 
         // Error - path points to directory.
         for (String path : Arrays.asList("/A", "/A/B1", "/A/B1/C1")) {
-            assertCreateFails(path, false, "Failed to create file (file already exists)");
-            assertCreateFails(path, true, "Failed to create file (path points to a directory)");
-            assertAppendFails(path, false, "Failed to open file (not a file)");
-            assertAppendFails(path, true, "Failed to open file (not a file)");
+            assertCreateFails(path, false, "Failed to create file (path points to an existing directory)");
+            assertCreateFails(path, true, "Failed to create file (path points to an existing directory)");
+            assertAppendFails(path, false, "Failed to open file (path points to an existing directory)");
+            assertAppendFails(path, true, "Failed to open file (path points to an existing directory)");
             assertOpenFails(path, "Failed to open file (not a file)");
         }
 
@@ -653,7 +653,7 @@ public class IgfsProcessorSelfTest extends IgfsCommonAbstractTest {
             assertEquals(text1, create(path, false, text1));
 
             // Error - file already exists.
-            assertCreateFails(path, false, "Failed to create file (file already exists)");
+            assertCreateFails(path, false, "Failed to create file (file already exists and overwrite flag is false)");
 
             // Overwrite existent.
             assertEquals(text2, create(path, true, text2));

http://git-wip-us.apache.org/repos/asf/ignite/blob/962fcce3/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java
index 954a011..cc5e1ce 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java
@@ -66,6 +66,12 @@ public class IgniteIgfsTestSuite extends TestSuite {
     public static TestSuite suite() throws Exception {
         TestSuite suite = new TestSuite("Ignite FS Test Suite For Platform Independent Tests");
 
+        suite.addTest(new TestSuite(IgfsPrimarySelfTest.class));
+        suite.addTest(new TestSuite(IgfsPrimaryOffheapTieredSelfTest.class));
+        suite.addTest(new TestSuite(IgfsPrimaryOffheapValuesSelfTest.class));
+        suite.addTest(new TestSuite(IgfsDualSyncSelfTest.class));
+        suite.addTest(new TestSuite(IgfsDualAsyncSelfTest.class));
+
         suite.addTest(new TestSuite(IgfsSizeSelfTest.class));
         suite.addTest(new TestSuite(IgfsAttributesSelfTest.class));
         suite.addTest(new TestSuite(IgfsFileInfoSelfTest.class));

http://git-wip-us.apache.org/repos/asf/ignite/blob/962fcce3/modules/hadoop/src/test/java/org/apache/ignite/igfs/Hadoop1DualAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/igfs/Hadoop1DualAbstractTest.java b/modules/hadoop/src/test/java/org/apache/ignite/igfs/Hadoop1DualAbstractTest.java
index efe95be..ea65464 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/igfs/Hadoop1DualAbstractTest.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/igfs/Hadoop1DualAbstractTest.java
@@ -64,11 +64,6 @@ public abstract class Hadoop1DualAbstractTest extends IgfsDualAbstractSelfTest {
         super(mode);
     }
 
-    /** {@inheritDoc} */
-    @Override public void testMkdirs() throws Exception {
-        fail("https://issues.apache.org/jira/browse/IGNITE-1620");
-    }
-
     /**
      * Creates secondary filesystems.
      * @return IgfsSecondaryFileSystem

http://git-wip-us.apache.org/repos/asf/ignite/blob/962fcce3/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopIgfs20FileSystemAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopIgfs20FileSystemAbstractSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopIgfs20FileSystemAbstractSelfTest.java
index c938571..b3afd22 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopIgfs20FileSystemAbstractSelfTest.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopIgfs20FileSystemAbstractSelfTest.java
@@ -897,7 +897,7 @@ public abstract class HadoopIgfs20FileSystemAbstractSelfTest extends IgfsCommonA
 
         os.close();
 
-        GridTestUtils.assertThrows(log, new Callable<Object>() {
+        GridTestUtils.assertThrowsInherited(log, new Callable<Object>() {
             @Override public Object call() throws Exception {
                 return fs.create(new Path(fsHome, dir), EnumSet.of(CreateFlag.APPEND),
                     Options.CreateOpts.perms(FsPermission.getDefault()));
@@ -919,8 +919,7 @@ public abstract class HadoopIgfs20FileSystemAbstractSelfTest extends IgfsCommonA
             Options.CreateOpts.perms(FsPermission.getDefault()));
 
         GridTestUtils.assertThrows(log, new Callable<Object>() {
-            @Override
-            public Object call() throws Exception {
+            @Override public Object call() throws Exception {
                 return fs.create(file, EnumSet.of(CreateFlag.APPEND),
                     Options.CreateOpts.perms(FsPermission.getDefault()));
             }

http://git-wip-us.apache.org/repos/asf/ignite/blob/962fcce3/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgniteHadoopFileSystemAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgniteHadoopFileSystemAbstractSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgniteHadoopFileSystemAbstractSelfTest.java
index 2626ebb..d368955 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgniteHadoopFileSystemAbstractSelfTest.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgniteHadoopFileSystemAbstractSelfTest.java
@@ -1096,7 +1096,7 @@ public abstract class IgniteHadoopFileSystemAbstractSelfTest extends IgfsCommonA
 
         os.close();
 
-        GridTestUtils.assertThrows(log, new Callable<Object>() {
+        GridTestUtils.assertThrowsInherited(log, new Callable<Object>() {
             @Override public Object call() throws Exception {
                 return fs.append(new Path(fsHome, dir), 1024);
             }


[21/50] [abbrv] ignite git commit: IGNITE-825: Disabled test remastered and restored.

Posted by ag...@apache.org.
IGNITE-825: Disabled test remastered and restored.


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

Branch: refs/heads/ignite-1016
Commit: 52a733f6bdc463b1b5527b29a0817a85bf1ed7bd
Parents: 49a5cc5
Author: iveselovskiy <iv...@gridgain.com>
Authored: Thu Oct 15 13:12:52 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Thu Oct 15 13:12:52 2015 +0300

----------------------------------------------------------------------
 .../HadoopIgfs20FileSystemAbstractSelfTest.java | 22 ++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/52a733f6/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopIgfs20FileSystemAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopIgfs20FileSystemAbstractSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopIgfs20FileSystemAbstractSelfTest.java
index b3afd22..9c301c9 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopIgfs20FileSystemAbstractSelfTest.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopIgfs20FileSystemAbstractSelfTest.java
@@ -1124,10 +1124,10 @@ public abstract class HadoopIgfs20FileSystemAbstractSelfTest extends IgfsCommonA
         is.close();
     }
 
-    /** @throws Exception If failed. */
+    /**
+     * @throws Exception If failed.
+     */
     public void testRenameDirectoryIfDstPathExists() throws Exception {
-        fail("https://issues.apache.org/jira/browse/IGNITE-825"); 
-        
         Path fsHome = new Path(primaryFsUri);
         Path srcDir = new Path(fsHome, "/tmp/");
         Path dstDir = new Path(fsHome, "/tmpNew/");
@@ -1142,11 +1142,21 @@ public abstract class HadoopIgfs20FileSystemAbstractSelfTest extends IgfsCommonA
 
         os.close();
 
-        fs.rename(srcDir, dstDir);
+        try {
+            fs.rename(srcDir, dstDir);
+
+            fail("FileAlreadyExistsException expected.");
+        }
+        catch (FileAlreadyExistsException ignore) {
+            // No-op.
+        }
 
+        // Check all the files stay unchanged:
         assertPathExists(fs, dstDir);
-        assertPathExists(fs, new Path(fsHome, "/tmpNew/tmp"));
-        assertPathExists(fs, new Path(fsHome, "/tmpNew/tmp/file1"));
+        assertPathExists(fs, new Path(dstDir, "file2"));
+
+        assertPathExists(fs, srcDir);
+        assertPathExists(fs, new Path(srcDir, "file1"));
     }
 
     /** @throws Exception If failed. */


[19/50] [abbrv] ignite git commit: IGNITE-1612

Posted by ag...@apache.org.
IGNITE-1612


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

Branch: refs/heads/ignite-1016
Commit: 1dc3936e6a8384e5b5052757d642ae0914be81be
Parents: 962fcce
Author: Anton Vinogradov <av...@apache.org>
Authored: Thu Oct 15 11:43:41 2015 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Thu Oct 15 11:43:41 2015 +0300

----------------------------------------------------------------------
 modules/apache-license-gen/pom.xml | 3 +++
 1 file changed, 3 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/1dc3936e/modules/apache-license-gen/pom.xml
----------------------------------------------------------------------
diff --git a/modules/apache-license-gen/pom.xml b/modules/apache-license-gen/pom.xml
index fa6a1e2..5d14f89 100644
--- a/modules/apache-license-gen/pom.xml
+++ b/modules/apache-license-gen/pom.xml
@@ -40,6 +40,9 @@
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-deploy-plugin</artifactId>
                 <version>2.8.2</version>
+                <configuration>
+                    <skip>true</skip>
+                </configuration>
             </plugin>
         </plugins>
     </build>


[07/50] [abbrv] ignite git commit: ignite-1526: full support of IBM JDK by Ignite

Posted by ag...@apache.org.
ignite-1526: full support of IBM JDK by Ignite


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

Branch: refs/heads/ignite-1016
Commit: 5fc682f11f43f61d14d6b70be5ccf949a9ae05ac
Parents: 4f95be2
Author: Andrey Gura <ag...@gridgain.com>
Authored: Fri Oct 9 13:54:56 2015 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Fri Oct 9 14:22:34 2015 +0300

----------------------------------------------------------------------
 .../discovery/GridDiscoveryManager.java         |   17 +-
 .../internal/portable/PortableContext.java      |    7 +
 .../portable/api/PortableMarshaller.java        |   14 +-
 .../ignite/internal/util/GridJavaProcess.java   |   12 +-
 .../ignite/internal/util/lang/GridFunc.java     |   12 +
 .../apache/ignite/marshaller/Marshaller.java    |    2 +-
 .../optimized/OptimizedMarshallerUtils.java     |    6 +-
 .../cache/GridCacheAbstractFullApiSelfTest.java |  486 ++++---
 .../CacheNoValueClassOnServerNodeTest.java      |    1 +
 ...tomicClientOnlyMultiNodeFullApiSelfTest.java |   71 +-
 ...achePartitionedMultiNodeFullApiSelfTest.java |  129 +-
 .../testframework/junits/GridAbstractTest.java  |  116 +-
 .../junits/IgniteTestResources.java             |    8 +-
 .../junits/common/GridCommonAbstractTest.java   |   15 +-
 .../junits/multijvm/AffinityProcessProxy.java   |  440 ++++--
 .../multijvm/IgniteCacheProcessProxy.java       | 1348 ++++++++++++++----
 .../multijvm/IgniteClusterProcessProxy.java     |  115 +-
 .../multijvm/IgniteEventsProcessProxy.java      |   50 +-
 .../junits/multijvm/IgniteNodeRunner.java       |   39 +-
 .../junits/multijvm/IgniteProcessProxy.java     |  107 +-
 .../cache/CacheConfigurationP2PTest.java        |    3 +
 21 files changed, 2186 insertions(+), 812 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/5fc682f1/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 1801b9c..cba06de 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
@@ -987,19 +987,24 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
 
         boolean locP2pEnabled = locNode.attribute(ATTR_PEER_CLASSLOADING);
 
-        boolean warned = false;
+        boolean ipV4Warned = false;
+
+        boolean jvmMajVerWarned = false;
 
         for (ClusterNode n : nodes) {
             int rmtJvmMajVer = nodeJavaMajorVersion(n);
 
-            if (locJvmMajVer != rmtJvmMajVer)
-                throw new IgniteCheckedException("Local node's java major version is different from remote node's one" +
-                    " [locJvmMajVer=" + locJvmMajVer + ", rmtJvmMajVer=" + rmtJvmMajVer + "]");
+            if (locJvmMajVer != rmtJvmMajVer && !jvmMajVerWarned) {
+                U.warn(log, "Local java version is different from remote [loc=" +
+                    locJvmMajVer + ", rmt=" + rmtJvmMajVer + "]");
+
+                jvmMajVerWarned = true;
+            }
 
             String rmtPreferIpV4 = n.attribute("java.net.preferIPv4Stack");
 
             if (!F.eq(rmtPreferIpV4, locPreferIpV4)) {
-                if (!warned)
+                if (!ipV4Warned)
                     U.warn(log, "Local node's value of 'java.net.preferIPv4Stack' " +
                         "system property differs from remote node's " +
                         "(all nodes in topology should have identical value) " +
@@ -1008,7 +1013,7 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
                         ", rmtAddrs=" + U.addressesAsString(n) + ']',
                         "Local and remote 'java.net.preferIPv4Stack' system properties do not match.");
 
-                warned = true;
+                ipV4Warned = true;
             }
 
             // Daemon nodes are allowed to have any deployment they need.

http://git-wip-us.apache.org/repos/asf/ignite/blob/5fc682f1/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
index 2ee96b7..1ad42ab 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
@@ -967,6 +967,9 @@ public class PortableContext implements Externalizable {
         }
     }
 
+    /**
+     * Basic class ID mapper.
+     */
     private static class BasicClassIdMapper implements PortableIdMapper {
         /** {@inheritDoc} */
         @Override public int typeId(String clsName) {
@@ -1121,6 +1124,10 @@ public class PortableContext implements Externalizable {
         /** Whether the following type is registered in a cache or not */
         private final boolean registered;
 
+        /**
+         * @param id Id.
+         * @param registered Registered.
+         */
         public Type(int id, boolean registered) {
             this.id = id;
             this.registered = registered;

http://git-wip-us.apache.org/repos/asf/ignite/blob/5fc682f1/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableMarshaller.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableMarshaller.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableMarshaller.java
index de0df8d..3dfbdf0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableMarshaller.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableMarshaller.java
@@ -29,12 +29,6 @@ import org.apache.ignite.internal.portable.GridPortableMarshaller;
 import org.apache.ignite.internal.portable.PortableContext;
 import org.apache.ignite.marshaller.AbstractMarshaller;
 import org.apache.ignite.marshaller.MarshallerContext;
-import org.apache.ignite.internal.portable.api.PortableException;
-import org.apache.ignite.internal.portable.api.PortableIdMapper;
-import org.apache.ignite.internal.portable.api.PortableObject;
-import org.apache.ignite.internal.portable.api.PortableProtocolVersion;
-import org.apache.ignite.internal.portable.api.PortableSerializer;
-import org.apache.ignite.internal.portable.api.PortableTypeConfiguration;
 import org.jetbrains.annotations.Nullable;
 
 /**
@@ -336,7 +330,7 @@ public class PortableMarshaller extends AbstractMarshaller {
 
     /** {@inheritDoc} */
     @Override public <T> T unmarshal(InputStream in, @Nullable ClassLoader clsLdr) throws IgniteCheckedException {
-        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+        ByteArrayOutputStream buf = new ByteArrayOutputStream();
 
         byte[] arr = new byte[4096];
         int cnt;
@@ -345,11 +339,11 @@ public class PortableMarshaller extends AbstractMarshaller {
         // returns number of bytes remaining.
         try {
             while ((cnt = in.read(arr)) != -1)
-                buffer.write(arr, 0, cnt);
+                buf.write(arr, 0, cnt);
 
-            buffer.flush();
+            buf.flush();
 
-            return impl.deserialize(buffer.toByteArray(), clsLdr);
+            return impl.deserialize(buf.toByteArray(), clsLdr);
         }
         catch (IOException e) {
             throw new PortableException("Failed to unmarshal the object from InputStream", e);

http://git-wip-us.apache.org/repos/asf/ignite/blob/5fc682f1/modules/core/src/main/java/org/apache/ignite/internal/util/GridJavaProcess.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/GridJavaProcess.java b/modules/core/src/main/java/org/apache/ignite/internal/util/GridJavaProcess.java
index 92c20fe..3371eb8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/GridJavaProcess.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/GridJavaProcess.java
@@ -89,7 +89,7 @@ public final class GridJavaProcess {
      */
     public static GridJavaProcess exec(Class cls, String params, @Nullable IgniteLogger log,
         @Nullable IgniteInClosure<String> printC, @Nullable GridAbsClosure procKilledC) throws Exception {
-        return exec(cls.getCanonicalName(), params, log, printC, procKilledC, null, null);
+        return exec(cls.getCanonicalName(), params, log, printC, procKilledC, null, null, null);
     }
 
     /**
@@ -108,7 +108,7 @@ public final class GridJavaProcess {
     public static GridJavaProcess exec(Class cls, String params, @Nullable IgniteLogger log,
         @Nullable IgniteInClosure<String> printC, @Nullable GridAbsClosure procKilledC,
         @Nullable Collection<String> jvmArgs, @Nullable String cp) throws Exception {
-        return exec(cls.getCanonicalName(), params, log, printC, procKilledC, jvmArgs, cp);
+        return exec(cls.getCanonicalName(), params, log, printC, procKilledC, null, jvmArgs, cp);
     }
 
     /**
@@ -116,9 +116,10 @@ public final class GridJavaProcess {
      *
      * @param clsName Class with main() method to be run.
      * @param params main() method parameters.
+     * @param log Log to use.
      * @param printC Optional closure to be called each time wrapped process prints line to system.out or system.err.
      * @param procKilledC Optional closure to be called when process termination is detected.
-     * @param log Log to use.
+     * @param javaHome Java home location. The process will be started under given JVM.
      * @param jvmArgs JVM arguments to use.
      * @param cp Additional classpath.
      * @return Wrapper around {@link Process}
@@ -126,7 +127,7 @@ public final class GridJavaProcess {
      */
     public static GridJavaProcess exec(String clsName, String params, @Nullable IgniteLogger log,
         @Nullable IgniteInClosure<String> printC, @Nullable GridAbsClosure procKilledC,
-        @Nullable Collection<String> jvmArgs, @Nullable String cp) throws Exception {
+        @Nullable String javaHome, @Nullable Collection<String> jvmArgs, @Nullable String cp) throws Exception {
         if (!(U.isLinux() || U.isMacOs() || U.isWindows()))
             throw new Exception("Your OS is not supported.");
 
@@ -140,7 +141,8 @@ public final class GridJavaProcess {
 
         List<String> procCommands = new ArrayList<>();
 
-        String javaBin = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java";
+        String javaBin = (javaHome == null ? System.getProperty("java.home") : javaHome) +
+            File.separator + "bin" + File.separator + "java";
 
         procCommands.add(javaBin);
         procCommands.addAll(jvmArgs == null ? U.jvmArgs() : jvmArgs);

http://git-wip-us.apache.org/repos/asf/ignite/blob/5fc682f1/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
index ffeeca0..43bc5f3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
@@ -103,6 +103,9 @@ public class GridFunc {
 
     /** */
     private static final IgniteClosure IDENTITY = new C1() {
+        /** */
+        private static final long serialVersionUID = -6338573080046225172L;
+
         @Override public Object apply(Object o) {
             return o;
         }
@@ -1196,6 +1199,9 @@ public class GridFunc {
         A.notNull(nodeId, "nodeId");
 
         return new P1<T>() {
+            /** */
+            private static final long serialVersionUID = -7082730222779476623L;
+
             @Override public boolean apply(ClusterNode e) {
                 return e.id().equals(nodeId);
             }
@@ -1705,6 +1711,9 @@ public class GridFunc {
         assert c != null;
 
         return new GridSerializableList<T2>() {
+            /** */
+            private static final long serialVersionUID = 3126625219739967068L;
+
             @Override public T2 get(int idx) {
                 return trans.apply(c.get(idx));
             }
@@ -1766,6 +1775,9 @@ public class GridFunc {
         assert m != null;
 
         return isEmpty(p) || isAlwaysTrue(p) ? m : new GridSerializableMap<K, V>() {
+            /** */
+            private static final long serialVersionUID = 5531745605372387948L;
+
             /** Entry predicate. */
             private IgnitePredicate<Entry<K, V>> ep = new P1<Map.Entry<K, V>>() {
                 @Override public boolean apply(Entry<K, V> e) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/5fc682f1/modules/core/src/main/java/org/apache/ignite/marshaller/Marshaller.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/Marshaller.java b/modules/core/src/main/java/org/apache/ignite/marshaller/Marshaller.java
index 3e815fd..a76daa8 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/Marshaller.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/Marshaller.java
@@ -92,7 +92,7 @@ public interface Marshaller {
     public byte[] marshal(@Nullable Object obj) throws IgniteCheckedException;
 
     /**
-     * Unmarshals object from the output stream using given class loader.
+     * Unmarshals object from the input stream using given class loader.
      * This method should not close given input stream.
      *
      * @param <T> Type of unmarshalled object.

http://git-wip-us.apache.org/repos/asf/ignite/blob/5fc682f1/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerUtils.java b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerUtils.java
index 4abbd04..584083c 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerUtils.java
@@ -42,6 +42,10 @@ class OptimizedMarshallerUtils {
     /** */
     private static final Unsafe UNSAFE = GridUnsafe.unsafe();
 
+    /** Use default {@code serialVersionUid} for {@link Serializable} classes. */
+    private static final boolean USE_DFLT_SUID =
+        Boolean.valueOf(System.getProperty("ignite.marsh.optimized.useDefaultSUID", Boolean.TRUE.toString()));
+
     /** */
     static final long HASH_SET_MAP_OFF;
 
@@ -283,7 +287,7 @@ class OptimizedMarshallerUtils {
      */
     @SuppressWarnings("ForLoopReplaceableByForEach")
     static short computeSerialVersionUid(Class cls, List<Field> fields) throws IOException {
-        if (Serializable.class.isAssignableFrom(cls) && !Enum.class.isAssignableFrom(cls))
+        if (USE_DFLT_SUID && Serializable.class.isAssignableFrom(cls) && !Enum.class.isAssignableFrom(cls))
             return (short)ObjectStreamClass.lookup(cls).getSerialVersionUID();
 
         MessageDigest md;

http://git-wip-us.apache.org/repos/asf/ignite/blob/5fc682f1/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
index 2a64963..ec3ea0c 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
@@ -19,6 +19,7 @@ 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;
 import java.util.Collection;
@@ -49,6 +50,7 @@ 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.CacheEntryProcessor;
 import org.apache.ignite.cache.CacheMemoryMode;
@@ -75,6 +77,7 @@ import org.apache.ignite.internal.util.typedef.internal.U;
 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.spi.discovery.tcp.TcpDiscoverySpi;
 import org.apache.ignite.spi.swapspace.inmemory.GridTestSwapSpaceSpi;
 import org.apache.ignite.testframework.GridTestUtils;
@@ -117,48 +120,37 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
     /** */
     public static final CacheEntryProcessor<String, Integer, String> ERR_PROCESSOR =
         new CacheEntryProcessor<String, Integer, String>() {
+            /** */
+            private static final long serialVersionUID = 0L;
+
             @Override public String process(MutableEntry<String, Integer> e, Object... args) {
                 throw new RuntimeException("Failed!");
             }
         };
 
     /** Increment processor for invoke operations. */
-    public static final EntryProcessor<String, Integer, String> INCR_PROCESSOR = new EntryProcessor<String, Integer, String>() {
-        @Override public String process(MutableEntry<String, Integer> e, Object... args) {
-            assertNotNull(e.getKey());
-
-            Integer old = e.getValue();
-
-            e.setValue(old == null ? 1 : old + 1);
-
-            return String.valueOf(old);
-        }
-    };
+    public static final EntryProcessor<String, Integer, String> INCR_PROCESSOR = new IncrementEntryProcessor();
 
     /** Increment processor for invoke operations with IgniteEntryProcessor. */
     public static final CacheEntryProcessor<String, Integer, String> INCR_IGNITE_PROCESSOR =
         new CacheEntryProcessor<String, Integer, String>() {
+            /** */
+            private static final long serialVersionUID = 0L;
+
             @Override public String process(MutableEntry<String, Integer> e, Object... args) {
                 return INCR_PROCESSOR.process(e, args);
             }
         };
 
     /** Increment processor for invoke operations. */
-    public static final EntryProcessor<String, Integer, String> RMV_PROCESSOR = new EntryProcessor<String, Integer, String>() {
-        @Override public String process(MutableEntry<String, Integer> e, Object... args) {
-            assertNotNull(e.getKey());
-
-            Integer old = e.getValue();
-
-            e.remove();
-
-            return String.valueOf(old);
-        }
-    };
+    public static final EntryProcessor<String, Integer, String> RMV_PROCESSOR = new RemoveEntryProcessor();
 
     /** Increment processor for invoke operations with IgniteEntryProcessor. */
     public static final CacheEntryProcessor<String, Integer, String> RMV_IGNITE_PROCESSOR =
         new CacheEntryProcessor<String, Integer, String>() {
+            /** */
+            private static final long serialVersionUID = 0L;
+
             @Override public String process(MutableEntry<String, Integer> e, Object... args) {
                 return RMV_PROCESSOR.process(e, args);
             }
@@ -346,21 +338,8 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
             assert jcache(i).localSize() != 0 || F.isEmpty(keysCol);
         }
 
-        for (int i = 0; i < gridCount(); i++) {
-            executeOnLocalOrRemoteJvm(i, new TestIgniteIdxRunnable() {
-                @Override public void run(int idx) throws Exception {
-                    GridCacheContext<String, Integer> ctx = context(idx);
-
-                    int sum = 0;
-
-                    for (String key : map.keySet())
-                        if (ctx.affinity().localNode(key, new AffinityTopologyVersion(ctx.discovery().topologyVersion())))
-                            sum++;
-
-                    assertEquals("Incorrect key size on cache #" + idx, sum, jcache(idx).localSize(ALL));
-                }
-            });
-        }
+        for (int i = 0; i < gridCount(); i++)
+            executeOnLocalOrRemoteJvm(i, new CheckCacheSizeTask(map));
 
         for (int i = 0; i < gridCount(); i++) {
             Collection<String> keysCol = mapped.get(grid(i).localNode());
@@ -1350,13 +1329,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
 
         assertEquals((Integer)3, cache.get("k1"));
 
-        EntryProcessor<String, Integer, Integer> c = new EntryProcessor<String, Integer, Integer>() {
-            @Override public Integer process(MutableEntry<String, Integer> e, Object... args) {
-                e.remove();
-
-                return null;
-            }
-        };
+        EntryProcessor<String, Integer, Integer> c = new RemoveAndReturnNullEntryProcessor();
 
         assertNull(cache.invoke("k1", c));
         assertNull(cache.get("k1"));
@@ -1364,11 +1337,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
         for (int i = 0; i < gridCount(); i++)
             assertNull(jcache(i).localPeek("k1", ONHEAP));
 
-        final EntryProcessor<String, Integer, Integer> errProcessor = new EntryProcessor<String, Integer, Integer>() {
-            @Override public Integer process(MutableEntry<String, Integer> e, Object... args) {
-                throw new EntryProcessorException("Test entry processor exception.");
-            }
-        };
+        final EntryProcessor<String, Integer, Integer> errProcessor = new FailedEntryProcessor();
 
         GridTestUtils.assertThrows(log, new Callable<Void>() {
             @Override public Void call() throws Exception {
@@ -2001,7 +1970,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
             assertFalse(cacheAsync.<Boolean>future().get());
         }
 
-        cache.localEvict(Arrays.asList("key2"));
+        cache.localEvict(Collections.singletonList("key2"));
 
         // Same checks inside tx.
         Transaction tx = inTx ? transactions().txStart() : null;
@@ -2357,27 +2326,8 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
             for (int i = 0; i < cnt; i++)
                 cache.remove(String.valueOf(i));
 
-            for (int g = 0; g < gridCount(); g++) {
-                executeOnLocalOrRemoteJvm(g, new TestIgniteIdxRunnable() {
-                    @Override public void run(int idx) throws Exception {
-                        for (int i = 0; i < cnt; i++) {
-                            String key = String.valueOf(i);
-
-                            GridCacheContext<String, Integer> cctx = context(idx);
-
-                            GridCacheEntryEx entry = cctx.isNear() ? cctx.near().dht().peekEx(key) :
-                                cctx.cache().peekEx(key);
-
-                            if (grid(idx).affinity(null).mapKeyToPrimaryAndBackups(key).contains(grid(idx).localNode())) {
-                                assertNotNull(entry);
-                                assertTrue(entry.deleted());
-                            }
-                            else
-                                assertNull(entry);
-                        }
-                    }
-                });
-            }
+            for (int g = 0; g < gridCount(); g++)
+                executeOnLocalOrRemoteJvm(g, new CheckEntriesDeletedTask(cnt));
         }
     }
 
@@ -2587,8 +2537,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
         c.add(null);
 
         GridTestUtils.assertThrows(log, new Callable<Void>() {
-            @Override
-            public Void call() throws Exception {
+            @Override public Void call() throws Exception {
                 cache.removeAll(c);
 
                 return null;
@@ -2725,7 +2674,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
     public void testRemoveAfterClear() throws Exception {
         IgniteEx ignite = grid(0);
 
-        boolean affNode = ((IgniteKernal)ignite).context().cache().internalCache(null).context().affinityNode();
+        boolean affNode = ignite.context().cache().internalCache(null).context().affinityNode();
 
         if (!affNode) {
             if (gridCount() < 2)
@@ -2766,13 +2715,6 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
     }
 
     /**
-     *
-     */
-    private void xxx() {
-        System.out.printf("");
-    }
-
-    /**
      * @throws Exception In case of error.
      */
     public void testClear() throws Exception {
@@ -3597,26 +3539,9 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
             info("Local keys (primary + backup): " + locKeys);
         }
 
-        for (int i = 0; i < gridCount(); i++) {
-            grid(i).events().localListen(new IgnitePredicate<Event>() {
-                @Override public boolean apply(Event evt) {
-                    info("Received event: " + evt);
-
-                    switch (evt.type()) {
-                        case EVT_CACHE_OBJECT_SWAPPED:
-                            swapEvts.incrementAndGet();
-
-                            break;
-                        case EVT_CACHE_OBJECT_UNSWAPPED:
-                            unswapEvts.incrementAndGet();
-
-                            break;
-                    }
-
-                    return true;
-                }
-            }, EVT_CACHE_OBJECT_SWAPPED, EVT_CACHE_OBJECT_UNSWAPPED);
-        }
+        for (int i = 0; i < gridCount(); i++)
+            grid(i).events().localListen(
+                new SwapEvtsLocalListener(swapEvts, unswapEvts), EVT_CACHE_OBJECT_SWAPPED, EVT_CACHE_OBJECT_UNSWAPPED);
 
         cache.localEvict(F.asList(k2, k3));
 
@@ -3934,7 +3859,6 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
                 map.put(entry.getKey(), entry.getValue());
         }
 
-        assert map != null;
         assert map.size() == 2;
         assert map.get("key1") == 1;
         assert map.get("key2") == 2;
@@ -3951,32 +3875,8 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
         if (nearEnabled())
             assertEquals(keys.size(), jcache().localSize(CachePeekMode.ALL));
         else {
-            for (int i = 0; i < gridCount(); i++) {
-                executeOnLocalOrRemoteJvm(i, new TestIgniteIdxRunnable() {
-                    @Override public void run(int idx) throws Exception {
-                        GridCacheContext<String, Integer> ctx = context(idx);
-
-                        if (ctx.cache().configuration().getMemoryMode() == OFFHEAP_TIERED)
-                            return;
-
-                        int size = 0;
-
-                        for (String key : keys) {
-                            if (ctx.affinity().localNode(key, ctx.discovery().topologyVersionEx())) {
-                                GridCacheEntryEx e =
-                                    ctx.isNear() ? ctx.near().dht().peekEx(key) : ctx.cache().peekEx(key);
-
-                                assert e != null : "Entry is null [idx=" + idx + ", key=" + key + ", ctx=" + ctx + ']';
-                                assert !e.deleted() : "Entry is deleted: " + e;
-
-                                size++;
-                            }
-                        }
-
-                        assertEquals("Incorrect size on cache #" + idx, size, jcache(idx).localSize(ALL));
-                    }
-                });
-            }
+            for (int i = 0; i < gridCount(); i++)
+                executeOnLocalOrRemoteJvm(i, new CheckEntriesTask(keys));
         }
     }
 
@@ -3989,21 +3889,8 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
             assertEquals("Invalid key size: " + jcache().localSize(ALL),
                 keys.size(), jcache().localSize(ALL));
         else {
-            for (int i = 0; i < gridCount(); i++) {
-                executeOnLocalOrRemoteJvm(i, new TestIgniteIdxRunnable() {
-                    @Override public void run(int idx) throws Exception {
-                        GridCacheContext<String, Integer> ctx = context(idx);
-
-                        int size = 0;
-
-                        for (String key : keys)
-                            if (ctx.affinity().localNode(key, ctx.discovery().topologyVersionEx()))
-                                size++;
-
-                        assertEquals("Incorrect key size on cache #" + idx, size, jcache(idx).localSize(ALL));
-                    }
-                });
-            }
+            for (int i = 0; i < gridCount(); i++)
+                executeOnLocalOrRemoteJvm(i, new CheckKeySizeTask(keys));
         }
     }
 
@@ -4061,27 +3948,8 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
      * @param cnt Keys count.
      * @return Collection of keys for which given cache is primary.
      */
-    protected List<String> primaryKeysForCache(final IgniteCache<String, Integer> cache, final int cnt, final int startFrom) {
-        return executeOnLocalOrRemoteJvm(cache, new TestCacheCallable<String, Integer, List<String>>() {
-            @Override public List<String> call(Ignite ignite, IgniteCache<String, Integer> cache) throws Exception {
-                List<String> found = new ArrayList<>();
-
-                Affinity<Object> affinity = ignite.affinity(cache.getName());
-
-                for (int i = startFrom; i < startFrom + 100_000; i++) {
-                    String key = "key" + i;
-
-                    if (affinity.isPrimary(ignite.cluster().localNode(), key)) {
-                        found.add(key);
-
-                        if (found.size() == cnt)
-                            return found;
-                    }
-                }
-
-                throw new IgniteException("Unable to find " + cnt + " keys as primary for cache.");
-            }
-        });
+    protected List<String> primaryKeysForCache(IgniteCache<String, Integer> cache, int cnt, int startFrom) {
+        return executeOnLocalOrRemoteJvm(cache, new CheckPrimaryKeysTask(startFrom, cnt));
     }
 
     /**
@@ -4272,18 +4140,8 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
      * Checks iterators are cleared.
      */
     private void checkIteratorsCleared() {
-        for (int j = 0; j < gridCount(); j++) {
-            executeOnLocalOrRemoteJvm(j, new TestIgniteIdxRunnable() {
-                @Override public void run(int idx) throws Exception {
-                    GridCacheQueryManager queries = context(idx).queries();
-
-                    Map map = GridTestUtils.getFieldValue(queries, GridCacheQueryManager.class, "qryIters");
-
-                    for (Object obj : map.values())
-                        assertEquals("Iterators not removed for grid " + idx, 0, ((Map)obj).size());
-                }
-            });
-        }
+        for (int j = 0; j < gridCount(); j++)
+            executeOnLocalOrRemoteJvm(j, new CheckIteratorTask());
     }
 
     /**
@@ -5226,4 +5084,280 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
         /** */
         ONE_BY_ONE
     }
+
+    /**
+     *
+     */
+    private static class RemoveEntryProcessor implements EntryProcessor<String, Integer, String>, Serializable {
+        /** {@inheritDoc} */
+        @Override public String process(MutableEntry<String, Integer> e, Object... args) {
+            assertNotNull(e.getKey());
+
+            Integer old = e.getValue();
+
+            e.remove();
+
+            return String.valueOf(old);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class IncrementEntryProcessor implements EntryProcessor<String, Integer, String>, Serializable {
+        /** {@inheritDoc} */
+        @Override public String process(MutableEntry<String, Integer> e, Object... args) {
+            assertNotNull(e.getKey());
+
+            Integer old = e.getValue();
+
+            e.setValue(old == null ? 1 : old + 1);
+
+            return String.valueOf(old);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class CheckEntriesTask extends TestIgniteIdxRunnable {
+        /** Keys. */
+        private final Collection<String> keys;
+
+        /**
+         * @param keys Keys.
+         */
+        public CheckEntriesTask(Collection<String> keys) {
+            this.keys = keys;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void run(int idx) throws Exception {
+            GridCacheContext<String, Integer> ctx = ((IgniteKernal)ignite).<String, Integer>internalCache().context();
+
+            if (ctx.cache().configuration().getMemoryMode() == OFFHEAP_TIERED)
+                return;
+
+            int size = 0;
+
+            for (String key : keys) {
+                if (ctx.affinity().localNode(key, ctx.discovery().topologyVersionEx())) {
+                    GridCacheEntryEx e =
+                        ctx.isNear() ? ctx.near().dht().peekEx(key) : ctx.cache().peekEx(key);
+
+                    assert e != null : "Entry is null [idx=" + idx + ", key=" + key + ", ctx=" + ctx + ']';
+                    assert !e.deleted() : "Entry is deleted: " + e;
+
+                    size++;
+                }
+            }
+
+            assertEquals("Incorrect size on cache #" + idx, size, ignite.cache(ctx.name()).localSize(ALL));
+        }
+    }
+
+    /**
+     *
+     */
+    private static class CheckCacheSizeTask extends TestIgniteIdxRunnable {
+        private final Map<String, Integer> map;
+
+        /**
+         * @param map Map.
+         */
+        public CheckCacheSizeTask(Map<String, Integer> map) {
+            this.map = map;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void run(int idx) throws Exception {
+            GridCacheContext<String, Integer> ctx = ((IgniteKernal)ignite).<String, Integer>internalCache().context();
+
+            int size = 0;
+
+            for (String key : map.keySet())
+                if (ctx.affinity().localNode(key, new AffinityTopologyVersion(ctx.discovery().topologyVersion())))
+                    size++;
+
+            assertEquals("Incorrect key size on cache #" + idx, size, ignite.cache(ctx.name()).localSize(ALL));
+        }
+    }
+
+    /**
+     *
+     */
+    private static class CheckPrimaryKeysTask implements TestCacheCallable<String, Integer, List<String>> {
+        /** Start from. */
+        private final int startFrom;
+
+        /** Count. */
+        private final int cnt;
+
+        /**
+         * @param startFrom Start from.
+         * @param cnt Count.
+         */
+        public CheckPrimaryKeysTask(int startFrom, int cnt) {
+            this.startFrom = startFrom;
+            this.cnt = cnt;
+        }
+
+        /** {@inheritDoc} */
+        @Override public List<String> call(Ignite ignite, IgniteCache<String, Integer> cache) throws Exception {
+            List<String> found = new ArrayList<>();
+
+            Affinity<Object> affinity = ignite.affinity(cache.getName());
+
+            for (int i = startFrom; i < startFrom + 100_000; i++) {
+                String key = "key" + i;
+
+                if (affinity.isPrimary(ignite.cluster().localNode(), key)) {
+                    found.add(key);
+
+                    if (found.size() == cnt)
+                        return found;
+                }
+            }
+
+            throw new IgniteException("Unable to find " + cnt + " keys as primary for cache.");
+        }
+    }
+
+    /**
+     *
+     */
+    private static class CheckIteratorTask extends TestIgniteIdxCallable<Void> {
+        /**
+         * @param idx Index.
+         */
+        @Override public Void call(int idx) throws Exception {
+            GridCacheContext<String, Integer> ctx = ((IgniteKernal)ignite).<String, Integer>internalCache().context();
+            GridCacheQueryManager queries = ctx.queries();
+
+            Map map = GridTestUtils.getFieldValue(queries, GridCacheQueryManager.class, "qryIters");
+
+            for (Object obj : map.values())
+                assertEquals("Iterators not removed for grid " + idx, 0, ((Map)obj).size());
+
+            return null;
+        }
+    }
+
+    /**
+     *
+     */
+    private static class RemoveAndReturnNullEntryProcessor implements
+        EntryProcessor<String, Integer, Integer>, Serializable {
+
+        /** {@inheritDoc} */
+        @Override public Integer process(MutableEntry<String, Integer> e, Object... args) {
+            e.remove();
+
+            return null;
+        }
+    }
+
+    /**
+     *
+     */
+    private static class SwapEvtsLocalListener implements IgnitePredicate<Event> {
+        @LoggerResource
+        private IgniteLogger log;
+
+        /** Swap events. */
+        private final AtomicInteger swapEvts;
+
+        /** Unswap events. */
+        private final AtomicInteger unswapEvts;
+
+        /**
+         * @param swapEvts Swap events.
+         * @param unswapEvts Unswap events.
+         */
+        public SwapEvtsLocalListener(AtomicInteger swapEvts, AtomicInteger unswapEvts) {
+            this.swapEvts = swapEvts;
+            this.unswapEvts = unswapEvts;
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean apply(Event evt) {
+            log.info("Received event: " + evt);
+
+            switch (evt.type()) {
+                case EVT_CACHE_OBJECT_SWAPPED:
+                    swapEvts.incrementAndGet();
+
+                    break;
+                case EVT_CACHE_OBJECT_UNSWAPPED:
+                    unswapEvts.incrementAndGet();
+
+                    break;
+            }
+
+            return true;
+        }
+    }
+
+    private static class CheckEntriesDeletedTask extends TestIgniteIdxRunnable {
+        private final int cnt;
+
+        public CheckEntriesDeletedTask(int cnt) {
+            this.cnt = cnt;
+        }
+
+        @Override public void run(int idx) throws Exception {
+            for (int i = 0; i < cnt; i++) {
+                String key = String.valueOf(i);
+
+                GridCacheContext<String, Integer> ctx = ((IgniteKernal)ignite).<String, Integer>internalCache().context();
+
+                GridCacheEntryEx entry = ctx.isNear() ? ctx.near().dht().peekEx(key) : ctx.cache().peekEx(key);
+
+                if (ignite.affinity(null).mapKeyToPrimaryAndBackups(key).contains(((IgniteKernal)ignite).localNode())) {
+                    assertNotNull(entry);
+                    assertTrue(entry.deleted());
+                }
+                else
+                    assertNull(entry);
+            }
+        }
+    }
+
+    /**
+     *
+     */
+    private static class CheckKeySizeTask extends TestIgniteIdxRunnable {
+        /** Keys. */
+        private final Collection<String> keys;
+
+        /**
+         * @param keys Keys.
+         */
+        public CheckKeySizeTask(Collection<String> keys) {
+            this.keys = keys;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void run(int idx) throws Exception {
+            GridCacheContext<String, Integer> ctx = ((IgniteKernal)ignite).<String, Integer>internalCache().context();
+
+            int size = 0;
+
+            for (String key : keys)
+                if (ctx.affinity().localNode(key, ctx.discovery().topologyVersionEx()))
+                    size++;
+
+            assertEquals("Incorrect key size on cache #" + idx, size, ignite.cache(null).localSize(ALL));
+        }
+    }
+
+    /**
+     *
+     */
+    private static class FailedEntryProcessor implements EntryProcessor<String, Integer, Integer>, Serializable {
+        /** {@inheritDoc} */
+        @Override public Integer process(MutableEntry<String, Integer> e, Object... args) {
+            throw new EntryProcessorException("Test entry processor exception.");
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/5fc682f1/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNoValueClassOnServerNodeTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNoValueClassOnServerNodeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNoValueClassOnServerNodeTest.java
index da694b5..c6ce81e 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNoValueClassOnServerNodeTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNoValueClassOnServerNodeTest.java
@@ -111,6 +111,7 @@ public class CacheNoValueClassOnServerNodeTest extends GridCommonAbstractTest {
                         }
                     },
                     null,
+                    null,
                     jvmArgs,
                     cp
                 );

http://git-wip-us.apache.org/repos/asf/ignite/blob/5fc682f1/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest.java
index 1511c45..927ee62 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest.java
@@ -22,6 +22,7 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -29,6 +30,7 @@ import java.util.concurrent.atomic.AtomicInteger;
 import javax.cache.expiry.Duration;
 import javax.cache.expiry.TouchedExpiryPolicy;
 import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteLogger;
 import org.apache.ignite.cache.CacheAtomicityMode;
 import org.apache.ignite.cache.CachePeekMode;
 import org.apache.ignite.configuration.CacheConfiguration;
@@ -37,6 +39,7 @@ import org.apache.ignite.events.Event;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.resources.LoggerResource;
 
 import static java.util.concurrent.TimeUnit.MILLISECONDS;
 import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
@@ -106,9 +109,11 @@ public class GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest extends GridCache
 
         affinityNodes(); // Just to ack cache configuration to log..
 
-        checkKeySize(map.keySet());
+        Set<String> keys = new LinkedHashSet<>(map.keySet());
 
-        checkSize(map.keySet());
+        checkKeySize(keys);
+
+        checkSize(keys);
 
         int fullCacheSize = 0;
 
@@ -317,24 +322,8 @@ public class GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest extends GridCache
         Collection<String> locKeys = new HashSet<>();
 
         for (int i = 0; i < gridCount(); i++) {
-            grid(i).events().localListen(new IgnitePredicate<Event>() {
-                @Override public boolean apply(Event evt) {
-                    info("Received event: " + evt);
-
-                    switch (evt.type()) {
-                        case EVT_CACHE_OBJECT_SWAPPED:
-                            swapEvts.incrementAndGet();
-
-                            break;
-                        case EVT_CACHE_OBJECT_UNSWAPPED:
-                            unswapEvts.incrementAndGet();
-
-                            break;
-                    }
-
-                    return true;
-                }
-            }, EVT_CACHE_OBJECT_SWAPPED, EVT_CACHE_OBJECT_UNSWAPPED);
+            grid(i).events().localListen(
+                new LocalListener(swapEvts, unswapEvts), EVT_CACHE_OBJECT_SWAPPED, EVT_CACHE_OBJECT_UNSWAPPED);
         }
 
         cache.localEvict(Collections.singleton(k2));
@@ -416,4 +405,46 @@ public class GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest extends GridCache
         assertEquals(cnt, swapEvts.get());
         assertEquals(cnt, unswapEvts.get());
     }
+
+    /**
+     *
+     */
+    private static class LocalListener implements IgnitePredicate<Event> {
+        /** Logger. */
+        @LoggerResource
+        private IgniteLogger log;
+
+        /** Swap events. */
+        private final AtomicInteger swapEvts;
+
+        /** Unswap events. */
+        private final AtomicInteger unswapEvts;
+
+        /**
+         * @param swapEvts Swap events.
+         * @param unswapEvts Unswap events.
+         */
+        public LocalListener(AtomicInteger swapEvts, AtomicInteger unswapEvts) {
+            this.swapEvts = swapEvts;
+            this.unswapEvts = unswapEvts;
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean apply(Event evt) {
+            log.info("Received event: " + evt);
+
+            switch (evt.type()) {
+                case EVT_CACHE_OBJECT_SWAPPED:
+                    swapEvts.incrementAndGet();
+
+                    break;
+                case EVT_CACHE_OBJECT_UNSWAPPED:
+                    unswapEvts.incrementAndGet();
+
+                    break;
+            }
+
+            return true;
+        }
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/5fc682f1/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java
index c04bf2e..a2440e2 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java
@@ -20,11 +20,14 @@ package org.apache.ignite.internal.processors.cache.distributed.near;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.HashSet;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteAtomicLong;
 import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteLogger;
 import org.apache.ignite.cache.CacheMemoryMode;
 import org.apache.ignite.cache.CachePeekMode;
 import org.apache.ignite.cache.affinity.Affinity;
@@ -36,6 +39,8 @@ import org.apache.ignite.internal.IgniteEx;
 import org.apache.ignite.internal.IgniteKernal;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.resources.IgniteInstanceResource;
+import org.apache.ignite.resources.LoggerResource;
 
 import static org.apache.ignite.cache.CacheMode.PARTITIONED;
 import static org.apache.ignite.cache.CacheMode.REPLICATED;
@@ -93,7 +98,7 @@ public class GridCachePartitionedMultiNodeFullApiSelfTest extends GridCacheParti
 
         atomicClockModeDelay(c0);
 
-        c1.removeAll(putMap.keySet());
+        c1.removeAll(new HashSet<>(putMap.keySet()));
 
         for (int i = 0; i < size; i++) {
             assertNull(c0.get(i));
@@ -159,22 +164,8 @@ public class GridCachePartitionedMultiNodeFullApiSelfTest extends GridCacheParti
             info("Finished putting value [i=" + i + ']');
         }
 
-        for (int i = 0; i < gridCount(); i++) {
-            executeOnLocalOrRemoteJvm(i, new TestIgniteIdxRunnable() {
-                @Override public void run(int idx) throws Exception {
-                    assertEquals(0, context(idx).tm().idMapSize());
-
-                    IgniteCache<Object, Object> cache = grid(idx).cache(null);
-                    ClusterNode node = grid(idx).localNode();
-
-                    for (int k = 0; k < size; k++) {
-                        if (affinity(cache).isPrimaryOrBackup(node, k))
-                            assertEquals("Check failed for node: " + node.id(), k,
-                                cache.localPeek(k, CachePeekMode.ONHEAP, CachePeekMode.OFFHEAP));
-                    }
-                }
-            });
-        }
+        for (int i = 0; i < gridCount(); i++)
+            executeOnLocalOrRemoteJvm(i, new CheckAffinityTask(size));
 
         for (int i = 0; i < size; i++) {
             info("Putting value 2 [i=" + i + ']');
@@ -199,28 +190,9 @@ public class GridCachePartitionedMultiNodeFullApiSelfTest extends GridCacheParti
 
         final IgniteAtomicLong unswapEvts = grid(0).atomicLong("unswapEvts", 0, true);
 
-        for (int i = 0; i < gridCount(); i++) {
-            final int iCopy = i;
-
-            grid(i).events().localListen(new IgnitePredicate<Event>() {
-                @Override public boolean apply(Event evt) {
-                    info("Received event: " + evt);
-
-                    switch (evt.type()) {
-                        case EVT_CACHE_OBJECT_SWAPPED:
-                            grid(iCopy).atomicLong("swapEvts", 0, false).incrementAndGet();
-
-                            break;
-                        case EVT_CACHE_OBJECT_UNSWAPPED:
-                            grid(iCopy).atomicLong("unswapEvts", 0, false).incrementAndGet();
-
-                            break;
-                    }
-
-                    return true;
-                }
-            }, EVT_CACHE_OBJECT_SWAPPED, EVT_CACHE_OBJECT_UNSWAPPED);
-        }
+        for (int i = 0; i < gridCount(); i++)
+            grid(i).events().localListen(
+                    new SwapUnswapLocalListener(), EVT_CACHE_OBJECT_SWAPPED, EVT_CACHE_OBJECT_UNSWAPPED);
 
         jcache().put("key", 1);
 
@@ -254,13 +226,8 @@ public class GridCachePartitionedMultiNodeFullApiSelfTest extends GridCacheParti
 
             boolean nearEnabled = nearEnabled(c);
 
-            if (nearEnabled) {
-                executeOnLocalOrRemoteJvm(i, new TestIgniteIdxRunnable() {
-                    @Override public void run(int idx) throws Exception {
-                        assertTrue(((IgniteKernal)ignite(idx)).internalCache().context().isNear());
-                    }
-                });
-            }
+            if (nearEnabled)
+                executeOnLocalOrRemoteJvm(i, new IsNearTask());
 
             Integer nearPeekVal = nearEnabled ? 1 : null;
 
@@ -476,4 +443,74 @@ public class GridCachePartitionedMultiNodeFullApiSelfTest extends GridCacheParti
             assertFalse(affinity(cache).isPrimaryOrBackup(other, key));
         }
     }
+
+    /**
+     *
+     */
+    private static class SwapUnswapLocalListener implements IgnitePredicate<Event> {
+        /** Logger. */
+        @LoggerResource
+        private IgniteLogger log;
+
+        /** Ignite. */
+        @IgniteInstanceResource
+        private Ignite ignite;
+
+        /** {@inheritDoc} */
+        @Override public boolean apply(Event evt) {
+            log.info("Received event: " + evt);
+
+            switch (evt.type()) {
+                case EVT_CACHE_OBJECT_SWAPPED:
+                    ignite.atomicLong("swapEvts", 0, false).incrementAndGet();
+
+                    break;
+                case EVT_CACHE_OBJECT_UNSWAPPED:
+                    ignite.atomicLong("unswapEvts", 0, false).incrementAndGet();
+
+                    break;
+            }
+
+            return true;
+        }
+    }
+
+    /**
+     *
+     */
+    private static class CheckAffinityTask extends TestIgniteIdxRunnable {
+        /** Size. */
+        private final int size;
+
+        /**
+         * @param size Size.
+         */
+        public CheckAffinityTask(int size) {
+            this.size = size;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void run(int idx) throws Exception {
+            assertEquals(0, ((IgniteKernal)ignite).<String, Integer>internalCache().context().tm().idMapSize());
+
+            IgniteCache<Object, Object> cache = ignite.cache(null);
+            ClusterNode node = ((IgniteKernal)ignite).localNode();
+
+            for (int k = 0; k < size; k++) {
+                if (affinity(cache).isPrimaryOrBackup(node, k))
+                    assertEquals("Check failed for node: " + node.id(), k,
+                        cache.localPeek(k, CachePeekMode.ONHEAP, CachePeekMode.OFFHEAP));
+            }
+        }
+    }
+
+    /**
+     *
+     */
+    private static class IsNearTask extends TestIgniteIdxRunnable {
+        /** {@inheritDoc} */
+        @Override public void run(int idx) throws Exception {
+            assertTrue(((IgniteKernal)ignite).internalCache().context().isNear());
+        }
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/5fc682f1/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 f54fe06..d133a84 100644
--- 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
@@ -73,6 +73,7 @@ import org.apache.ignite.lang.IgniteClosure;
 import org.apache.ignite.marshaller.Marshaller;
 import org.apache.ignite.marshaller.MarshallerExclusions;
 import org.apache.ignite.marshaller.jdk.JdkMarshaller;
+import org.apache.ignite.resources.IgniteInstanceResource;
 import org.apache.ignite.spi.checkpoint.sharedfs.SharedFsCheckpointSpi;
 import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
 import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
@@ -1471,6 +1472,8 @@ public abstract class GridAbstractTest extends TestCase {
 
         if (!isMultiJvmObject(ignite))
             try {
+                job.setIgnite(ignite);
+
                 return job.call(idx);
             }
             catch (Exception e) {
@@ -1532,11 +1535,7 @@ public abstract class GridAbstractTest extends TestCase {
 
         IgniteProcessProxy proxy = (IgniteProcessProxy)ignite;
 
-        return proxy.remoteCompute().call(new IgniteCallable<R>() {
-            @Override public R call() throws Exception {
-                return job.call(idx);
-            }
-        });
+        return proxy.remoteCompute().call(new ExecuteRemotelyTask<>(job, idx));
     }
 
     /**
@@ -1546,15 +1545,7 @@ public abstract class GridAbstractTest extends TestCase {
      * @param job Job.
      */
     public static <R> R executeRemotely(IgniteProcessProxy proxy, final TestIgniteCallable<R> job) {
-        final UUID id = proxy.getId();
-
-        return proxy.remoteCompute().call(new IgniteCallable<R>() {
-            @Override public R call() throws Exception {
-                Ignite ignite = Ignition.ignite(id);
-
-                return job.call(ignite);
-            }
-        });
+        return proxy.remoteCompute().call(new TestRemoteTask<>(proxy.getId(), job));
     }
 
     /**
@@ -1571,6 +1562,8 @@ public abstract class GridAbstractTest extends TestCase {
         final String cacheName = cache.getName();
 
         return proxy.remoteCompute().call(new IgniteCallable<R>() {
+            private static final long serialVersionUID = -3868429485920845137L;
+
             @Override public R call() throws Exception {
                 Ignite ignite = Ignition.ignite(id);
                 IgniteCache<K,V> cache = ignite.cache(cacheName);
@@ -1745,6 +1738,22 @@ public abstract class GridAbstractTest extends TestCase {
     }
 
     /**
+     * @param name Name.
+     * @param remote Remote.
+     * @param thisRemote This remote.
+     */
+    public static IgniteEx grid(String name, boolean remote, boolean thisRemote) {
+        if (!remote)
+            return (IgniteEx)G.ignite(name);
+        else {
+            if (thisRemote)
+                return IgniteNodeRunner.startedInstance();
+            else
+                return IgniteProcessProxy.ignite(name);
+        }
+    }
+
+    /**
      *
      */
     private static interface WriteReplaceOwner {
@@ -1781,6 +1790,67 @@ public abstract class GridAbstractTest extends TestCase {
     }
 
     /**
+     * Remote computation task.
+     */
+    private static class TestRemoteTask<R> implements IgniteCallable<R> {
+        /** */
+        private static final long serialVersionUID = 0L;
+
+        /** Node ID. */
+        private final UUID id;
+
+        /** Job. */
+        private final TestIgniteCallable<R> job;
+
+        /**
+         * @param id Id.
+         * @param job Job.
+         */
+        public TestRemoteTask(UUID id, TestIgniteCallable<R> job) {
+            this.id = id;
+            this.job = job;
+        }
+
+        /** {@inheritDoc} */
+        @Override public R call() throws Exception {
+            Ignite ignite = Ignition.ignite(id);
+
+            return job.call(ignite);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class ExecuteRemotelyTask<R> implements IgniteCallable<R> {
+        /** Ignite. */
+        @IgniteInstanceResource
+        protected Ignite ignite;
+
+        /** Job. */
+        private final TestIgniteIdxCallable<R> job;
+
+        /** Index. */
+        private final int idx;
+
+        /**
+         * @param job Job.
+         * @param idx Index.
+         */
+        public ExecuteRemotelyTask(TestIgniteIdxCallable<R> job, int idx) {
+            this.job = job;
+            this.idx = idx;
+        }
+
+        /** {@inheritDoc} */
+        @Override public R call() throws Exception {
+            job.setIgnite(ignite);
+
+            return job.call(idx);
+        }
+    }
+
+    /**
      * Test counters.
      */
     protected class TestCounters {
@@ -1923,17 +1993,27 @@ public abstract class GridAbstractTest extends TestCase {
     }
 
     /** */
-    public static interface TestIgniteIdxCallable<R> extends Serializable {
+    public static abstract class TestIgniteIdxCallable<R> implements Serializable {
+        @IgniteInstanceResource
+        protected Ignite ignite;
+
+        /**
+         * @param ignite Ignite.
+         */
+        public void setIgnite(Ignite ignite) {
+            this.ignite = ignite;
+        }
+
         /**
          * @param idx Grid index.
          */
-        R call(int idx) throws Exception;
+        protected abstract R call(int idx) throws Exception;
     }
 
     /** */
-    public abstract static class TestIgniteIdxRunnable implements TestIgniteIdxCallable<Object> {
+    public abstract static class TestIgniteIdxRunnable extends TestIgniteIdxCallable<Void> {
         /** {@inheritDoc} */
-        @Override public Object call(int idx) throws Exception {
+        @Override public Void call(int idx) throws Exception {
             run(idx);
 
             return null;

http://git-wip-us.apache.org/repos/asf/ignite/blob/5fc682f1/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteTestResources.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteTestResources.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteTestResources.java
index eb72252..406318f 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteTestResources.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteTestResources.java
@@ -42,6 +42,9 @@ import org.jetbrains.annotations.Nullable;
  * Test resources for injection.
  */
 public class IgniteTestResources {
+    /** Marshaller class name. */
+    public static final String MARSH_CLASS_NAME = "test.marshaller.class";
+
     /** */
     private static final IgniteLogger rootLog = new GridTestLog4jLogger(false);
 
@@ -230,8 +233,9 @@ public class IgniteTestResources {
      * @throws IgniteCheckedException If failed.
      */
     @SuppressWarnings("unchecked")
-    public synchronized Marshaller getMarshaller() throws IgniteCheckedException {
-        String marshallerName = GridTestProperties.getProperty(GridTestProperties.MARSH_CLASS_NAME);
+    public static synchronized Marshaller getMarshaller() throws IgniteCheckedException {
+        String marshallerName =
+            System.getProperty(MARSH_CLASS_NAME, GridTestProperties.getProperty(GridTestProperties.MARSH_CLASS_NAME));
 
         Marshaller marsh;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/5fc682f1/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 4bcf51e..e4c2129 100644
--- 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
@@ -246,10 +246,12 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest {
     protected static <K, V> boolean nearEnabled(final IgniteCache<K,V> cache) {
         CacheConfiguration cfg = GridAbstractTest.executeOnLocalOrRemoteJvm(cache,
             new TestCacheCallable<K, V, CacheConfiguration>() {
-            @Override public CacheConfiguration call(Ignite ignite, IgniteCache<K, V> cache) throws Exception {
-                return ((IgniteKernal)ignite).<K, V>internalCache(cache.getName()).context().config();
-            }
-        });
+                private static final long serialVersionUID = 0L;
+
+                @Override public CacheConfiguration call(Ignite ignite, IgniteCache<K, V> cache) throws Exception {
+                    return ((IgniteKernal)ignite).<K, V>internalCache(cache.getName()).context().config();
+                }
+            });
 
         return isNearEnabled(cfg);
     }
@@ -285,10 +287,13 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest {
      * @throws Exception If failed.
      */
     @SuppressWarnings("unchecked")
-    protected static <K> void loadAll(Cache<K, ?> cache, final Set<K> keys, final boolean replaceExistingValues) throws Exception {
+    protected static <K> void loadAll(Cache<K, ?> cache, final Set<K> keys, final boolean replaceExistingValues)
+        throws Exception {
         IgniteCache<K, Object> cacheCp = (IgniteCache<K, Object>)cache;
 
         GridAbstractTest.executeOnLocalOrRemoteJvm(cacheCp, new TestCacheRunnable<K, Object>() {
+            private static final long serialVersionUID = -3030833765012500545L;
+
             @Override public void run(Ignite ignite, IgniteCache<K, Object> cache) throws Exception {
                 final AtomicReference<Exception> ex = new AtomicReference<>();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/5fc682f1/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/AffinityProcessProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/AffinityProcessProxy.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/AffinityProcessProxy.java
index e1959e5..57fbcfc 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/AffinityProcessProxy.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/AffinityProcessProxy.java
@@ -19,12 +19,12 @@ package org.apache.ignite.testframework.junits.multijvm;
 
 import java.util.Collection;
 import java.util.Map;
-import java.util.UUID;
+import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCompute;
-import org.apache.ignite.Ignition;
 import org.apache.ignite.cache.affinity.Affinity;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.lang.IgniteCallable;
+import org.apache.ignite.resources.IgniteInstanceResource;
 import org.jetbrains.annotations.Nullable;
 
 /**
@@ -38,160 +38,388 @@ public class AffinityProcessProxy<K> implements Affinity<K> {
     /** Cache name. */
     private final String cacheName;
 
-    /** Grid id. */
-    private final UUID gridId;
-
     /**
      * @param cacheName Cache name.
-     * @param proxy Ignite ptocess proxy.
+     * @param proxy Ignite process proxy.
      */
     public AffinityProcessProxy(String cacheName, IgniteProcessProxy proxy) {
         this.cacheName = cacheName;
-        gridId = proxy.getId();
-        compute = proxy.remoteCompute();
-    }
-
-    /**
-     * Returns cache instance. Method to be called from closure at another JVM.
-     *
-     * @return Cache.
-     */
-    private Affinity<Object> affinity() {
-        return Ignition.ignite(gridId).affinity(cacheName);
+        this.compute = proxy.remoteCompute();
     }
 
     /** {@inheritDoc} */
     @Override public int partitions() {
-        return (int)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return affinity().partitions();
-            }
-        });
+        return compute.call(new PartitionsTask(cacheName));
     }
 
     /** {@inheritDoc} */
-    @Override public int partition(final K key) {
-        return (int)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return affinity().partition(key);
-            }
-        });
+    @Override public int partition(K key) {
+        return compute.call(new PartitionTask<>(cacheName, key));
     }
 
     /** {@inheritDoc} */
-    @Override public boolean isPrimary(final ClusterNode n, final K key) {
-        return (boolean)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return affinity().isPrimary(n, key);
-            }
-        });
+    @Override public boolean isPrimary(ClusterNode n, K key) {
+        return compute.call(new PrimaryOrBackupNodeTask<>(cacheName, key, n, true, false));
     }
 
     /** {@inheritDoc} */
-    @Override public boolean isBackup(final ClusterNode n, final K key) {
-        return (boolean)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return affinity().isBackup(n, key);
-            }
-        });
+    @Override public boolean isBackup(ClusterNode n, K key) {
+        return compute.call(new PrimaryOrBackupNodeTask<>(cacheName, key, n, false, true));
     }
 
     /** {@inheritDoc} */
-    @Override public boolean isPrimaryOrBackup(final ClusterNode n, final K key) {
-        return (boolean)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return affinity().isPrimaryOrBackup(n, key);
-            }
-        });
+    @Override public boolean isPrimaryOrBackup(ClusterNode n, K key) {
+        return compute.call(new PrimaryOrBackupNodeTask<>(cacheName, key, n, true, true));
     }
 
     /** {@inheritDoc} */
-    @Override public int[] primaryPartitions(final ClusterNode n) {
-        return (int[])compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return affinity().primaryPartitions(n);
-            }
-        });
+    @Override public int[] primaryPartitions(ClusterNode n) {
+        return compute.call(new GetPartitionsTask(cacheName, n, true, false));
     }
 
     /** {@inheritDoc} */
-    @Override public int[] backupPartitions(final ClusterNode n) {
-        return (int[])compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return affinity().backupPartitions(n);
-            }
-        });
+    @Override public int[] backupPartitions(ClusterNode n) {
+        return compute.call(new GetPartitionsTask(cacheName, n, false, true));
     }
 
     /** {@inheritDoc} */
-    @Override public int[] allPartitions(final ClusterNode n) {
-        return (int[])compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return affinity().allPartitions(n);
-            }
-        });
+    @Override public int[] allPartitions(ClusterNode n) {
+        return compute.call(new GetPartitionsTask(cacheName, n, true, true));
     }
 
     /** {@inheritDoc} */
-    @Override public Object affinityKey(final K key) {
-        return compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return affinity().affinityKey(key);
-            }
-        });
+    @Override public Object affinityKey(K key) {
+        return compute.call(new AffinityKeyTask<>(cacheName, key));
     }
 
     /** {@inheritDoc} */
-    @Override public Map<ClusterNode, Collection<K>> mapKeysToNodes(final Collection<? extends K> keys) {
-        return (Map<ClusterNode, Collection<K>>)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return affinity().mapKeysToNodes(keys);
-            }
-        });
+    @Override public Map<ClusterNode, Collection<K>> mapKeysToNodes(Collection<? extends K> keys) {
+        return compute.call(new MapKeysToNodesTask<>(cacheName, keys));
     }
 
     /** {@inheritDoc} */
-    @Nullable @Override public ClusterNode mapKeyToNode(final K key) {
-        return (ClusterNode)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return affinity().mapKeyToNode(key);
-            }
-        });
+    @Nullable @Override public ClusterNode mapKeyToNode(K key) {
+        return compute.call(new MapKeyToNodeTask<>(cacheName, key));
     }
 
     /** {@inheritDoc} */
-    @Override public Collection<ClusterNode> mapKeyToPrimaryAndBackups(final K key) {
-        return (Collection<ClusterNode>)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return affinity().mapKeyToPrimaryAndBackups(key);
-            }
-        });
+    @Override public Collection<ClusterNode> mapKeyToPrimaryAndBackups(K key) {
+        return compute.call(new MapKeyToPrimaryAndBackupsTask<>(cacheName, key));
     }
 
     /** {@inheritDoc} */
-    @Override public ClusterNode mapPartitionToNode(final int part) {
-        return (ClusterNode)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return affinity().mapPartitionToNode(part);
-            }
-        });
+    @Override public ClusterNode mapPartitionToNode(int part) {
+        return compute.call(new MapPartitionToNode<>(cacheName, part));
     }
 
     /** {@inheritDoc} */
-    @Override public Map<Integer, ClusterNode> mapPartitionsToNodes(final Collection<Integer> parts) {
-        return (Map<Integer, ClusterNode>)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return affinity().mapPartitionsToNodes(parts);
-            }
-        });
+    @Override public Map<Integer, ClusterNode> mapPartitionsToNodes(Collection<Integer> parts) {
+        return compute.call(new MapPartitionsToNodes<>(cacheName, parts));
     }
 
     /** {@inheritDoc} */
-    @Override public Collection<ClusterNode> mapPartitionToPrimaryAndBackups(final int part) {
-        return (Collection<ClusterNode>)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return affinity().mapPartitionToPrimaryAndBackups(part);
-            }
-        });
+    @Override public Collection<ClusterNode> mapPartitionToPrimaryAndBackups(int part) {
+        return compute.call(new MapPartitionsToPrimaryAndBackupsTask<>(cacheName, part));
+    }
+
+    /**
+     *
+     */
+    private static class PrimaryOrBackupNodeTask<K> extends AffinityTaskAdapter<K, Boolean> {
+        /** Key. */
+        private final K key;
+
+        /** Node. */
+        private final ClusterNode n;
+
+        /** Primary. */
+        private final boolean primary;
+
+        /** Backup. */
+        private final boolean backup;
+
+        /**
+         * @param cacheName Cache name.
+         * @param key Key.
+         * @param n N.
+         */
+        public PrimaryOrBackupNodeTask(String cacheName, K key, ClusterNode n,
+            boolean primary, boolean backup) {
+            super(cacheName);
+            this.key = key;
+            this.n = n;
+            this.primary = primary;
+            this.backup = backup;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Boolean call() throws Exception {
+            if (primary && backup)
+                return affinity().isPrimaryOrBackup(n, key);
+            else if (primary)
+                return affinity().isPrimary(n, key);
+            else if (backup)
+                return affinity().isBackup(n, key);
+            else
+                throw new IllegalStateException("primary or backup or both flags should be switched on");
+        }
+    }
+
+    /**
+     *
+     */
+    private static class MapKeyToPrimaryAndBackupsTask<K> extends AffinityTaskAdapter<K, Collection<ClusterNode>> {
+        /** Key. */
+        private final K key;
+
+        /**
+         * @param cacheName Cache name.
+         * @param key Key.
+         */
+        public MapKeyToPrimaryAndBackupsTask(String cacheName, K key) {
+            super(cacheName);
+            this.key = key;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Collection<ClusterNode> call() throws Exception {
+            return affinity().mapKeyToPrimaryAndBackups(key);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class PartitionsTask extends AffinityTaskAdapter<Void, Integer> {
+        /**
+         * @param cacheName Cache name.
+         */
+        public PartitionsTask(String cacheName) {
+            super(cacheName);
+        }
+
+        /** {@inheritDoc} */
+        @Override public Integer call() throws Exception {
+            return affinity().partitions();
+        }
+    }
+
+    /**
+     *
+     */
+    private static class PartitionTask<K> extends AffinityTaskAdapter<K, Integer> {
+        /** Key. */
+        private final K key;
+
+        /**
+         * @param cacheName Cache name.
+         * @param key Key.
+         */
+        public PartitionTask(String cacheName, K key) {
+            super(cacheName);
+            this.key = key;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Integer call() throws Exception {
+            return affinity().partition(key);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class GetPartitionsTask extends AffinityTaskAdapter<Void, int[]> {
+        /** Node. */
+        private final ClusterNode n;
+
+        /** Primary. */
+        private final boolean primary;
+
+        /** Backup. */
+        private final boolean backup;
+
+        /**
+         * @param cacheName Cache name.
+         * @param n N.
+         * @param primary Primary.
+         * @param backup Backup.
+         */
+        public GetPartitionsTask(String cacheName, ClusterNode n, boolean primary, boolean backup) {
+            super(cacheName);
+            this.n = n;
+            this.primary = primary;
+            this.backup = backup;
+        }
+
+        /** {@inheritDoc} */
+        @Override public int[] call() throws Exception {
+            if (primary && backup)
+                return affinity().allPartitions(n);
+            else if (primary)
+                return affinity().primaryPartitions(n);
+            else if (backup)
+                return affinity().backupPartitions(n);
+            else
+                throw new IllegalStateException("primary or backup or both flags should be switched on");
+        }
+    }
+
+    /**
+     *
+     */
+    private static class AffinityKeyTask<K> extends AffinityTaskAdapter<K, Object> {
+        /** Key. */
+        private final K key;
+
+        /**
+         * @param cacheName Cache name.
+         * @param key Key.
+         */
+        public AffinityKeyTask(String cacheName, K key) {
+            super(cacheName);
+            this.key = key;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Object call() throws Exception {
+            return affinity().affinityKey(key);
+        }
+    }
+
+    /**
+     * @param <K>
+     */
+    private static class MapKeysToNodesTask<K> extends AffinityTaskAdapter<K, Map<ClusterNode, Collection<K>>> {
+        /** Keys. */
+        private final Collection<? extends K> keys;
+
+        /**
+         * @param cacheName Cache name.
+         * @param keys Keys.
+         */
+        public MapKeysToNodesTask(String cacheName, Collection<? extends K> keys) {
+            super(cacheName);
+            this.keys = keys;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Map<ClusterNode, Collection<K>> call() throws Exception {
+            return affinity().mapKeysToNodes(keys);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class MapKeyToNodeTask<K> extends AffinityTaskAdapter<K, ClusterNode> {
+        /** Key. */
+        private final K key;
+
+        /**
+         * @param cacheName Cache name.
+         * @param key Key.
+         */
+        public MapKeyToNodeTask(String cacheName, K key) {
+            super(cacheName);
+            this.key = key;
+        }
+
+        /** {@inheritDoc} */
+        @Override public ClusterNode call() throws Exception {
+            return affinity().mapKeyToNode(key);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class MapPartitionToNode<K> extends AffinityTaskAdapter<K, ClusterNode> {
+        /** Partition. */
+        private final int part;
+
+        /**
+         * @param cacheName Cache name.
+         * @param part Partition.
+         */
+        public MapPartitionToNode(String cacheName, int part) {
+            super(cacheName);
+            this.part = part;
+        }
+
+        /** {@inheritDoc} */
+        @Override public ClusterNode call() throws Exception {
+            return affinity().mapPartitionToNode(part);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class MapPartitionsToNodes<K> extends AffinityTaskAdapter<K, Map<Integer, ClusterNode>> {
+        /** Parts. */
+        private final Collection<Integer> parts;
+
+        /**
+         * @param cacheName Cache name.
+         * @param parts Parts.
+         */
+        public MapPartitionsToNodes(String cacheName, Collection<Integer> parts) {
+            super(cacheName);
+            this.parts = parts;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Map<Integer, ClusterNode> call() throws Exception {
+            return affinity().mapPartitionsToNodes(parts);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class MapPartitionsToPrimaryAndBackupsTask<K> extends AffinityTaskAdapter<K, Collection<ClusterNode>> {
+        /** Partition. */
+        private final int part;
+
+        /**
+         * @param cacheName Cache name.
+         * @param part Partition.
+         */
+        public MapPartitionsToPrimaryAndBackupsTask(String cacheName, int part) {
+            super(cacheName);
+            this.part = part;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Collection<ClusterNode> call() throws Exception {
+            return affinity().mapPartitionToPrimaryAndBackups(part);
+        }
+    }
+
+    /**
+     *
+     */
+    private abstract static class AffinityTaskAdapter<K, R> implements IgniteCallable<R> {
+        /** Ignite. */
+        @IgniteInstanceResource
+        protected Ignite ignite;
+
+        /** Cache name. */
+        protected final String cacheName;
+
+        /**
+         * @param cacheName Cache name.
+         */
+        public AffinityTaskAdapter(String cacheName) {
+            this.cacheName = cacheName;
+        }
+
+        /**
+         * @return Affinity.
+         */
+        protected Affinity<K> affinity() {
+            return ignite.affinity(cacheName);
+        }
     }
 }
\ No newline at end of file


[26/50] [abbrv] ignite git commit: IGNITE-1653

Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/cluster/ClusterGroupExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/cluster/ClusterGroupExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/cluster/ClusterGroupExample.java
new file mode 100644
index 0000000..caea8a7
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/cluster/ClusterGroupExample.java
@@ -0,0 +1,86 @@
+/*
+ *  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.examples.java8.cluster;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCluster;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cluster.ClusterGroup;
+import org.apache.ignite.examples.ExampleNodeStartup;
+import org.apache.ignite.examples.ExamplesUtils;
+
+/**
+ * Demonstrates new functional APIs.
+ * <p>
+ * Remote nodes should always be started with special configuration file which
+ * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
+ * <p>
+ * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
+ * with {@code examples/config/example-ignite.xml} configuration.
+ */
+public class ClusterGroupExample {
+    /**
+     * Executes example.
+     *
+     * @param args Command line arguments, none required.
+     * @throws IgniteException If example execution failed.
+     */
+    public static void main(String[] args) throws IgniteException {
+        try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+            if (!ExamplesUtils.checkMinTopologySize(ignite.cluster(), 2))
+                return;
+
+            System.out.println();
+            System.out.println("Compute example started.");
+
+            IgniteCluster cluster = ignite.cluster();
+
+            // Say hello to all nodes in the cluster, including local node.
+            sayHello(ignite, cluster);
+
+            // Say hello to all remote nodes.
+            sayHello(ignite, cluster.forRemotes());
+
+            // Pick random node out of remote nodes.
+            ClusterGroup randomNode = cluster.forRemotes().forRandom();
+
+            // Say hello to a random node.
+            sayHello(ignite, randomNode);
+
+            // Say hello to all nodes residing on the same host with random node.
+            sayHello(ignite, cluster.forHost(randomNode.node()));
+
+            // Say hello to all nodes that have current CPU load less than 50%.
+            sayHello(ignite, cluster.forPredicate(n -> n.metrics().getCurrentCpuLoad() < 0.5));
+        }
+    }
+
+    /**
+     * Print 'Hello' message on remote nodes.
+     *
+     * @param ignite Ignite.
+     * @param grp Cluster group.
+     * @throws IgniteException If failed.
+     */
+    private static void sayHello(Ignite ignite, final ClusterGroup grp) throws IgniteException {
+        // Print out hello message on all cluster nodes.
+        ignite.compute(grp).broadcast(
+            () -> System.out.println(">>> Hello Node: " + grp.ignite().cluster().localNode().id()));
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/cluster/package-info.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/cluster/package-info.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/cluster/package-info.java
new file mode 100644
index 0000000..b96e98a
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/cluster/package-info.java
@@ -0,0 +1,22 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+ * <!-- Package description. -->
+ * Cluster group example.
+ */
+package org.apache.ignite.examples.java8.cluster;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeAsyncExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeAsyncExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeAsyncExample.java
new file mode 100644
index 0000000..8d9cc64
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeAsyncExample.java
@@ -0,0 +1,75 @@
+/*
+ *  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.examples.java8.computegrid;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCompute;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.examples.ExampleNodeStartup;
+import org.apache.ignite.lang.IgniteFuture;
+import org.apache.ignite.lang.IgniteRunnable;
+
+/**
+ * Demonstrates a simple use of {@link IgniteRunnable}.
+ * <p>
+ * Remote nodes should always be started with special configuration file which
+ * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
+ * <p>
+ * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
+ * with {@code examples/config/example-ignite.xml} configuration.
+ */
+public class ComputeAsyncExample {
+    /**
+     * Executes example.
+     *
+     * @param args Command line arguments, none required.
+     * @throws IgniteException If example execution failed.
+     */
+    public static void main(String[] args) throws IgniteException {
+        try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+            System.out.println();
+            System.out.println("Compute asynchronous example started.");
+
+            // Enable asynchronous mode.
+            IgniteCompute compute = ignite.compute().withAsync();
+
+            Collection<IgniteFuture<?>> futs = new ArrayList<>();
+
+            // Iterate through all words in the sentence and create runnable jobs.
+            for (final String word : "Print words using runnable".split(" ")) {
+                // Execute runnable on some node.
+                compute.run(() -> {
+                    System.out.println();
+                    System.out.println(">>> Printing '" + word + "' on this node from ignite job.");
+                });
+
+                futs.add(compute.future());
+            }
+
+            // Wait for completion of all futures.
+            futs.forEach(IgniteFuture::get);
+
+            System.out.println();
+            System.out.println(">>> Finished printing words using runnable execution.");
+            System.out.println(">>> Check all nodes for output (this node is also part of the cluster).");
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeBroadcastExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeBroadcastExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeBroadcastExample.java
new file mode 100644
index 0000000..1aed33b
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeBroadcastExample.java
@@ -0,0 +1,102 @@
+/*
+ *  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.examples.java8.computegrid;
+
+import java.util.Collection;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.examples.ExampleNodeStartup;
+
+/**
+ * Demonstrates broadcasting computations within cluster.
+ * <p>
+ * Remote nodes should always be started with special configuration file which
+ * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
+ * <p>
+ * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
+ * with {@code examples/config/example-ignite.xml} configuration.
+ */
+public class ComputeBroadcastExample {
+    /**
+     * Executes example.
+     *
+     * @param args Command line arguments, none required.
+     * @throws IgniteException If example execution failed.
+     */
+    public static void main(String[] args) throws IgniteException {
+        try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+            System.out.println();
+            System.out.println(">>> Compute broadcast example started.");
+
+            // Print hello message on all nodes.
+            hello(ignite);
+
+            // Gather system info from all nodes.
+            gatherSystemInfo(ignite);
+       }
+    }
+
+    /**
+     * Print 'Hello' message on all nodes.
+     *
+     * @param ignite Ignite instance.
+     * @throws IgniteException If failed.
+     */
+    private static void hello(Ignite ignite) throws IgniteException {
+        // Print out hello message on all nodes.
+        ignite.compute().broadcast(() -> {
+            System.out.println();
+            System.out.println(">>> Hello Node! :)");
+        });
+
+        System.out.println();
+        System.out.println(">>> Check all nodes for hello message output.");
+    }
+
+    /**
+     * Gather system info from all nodes and print it out.
+     *
+     * @param ignite Ignite instance.
+     * @throws IgniteException if failed.
+     */
+    private static void gatherSystemInfo(Ignite ignite) throws IgniteException {
+        // Gather system info from all nodes.
+        Collection<String> res = ignite.compute().broadcast(() -> {
+            System.out.println();
+            System.out.println("Executing task on node: " + ignite.cluster().localNode().id());
+
+            return "Node ID: " + ignite.cluster().localNode().id() + "\n" +
+                "OS: " + System.getProperty("os.name") + " " + System.getProperty("os.version") + " " +
+                System.getProperty("os.arch") + "\n" +
+                "User: " + System.getProperty("user.name") + "\n" +
+                "JRE: " + System.getProperty("java.runtime.name") + " " +
+                System.getProperty("java.runtime.version");
+        });
+
+        // Print result.
+        System.out.println();
+        System.out.println("Nodes system information:");
+        System.out.println();
+
+        res.forEach(r -> {
+            System.out.println(r);
+            System.out.println();
+        });
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeCallableExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeCallableExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeCallableExample.java
new file mode 100644
index 0000000..cadb447
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeCallableExample.java
@@ -0,0 +1,75 @@
+/*
+ *  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.examples.java8.computegrid;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.examples.ExampleNodeStartup;
+import org.apache.ignite.lang.IgniteCallable;
+
+/**
+ * Demonstrates using of {@link IgniteCallable} job execution on the cluster.
+ * <p>
+ * This example takes a sentence composed of multiple words and counts number of non-space
+ * characters in the sentence by having each compute job count characters in each individual
+ * word.
+ * <p>
+ * Remote nodes should always be started with special configuration file which
+ * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
+ * <p>
+ * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
+ * with {@code examples/config/example-ignite.xml} configuration.
+ */
+public class ComputeCallableExample {
+    /**
+     * Executes example.
+     *
+     * @param args Command line arguments, none required.
+     * @throws IgniteException If example execution failed.
+     */
+    public static void main(String[] args) throws IgniteException {
+        try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+            System.out.println();
+            System.out.println(">>> Compute callable example started.");
+
+            Collection<IgniteCallable<Integer>> calls = new ArrayList<>();
+
+            // Iterate through all words in the sentence and create callable jobs.
+            for (String word : "Count characters using callable".split(" ")) {
+                calls.add(() -> {
+                    System.out.println();
+                    System.out.println(">>> Printing '" + word + "' on this node from ignite job.");
+
+                    return word.length();
+                });
+            }
+
+            // Execute collection of callables on the ignite.
+            Collection<Integer> res = ignite.compute().call(calls);
+
+            int sum = res.stream().mapToInt(i -> i).sum();
+
+            System.out.println();
+            System.out.println(">>> Total number of characters in the phrase is '" + sum + "'.");
+            System.out.println(">>> Check all nodes for output (this node is also part of the cluster).");
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeClosureExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeClosureExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeClosureExample.java
new file mode 100644
index 0000000..c4d3c94
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeClosureExample.java
@@ -0,0 +1,71 @@
+/*
+ *  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.examples.java8.computegrid;
+
+import java.util.Arrays;
+import java.util.Collection;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.examples.ExampleNodeStartup;
+
+/**
+ * Demonstrates a simple use of Ignite with reduce closure.
+ * <p>
+ * This example splits a phrase into collection of words, computes their length on different
+ * nodes and then computes total amount of non-whitespaces characters in the phrase.
+ * <p>
+ * Remote nodes should always be started with special configuration file which
+ * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
+ * <p>
+ * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
+ * with {@code examples/config/example-ignite.xml} configuration.
+ */
+public class ComputeClosureExample {
+    /**
+     * Executes example.
+     *
+     * @param args Command line arguments, none required.
+     * @throws IgniteException If example execution failed.
+     */
+    public static void main(String[] args) throws IgniteException {
+        try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+            System.out.println();
+            System.out.println(">>> Compute closure example started.");
+
+            // Execute closure on all cluster nodes.
+            Collection<Integer> res = ignite.compute().apply(
+                (String word) -> {
+                    System.out.println();
+                    System.out.println(">>> Printing '" + word + "' on this node from ignite job.");
+
+                    // Return number of letters in the word.
+                    return word.length();
+                },
+                // Job parameters. Ignite will create as many jobs as there are parameters.
+                Arrays.asList("Count characters using closure".split(" "))
+            );
+
+            int sum = res.stream().mapToInt(i -> i).sum();
+
+            System.out.println();
+            System.out.println(">>> Total number of characters in the phrase is '" + sum + "'.");
+            System.out.println(">>> Check all nodes for output (this node is also part of the cluster).");
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeRunnableExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeRunnableExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeRunnableExample.java
new file mode 100644
index 0000000..acb9893
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/ComputeRunnableExample.java
@@ -0,0 +1,64 @@
+/*
+ *  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.examples.java8.computegrid;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCompute;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.examples.ExampleNodeStartup;
+import org.apache.ignite.lang.IgniteRunnable;
+
+/**
+ * Demonstrates a simple use of {@link IgniteRunnable}.
+ * <p>
+ * Remote nodes should always be 0started with special configuration file which
+ * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
+ * <p>
+ * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
+ * with {@code examples/config/example-ignite.xml} configuration.
+ */
+public class ComputeRunnableExample {
+    /**
+     * Executes example.
+     *
+     * @param args Command line arguments, none required.
+     * @throws IgniteException If example execution failed.
+     */
+    public static void main(String[] args) throws IgniteException {
+        try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+            System.out.println();
+            System.out.println("Compute runnable example started.");
+
+            IgniteCompute compute = ignite.compute();
+
+            // Iterate through all words in the sentence and create runnable jobs.
+            for (final String word : "Print words using runnable".split(" ")) {
+                // Execute runnable on some node.
+                compute.run(() -> {
+                    System.out.println();
+                    System.out.println(">>> Printing '" + word + "' on this node from ignite job.");
+                });
+            }
+
+            System.out.println();
+            System.out.println(">>> Finished printing words using runnable execution.");
+            System.out.println(">>> Check all nodes for output (this node is also part of the cluster).");
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/package-info.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/package-info.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/package-info.java
new file mode 100644
index 0000000..cda49ef
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/computegrid/package-info.java
@@ -0,0 +1,22 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+ * <!-- Package description. -->
+ * Basic examples for computational ignite functionality.
+ */
+package org.apache.ignite.examples.java8.computegrid;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAffinityExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAffinityExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAffinityExample.java
new file mode 100644
index 0000000..f4a3b03
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAffinityExample.java
@@ -0,0 +1,137 @@
+/*
+ *  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.examples.java8.datagrid;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Map;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteCluster;
+import org.apache.ignite.IgniteCompute;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.examples.ExampleNodeStartup;
+import org.apache.ignite.lang.IgniteRunnable;
+
+/**
+ * This example demonstrates the simplest code that populates the distributed cache
+ * and co-locates simple closure execution with each key. The goal of this particular
+ * example is to provide the simplest code example of this logic.
+ * <p>
+ * Remote nodes should always be started with special configuration file which
+ * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
+ * <p>
+ * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will
+ * start node with {@code examples/config/example-ignite.xml} configuration.
+ */
+public final class CacheAffinityExample {
+    /** Cache name. */
+    private static final String CACHE_NAME = CacheAffinityExample.class.getSimpleName();
+
+    /** Number of keys. */
+    private static final int KEY_CNT = 20;
+
+    /**
+     * Executes example.
+     *
+     * @param args Command line arguments, none required.
+     * @throws IgniteException If example execution failed.
+     */
+    public static void main(String[] args) throws IgniteException {
+        try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+            System.out.println();
+            System.out.println(">>> Cache affinity example started.");
+
+            CacheConfiguration<Integer, String> cfg = new CacheConfiguration<>();
+
+            cfg.setCacheMode(CacheMode.PARTITIONED);
+            cfg.setName(CACHE_NAME);
+
+            try (IgniteCache<Integer, String> cache = ignite.getOrCreateCache(cfg)) {
+                for (int i = 0; i < KEY_CNT; i++)
+                    cache.put(i, Integer.toString(i));
+
+                // Co-locates jobs with data using IgniteCompute.affinityRun(...) method.
+                visitUsingAffinityRun();
+
+                // Co-locates jobs with data using IgniteCluster.mapKeysToNodes(...) method.
+                visitUsingMapKeysToNodes();
+            }
+        }
+    }
+
+    /**
+     * Collocates jobs with keys they need to work on using
+     * {@link IgniteCompute#affinityRun(String, Object, IgniteRunnable)} method.
+     */
+    private static void visitUsingAffinityRun() {
+        Ignite ignite = Ignition.ignite();
+
+        final IgniteCache<Integer, String> cache = ignite.cache(CACHE_NAME);
+
+        for (int i = 0; i < KEY_CNT; i++) {
+            int key = i;
+
+            // This runnable will execute on the remote node where
+            // data with the given key is located. Since it will be co-located
+            // we can use local 'peek' operation safely.
+            ignite.compute().affinityRun(CACHE_NAME, key,
+                () -> System.out.println("Co-located using affinityRun [key= " + key + ", value=" + cache.localPeek(key) + ']'));
+        }
+    }
+
+    /**
+     * Collocates jobs with keys they need to work on using {@link IgniteCluster#mapKeysToNodes(String, Collection)}
+     * method. The difference from {@code affinityRun(...)} method is that here we process multiple keys
+     * in a single job.
+     */
+    private static void visitUsingMapKeysToNodes() {
+        final Ignite ignite = Ignition.ignite();
+
+        Collection<Integer> keys = new ArrayList<>(KEY_CNT);
+
+        for (int i = 0; i < KEY_CNT; i++)
+            keys.add(i);
+
+        // Map all keys to nodes.
+        Map<ClusterNode, Collection<Integer>> mappings = ignite.cluster().mapKeysToNodes(CACHE_NAME, keys);
+
+        for (Map.Entry<ClusterNode, Collection<Integer>> mapping : mappings.entrySet()) {
+            ClusterNode node = mapping.getKey();
+
+            final Collection<Integer> mappedKeys = mapping.getValue();
+
+            if (node != null) {
+                // Bring computations to the nodes where the data resides (i.e. collocation).
+                ignite.compute(ignite.cluster().forNode(node)).run(() -> {
+                    IgniteCache<Integer, String> cache = ignite.cache(CACHE_NAME);
+
+                    // Peek is a local memory lookup, however, value should never be 'null'
+                    // as we are co-located with node that has a given key.
+                    for (Integer key : mappedKeys)
+                        System.out.println("Co-located using mapKeysToNodes [key= " + key +
+                            ", value=" + cache.localPeek(key) + ']');
+                });
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheApiExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheApiExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheApiExample.java
new file mode 100644
index 0000000..1891a35
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheApiExample.java
@@ -0,0 +1,105 @@
+/*
+ *  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.examples.java8.datagrid;
+
+import java.util.concurrent.ConcurrentMap;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.examples.ExampleNodeStartup;
+
+/**
+ * This example demonstrates some of the cache rich API capabilities.
+ * <p>
+ * Remote nodes should always be started with special configuration file which
+ * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
+ * <p>
+ * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will
+ * start node with {@code examples/config/example-ignite.xml} configuration.
+ */
+public class CacheApiExample {
+    /** Cache name. */
+    private static final String CACHE_NAME = CacheApiExample.class.getSimpleName();
+
+    /**
+     * Executes example.
+     *
+     * @param args Command line arguments, none required.
+     * @throws IgniteException If example execution failed.
+     */
+    public static void main(String[] args) throws IgniteException {
+        try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+            System.out.println();
+            System.out.println(">>> Cache API example started.");
+
+            CacheConfiguration<Integer, String> cfg = new CacheConfiguration<>();
+
+            cfg.setCacheMode(CacheMode.PARTITIONED);
+            cfg.setName(CACHE_NAME);
+
+            try (IgniteCache<Integer, String> cache = ignite.getOrCreateCache(cfg)) {
+                // Demonstrate atomic map operations.
+                atomicMapOperations(cache);
+            }
+        }
+    }
+
+    /**
+     * Demonstrates cache operations similar to {@link ConcurrentMap} API. Note that
+     * cache API is a lot richer than the JDK {@link ConcurrentMap}.
+     *
+     * @throws IgniteException If failed.
+     */
+    private static void atomicMapOperations(final IgniteCache<Integer, String> cache) throws IgniteException {
+        System.out.println();
+        System.out.println(">>> Cache atomic map operation examples.");
+
+        // Put and return previous value.
+        String v = cache.getAndPut(1, "1");
+        assert v == null;
+
+        // Put and do not return previous value (all methods ending with 'x' return boolean).
+        // Performs better when previous value is not needed.
+        cache.put(2, "2");
+
+        // Put-if-absent.
+        boolean b1 = cache.putIfAbsent(4, "4");
+        boolean b2 = cache.putIfAbsent(4, "44");
+        assert b1 && !b2;
+
+        // Invoke - assign new value based on previous value.
+        cache.put(6, "6");
+
+        cache.invoke(6, (entry, args) -> {
+            String val = entry.getValue();
+
+            entry.setValue(val + "6"); // Set new value based on previous value.
+
+            return null;
+        });
+
+        // Replace.
+        cache.put(7, "7");
+        b1 = cache.replace(7, "7", "77");
+        b2 = cache.replace(7, "7", "777");
+        assert b1 & !b2;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAsyncApiExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAsyncApiExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAsyncApiExample.java
new file mode 100644
index 0000000..b457b27
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/CacheAsyncApiExample.java
@@ -0,0 +1,85 @@
+/*
+ *  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.examples.java8.datagrid;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.examples.ExampleNodeStartup;
+import org.apache.ignite.lang.IgniteFuture;
+
+/**
+ * This example demonstrates some of the cache rich API capabilities.
+ * <p>
+ * Remote nodes should always be started with special configuration file which
+ * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
+ * <p>
+ * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will
+ * start node with {@code examples/config/example-ignite.xml} configuration.
+ */
+public class CacheAsyncApiExample {
+    /** Cache name. */
+    private static final String CACHE_NAME = CacheAsyncApiExample.class.getSimpleName();
+
+    /**
+     * Executes example.
+     *
+     * @param args Command line arguments, none required.
+     * @throws IgniteException If example execution failed.
+     */
+    public static void main(String[] args) throws IgniteException {
+        try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+            System.out.println();
+            System.out.println(">>> Cache asynchronous API example started.");
+
+            CacheConfiguration<Integer, String> cfg = new CacheConfiguration<>();
+
+            cfg.setCacheMode(CacheMode.PARTITIONED);
+            cfg.setName(CACHE_NAME);
+
+            try (IgniteCache<Integer, String> cache = ignite.getOrCreateCache(cfg)) {
+                // Enable asynchronous mode.
+                IgniteCache<Integer, String> asyncCache = cache.withAsync();
+
+                Collection<IgniteFuture<?>> futs = new ArrayList<>();
+
+                // Execute several puts asynchronously.
+                for (int i = 0; i < 10; i++) {
+                    asyncCache.put(i, String.valueOf(i));
+
+                    futs.add(asyncCache.future());
+                }
+
+                // Wait for completion of all futures.
+                futs.forEach(IgniteFuture::get);
+
+                // Execute get operation asynchronously.
+                asyncCache.get(1);
+
+                // Asynchronously wait for result.
+                asyncCache.<String>future().listen(fut ->
+                    System.out.println("Get operation completed [value=" + fut.get() + ']'));
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/package-info.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/package-info.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/package-info.java
new file mode 100644
index 0000000..0bd86a0
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datagrid/package-info.java
@@ -0,0 +1,22 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+ * <!-- Package description. -->
+ * Demonstrates data ignite cache usage.
+ */
+package org.apache.ignite.examples.java8.datagrid;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datastructures/IgniteExecutorServiceExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datastructures/IgniteExecutorServiceExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datastructures/IgniteExecutorServiceExample.java
new file mode 100644
index 0000000..0155144
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datastructures/IgniteExecutorServiceExample.java
@@ -0,0 +1,70 @@
+/*
+ *  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.examples.java8.datastructures;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.TimeUnit;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.examples.ExampleNodeStartup;
+import org.apache.ignite.lang.IgniteRunnable;
+
+/**
+ * Simple example to demonstrate usage of distributed executor service provided by Ignite.
+ * <p>
+ * Remote nodes should always be started with special configuration file which
+ * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
+ * <p>
+ * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
+ * with {@code examples/config/example-ignite.xml} configuration.
+ */
+public final class IgniteExecutorServiceExample {
+    /**
+     * Executes example.
+     *
+     * @param args Command line arguments, none required.
+     * @throws Exception If example execution failed.
+     */
+    @SuppressWarnings({"TooBroadScope"})
+    public static void main(String[] args) throws Exception {
+        try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+            System.out.println();
+            System.out.println(">>> Compute executor service example started.");
+
+            // Get ignite-enabled executor service.
+            ExecutorService exec = ignite.executorService();
+
+            // Iterate through all words in the sentence and create callable jobs.
+            for (final String word : "Print words using runnable".split(" ")) {
+                // Execute runnable on some node.
+                exec.submit((IgniteRunnable)() -> {
+                    System.out.println();
+                    System.out.println(">>> Printing '" + word + "' on this node from ignite job.");
+                });
+            }
+
+            exec.shutdown();
+
+            // Wait for all jobs to complete (0 means no limit).
+            exec.awaitTermination(0, TimeUnit.MILLISECONDS);
+
+            System.out.println();
+            System.out.println(">>> Check all nodes for output (this node is also part of the cluster).");
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datastructures/package-info.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datastructures/package-info.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datastructures/package-info.java
new file mode 100644
index 0000000..86f3423
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/datastructures/package-info.java
@@ -0,0 +1,22 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+ * <!-- Package description. -->
+ * Demonstrates using of blocking and non-blocking queues and atomic data structures.
+ */
+package org.apache.ignite.examples.java8.datastructures;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/events/EventsExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/events/EventsExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/events/EventsExample.java
new file mode 100644
index 0000000..df2d52b
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/events/EventsExample.java
@@ -0,0 +1,135 @@
+/*
+ *  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.examples.java8.events;
+
+import java.util.UUID;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.compute.ComputeTaskSession;
+import org.apache.ignite.events.TaskEvent;
+import org.apache.ignite.examples.ExampleNodeStartup;
+import org.apache.ignite.lang.IgniteBiPredicate;
+import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.lang.IgniteRunnable;
+import org.apache.ignite.resources.TaskSessionResource;
+
+import static org.apache.ignite.events.EventType.EVTS_TASK_EXECUTION;
+
+/**
+ * Demonstrates event consume API that allows to register event listeners on remote nodes.
+ * Note that ignite events are disabled by default and must be specifically enabled,
+ * just like in {@code examples/config/example-ignite.xml} file.
+ * <p>
+ * Remote nodes should always be started with configuration: {@code 'ignite.sh examples/config/example-ignite.xml'}.
+ * <p>
+ * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start
+ * node with {@code examples/config/example-ignite.xml} configuration.
+ */
+public class EventsExample {
+    /**
+     * Executes example.
+     *
+     * @param args Command line arguments, none required.
+     * @throws Exception If example execution failed.
+     */
+    public static void main(String[] args) throws Exception {
+        try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+            System.out.println();
+            System.out.println(">>> Events API example started.");
+
+            // Listen to events happening on local node.
+            localListen();
+
+            // Listen to events happening on all cluster nodes.
+            remoteListen();
+
+            // Wait for a while while callback is notified about remaining puts.
+            Thread.sleep(1000);
+        }
+    }
+
+    /**
+     * Listen to events that happen only on local node.
+     *
+     * @throws IgniteException If failed.
+     */
+    private static void localListen() throws IgniteException {
+        System.out.println();
+        System.out.println(">>> Local event listener example.");
+
+        Ignite ignite = Ignition.ignite();
+
+        IgnitePredicate<TaskEvent> lsnr = evt -> {
+            System.out.println("Received task event [evt=" + evt.name() + ", taskName=" + evt.taskName() + ']');
+
+            return true; // Return true to continue listening.
+        };
+
+        // Register event listener for all local task execution events.
+        ignite.events().localListen(lsnr, EVTS_TASK_EXECUTION);
+
+        // Generate task events.
+        ignite.compute().withName("example-event-task").run(() -> System.out.println("Executing sample job."));
+
+        // Unsubscribe local task event listener.
+        ignite.events().stopLocalListen(lsnr);
+    }
+
+    /**
+     * Listen to events coming from all cluster nodes.
+     *
+     * @throws IgniteException If failed.
+     */
+    private static void remoteListen() throws IgniteException {
+        System.out.println();
+        System.out.println(">>> Remote event listener example.");
+
+        // This optional local callback is called for each event notification
+        // that passed remote predicate listener.
+        IgniteBiPredicate<UUID, TaskEvent> locLsnr = (nodeId, evt) -> {
+            // Remote filter only accepts tasks whose name being with "good-task" prefix.
+            assert evt.taskName().startsWith("good-task");
+
+            System.out.println("Received task event [evt=" + evt.name() + ", taskName=" + evt.taskName());
+
+            return true; // Return true to continue listening.
+        };
+
+        // Remote filter which only accepts tasks whose name begins with "good-task" prefix.
+        IgnitePredicate<TaskEvent> rmtLsnr = evt -> evt.taskName().startsWith("good-task");
+
+        Ignite ignite = Ignition.ignite();
+
+        // Register event listeners on all nodes to listen for task events.
+        ignite.events().remoteListen(locLsnr, rmtLsnr, EVTS_TASK_EXECUTION);
+
+        // Generate task events.
+        for (int i = 0; i < 10; i++) {
+            ignite.compute().withName(i < 5 ? "good-task-" + i : "bad-task-" + i).run(new IgniteRunnable() {
+                // Auto-inject task session.
+                @TaskSessionResource
+                private ComputeTaskSession ses;
+
+                @Override public void run() {
+                    System.out.println("Executing sample job for task: " + ses.getTaskName());
+                }
+            });
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/events/package-info.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/events/package-info.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/events/package-info.java
new file mode 100644
index 0000000..b402e78
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/events/package-info.java
@@ -0,0 +1,22 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+ * <!-- Package description. -->
+ * Demonstrates events management API.
+ */
+package org.apache.ignite.examples.java8.events;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingExample.java
new file mode 100644
index 0000000..8b88708
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingExample.java
@@ -0,0 +1,166 @@
+/*
+ *  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.examples.java8.messaging;
+
+import java.util.concurrent.CountDownLatch;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteMessaging;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cluster.ClusterGroup;
+import org.apache.ignite.examples.ExampleNodeStartup;
+import org.apache.ignite.examples.ExamplesUtils;
+
+/**
+ * Example that demonstrates how to exchange messages between nodes. Use such
+ * functionality for cases when you need to communicate to other nodes outside
+ * of ignite task.
+ * <p>
+ * To run this example you must have at least one remote node started.
+ * <p>
+ * Remote nodes should always be started with special configuration file which
+ * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
+ * <p>
+ * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
+ * with {@code examples/config/example-ignite.xml} configuration.
+ */
+public final class MessagingExample {
+    /** Number of messages. */
+    private static final int MESSAGES_NUM = 10;
+
+    /** Message topics. */
+    private enum TOPIC { ORDERED, UNORDERED }
+
+    /**
+     * Executes example.
+     *
+     * @param args Command line arguments, none required.
+     * @throws IgniteException If example execution failed.
+     */
+    public static void main(String[] args) throws Exception {
+        try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+            if (!ExamplesUtils.checkMinTopologySize(ignite.cluster(), 2)) {
+                System.out.println();
+                System.out.println(">>> Please start at least 2 cluster nodes to run example.");
+                System.out.println();
+
+                return;
+            }
+
+            System.out.println();
+            System.out.println(">>> Messaging example started.");
+
+            // Group for remote nodes.
+            ClusterGroup rmtGrp = ignite.cluster().forRemotes();
+
+            // Listen for messages from remote nodes to make sure that they received all the messages.
+            int msgCnt = rmtGrp.nodes().size() * MESSAGES_NUM;
+
+            CountDownLatch orderedLatch = new CountDownLatch(msgCnt);
+            CountDownLatch unorderedLatch = new CountDownLatch(msgCnt);
+
+            localListen(ignite.message(ignite.cluster().forLocal()), orderedLatch, unorderedLatch);
+
+            // Register listeners on all cluster nodes.
+            startListening(ignite, ignite.message(rmtGrp));
+
+            // Send unordered messages to all remote nodes.
+            for (int i = 0; i < MESSAGES_NUM; i++)
+                ignite.message(rmtGrp).send(TOPIC.UNORDERED, Integer.toString(i));
+
+            System.out.println(">>> Finished sending unordered messages.");
+
+            // Send ordered messages to all remote nodes.
+            for (int i = 0; i < MESSAGES_NUM; i++)
+                ignite.message(rmtGrp).sendOrdered(TOPIC.ORDERED, Integer.toString(i), 0);
+
+            System.out.println(">>> Finished sending ordered messages.");
+            System.out.println(">>> Check output on all nodes for message printouts.");
+            System.out.println(">>> Will wait for messages acknowledgements from all remote nodes.");
+
+            orderedLatch.await();
+            unorderedLatch.await();
+
+            System.out.println(">>> Messaging example finished.");
+        }
+    }
+
+    /**
+     * Start listening to messages on remote cluster nodes.
+     *
+     * @param ignite Ignite.
+     * @param imsg Ignite messaging.
+     * @throws IgniteException If failed.
+     */
+    private static void startListening(final Ignite ignite, IgniteMessaging imsg) throws IgniteException {
+        // Add ordered message listener.
+        imsg.remoteListen(TOPIC.ORDERED, (nodeId, msg) -> {
+            System.out.println("Received ordered message [msg=" + msg + ", fromNodeId=" + nodeId + ']');
+
+            try {
+                ignite.message(ignite.cluster().forNodeId(nodeId)).send(TOPIC.ORDERED, msg);
+            }
+            catch (IgniteException e) {
+                e.printStackTrace();
+            }
+
+            return true; // Return true to continue listening.
+        });
+
+        // Add unordered message listener.
+        imsg.remoteListen(TOPIC.UNORDERED, (nodeId, msg) -> {
+            System.out.println("Received unordered message [msg=" + msg + ", fromNodeId=" + nodeId + ']');
+
+            try {
+                ignite.message(ignite.cluster().forNodeId(nodeId)).send(TOPIC.UNORDERED, msg);
+            }
+            catch (IgniteException e) {
+                e.printStackTrace();
+            }
+
+            return true; // Return true to continue listening.
+        });
+    }
+
+    /**
+     * Listen for messages from remote nodes.
+     *
+     * @param imsg Ignite messaging.
+     * @param orderedLatch Latch for ordered messages acks.
+     * @param unorderedLatch Latch for unordered messages acks.
+     */
+    private static void localListen(
+        IgniteMessaging imsg,
+        final CountDownLatch orderedLatch,
+        final CountDownLatch unorderedLatch
+    ) {
+        imsg.localListen(TOPIC.ORDERED, (nodeId, msg) -> {
+            orderedLatch.countDown();
+
+            // Return true to continue listening, false to stop.
+            return orderedLatch.getCount() > 0;
+        });
+
+        imsg.localListen(TOPIC.UNORDERED, (nodeId, msg) -> {
+            unorderedLatch.countDown();
+
+            // Return true to continue listening, false to stop.
+            return unorderedLatch.getCount() > 0;
+        });
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingPingPongExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingPingPongExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingPingPongExample.java
new file mode 100644
index 0000000..b19b476
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingPingPongExample.java
@@ -0,0 +1,113 @@
+/*
+ *  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.examples.java8.messaging;
+
+import java.util.concurrent.CountDownLatch;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cluster.ClusterGroup;
+import org.apache.ignite.examples.ExampleNodeStartup;
+import org.apache.ignite.examples.ExamplesUtils;
+
+/**
+ * Demonstrates simple message exchange between local and remote nodes.
+ * <p>
+ * To run this example you must have at least one remote node started.
+ * <p>
+ * Remote nodes should always be started with special configuration file which
+ * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
+ * <p>
+ * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
+ * with {@code examples/config/example-ignite.xml} configuration.
+ */
+public class MessagingPingPongExample {
+    /**
+     * Executes example.
+     *
+     * @param args Command line arguments, none required.
+     * @throws Exception If example execution failed.
+     */
+    public static void main(String[] args) throws Exception {
+        // Game is played over the default ignite.
+        try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+            if (!ExamplesUtils.checkMinTopologySize(ignite.cluster(), 2))
+                return;
+
+            System.out.println();
+            System.out.println(">>> Messaging ping-pong example started.");
+
+            // Pick random remote node as a partner.
+            ClusterGroup nodeB = ignite.cluster().forRemotes().forRandom();
+
+            // Note that both nodeA and nodeB will always point to
+            // same nodes regardless of whether they were implicitly
+            // serialized and deserialized on another node as part of
+            // anonymous closure's state during its remote execution.
+
+            // Set up remote player.
+            ignite.message(nodeB).remoteListen(null, (nodeId, rcvMsg) -> {
+                System.out.println("Received message [msg=" + rcvMsg + ", sender=" + nodeId + ']');
+
+                if ("PING".equals(rcvMsg)) {
+                    ignite.message(ignite.cluster().forNodeId(nodeId)).send(null, "PONG");
+
+                    return true; // Continue listening.
+                }
+
+                return false; // Unsubscribe.
+            });
+
+            int MAX_PLAYS = 10;
+
+            final CountDownLatch cnt = new CountDownLatch(MAX_PLAYS);
+
+            // Set up local player.
+            ignite.message().localListen(null, (nodeId, rcvMsg) -> {
+                System.out.println("Received message [msg=" + rcvMsg + ", sender=" + nodeId + ']');
+
+                if (cnt.getCount() == 1) {
+                    ignite.message(ignite.cluster().forNodeId(nodeId)).send(null, "STOP");
+
+                    cnt.countDown();
+
+                    return false; // Stop listening.
+                }
+                else if ("PONG".equals(rcvMsg))
+                    ignite.message(ignite.cluster().forNodeId(nodeId)).send(null, "PING");
+                else
+                    throw new IgniteException("Received unexpected message: " + rcvMsg);
+
+                cnt.countDown();
+
+                return true; // Continue listening.
+            });
+
+            // Serve!
+            ignite.message(nodeB).send(null, "PING");
+
+            // Wait til the game is over.
+            try {
+                cnt.await();
+            }
+            catch (InterruptedException e) {
+                System.err.println("Hm... let us finish the game!\n" + e);
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/messaging/package-info.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/messaging/package-info.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/messaging/package-info.java
new file mode 100644
index 0000000..75180cf
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/messaging/package-info.java
@@ -0,0 +1,22 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+ * <!-- Package description. -->
+ * Demonstrates how to exchange messages between nodes.
+ */
+package org.apache.ignite.examples.java8.messaging;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/ComputeScheduleExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/ComputeScheduleExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/ComputeScheduleExample.java
new file mode 100644
index 0000000..8c85a3e
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/ComputeScheduleExample.java
@@ -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.
+ */
+
+package org.apache.ignite.examples.java8.misc.schedule;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.examples.ExampleNodeStartup;
+import org.apache.ignite.scheduler.SchedulerFuture;
+
+/**
+ * Demonstrates a cron-based {@link Runnable} execution scheduling.
+ * Test runnable object broadcasts a phrase to all cluster nodes every minute
+ * three times with initial scheduling delay equal to five seconds.
+ * <p>
+ * Remote nodes should always be started with special configuration file which
+ * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
+ * <p>
+ * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node
+ * with {@code examples/config/example-ignite.xml} configuration.
+ */
+public class ComputeScheduleExample {
+    /**
+     * Executes example.
+     *
+     * @param args Command line arguments, none required.
+     * @throws IgniteException If example execution failed.
+     */
+    public static void main(String[] args) throws IgniteException {
+        try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+            System.out.println();
+            System.out.println("Compute schedule example started.");
+
+            // Schedule output message every minute.
+            SchedulerFuture<?> fut = ignite.scheduler().scheduleLocal(() ->
+                ignite.compute().broadcast(() -> {
+                    System.out.println();
+                    System.out.println("Howdy! :)");
+
+                    return "Howdy! :)";
+                }),
+                "{5, 3} * * * * *" // Cron expression.
+            );
+
+            while (!fut.isDone())
+                System.out.println(">>> Invocation result: " + fut.get());
+
+            System.out.println();
+            System.out.println(">>> Schedule future is done and has been unscheduled.");
+            System.out.println(">>> Check all nodes for hello message output.");
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/package-info.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/package-info.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/package-info.java
new file mode 100644
index 0000000..42132f1
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/misc/schedule/package-info.java
@@ -0,0 +1,22 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+ * <!-- Package description. -->
+ * Demonstrates usage of cron-based scheduler.
+ */
+package org.apache.ignite.examples.java8.misc.schedule;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/package-info.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/package-info.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/package-info.java
new file mode 100644
index 0000000..66847dc
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/package-info.java
@@ -0,0 +1,23 @@
+/*
+ *  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 description. -->
+ * Basic examples for ignite functionality utilizing Java8 lambdas.
+ * Use "java8" examples with JDK8 in addition to the "java" examples.
+ */
+package org.apache.ignite.examples.java8;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamTransformerExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamTransformerExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamTransformerExample.java
new file mode 100644
index 0000000..538c4eb
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamTransformerExample.java
@@ -0,0 +1,101 @@
+/*
+ *  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.examples.java8.streaming;
+
+import java.util.List;
+import java.util.Random;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteDataStreamer;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.examples.ExampleNodeStartup;
+import org.apache.ignite.examples.ExamplesUtils;
+import org.apache.ignite.stream.StreamTransformer;
+
+/**
+ * Stream random numbers into the streaming cache.
+ * To start the example, you should:
+ * <ul>
+ *     <li>Start a few nodes using {@link ExampleNodeStartup} or by starting remote nodes as specified below.</li>
+ *     <li>Start streaming using {@link StreamTransformerExample}.</li>
+ * </ul>
+ * <p>
+ * You should start remote nodes by running {@link ExampleNodeStartup} in another JVM.
+ */
+public class StreamTransformerExample {
+    /** Random number generator. */
+    private static final Random RAND = new Random();
+
+    /** Range within which to generate numbers. */
+    private static final int RANGE = 1000;
+
+    public static void main(String[] args) throws Exception {
+        // Mark this cluster member as client.
+        Ignition.setClientMode(true);
+
+        try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+            if (!ExamplesUtils.hasServerNodes(ignite))
+                return;
+
+            CacheConfiguration<Integer, Long> cfg = new CacheConfiguration<>("randomNumbers");
+
+            // Index key and value.
+            cfg.setIndexedTypes(Integer.class, Long.class);
+
+            // Auto-close cache at the end of the example.
+            try (IgniteCache<Integer, Long> stmCache = ignite.getOrCreateCache(cfg)) {
+                try (IgniteDataStreamer<Integer, Long> stmr = ignite.dataStreamer(stmCache.getName())) {
+                    // Allow data updates.
+                    stmr.allowOverwrite(true);
+
+                    // Configure data transformation to count random numbers added to the stream.
+                    stmr.receiver(StreamTransformer.from((e, arg) -> {
+                        // Get current count.
+                        Long val = e.getValue();
+
+                        // Increment count by 1.
+                        e.setValue(val == null ? 1L : val + 1);
+
+                        return null;
+                    }));
+
+                    // Stream 10 million of random numbers into the streamer cache.
+                    for (int i = 1; i <= 10_000_000; i++) {
+                        stmr.addData(RAND.nextInt(RANGE), 1L);
+
+                        if (i % 500_000 == 0)
+                            System.out.println("Number of tuples streamed into Ignite: " + i);
+                    }
+                }
+
+                // Query top 10 most popular numbers every.
+                SqlFieldsQuery top10Qry = new SqlFieldsQuery("select _key, _val from Long order by _val desc limit 10");
+
+                // Execute queries.
+                List<List<?>> top10 = stmCache.query(top10Qry).getAll();
+
+                System.out.println("Top 10 most popular numbers:");
+
+                // Print top 10 words.
+                ExamplesUtils.printQueryResults(top10);
+            }
+        }
+    }
+}
\ No newline at end of file


[32/50] [abbrv] ignite git commit: IGNITE-1622 - Fixed cache.clear() with near cache

Posted by ag...@apache.org.
IGNITE-1622 - Fixed cache.clear() with near cache


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

Branch: refs/heads/ignite-1016
Commit: a228c246ae58894d0939887218252c2bde882fce
Parents: c9eb539
Author: Valentin Kulichenko <va...@gmail.com>
Authored: Thu Oct 15 16:02:38 2015 -0700
Committer: Valentin Kulichenko <va...@gmail.com>
Committed: Thu Oct 15 16:02:38 2015 -0700

----------------------------------------------------------------------
 .../processors/cache/GridCacheAdapter.java      | 357 +++++++++++--------
 .../cache/GridCacheClearAllRunnable.java        |  18 +-
 .../cache/GridCacheConcurrentMap.java           |   4 +-
 .../processors/cache/GridCacheProxyImpl.java    |  14 +-
 .../processors/cache/IgniteCacheProxy.java      |   2 +-
 .../processors/cache/IgniteInternalCache.java   |  19 +-
 .../distributed/dht/GridDhtCacheAdapter.java    |   6 +-
 .../distributed/near/GridNearCacheAdapter.java  |  21 +-
 .../near/GridNearCacheClearAllRunnable.java     |   9 +-
 .../cache/GridCacheClearSelfTest.java           | 308 ++++++++++++++++
 .../dht/GridCacheDhtEntrySelfTest.java          |   2 +-
 .../IgniteCacheFullApiSelfTestSuite.java        |   8 +-
 12 files changed, 587 insertions(+), 181 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/a228c246/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 ae987b7..417b396 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
@@ -129,6 +129,7 @@ import org.apache.ignite.lang.IgniteCallable;
 import org.apache.ignite.lang.IgniteClosure;
 import org.apache.ignite.lang.IgniteInClosure;
 import org.apache.ignite.lang.IgniteOutClosure;
+import org.apache.ignite.lang.IgniteProductVersion;
 import org.apache.ignite.lang.IgniteUuid;
 import org.apache.ignite.mxbean.CacheMetricsMXBean;
 import org.apache.ignite.plugin.security.SecurityPermission;
@@ -149,7 +150,6 @@ import static org.apache.ignite.internal.processors.dr.GridDrType.DR_LOAD;
 import static org.apache.ignite.internal.processors.dr.GridDrType.DR_NONE;
 import static org.apache.ignite.internal.processors.task.GridTaskThreadContextKey.TC_NO_FAILOVER;
 import static org.apache.ignite.internal.processors.task.GridTaskThreadContextKey.TC_SUBGRID;
-import static org.apache.ignite.internal.processors.task.GridTaskThreadContextKey.TC_TIMEOUT;
 import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC;
 import static org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED;
 
@@ -1057,44 +1057,52 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
     /**
      * Split clearLocally all task into multiple runnables.
      *
+     * @param srv Whether to clear server cache.
+     * @param near Whether to clear near cache.
+     * @param readers Whether to clear readers.
      * @return Split runnables.
      */
-    public List<GridCacheClearAllRunnable<K, V>> splitClearLocally() {
-        assert CLEAR_ALL_SPLIT_THRESHOLD > 0;
+    public List<GridCacheClearAllRunnable<K, V>> splitClearLocally(boolean srv, boolean near, boolean readers) {
+        if ((isNear() && near) || (!isNear() && srv)) {
+            int keySize = size();
 
-        int keySize = size();
+            int cnt = Math.min(keySize / CLEAR_ALL_SPLIT_THRESHOLD + (keySize % CLEAR_ALL_SPLIT_THRESHOLD != 0 ? 1 : 0),
+                    Runtime.getRuntime().availableProcessors());
 
-        int cnt = Math.min(keySize / CLEAR_ALL_SPLIT_THRESHOLD + (keySize % CLEAR_ALL_SPLIT_THRESHOLD != 0 ? 1 : 0),
-            Runtime.getRuntime().availableProcessors());
+            if (cnt == 0)
+                cnt = 1; // Still perform cleanup since there could be entries in swap.
 
-        if (cnt == 0)
-            cnt = 1; // Still perform cleanup since there could be entries in swap.
+            GridCacheVersion obsoleteVer = ctx.versions().next();
 
-        GridCacheVersion obsoleteVer = ctx.versions().next();
-
-        List<GridCacheClearAllRunnable<K, V>> res = new ArrayList<>(cnt);
+            List<GridCacheClearAllRunnable<K, V>> res = new ArrayList<>(cnt);
 
-        for (int i = 0; i < cnt; i++)
-            res.add(new GridCacheClearAllRunnable<>(this, obsoleteVer, i, cnt));
+            for (int i = 0; i < cnt; i++)
+                res.add(new GridCacheClearAllRunnable<>(this, obsoleteVer, i, cnt, readers));
 
-        return res;
+            return res;
+        }
+        else
+            return null;
     }
 
     /** {@inheritDoc} */
     @Override public boolean clearLocally(K key) {
-        return clearLocally0(key);
+        return clearLocally0(key, false);
     }
 
     /** {@inheritDoc} */
-    @Override public void clearLocallyAll(Set<? extends K> keys) {
-        clearLocally0(keys);
+    @Override public void clearLocallyAll(Set<? extends K> keys, boolean srv, boolean near, boolean readers) {
+        if (keys != null && ((isNear() && near) || (!isNear() && srv))) {
+            for (K key : keys)
+                clearLocally0(key, readers);
+        }
     }
 
     /** {@inheritDoc} */
-    @Override public void clearLocally() {
+    @Override public void clearLocally(boolean srv, boolean near, boolean readers) {
         ctx.checkSecurity(SecurityPermission.CACHE_REMOVE);
 
-        List<GridCacheClearAllRunnable<K, V>> jobs = splitClearLocally();
+        List<GridCacheClearAllRunnable<K, V>> jobs = splitClearLocally(srv, near, readers);
 
         if (!F.isEmpty(jobs)) {
             ExecutorService execSvc = null;
@@ -1128,135 +1136,102 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
         }
     }
 
-    /**
-     * @param keys Keys.
-     * @param readers Readers flag.
-     */
-    public void clearLocally(Collection<KeyCacheObject> keys, boolean readers) {
-        if (F.isEmpty(keys))
-            return;
-
-        GridCacheVersion obsoleteVer = ctx.versions().next();
-
-        for (KeyCacheObject key : keys) {
-            GridCacheEntryEx e = peekEx(key);
-
-            try {
-                if (e != null)
-                    e.clear(obsoleteVer, readers, null);
-            }
-            catch (IgniteCheckedException ex) {
-                U.error(log, "Failed to clearLocally entry (will continue to clearLocally other entries): " + e,
-                    ex);
-            }
-        }
-    }
-
-    /**
-     * Clears entry from cache.
-     *
-     * @param obsoleteVer Obsolete version to set.
-     * @param key Key to clearLocally.
-     * @param filter Optional filter.
-     * @return {@code True} if cleared.
-     */
-    private boolean clearLocally(GridCacheVersion obsoleteVer, K key, @Nullable CacheEntryPredicate[] filter) {
-        try {
-            KeyCacheObject cacheKey = ctx.toCacheKeyObject(key);
-
-            GridCacheEntryEx entry = ctx.isSwapOrOffheapEnabled() ? entryEx(cacheKey) : peekEx(cacheKey);
-
-            if (entry != null)
-                return entry.clear(obsoleteVer, false, filter);
-        }
-        catch (GridDhtInvalidPartitionException ignored) {
-            return false;
-        }
-        catch (IgniteCheckedException ex) {
-            U.error(log, "Failed to clearLocally entry for key: " + key, ex);
-        }
-
-        return false;
-    }
-
     /** {@inheritDoc} */
     @Override public void clear() throws IgniteCheckedException {
-        // Clear local cache synchronously.
-        clearLocally();
-
-        clearRemotes(0, null);
+        clear((Set<? extends K>)null);
     }
 
     /** {@inheritDoc} */
     @Override public void clear(K key) throws IgniteCheckedException {
-        // Clear local cache synchronously.
-        clearLocally(key);
-
-        clearRemotes(0, Collections.singleton(key));
+        clear(Collections.singleton(key));
     }
 
     /** {@inheritDoc} */
     @Override public void clearAll(Set<? extends K> keys) throws IgniteCheckedException {
-        // Clear local cache synchronously.
-        clearLocallyAll(keys);
+        clear(keys);
+    }
 
-        clearRemotes(0, keys);
+    /** {@inheritDoc} */
+    @Override public IgniteInternalFuture<?> clearAsync() {
+        return clearAsync((Set<? extends K>)null);
     }
 
     /** {@inheritDoc} */
     @Override public IgniteInternalFuture<?> clearAsync(K key) {
-        return clearKeysAsync(Collections.singleton(key));
+        return clearAsync(Collections.singleton(key));
     }
 
     /** {@inheritDoc} */
-    @Override public IgniteInternalFuture<?> clearAsync(Set<? extends K> keys) {
-        return clearKeysAsync(keys);
+    @Override public IgniteInternalFuture<?> clearAllAsync(Set<? extends K> keys) {
+        return clearAsync(keys);
     }
 
     /**
-     * @param timeout Timeout for clearLocally all task in milliseconds (0 for never).
-     *      Set it to larger value for large caches.
-     * @param keys Keys to clear or {@code null} if all cache should be cleared.
-     * @throws IgniteCheckedException In case of cache could not be cleared on any of the nodes.
+     * @param keys Keys to clear.
+     * @throws IgniteCheckedException In case of error.
      */
-    private void clearRemotes(long timeout, @Nullable final Set<? extends K> keys) throws IgniteCheckedException {
-        // Send job to remote nodes only.
-        Collection<ClusterNode> nodes =
-            ctx.grid().cluster().forCacheNodes(name(), true, true, false).forRemotes().nodes();
-
-        if (!nodes.isEmpty()) {
-            ctx.kernalContext().task().setThreadContext(TC_TIMEOUT, timeout);
-
-            ctx.kernalContext().task().setThreadContext(TC_SUBGRID, nodes);
-
-            ctx.kernalContext().task().execute(
-                new ClearTask(ctx.name(), ctx.affinity().affinityTopologyVersion(), keys), null).get();
-        }
+    private void clear(@Nullable Set<? extends K> keys) throws IgniteCheckedException {
+        executeClearTask(keys, false).get();
+        executeClearTask(keys, true).get();
     }
 
-    /** {@inheritDoc} */
-    @Override public IgniteInternalFuture<?> clearAsync() {
-        return clearKeysAsync(null);
+    /**
+     * @param keys Keys to clear or {@code null} if all cache should be cleared.
+     * @return Future.
+     */
+    private IgniteInternalFuture<?> clearAsync(@Nullable final Set<? extends K> keys) {
+        return executeClearTask(keys, false).chain(new CX1<IgniteInternalFuture<?>, Object>() {
+            @Override public Object applyx(IgniteInternalFuture<?> fut) throws IgniteCheckedException {
+                executeClearTask(keys, true).get();
+
+                return null;
+            }
+        });
     }
 
     /**
-     * @param keys Keys to clear or {@code null} if all cache should be cleared.
+     * @param keys Keys to clear.
+     * @param near Near cache flag.
      * @return Future.
      */
-    private IgniteInternalFuture<?> clearKeysAsync(final Set<? extends K> keys) {
-        Collection<ClusterNode> nodes = ctx.grid().cluster().forCacheNodes(name(), true, true, false).nodes();
+    private IgniteInternalFuture<?> executeClearTask(@Nullable Set<? extends K> keys, boolean near) {
+        Collection<ClusterNode> srvNodes = ctx.grid().cluster().forCacheNodes(name(), !near, near, false).nodes();
 
-        if (!nodes.isEmpty()) {
-            ctx.kernalContext().task().setThreadContext(TC_SUBGRID, nodes);
+        if (!srvNodes.isEmpty()) {
+            ctx.kernalContext().task().setThreadContext(TC_SUBGRID, srvNodes);
 
             return ctx.kernalContext().task().execute(
-                new ClearTask(ctx.name(), ctx.affinity().affinityTopologyVersion(), keys), null);
+                new ClearTask(ctx.name(), ctx.affinity().affinityTopologyVersion(), keys, near), null);
         }
         else
             return new GridFinishedFuture<>();
     }
 
     /**
+     * @param keys Keys.
+     * @param readers Readers flag.
+     */
+    public void clearLocally(Collection<KeyCacheObject> keys, boolean readers) {
+        if (F.isEmpty(keys))
+            return;
+
+        GridCacheVersion obsoleteVer = ctx.versions().next();
+
+        for (KeyCacheObject key : keys) {
+            GridCacheEntryEx e = peekEx(key);
+
+            try {
+                if (e != null)
+                    e.clear(obsoleteVer, readers, null);
+            }
+            catch (IgniteCheckedException ex) {
+                U.error(log, "Failed to clearLocally entry (will continue to clearLocally other entries): " + e,
+                    ex);
+            }
+        }
+    }
+
+    /**
      * @param entry Removes entry from cache if currently mapped value is the same as passed.
      */
     public void removeEntry(GridCacheEntryEx entry) {
@@ -4427,39 +4402,33 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
     }
 
     /**
-     * @param keys Keys.
-     * @param filter Filters to evaluate.
+     * @param key Key.
+     * @param readers Whether to clear readers.
      */
-    public void clearLocally0(Collection<? extends K> keys,
-        @Nullable CacheEntryPredicate... filter) {
+    private boolean clearLocally0(K key, boolean readers) {
         ctx.checkSecurity(SecurityPermission.CACHE_REMOVE);
 
-        if (F.isEmpty(keys))
-            return;
-
         if (keyCheck)
-            validateCacheKeys(keys);
+            validateCacheKey(key);
 
         GridCacheVersion obsoleteVer = ctx.versions().next();
 
-        for (K k : keys)
-            clearLocally(obsoleteVer, k, filter);
-    }
-
-    /**
-     * @param key Key.
-     * @param filter Filters to evaluate.
-     * @return {@code True} if cleared.
-     */
-    public boolean clearLocally0(K key, @Nullable CacheEntryPredicate... filter) {
-        A.notNull(key, "key");
+        try {
+            KeyCacheObject cacheKey = ctx.toCacheKeyObject(key);
 
-        if (keyCheck)
-            validateCacheKey(key);
+            GridCacheEntryEx entry = ctx.isSwapOrOffheapEnabled() ? entryEx(cacheKey) : peekEx(cacheKey);
 
-        ctx.checkSecurity(SecurityPermission.CACHE_REMOVE);
+            if (entry != null)
+                return entry.clear(obsoleteVer, readers, null);
+        }
+        catch (GridDhtInvalidPartitionException ignored) {
+            // No-op.
+        }
+        catch (IgniteCheckedException ex) {
+            U.error(log, "Failed to clearLocally entry for key: " + key, ex);
+        }
 
-        return clearLocally(ctx.versions().next(), key, filter);
+        return false;
     }
 
     /** {@inheritDoc} */
@@ -5178,10 +5147,24 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
         /** {@inheritDoc} */
         @Nullable @Override public Object localExecute(@Nullable IgniteInternalCache cache) {
             if (cache != null)
-                cache.clearLocally();
+                cache.clearLocally(clearServerCache(), clearNearCache(), true);
 
             return null;
         }
+
+        /**
+         * @return Whether to clear server cache.
+         */
+        protected boolean clearServerCache() {
+            return true;
+        }
+
+        /**
+         * @return Whether to clear near cache.
+         */
+        protected boolean clearNearCache() {
+            return false;
+        }
     }
 
     /**
@@ -5209,10 +5192,87 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
         /** {@inheritDoc} */
         @Nullable @Override public Object localExecute(@Nullable IgniteInternalCache cache) {
             if (cache != null)
-                cache.clearLocallyAll(keys);
+                cache.clearLocallyAll(keys, clearServerCache(), clearNearCache(), true);
 
             return null;
         }
+
+        /**
+         * @return Whether to clear server cache.
+         */
+        protected boolean clearServerCache() {
+            return true;
+        }
+
+        /**
+         * @return Whether to clear near cache.
+         */
+        protected boolean clearNearCache() {
+            return false;
+        }
+    }
+
+    /**
+     * Global clear all for near cache.
+     */
+    @GridInternal
+    private static class GlobalClearAllNearJob extends GlobalClearAllJob {
+        /** */
+        private static final long serialVersionUID = 0L;
+
+        /**
+         * @param cacheName Cache name.
+         * @param topVer Affinity topology version.
+         */
+        private GlobalClearAllNearJob(String cacheName, AffinityTopologyVersion topVer) {
+            super(cacheName, topVer);
+        }
+
+        /**
+         * @return Whether to clear server cache.
+         */
+        @Override protected boolean clearServerCache() {
+            return false;
+        }
+
+        /**
+         * @return Whether to clear near cache.
+         */
+        @Override protected boolean clearNearCache() {
+            return true;
+        }
+    }
+
+    /**
+     * Global clear keys for near cache.
+     */
+    @GridInternal
+    private static class GlobalClearKeySetNearJob<K> extends GlobalClearKeySetJob<K> {
+        /** */
+        private static final long serialVersionUID = 0L;
+
+        /**
+         * @param cacheName Cache name.
+         * @param topVer Affinity topology version.
+         * @param keys Keys to clear.
+         */
+        private GlobalClearKeySetNearJob(String cacheName, AffinityTopologyVersion topVer, Set<? extends K> keys) {
+            super(cacheName, topVer, keys);
+        }
+
+        /**
+         * @return Whether to clear server cache.
+         */
+        protected boolean clearServerCache() {
+            return false;
+        }
+
+        /**
+         * @return Whether to clear near cache.
+         */
+        protected boolean clearNearCache() {
+            return true;
+        }
     }
 
     /**
@@ -5972,6 +6032,9 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
         /** */
         private static final long serialVersionUID = 0L;
 
+        /** */
+        public static final IgniteProductVersion NEAR_JOB_SINCE = IgniteProductVersion.fromString("1.5.0");
+
         /** Cache name. */
         private final String cacheName;
 
@@ -5981,26 +6044,40 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
         /** Keys to clear. */
         private final Set<? extends K> keys;
 
+        /** Near cache flag. */
+        private final boolean near;
+
         /**
          * @param cacheName Cache name.
          * @param topVer Affinity topology version.
          * @param keys Keys to clear.
+         * @param near Near cache flag.
          */
-        public ClearTask(String cacheName, AffinityTopologyVersion topVer, Set<? extends K> keys) {
+        public ClearTask(String cacheName, AffinityTopologyVersion topVer, Set<? extends K> keys, boolean near) {
             this.cacheName = cacheName;
             this.topVer = topVer;
             this.keys = keys;
+            this.near = near;
         }
 
         /** {@inheritDoc} */
         @Nullable @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid,
             @Nullable Object arg) throws IgniteException {
-            Map<ComputeJob, ClusterNode> jobs = new HashMap();
+            Map<ComputeJob, ClusterNode> jobs = new HashMap<>();
 
             for (ClusterNode node : subgrid) {
-                jobs.put(keys == null ? new GlobalClearAllJob(cacheName, topVer) :
-                        new GlobalClearKeySetJob<K>(cacheName, topVer, keys),
-                    node);
+                ComputeJob job;
+
+                if (near && node.version().compareTo(NEAR_JOB_SINCE) >= 0) {
+                    job = keys == null ? new GlobalClearAllNearJob(cacheName, topVer) :
+                        new GlobalClearKeySetNearJob<>(cacheName, topVer, keys);
+                }
+                else {
+                    job = keys == null ? new GlobalClearAllJob(cacheName, topVer) :
+                        new GlobalClearKeySetJob<>(cacheName, topVer, keys);
+                }
+
+                jobs.put(job, node);
             }
 
             return jobs;

http://git-wip-us.apache.org/repos/asf/ignite/blob/a228c246/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheClearAllRunnable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheClearAllRunnable.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheClearAllRunnable.java
index feafc58..77c5a55 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheClearAllRunnable.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheClearAllRunnable.java
@@ -28,7 +28,7 @@ import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.internal.util.typedef.internal.U;
 
 /**
- * Base runnable for {@link GridCacheAdapter#clearLocally()} routine.
+ * Base runnable for {@link IgniteInternalCache#clearLocally(boolean, boolean, boolean)} routine.
  */
 public class GridCacheClearAllRunnable<K, V> implements Runnable {
     /** Cache to be cleared. */
@@ -43,6 +43,9 @@ public class GridCacheClearAllRunnable<K, V> implements Runnable {
     /** Mods count across all spawned clearLocally runnables. */
     protected final int totalCnt;
 
+    /** Whether to clear readers. */
+    protected final boolean readers;
+
     /** Cache context. */
     protected final GridCacheContext<K, V> ctx;
 
@@ -57,7 +60,8 @@ public class GridCacheClearAllRunnable<K, V> implements Runnable {
      * @param id Mod for the given runnable.
      * @param totalCnt Mods count across all spawned clearLocally runnables.
      */
-    public GridCacheClearAllRunnable(GridCacheAdapter<K, V> cache, GridCacheVersion obsoleteVer, int id, int totalCnt) {
+    public GridCacheClearAllRunnable(GridCacheAdapter<K, V> cache, GridCacheVersion obsoleteVer,
+        int id, int totalCnt, boolean readers) {
         assert cache != null;
         assert obsoleteVer != null;
         assert id >= 0;
@@ -68,6 +72,7 @@ public class GridCacheClearAllRunnable<K, V> implements Runnable {
         this.obsoleteVer = obsoleteVer;
         this.id = id;
         this.totalCnt = totalCnt;
+        this.readers = readers;
 
         ctx = cache.context();
         log = ctx.logger(getClass());
@@ -138,7 +143,7 @@ public class GridCacheClearAllRunnable<K, V> implements Runnable {
      */
     protected void clearEntry(GridCacheEntryEx e) {
         try {
-            e.clear(obsoleteVer, false, CU.empty0());
+            e.clear(obsoleteVer, readers, CU.empty0());
         }
         catch (IgniteCheckedException ex) {
             U.error(log, "Failed to clearLocally entry from cache (will continue to clearLocally other entries): " + e, ex);
@@ -172,6 +177,13 @@ public class GridCacheClearAllRunnable<K, V> implements Runnable {
         return totalCnt;
     }
 
+    /**
+     * @return Whether to clean readers.
+     */
+    public boolean readers() {
+        return readers;
+    }
+
     /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(GridCacheClearAllRunnable.class, this);

http://git-wip-us.apache.org/repos/asf/ignite/blob/a228c246/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMap.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMap.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMap.java
index a1fc585..1be7c07 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMap.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMap.java
@@ -1968,7 +1968,7 @@ public class GridCacheConcurrentMap {
 
         /** {@inheritDoc} */
         @Override public void clear() {
-            ctx.cache().clearLocally0(new KeySet<K, V>(map, filter, false));
+            ctx.cache().clearLocallyAll(new KeySet<K, V>(map, filter, false), true, true, false);
         }
 
         /** {@inheritDoc} */
@@ -2413,4 +2413,4 @@ public class GridCacheConcurrentMap {
             set = (Set0<K, V>)in.readObject();
         }
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/a228c246/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
index 4d26bd8..cd779f2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
@@ -937,11 +937,11 @@ public class GridCacheProxyImpl<K, V> implements IgniteInternalCache<K, V>, Exte
     }
 
     /** {@inheritDoc} */
-    @Override public void clearLocally() {
+    @Override public void clearLocally(boolean srv, boolean near, boolean readers) {
         CacheOperationContext prev = gate.enter(opCtx);
 
         try {
-            delegate.clearLocally();
+            delegate.clearLocally(srv, near, readers);
         }
         finally {
             gate.leave(prev);
@@ -985,11 +985,11 @@ public class GridCacheProxyImpl<K, V> implements IgniteInternalCache<K, V>, Exte
     }
 
     /** {@inheritDoc} */
-    @Override public IgniteInternalFuture<?> clearAsync(Set<? extends K> keys) {
+    @Override public IgniteInternalFuture<?> clearAllAsync(Set<? extends K> keys) {
         CacheOperationContext prev = gate.enter(opCtx);
 
         try {
-            return delegate.clearAsync(keys);
+            return delegate.clearAllAsync(keys);
         }
         finally {
             gate.leave(prev);
@@ -1009,11 +1009,11 @@ public class GridCacheProxyImpl<K, V> implements IgniteInternalCache<K, V>, Exte
     }
 
     /** {@inheritDoc} */
-    @Override public void clearLocallyAll(Set<? extends K> keys) {
+    @Override public void clearLocallyAll(Set<? extends K> keys, boolean srv, boolean near, boolean readers) {
         CacheOperationContext prev = gate.enter(opCtx);
 
         try {
-            delegate.clearLocallyAll(keys);
+            delegate.clearLocallyAll(keys, srv, near, readers);
         }
         finally {
             gate.leave(prev);
@@ -1536,4 +1536,4 @@ public class GridCacheProxyImpl<K, V> implements IgniteInternalCache<K, V>, Exte
     @Override public String toString() {
         return S.toString(GridCacheProxyImpl.class, this);
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/a228c246/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 ae96f23..c563e59 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
@@ -1311,7 +1311,7 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
 
         try {
             if (isAsync())
-                setFuture(delegate.clearAsync(keys));
+                setFuture(delegate.clearAllAsync(keys));
             else
                 delegate.clearAll(keys);
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/a228c246/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java
index 07650da..167cc8e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java
@@ -925,8 +925,12 @@ public interface IgniteInternalCache<K, V> extends Iterable<Cache.Entry<K, V>> {
      * Note that this operation is local as it merely clears
      * entries from local cache. It does not remove entries from
      * remote caches or from underlying persistent storage.
+     *
+     * @param srv Whether to clear server cache.
+     * @param near Whether to clear near cache.
+     * @param readers Whether to clear readers.
      */
-    public void clearLocally();
+    public void clearLocally(boolean srv, boolean near, boolean readers);
 
     /**
      * Clears an entry from this cache and swap storage only if the entry
@@ -958,8 +962,11 @@ public interface IgniteInternalCache<K, V> extends Iterable<Cache.Entry<K, V>> {
      * remote caches or from underlying persistent storage.
      *
      * @param keys Keys to clearLocally.
+     * @param srv Whether to clear server cache.
+     * @param near Whether to clear near cache.
+     * @param readers Whether to clear readers.
      */
-    public void clearLocallyAll(Set<? extends K> keys);
+    public void clearLocallyAll(Set<? extends K> keys, boolean srv, boolean near, boolean readers);
 
     /**
      * Clears key on all nodes that store it's data. That is, caches are cleared on remote
@@ -976,7 +983,7 @@ public interface IgniteInternalCache<K, V> extends Iterable<Cache.Entry<K, V>> {
 
     /**
      * Clears keys on all nodes that store it's data. That is, caches are cleared on remote
-     * nodes and local node, as opposed to {@link IgniteInternalCache#clearLocallyAll(Set)} method which only
+     * nodes and local node, as opposed to {@link IgniteInternalCache#clearLocallyAll(Set, boolean, boolean, boolean)} method which only
      * clears local node's cache.
      * <p>
      * Ignite will make the best attempt to clear caches on all nodes. If some caches
@@ -989,7 +996,7 @@ public interface IgniteInternalCache<K, V> extends Iterable<Cache.Entry<K, V>> {
 
     /**
      * Clears cache on all nodes that store it's data. That is, caches are cleared on remote
-     * nodes and local node, as opposed to {@link IgniteInternalCache#clearLocally()} method which only
+     * nodes and local node, as opposed to {@link IgniteInternalCache#clearLocally(boolean, boolean, boolean)} method which only
      * clears local node's cache.
      * <p>
      * Ignite will make the best attempt to clear caches on all nodes. If some caches
@@ -1015,7 +1022,7 @@ public interface IgniteInternalCache<K, V> extends Iterable<Cache.Entry<K, V>> {
      * @param keys Keys to clear.
      * @return Clear future.
      */
-    public IgniteInternalFuture<?> clearAsync(Set<? extends K> keys);
+    public IgniteInternalFuture<?> clearAllAsync(Set<? extends K> keys);
 
     /**
      * Removes given key mapping from cache. If cache previously contained value for the given key,
@@ -1802,4 +1809,4 @@ public interface IgniteInternalCache<K, V> extends Iterable<Cache.Entry<K, V>> {
      * @return Future to be completed whenever loading completes.
      */
     public IgniteInternalFuture<?> localLoadCacheAsync(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args);
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/a228c246/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
index 3ce9ee9..333bce2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
@@ -972,8 +972,8 @@ public abstract class GridDhtCacheAdapter<K, V> extends GridDistributedCacheAdap
     }
 
     /** {@inheritDoc} */
-    @Override public List<GridCacheClearAllRunnable<K, V>> splitClearLocally() {
-        return ctx.affinityNode() ? super.splitClearLocally() :
+    @Override public List<GridCacheClearAllRunnable<K, V>> splitClearLocally(boolean srv, boolean near, boolean readers) {
+        return ctx.affinityNode() ? super.splitClearLocally(srv, near, readers) :
             Collections.<GridCacheClearAllRunnable<K, V>>emptyList();
     }
 
@@ -1184,4 +1184,4 @@ public abstract class GridDhtCacheAdapter<K, V> extends GridDistributedCacheAdap
             return topVer;
         }
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/a228c246/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java
index 01c3e2b..fe519a7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java
@@ -99,7 +99,7 @@ public abstract class GridNearCacheAdapter<K, V> extends GridDistributedCacheAda
             /** {@inheritDoc} */
             @Override public GridCacheMapEntry create(
                 GridCacheContext ctx,
-                AffinityTopologyVersion topVer, 
+                AffinityTopologyVersion topVer,
                 KeyCacheObject key,
                 int hash,
                 CacheObject val,
@@ -450,16 +450,15 @@ public abstract class GridNearCacheAdapter<K, V> extends GridDistributedCacheAda
     }
 
     /** {@inheritDoc} */
-    @Override public boolean clearLocally0(K key, @Nullable CacheEntryPredicate[] filter) {
-        return super.clearLocally0(key, filter) | dht().clearLocally0(key, filter);
+    @Override public boolean clearLocally(K key) {
+        return super.clearLocally(key) | dht().clearLocally(key);
     }
 
     /** {@inheritDoc} */
-    @Override public void clearLocally0(Collection<? extends K> keys,
-        @Nullable CacheEntryPredicate[] filter) {
-        super.clearLocally0(keys, filter);
+    @Override public void clearLocallyAll(Set<? extends K> keys, boolean srv, boolean near, boolean readers) {
+        super.clearLocallyAll(keys, srv, near, readers);
 
-        dht().clearLocally0(keys, filter);
+        dht().clearLocallyAll(keys, srv, near, readers);
     }
 
     /** {@inheritDoc} */
@@ -532,13 +531,13 @@ public abstract class GridNearCacheAdapter<K, V> extends GridDistributedCacheAda
     }
 
     /** {@inheritDoc} */
-    @Override public List<GridCacheClearAllRunnable<K, V>> splitClearLocally() {
+    @Override public List<GridCacheClearAllRunnable<K, V>> splitClearLocally(boolean srv, boolean near, boolean readers) {
         assert configuration().getNearConfiguration() != null;
 
         if (ctx.affinityNode()) {
             GridCacheVersion obsoleteVer = ctx.versions().next();
 
-            List<GridCacheClearAllRunnable<K, V>> dhtJobs = dht().splitClearLocally();
+            List<GridCacheClearAllRunnable<K, V>> dhtJobs = dht().splitClearLocally(srv, near, readers);
 
             List<GridCacheClearAllRunnable<K, V>> res = new ArrayList<>(dhtJobs.size());
 
@@ -548,7 +547,7 @@ public abstract class GridNearCacheAdapter<K, V> extends GridDistributedCacheAda
             return res;
         }
         else
-            return super.splitClearLocally();
+            return super.splitClearLocally(srv, near, readers);
     }
 
     /**
@@ -662,4 +661,4 @@ public abstract class GridNearCacheAdapter<K, V> extends GridDistributedCacheAda
     @Override public String toString() {
         return S.toString(GridNearCacheAdapter.class, this);
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/a228c246/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheClearAllRunnable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheClearAllRunnable.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheClearAllRunnable.java
index 675ea8d..eea0b6e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheClearAllRunnable.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheClearAllRunnable.java
@@ -19,11 +19,12 @@ package org.apache.ignite.internal.processors.cache.distributed.near;
 
 import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
 import org.apache.ignite.internal.processors.cache.GridCacheClearAllRunnable;
+import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
 import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
 import org.apache.ignite.internal.util.typedef.internal.S;
 
 /**
- * Runnable for {@link GridCacheAdapter#clearLocally()} routine for near cache.
+ * Runnable for {@link IgniteInternalCache#clearLocally(boolean, boolean, boolean)} routine for near cache.
  */
 public class GridNearCacheClearAllRunnable<K, V> extends GridCacheClearAllRunnable<K, V> {
     /** Runnable for DHT cache. */
@@ -38,9 +39,7 @@ public class GridNearCacheClearAllRunnable<K, V> extends GridCacheClearAllRunnab
      */
     public GridNearCacheClearAllRunnable(GridCacheAdapter<K, V> cache, GridCacheVersion obsoleteVer,
         GridCacheClearAllRunnable<K, V> dhtJob) {
-        super(cache, obsoleteVer, dhtJob.id(), dhtJob.totalCount());
-
-        assert dhtJob != null;
+        super(cache, obsoleteVer, dhtJob.id(), dhtJob.totalCount(), dhtJob.readers());
 
         this.dhtJob = dhtJob;
     }
@@ -61,4 +60,4 @@ public class GridNearCacheClearAllRunnable<K, V> extends GridCacheClearAllRunnab
     @Override public String toString() {
         return S.toString(GridNearCacheClearAllRunnable.class, this);
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/a228c246/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheClearSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheClearSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheClearSelfTest.java
new file mode 100644
index 0000000..5e14f14
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheClearSelfTest.java
@@ -0,0 +1,308 @@
+/*
+ * 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.util.Collections;
+import java.util.Set;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.CacheMemoryMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.CachePeekMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.NearCacheConfiguration;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Tests for cache clear.
+ */
+public class GridCacheClearSelfTest extends GridCommonAbstractTest {
+    /** */
+    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        TcpDiscoverySpi disco = new TcpDiscoverySpi();
+
+        disco.setIpFinder(IP_FINDER);
+
+        cfg.setDiscoverySpi(disco);
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        startGridsMultiThreaded(3);
+
+        Ignition.setClientMode(true);
+
+        startGrid("client1");
+        startGrid("client2");
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTestsStopped() throws Exception {
+        stopAllGrids();
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testClearPartitioned() throws Exception {
+        testClear(CacheMode.PARTITIONED, CacheMemoryMode.ONHEAP_TIERED, false, null);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testClearPartitionedOffHeap() throws Exception {
+        testClear(CacheMode.PARTITIONED, CacheMemoryMode.OFFHEAP_TIERED, false, null);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testClearPartitionedNear() throws Exception {
+        testClear(CacheMode.PARTITIONED, CacheMemoryMode.ONHEAP_TIERED, true, null);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testClearPartitionedOffHeapNear() throws Exception {
+        testClear(CacheMode.PARTITIONED, CacheMemoryMode.OFFHEAP_TIERED, true, null);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testClearReplicated() throws Exception {
+        testClear(CacheMode.REPLICATED, CacheMemoryMode.ONHEAP_TIERED, false, null);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testClearReplicatedOffHeap() throws Exception {
+        testClear(CacheMode.REPLICATED, CacheMemoryMode.OFFHEAP_TIERED, false, null);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testClearReplicatedNear() throws Exception {
+        testClear(CacheMode.REPLICATED, CacheMemoryMode.ONHEAP_TIERED, true, null);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testClearReplicatedOffHeapNear() throws Exception {
+        testClear(CacheMode.REPLICATED, CacheMemoryMode.OFFHEAP_TIERED, true, null);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testClearKeyPartitioned() throws Exception {
+        testClear(CacheMode.PARTITIONED, CacheMemoryMode.ONHEAP_TIERED, false, Collections.singleton(3));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testClearKeyPartitionedOffHeap() throws Exception {
+        testClear(CacheMode.PARTITIONED, CacheMemoryMode.OFFHEAP_TIERED, false, Collections.singleton(3));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testClearKeyPartitionedNear() throws Exception {
+        testClear(CacheMode.PARTITIONED, CacheMemoryMode.ONHEAP_TIERED, true, Collections.singleton(3));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testClearKeyPartitionedOffHeapNear() throws Exception {
+        testClear(CacheMode.PARTITIONED, CacheMemoryMode.OFFHEAP_TIERED, true, Collections.singleton(3));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testClearKeyReplicated() throws Exception {
+        testClear(CacheMode.REPLICATED, CacheMemoryMode.ONHEAP_TIERED, false, Collections.singleton(3));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testClearKeyReplicatedOffHeap() throws Exception {
+        testClear(CacheMode.REPLICATED, CacheMemoryMode.OFFHEAP_TIERED, false, Collections.singleton(3));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testClearKeyReplicatedNear() throws Exception {
+        testClear(CacheMode.REPLICATED, CacheMemoryMode.ONHEAP_TIERED, true, Collections.singleton(3));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testClearKeyReplicatedOffHeapNear() throws Exception {
+        testClear(CacheMode.REPLICATED, CacheMemoryMode.OFFHEAP_TIERED, true, Collections.singleton(3));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testClearKeysPartitioned() throws Exception {
+        testClear(CacheMode.PARTITIONED, CacheMemoryMode.ONHEAP_TIERED, false, F.asSet(2, 6, 9));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testClearKeysPartitionedOffHeap() throws Exception {
+        testClear(CacheMode.PARTITIONED, CacheMemoryMode.OFFHEAP_TIERED, false, F.asSet(2, 6, 9));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testClearKeysPartitionedNear() throws Exception {
+        testClear(CacheMode.PARTITIONED, CacheMemoryMode.ONHEAP_TIERED, true, F.asSet(2, 6, 9));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testClearKeysPartitionedOffHeapNear() throws Exception {
+        testClear(CacheMode.PARTITIONED, CacheMemoryMode.OFFHEAP_TIERED, true, F.asSet(2, 6, 9));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testClearKeysReplicated() throws Exception {
+        testClear(CacheMode.REPLICATED, CacheMemoryMode.ONHEAP_TIERED, false, F.asSet(2, 6, 9));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testClearKeysReplicatedOffHeap() throws Exception {
+        testClear(CacheMode.REPLICATED, CacheMemoryMode.OFFHEAP_TIERED, false, F.asSet(2, 6, 9));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testClearKeysReplicatedNear() throws Exception {
+        testClear(CacheMode.REPLICATED, CacheMemoryMode.ONHEAP_TIERED, true, F.asSet(2, 6, 9));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testClearKeysReplicatedOffHeapNear() throws Exception {
+        testClear(CacheMode.REPLICATED, CacheMemoryMode.OFFHEAP_TIERED, true, F.asSet(2, 6, 9));
+    }
+
+    /**
+     * @param cacheMode Cache mode.
+     * @param memMode Memory mode.
+     * @param near Near cache flag.
+     * @param keys Keys to clear.
+     */
+    private void testClear(CacheMode cacheMode, CacheMemoryMode memMode, boolean near, @Nullable Set<Integer> keys) {
+        Ignite client1 = client1();
+        Ignite client2 = client2();
+
+        try {
+            CacheConfiguration<Integer, Integer> cfg = new CacheConfiguration<>("cache");
+
+            cfg.setCacheMode(cacheMode);
+            cfg.setMemoryMode(memMode);
+
+            IgniteCache<Integer, Integer> cache1 = near ?
+                client1.createCache(cfg, new NearCacheConfiguration<Integer, Integer>()) :
+                client1.createCache(cfg);
+
+            IgniteCache<Integer, Integer> cache2 = near ?
+                client2.createNearCache("cache", new NearCacheConfiguration<Integer, Integer>()) :
+                client2.<Integer, Integer>cache("cache");
+
+            for (int i = 0; i < 10; i++)
+                cache1.put(i, i);
+
+            for (int i = 0; i < 10; i++)
+                cache2.get(i);
+
+            assertEquals(10, cache1.size(CachePeekMode.PRIMARY));
+            assertEquals(10, cache2.size(CachePeekMode.PRIMARY));
+            assertEquals(near ? 10 : 0, cache1.localSize(CachePeekMode.NEAR));
+            assertEquals(near ? 10 : 0, cache2.localSize(CachePeekMode.NEAR));
+
+            if (F.isEmpty(keys))
+                cache1.clear();
+            else if (keys.size() == 1)
+                cache1.clear(F.first(keys));
+            else
+                cache1.clearAll(keys);
+
+            int expSize = F.isEmpty(keys) ? 0 : 10 - keys.size();
+
+            assertEquals(expSize, cache1.size(CachePeekMode.PRIMARY));
+            assertEquals(expSize, cache2.size(CachePeekMode.PRIMARY));
+            assertEquals(near ? expSize : 0, cache1.localSize(CachePeekMode.NEAR));
+            assertEquals(near ? expSize : 0, cache2.localSize(CachePeekMode.NEAR));
+        }
+        finally {
+            client1.destroyCache("cache");
+        }
+    }
+
+    /**
+     * @return Client 1.
+     */
+    private Ignite client1() {
+        return grid("client1");
+    }
+
+    /**
+     * @return Client 2.
+     */
+    private Ignite client2() {
+        return grid("client2");
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/a228c246/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEntrySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEntrySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEntrySelfTest.java
index 26548b9..62fee5e 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEntrySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEntrySelfTest.java
@@ -314,4 +314,4 @@ public class GridCacheDhtEntrySelfTest extends GridCommonAbstractTest {
 
         return F.t(primary, other);
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/a228c246/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFullApiSelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFullApiSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFullApiSelfTestSuite.java
index ff53250..c2f27fe 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFullApiSelfTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFullApiSelfTestSuite.java
@@ -18,6 +18,7 @@
 package org.apache.ignite.testsuites;
 
 import junit.framework.TestSuite;
+import org.apache.ignite.internal.processors.cache.GridCacheClearSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheAtomicFullApiSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheAtomicNearEnabledFullApiSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheAtomicNearEnabledPrimaryWriteOrderFullApiSelfTest;
@@ -204,11 +205,14 @@ public class IgniteCacheFullApiSelfTestSuite extends TestSuite {
         suite.addTestSuite(GridCachePartitionedNearDisabledOffHeapTieredMultiNodeFullApiSelfTest.class);
         suite.addTestSuite(GridCachePartitionedNearDisabledAtomicOffHeapTieredMultiNodeFullApiSelfTest.class);
 
-        // Multithreaded
+        // Multithreaded.
         suite.addTestSuite(GridCacheLocalFullApiMultithreadedSelfTest.class);
         suite.addTestSuite(GridCacheReplicatedFullApiMultithreadedSelfTest.class);
         suite.addTestSuite(GridCachePartitionedFullApiMultithreadedSelfTest.class);
 
+        // Other.
+        suite.addTestSuite(GridCacheClearSelfTest.class);
+
         return suite;
     }
-}
\ No newline at end of file
+}


[44/50] [abbrv] ignite git commit: Merge remote-tracking branch 'apache/master'

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


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

Branch: refs/heads/ignite-1016
Commit: 43b40f4c405eac860b75c0648a0656dbb12eec92
Parents: 6ffd5ce f619e09
Author: ashutak <as...@gridgain.com>
Authored: Tue Oct 20 15:56:50 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Tue Oct 20 15:56:50 2015 +0300

----------------------------------------------------------------------
 .../ignite/internal/processors/igfs/IgfsMetaManager.java  | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------



[48/50] [abbrv] ignite git commit: Muted test GridCacheAtomicNearEnabledFairAffinityMultiNodeFullApiSelfTest#testIgniteCacheIterator

Posted by ag...@apache.org.
Muted test GridCacheAtomicNearEnabledFairAffinityMultiNodeFullApiSelfTest#testIgniteCacheIterator


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

Branch: refs/heads/ignite-1016
Commit: 91e31e99c2574f7cede8d80ec9b8d981ccc34bcb
Parents: c28af3c
Author: ashutak <as...@gridgain.com>
Authored: Wed Oct 21 20:03:29 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Wed Oct 21 20:03:29 2015 +0300

----------------------------------------------------------------------
 ...tomicNearEnabledFairAffinityMultiNodeFullApiSelfTest.java | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/91e31e99/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearEnabledFairAffinityMultiNodeFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearEnabledFairAffinityMultiNodeFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearEnabledFairAffinityMultiNodeFullApiSelfTest.java
index 8e47134..de4a53d 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearEnabledFairAffinityMultiNodeFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearEnabledFairAffinityMultiNodeFullApiSelfTest.java
@@ -34,7 +34,13 @@ public class GridCacheAtomicNearEnabledFairAffinityMultiNodeFullApiSelfTest
         return cfg;
     }
 
+    /** {@inheritDoc} */
     @Override public void testWithSkipStore(){
         fail("https://issues.apache.org/jira/browse/IGNITE-1582");
     }
-}
\ No newline at end of file
+
+    /** {@inheritDoc} */
+    @Override public void testIgniteCacheIterator() throws Exception {
+        fail("https://issues.apache.org/jira/browse/IGNITE-1756");
+    }
+}


[15/50] [abbrv] ignite git commit: ignite-1.4.2 - Fixed resource cleanup for caches created from template.

Posted by ag...@apache.org.
ignite-1.4.2 - Fixed resource cleanup for caches created from template.


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

Branch: refs/heads/ignite-1016
Commit: 30b731b3c54609b77293e08c401db2d96e48e8d9
Parents: 94f549f
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Mon Oct 12 16:09:59 2015 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Mon Oct 12 16:09:59 2015 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheProcessor.java    | 23 ++++++++++-----
 .../IgniteCacheConfigurationTemplateTest.java   | 31 ++++++++++++++++++++
 2 files changed, 46 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/30b731b3/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 8c96c0c..722e570 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
@@ -639,7 +639,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
             if (ctx.config().isDaemon() && !CU.isMarshallerCache(cfgs[i].getName()))
                 continue;
 
-            checkSerializable(cfgs[i]);
+            cloneCheckSerializable(cfgs[i]);
 
             CacheConfiguration<?, ?> cfg = new CacheConfiguration(cfgs[i]);
 
@@ -2023,9 +2023,14 @@ public class GridCacheProcessor extends GridProcessorAdapter {
      * @return Future that will be completed when cache is deployed.
      */
     public IgniteInternalFuture<?> createFromTemplate(String cacheName) {
-        CacheConfiguration cfg = createConfigFromTemplate(cacheName);
+        try {
+            CacheConfiguration cfg = createConfigFromTemplate(cacheName);
 
-        return dynamicStartCache(cfg, cacheName, null, true, true);
+            return dynamicStartCache(cfg, cacheName, null, true, true);
+        }
+        catch (IgniteCheckedException e) {
+            throw U.convertException(e);
+        }
     }
 
     /**
@@ -2052,7 +2057,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
      * @param cacheName Cache name.
      * @return Cache configuration.
      */
-    private CacheConfiguration createConfigFromTemplate(String cacheName) {
+    private CacheConfiguration createConfigFromTemplate(String cacheName) throws IgniteCheckedException {
         CacheConfiguration cfgTemplate = null;
 
         CacheConfiguration dfltCacheCfg = null;
@@ -2112,6 +2117,8 @@ public class GridCacheProcessor extends GridProcessorAdapter {
 
         if (cfgTemplate == null)
             cfgTemplate = new CacheConfiguration();
+        else
+            cfgTemplate = cloneCheckSerializable(cfgTemplate);
 
         CacheConfiguration cfg = new CacheConfiguration(cfgTemplate);
 
@@ -2168,7 +2175,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
 
         if (ccfg != null) {
             try {
-                checkSerializable(ccfg);
+                cloneCheckSerializable(ccfg);
             }
             catch (IgniteCheckedException e) {
                 return new GridFinishedFuture<>(e);
@@ -3340,9 +3347,9 @@ public class GridCacheProcessor extends GridProcessorAdapter {
      * @param val Object to check.
      * @throws IgniteCheckedException If validation failed.
      */
-    private void checkSerializable(CacheConfiguration val) throws IgniteCheckedException {
+    private CacheConfiguration cloneCheckSerializable(CacheConfiguration val) throws IgniteCheckedException {
         if (val == null)
-            return;
+            return null;
 
         if (val.getCacheStoreFactory() != null) {
             try {
@@ -3356,7 +3363,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
         }
 
         try {
-            marshaller.unmarshal(marshaller.marshal(val), val.getClass().getClassLoader());
+            return marshaller.unmarshal(marshaller.marshal(val), val.getClass().getClassLoader());
         }
         catch (IgniteCheckedException e) {
             throw new IgniteCheckedException("Failed to validate cache configuration " +

http://git-wip-us.apache.org/repos/asf/ignite/blob/30b731b3/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigurationTemplateTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigurationTemplateTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigurationTemplateTest.java
index d3ba2d6..87a30a6 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigurationTemplateTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigurationTemplateTest.java
@@ -24,6 +24,7 @@ import java.util.concurrent.atomic.AtomicInteger;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.cache.CacheExistsException;
+import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.events.Event;
@@ -365,6 +366,36 @@ public class IgniteCacheConfigurationTemplateTest extends GridCommonAbstractTest
     }
 
     /**
+     * @throws Exception If failed.
+     */
+    public void testTemplateCleanup() throws Exception {
+        startGridsMultiThreaded(3);
+
+        try {
+            CacheConfiguration ccfg = new CacheConfiguration("affTemplate-*");
+
+            ccfg.setAffinity(new RendezvousAffinityFunction());
+
+            ignite(0).addCacheConfiguration(ccfg);
+
+            ignite(0).getOrCreateCache("affTemplate-1");
+
+            IgniteCache<Object, Object> cache = ignite(0).getOrCreateCache("affTemplate-2");
+
+            ignite(0).destroyCache("affTemplate-1");
+
+            startGrid(3);
+
+            cache.put(1, 1);
+
+            assertEquals(1, cache.get(1));
+        }
+        finally {
+            stopAllGrids();
+        }
+    }
+
+    /**
      * @param ignite Ignite.
      * @param name Cache name.
      * @param expBackups Expected number of backups.


[38/50] [abbrv] ignite git commit: Mute tests

Posted by ag...@apache.org.
Mute tests


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

Branch: refs/heads/ignite-1016
Commit: 9527933e5fd088bdb1e541daf6cf3fb412aadc1e
Parents: 50cf42a
Author: ashutak <as...@gridgain.com>
Authored: Mon Oct 19 14:58:57 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Mon Oct 19 14:58:57 2015 +0300

----------------------------------------------------------------------
 .../cache/distributed/dht/GridCacheTxNodeFailureSelfTest.java    | 2 ++
 .../dht/IgniteAtomicLongChangingTopologySelfTest.java            | 4 +++-
 .../ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java | 2 ++
 3 files changed, 7 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/9527933e/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheTxNodeFailureSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheTxNodeFailureSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheTxNodeFailureSelfTest.java
index 4302486..cadd03f 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheTxNodeFailureSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheTxNodeFailureSelfTest.java
@@ -137,6 +137,8 @@ public class GridCacheTxNodeFailureSelfTest extends GridCommonAbstractTest {
      * @throws Exception If failed.
      */
     public void testPrimaryNodeFailureBackupRollbackOptimistic() throws Exception {
+        fail("https://issues.apache.org/jira/browse/IGNITE-1731");
+
         checkPrimaryNodeFailureBackupCommit(OPTIMISTIC, false, false);
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/9527933e/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteAtomicLongChangingTopologySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteAtomicLongChangingTopologySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteAtomicLongChangingTopologySelfTest.java
index 32a86e4..19daa26 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteAtomicLongChangingTopologySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteAtomicLongChangingTopologySelfTest.java
@@ -133,6 +133,8 @@ public class IgniteAtomicLongChangingTopologySelfTest extends GridCommonAbstract
      * @throws Exception If failed.
      */
     public void testClientAtomicLongCreateCloseFailover() throws Exception {
+        fail("https://issues.apache.org/jira/browse/IGNITE-1732");
+
         testFailoverWithClient(new IgniteInClosure<Ignite>() {
             @Override public void apply(Ignite ignite) {
                 for (int i = 0; i < 100; i++) {
@@ -391,4 +393,4 @@ public class IgniteAtomicLongChangingTopologySelfTest extends GridCommonAbstract
             }
         }, 1, "grunner-" + i);
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/9527933e/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java
index a8c8388..26d87a9 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java
@@ -74,6 +74,8 @@ public class SqlFieldsQuerySelfTest extends GridCommonAbstractTest {
      * @throws Exception If error.
      */
     public void testSqlFieldsQueryWithTopologyChanges() throws Exception {
+        fail("https://issues.apache.org/jira/browse/IGNITE-1698");
+
         startGrid(0);
 
         createAndFillCache();


[09/50] [abbrv] ignite git commit: ignite-1168 Added support for metadata, scan commands in rest.

Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/12235254/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/top/GridTopologyCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/top/GridTopologyCommandHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/top/GridTopologyCommandHandler.java
index aee8a1f..3b36c6a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/top/GridTopologyCommandHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/top/GridTopologyCommandHandler.java
@@ -27,11 +27,11 @@ import java.util.Iterator;
 import java.util.Map;
 import java.util.UUID;
 import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.cache.CacheMode;
 import org.apache.ignite.cluster.ClusterMetrics;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.IgniteInternalFuture;
-import org.apache.ignite.internal.processors.cache.GridCacheAttributes;
 import org.apache.ignite.internal.processors.port.GridPortRecord;
 import org.apache.ignite.internal.processors.rest.GridRestCommand;
 import org.apache.ignite.internal.processors.rest.GridRestProtocol;
@@ -44,6 +44,7 @@ import org.apache.ignite.internal.processors.rest.request.GridRestTopologyReques
 import org.apache.ignite.internal.util.future.GridFinishedFuture;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.P1;
+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.spi.IgnitePortProtocol;
@@ -194,24 +195,26 @@ public class GridTopologyCommandHandler extends GridRestCommandHandlerAdapter {
         nodeBean.setTcpAddresses(nonEmptyList(node.<Collection<String>>attribute(ATTR_REST_TCP_ADDRS)));
         nodeBean.setTcpHostNames(nonEmptyList(node.<Collection<String>>attribute(ATTR_REST_TCP_HOST_NAMES)));
 
-        GridCacheAttributes[] caches = node.attribute(ATTR_CACHE);
+        Map<String, CacheMode> nodeCaches = ctx.discovery().nodeCaches(node);
 
-        if (!F.isEmpty(caches)) {
-            Map<String, String> cacheMap = new HashMap<>();
+        Map<String, String> cacheMap = U.newHashMap(nodeCaches.size());
 
-            for (GridCacheAttributes cacheAttr : caches) {
-                if (ctx.cache().systemCache(cacheAttr.cacheName()))
-                    continue;
+        for (Map.Entry<String, CacheMode> cache : nodeCaches.entrySet()) {
+            String cacheName = cache.getKey();
 
-                if (cacheAttr.cacheName() != null)
-                    cacheMap.put(cacheAttr.cacheName(), cacheAttr.cacheMode().toString());
-                else
-                    nodeBean.setDefaultCacheMode(cacheAttr.cacheMode().toString());
-            }
+            if (CU.isSystemCache(cacheName) || CU.isIgfsCache(ctx.config(), cacheName))
+                continue;
+
+            String mode = cache.getValue().toString();
 
-            nodeBean.setCaches(cacheMap);
+            if (cacheName != null)
+                cacheMap.put(cacheName, mode);
+            else
+                nodeBean.setDefaultCacheMode(mode);
         }
 
+        nodeBean.setCaches(cacheMap);
+
         if (mtr) {
             ClusterMetrics metrics = node.metrics();
 
@@ -304,6 +307,135 @@ public class GridTopologyCommandHandler extends GridRestCommandHandlerAdapter {
     }
 
     /**
+     * Creates node bean out of grid node. Notice that cache attribute is handled separately.
+     *
+     * @param node Grid node.
+     * @param mtr {@code true} to add metrics.
+     * @param attr {@code true} to add attributes.
+     * @return Grid Node bean.
+     */
+    private GridClientNodeBean createNodeBean(ClusterNode node, boolean mtr, boolean attr) {
+        assert node != null;
+
+        GridClientNodeBean nodeBean = new GridClientNodeBean();
+
+        nodeBean.setNodeId(node.id());
+        nodeBean.setConsistentId(node.consistentId());
+        nodeBean.setTcpPort(attribute(node, ATTR_REST_TCP_PORT, 0));
+
+        nodeBean.setTcpAddresses(nonEmptyList(node.<Collection<String>>attribute(ATTR_REST_TCP_ADDRS)));
+        nodeBean.setTcpHostNames(nonEmptyList(node.<Collection<String>>attribute(ATTR_REST_TCP_HOST_NAMES)));
+
+        Map<String, CacheMode> nodeCaches = ctx.discovery().nodeCaches(node);
+
+        Map<String, String> cacheMap = U.newHashMap(nodeCaches.size());
+
+        for (Map.Entry<String, CacheMode> cache : nodeCaches.entrySet()) {
+            String cacheName = cache.getKey();
+
+            if (CU.isSystemCache(cacheName) || CU.isIgfsCache(ctx.config(), cacheName))
+                continue;
+
+            String mode = cache.getValue().toString();
+
+            if (cacheName != null)
+                cacheMap.put(cacheName, mode);
+            else
+                nodeBean.setDefaultCacheMode(mode);
+        }
+
+        nodeBean.setCaches(cacheMap);
+
+        if (mtr) {
+            ClusterMetrics metrics = node.metrics();
+
+            GridClientNodeMetricsBean metricsBean = new GridClientNodeMetricsBean();
+
+            metricsBean.setStartTime(metrics.getStartTime());
+            metricsBean.setAverageActiveJobs(metrics.getAverageActiveJobs());
+            metricsBean.setAverageCancelledJobs(metrics.getAverageCancelledJobs());
+            metricsBean.setAverageCpuLoad(metrics.getAverageCpuLoad());
+            metricsBean.setAverageJobExecuteTime(metrics.getAverageJobExecuteTime());
+            metricsBean.setAverageJobWaitTime(metrics.getAverageJobWaitTime());
+            metricsBean.setAverageRejectedJobs(metrics.getAverageRejectedJobs());
+            metricsBean.setAverageWaitingJobs(metrics.getAverageWaitingJobs());
+            metricsBean.setCurrentActiveJobs(metrics.getCurrentActiveJobs());
+            metricsBean.setCurrentCancelledJobs(metrics.getCurrentCancelledJobs());
+            metricsBean.setCurrentCpuLoad(metrics.getCurrentCpuLoad());
+            metricsBean.setCurrentGcCpuLoad(metrics.getCurrentGcCpuLoad());
+            metricsBean.setCurrentDaemonThreadCount(metrics.getCurrentDaemonThreadCount());
+            metricsBean.setCurrentIdleTime(metrics.getCurrentIdleTime());
+            metricsBean.setCurrentJobExecuteTime(metrics.getCurrentJobExecuteTime());
+            metricsBean.setCurrentJobWaitTime(metrics.getCurrentJobWaitTime());
+            metricsBean.setCurrentRejectedJobs(metrics.getCurrentRejectedJobs());
+            metricsBean.setCurrentThreadCount(metrics.getCurrentThreadCount());
+            metricsBean.setCurrentWaitingJobs(metrics.getCurrentWaitingJobs());
+            metricsBean.setHeapMemoryCommitted(metrics.getHeapMemoryCommitted());
+            metricsBean.setHeapMemoryInitialized(metrics.getHeapMemoryInitialized());
+            metricsBean.setHeapMemoryMaximum(metrics.getHeapMemoryMaximum());
+            metricsBean.setHeapMemoryUsed(metrics.getHeapMemoryUsed());
+            metricsBean.setLastDataVersion(metrics.getLastDataVersion());
+            metricsBean.setLastUpdateTime(metrics.getLastUpdateTime());
+            metricsBean.setMaximumActiveJobs(metrics.getMaximumActiveJobs());
+            metricsBean.setMaximumCancelledJobs(metrics.getMaximumCancelledJobs());
+            metricsBean.setMaximumJobExecuteTime(metrics.getMaximumJobExecuteTime());
+            metricsBean.setMaximumJobWaitTime(metrics.getMaximumJobWaitTime());
+            metricsBean.setMaximumRejectedJobs(metrics.getMaximumRejectedJobs());
+            metricsBean.setMaximumThreadCount(metrics.getMaximumThreadCount());
+            metricsBean.setMaximumWaitingJobs(metrics.getMaximumWaitingJobs());
+            metricsBean.setNodeStartTime(metrics.getNodeStartTime());
+            metricsBean.setNonHeapMemoryCommitted(metrics.getNonHeapMemoryCommitted());
+            metricsBean.setNonHeapMemoryInitialized(metrics.getNonHeapMemoryInitialized());
+            metricsBean.setNonHeapMemoryMaximum(metrics.getNonHeapMemoryMaximum());
+            metricsBean.setNonHeapMemoryUsed(metrics.getNonHeapMemoryUsed());
+            metricsBean.setStartTime(metrics.getStartTime());
+            metricsBean.setTotalCancelledJobs(metrics.getTotalCancelledJobs());
+            metricsBean.setTotalCpus(metrics.getTotalCpus());
+            metricsBean.setTotalExecutedJobs(metrics.getTotalExecutedJobs());
+            metricsBean.setTotalIdleTime(metrics.getTotalIdleTime());
+            metricsBean.setTotalRejectedJobs(metrics.getTotalRejectedJobs());
+            metricsBean.setTotalStartedThreadCount(metrics.getTotalStartedThreadCount());
+            metricsBean.setTotalExecutedTasks(metrics.getTotalExecutedTasks());
+            metricsBean.setSentMessagesCount(metrics.getSentMessagesCount());
+            metricsBean.setSentBytesCount(metrics.getSentBytesCount());
+            metricsBean.setReceivedMessagesCount(metrics.getReceivedMessagesCount());
+            metricsBean.setReceivedBytesCount(metrics.getReceivedBytesCount());
+            metricsBean.setUpTime(metrics.getUpTime());
+
+            nodeBean.setMetrics(metricsBean);
+        }
+
+        if (attr) {
+            Map<String, Object> attrs = new HashMap<>(node.attributes());
+
+            attrs.remove(ATTR_CACHE);
+            attrs.remove(ATTR_TX_CONFIG);
+            attrs.remove(ATTR_SECURITY_SUBJECT);
+            attrs.remove(ATTR_SECURITY_CREDENTIALS);
+
+            for (Iterator<Map.Entry<String, Object>> i = attrs.entrySet().iterator(); i.hasNext();) {
+                Map.Entry<String, Object> e = i.next();
+
+                if (!e.getKey().startsWith("org.apache.ignite.") && !e.getKey().startsWith("plugins.") &&
+                    System.getProperty(e.getKey()) == null) {
+                    i.remove();
+
+                    continue;
+                }
+
+                if (e.getValue() != null) {
+                  if (e.getValue().getClass().isEnum() || e.getValue() instanceof InetAddress)
+                      e.setValue(e.getValue().toString());
+                  else if (e.getValue().getClass().isArray())
+                      i.remove();
+                }
+            }
+
+            nodeBean.setAttributes(attrs);
+        }
+
+        return nodeBean;
+    }    /**
      * @param col Collection;
      * @return Non-empty list.
      */
@@ -345,4 +477,4 @@ public class GridTopologyCommandHandler extends GridRestCommandHandlerAdapter {
     @Override public String toString() {
         return S.toString(GridTopologyCommandHandler.class, this);
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/12235254/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/RestQueryRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/RestQueryRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/RestQueryRequest.java
new file mode 100644
index 0000000..a719776
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/RestQueryRequest.java
@@ -0,0 +1,175 @@
+/*
+ *
+ *  * 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.rest.request;
+
+/**
+ * Sql query request.
+ */
+public class RestQueryRequest extends GridRestRequest {
+    /** Sql query. */
+    private String sqlQry;
+
+    /** Sql query arguments. */
+    private Object[] args;
+
+    /** Page size. */
+    private Integer pageSize;
+
+    /** Cache name. */
+    private String cacheName;
+
+    /** Query id. */
+    private Long qryId;
+
+    /** Query type name. */
+    private String typeName;
+
+    /** Predicate class name for scan query. */
+    private String className;
+
+    /** Query type. */
+    private QueryType type;
+
+    /**
+     * @param sqlQry Sql query.
+     */
+    public void sqlQuery(String sqlQry) {
+        this.sqlQry = sqlQry;
+    }
+
+    /**
+     * @return Sql query.
+     */
+    public String sqlQuery() {
+        return sqlQry;
+    }
+
+    /**
+     * @param args Sql query arguments.
+     */
+    public void arguments(Object[] args) {
+        this.args = args;
+    }
+
+    /**
+     * @return Sql query arguments.
+     */
+    public Object[] arguments() {
+        return args;
+    }
+
+    /**
+     * @param pageSize Page size.
+     */
+    public void pageSize(Integer pageSize) {
+        this.pageSize = pageSize;
+    }
+
+    /**
+     * @return Page size.
+     */
+    public int pageSize() {
+        return pageSize;
+    }
+
+    /**
+     * @param cacheName Cache name.
+     */
+    public void cacheName(String cacheName) {
+        this.cacheName = cacheName;
+    }
+
+    /**
+     * @return Cache name.
+     */
+    public String cacheName() {
+        return cacheName;
+    }
+
+    /**
+     * @param id Query id.
+     */
+    public void queryId(Long id) {
+        this.qryId = id;
+    }
+
+    /**
+     * @return Query id.
+     */
+    public Long queryId() {
+        return qryId;
+    }
+
+    /**
+     * @param typeName Query type name.
+     */
+    public void typeName(String typeName) {
+        this.typeName = typeName;
+    }
+
+    /**
+     * @return Query type name.
+     */
+    public String typeName() {
+        return typeName;
+    }
+
+    /**
+     * @return Predicate class name for scan query.
+     */
+    public String className() {
+        return className;
+    }
+
+    /**
+     * @param className Predicate class name for scan query.
+     */
+    public void className(String className) {
+        this.className = className;
+    }
+
+    /**
+     * @param type Query type.
+     */
+    public void queryType(QueryType type) {
+        this.type = type;
+    }
+
+    /**
+     * @return Query type.
+     */
+    public QueryType queryType() {
+        return type;
+    }
+
+    /**
+     * Supported query types.
+     */
+    public enum QueryType {
+        /** Sql query. */
+        SQL,
+
+        /** Sql fields query. */
+        SQL_FIELDS,
+
+        /** Scan query. */
+        SCAN
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/12235254/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/RestSqlQueryRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/RestSqlQueryRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/RestSqlQueryRequest.java
deleted file mode 100644
index b6ab339..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/RestSqlQueryRequest.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.rest.request;
-
-/**
- * Sql query request.
- */
-public class RestSqlQueryRequest extends GridRestRequest {
-    /** Sql query. */
-    private String sqlQry;
-
-    /** Sql query arguments. */
-    private Object[] args;
-
-    /** Page size. */
-    private Integer pageSize;
-
-    /** Cache name. */
-    private String cacheName;
-
-    /** Query id. */
-    private Long qryId;
-
-    /** Query type name. */
-    private String typeName;
-
-    /**
-     * @param sqlQry Sql query.
-     */
-    public void sqlQuery(String sqlQry) {
-        this.sqlQry = sqlQry;
-    }
-
-    /**
-     * @return Sql query.
-     */
-    public String sqlQuery() {
-        return sqlQry;
-    }
-
-    /**
-     * @param args Sql query arguments.
-     */
-    public void arguments(Object[] args) {
-        this.args = args;
-    }
-
-    /**
-     * @return Sql query arguments.
-     */
-    public Object[] arguments() {
-        return args;
-    }
-
-    /**
-     * @param pageSize Page size.
-     */
-    public void pageSize(Integer pageSize) {
-        this.pageSize = pageSize;
-    }
-
-    /**
-     * @return Page size.
-     */
-    public int pageSize() {
-        return pageSize;
-    }
-
-    /**
-     * @param cacheName Cache name.
-     */
-    public void cacheName(String cacheName) {
-        this.cacheName = cacheName;
-    }
-
-    /**
-     * @return Cache name.
-     */
-    public String cacheName() {
-        return cacheName;
-    }
-
-    /**
-     * @param id Query id.
-     */
-    public void queryId(Long id) {
-        this.qryId = id;
-    }
-
-    /**
-     * @return Query id.
-     */
-    public Long queryId() {
-        return qryId;
-    }
-
-    /**
-     * @param typeName Query type name.
-     */
-    public void typeName(String typeName) {
-        this.typeName = typeName;
-    }
-
-    /**
-     * @return Query type name.
-     */
-    public String typeName() {
-        return typeName;
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/12235254/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyJsonConfig.java
----------------------------------------------------------------------
diff --git a/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyJsonConfig.java b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyJsonConfig.java
index 60b44ee..0adbc14 100644
--- a/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyJsonConfig.java
+++ b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyJsonConfig.java
@@ -17,10 +17,19 @@
 
 package org.apache.ignite.internal.processors.rest.protocols.http.jetty;
 
+import java.text.DateFormat;
 import java.util.UUID;
+import net.sf.json.JSONObject;
 import net.sf.json.JsonConfig;
+import net.sf.json.processors.JsonBeanProcessor;
+import net.sf.json.processors.JsonBeanProcessorMatcher;
 import net.sf.json.processors.JsonValueProcessor;
 
+import java.util.*;
+import net.sf.json.processors.JsonValueProcessorMatcher;
+import org.apache.ignite.internal.processors.cache.query.GridCacheSqlIndexMetadata;
+import org.apache.ignite.internal.processors.cache.query.GridCacheSqlMetadata;
+
 /**
  * Jetty protocol json configuration.
  */
@@ -29,21 +38,158 @@ public class GridJettyJsonConfig extends JsonConfig {
      * Constructs default jetty json config.
      */
     public GridJettyJsonConfig() {
-        registerJsonValueProcessor(UUID.class, new ToStringJsonProcessor());
+        registerJsonValueProcessor(UUID.class, new UUIDToStringJsonProcessor());
+        registerJsonValueProcessor(Date.class, new DateToStringJsonProcessor());
+        registerJsonValueProcessor(java.sql.Date.class, new DateToStringJsonProcessor());
+
+        registerJsonBeanProcessor(GridCacheSqlMetadata.class, new GridCacheSqlMetadataBeanProcessor());
+        registerJsonValueProcessor(GridCacheSqlIndexMetadata.class, new GridCacheSqlIndexMetadataToJson());
+
+        setJsonBeanProcessorMatcher(new GridJettyJsonBeanProcessorMatcher());
+        setJsonValueProcessorMatcher(new GridJettyJsonValueProcessorMatcher());
     }
 
     /**
-     * Helper class for simple to-string conversion for the beans.
+     * Helper class for simple to-string conversion for {@link UUID}.
      */
-    private static class ToStringJsonProcessor implements JsonValueProcessor {
+    private static class UUIDToStringJsonProcessor implements JsonValueProcessor {
         /** {@inheritDoc} */
         @Override public Object processArrayValue(Object val, JsonConfig jsonCfg) {
-            throw new UnsupportedOperationException("Serialize array to string is not supported: " + val);
+            if (val == null)
+                return new JSONObject(true);
+
+            if (val instanceof UUID)
+                return val.toString();
+
+            throw new UnsupportedOperationException("Serialize value to json is not supported: " + val);
         }
 
         /** {@inheritDoc} */
         @Override public Object processObjectValue(String key, Object val, JsonConfig jsonCfg) {
-            return val == null ? null : val.toString();
+            return processArrayValue(val, jsonCfg);
+        }
+    }
+
+    /**
+     * Helper class for simple to-string conversion for {@link Date}.
+     */
+    private static class DateToStringJsonProcessor implements JsonValueProcessor {
+        private final DateFormat enUsFormat
+            =  DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT, Locale.US);
+
+        /** {@inheritDoc} */
+        @Override public synchronized Object processArrayValue(Object val, JsonConfig jsonCfg) {
+            if (val == null)
+                return new JSONObject(true);
+
+            if (val instanceof Date)
+                return enUsFormat.format(val);
+
+            throw new UnsupportedOperationException("Serialize value to json is not supported: " + val);
+        }
+
+        /** {@inheritDoc} */
+        @Override public synchronized Object processObjectValue(String key, Object val, JsonConfig jsonCfg) {
+            return processArrayValue(val, jsonCfg);
+        }
+    }
+
+    /**
+     * Helper class for simple to-json conversion for {@link GridCacheSqlMetadata}.
+     */
+    private static class GridCacheSqlMetadataBeanProcessor implements JsonBeanProcessor {
+        /** {@inheritDoc} */
+        @Override public JSONObject processBean(Object bean, JsonConfig jsonCfg) {
+            if (bean == null)
+                return new JSONObject(true);
+
+            if (bean instanceof GridCacheSqlMetadata) {
+                GridCacheSqlMetadata r = (GridCacheSqlMetadata) bean;
+
+                return new JSONObject()
+                    .element("cacheName", r.cacheName(), jsonCfg)
+                    .element("types", r.types(), jsonCfg)
+                    .element("keyClasses", r.keyClasses(), jsonCfg)
+                    .element("valClasses", r.valClasses(), jsonCfg)
+                    .element("fields", r.fields(), jsonCfg)
+                    .element("indexes", r.indexes(), jsonCfg);
+            }
+
+            throw new UnsupportedOperationException("Serialize bean to json is not supported: " + bean);
+        }
+    }
+
+    /**
+     * Helper class for simple to-json conversion for {@link GridCacheSqlIndexMetadata}.
+     */
+    private static class GridCacheSqlIndexMetadataToJson implements JsonValueProcessor {
+        /** {@inheritDoc} */
+        @Override public Object processArrayValue(Object val, JsonConfig jsonCfg) {
+            if (val == null)
+                return new JSONObject(true);
+
+            if (val instanceof GridCacheSqlIndexMetadata) {
+                GridCacheSqlIndexMetadata r = (GridCacheSqlIndexMetadata) val;
+
+                return new JSONObject()
+                    .element("name", r.name())
+                    .element("fields", r.fields())
+                    .element("descendings", r.descendings())
+                    .element("unique", r.unique());
+            }
+
+            throw new UnsupportedOperationException("Serialize array to string is not supported: " + val);
+        }
+
+        /** {@inheritDoc} */
+        @Override public Object processObjectValue(String key, Object value, JsonConfig jsonCfg) {
+            return processArrayValue(value, jsonCfg);
+        }
+    }
+
+    /**
+     * Class for finding a matching JsonBeanProcessor. Matches the target class with instanceOf.
+     */
+    private static final class GridJettyJsonBeanProcessorMatcher extends JsonBeanProcessorMatcher {
+        /** {@inheritDoc} */
+        @Override public Object getMatch(Class target, Set keys) {
+            if (target == null || keys == null)
+                return null;
+
+            if (keys.contains(target))
+                return target;
+
+            for (Object key : keys) {
+                Class<?> clazz = (Class<?>) key;
+
+                if (clazz.isAssignableFrom(target))
+                    return key;
+            }
+
+            return null;
+        }
+    }
+
+    /**
+     * Class for finding a matching JsonValueProcessor. Matches the target class with instanceOf.
+     */
+    private static final class GridJettyJsonValueProcessorMatcher extends JsonValueProcessorMatcher {
+        /** {@inheritDoc} */
+        @Override public Object getMatch(Class target, Set keys) {
+            if (target == null || keys == null)
+                return null;
+
+            if (keys.contains(target))
+                return target;
+
+            for (Object key : keys) {
+                Class<?> clazz = (Class<?>) key;
+
+                if (clazz.isAssignableFrom(target))
+                    return key;
+            }
+
+            return null;
         }
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/12235254/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java
----------------------------------------------------------------------
diff --git a/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java
index 9b82098..48a60a9 100644
--- a/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java
+++ b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java
@@ -51,7 +51,7 @@ import org.apache.ignite.internal.processors.rest.request.GridRestLogRequest;
 import org.apache.ignite.internal.processors.rest.request.GridRestRequest;
 import org.apache.ignite.internal.processors.rest.request.GridRestTaskRequest;
 import org.apache.ignite.internal.processors.rest.request.GridRestTopologyRequest;
-import org.apache.ignite.internal.processors.rest.request.RestSqlQueryRequest;
+import org.apache.ignite.internal.processors.rest.request.RestQueryRequest;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteClosure;
@@ -64,6 +64,7 @@ import static org.apache.ignite.internal.processors.rest.GridRestCommand.CACHE_C
 import static org.apache.ignite.internal.processors.rest.GridRestCommand.CACHE_GET_ALL;
 import static org.apache.ignite.internal.processors.rest.GridRestCommand.CACHE_PUT_ALL;
 import static org.apache.ignite.internal.processors.rest.GridRestCommand.CACHE_REMOVE_ALL;
+import static org.apache.ignite.internal.processors.rest.GridRestCommand.EXECUTE_SQL_QUERY;
 import static org.apache.ignite.internal.processors.rest.GridRestResponse.STATUS_FAILED;
 
 /**
@@ -84,19 +85,15 @@ public class GridJettyRestHandler extends AbstractHandler {
 
     /** Logger. */
     private final IgniteLogger log;
-
+    /** Authentication checker. */
+    private final IgniteClosure<String, Boolean> authChecker;
     /** Request handlers. */
     private GridRestProtocolHandler hnd;
-
     /** Default page. */
     private volatile String dfltPage;
-
     /** Favicon. */
     private volatile byte[] favicon;
 
-    /** Authentication checker. */
-    private final IgniteClosure<String, Boolean> authChecker;
-
     /**
      * Creates new HTTP requests handler.
      *
@@ -135,6 +132,74 @@ public class GridJettyRestHandler extends AbstractHandler {
     }
 
     /**
+     * Retrieves long value from parameters map.
+     *
+     * @param key Key.
+     * @param params Parameters map.
+     * @param dfltVal Default value.
+     * @return Long value from parameters map or {@code dfltVal} if null
+     *     or not exists.
+     * @throws IgniteCheckedException If parsing failed.
+     */
+    @Nullable private static Long longValue(String key, Map<String, Object> params, Long dfltVal) throws IgniteCheckedException {
+        assert key != null;
+
+        String val = (String) params.get(key);
+
+        try {
+            return val == null ? dfltVal : Long.valueOf(val);
+        }
+        catch (NumberFormatException ignore) {
+            throw new IgniteCheckedException("Failed to parse parameter of Long type [" + key + "=" + val + "]");
+        }
+    }
+
+    /**
+     * Retrieves int value from parameters map.
+     *
+     * @param key Key.
+     * @param params Parameters map.
+     * @param dfltVal Default value.
+     * @return Integer value from parameters map or {@code dfltVal} if null
+     *     or not exists.
+     * @throws IgniteCheckedException If parsing failed.
+     */
+    @Nullable private static Integer intValue(String key, Map<String, Object> params, Integer dfltVal) throws IgniteCheckedException {
+        assert key != null;
+
+        String val = (String) params.get(key);
+
+        try {
+            return val == null ? dfltVal : Integer.valueOf(val);
+        }
+        catch (NumberFormatException ignore) {
+            throw new IgniteCheckedException("Failed to parse parameter of Integer type [" + key + "=" + val + "]");
+        }
+    }
+
+    /**
+     * Retrieves UUID value from parameters map.
+     *
+     * @param key Key.
+     * @param params Parameters map.
+     * @return UUID value from parameters map or {@code null} if null
+     *     or not exists.
+     * @throws IgniteCheckedException If parsing failed.
+     */
+    @Nullable private static UUID uuidValue(String key, Map<String, Object> params) throws IgniteCheckedException {
+        assert key != null;
+
+        String val = (String) params.get(key);
+
+        try {
+            return val == null ? null : UUID.fromString(val);
+        }
+        catch (NumberFormatException ignore) {
+            throw new IgniteCheckedException("Failed to parse parameter of UUID type [" + key + "=" + val + "]");
+        }
+    }
+
+    /**
      * @throws IOException If failed.
      */
     private void initDefaultPage() throws IOException {
@@ -396,6 +461,7 @@ public class GridJettyRestHandler extends AbstractHandler {
             case CACHE_CAS:
             case CACHE_METRICS:
             case CACHE_SIZE:
+            case CACHE_METADATA:
             case CACHE_REPLACE:
             case CACHE_APPEND:
             case CACHE_PREPEND: {
@@ -497,9 +563,9 @@ public class GridJettyRestHandler extends AbstractHandler {
 
             case EXECUTE_SQL_QUERY:
             case EXECUTE_SQL_FIELDS_QUERY: {
-                RestSqlQueryRequest restReq0 = new RestSqlQueryRequest();
+                RestQueryRequest restReq0 = new RestQueryRequest();
 
-                restReq0.sqlQuery((String) params.get("qry"));
+                restReq0.sqlQuery((String)params.get("qry"));
 
                 restReq0.arguments(values("arg", params).toArray());
 
@@ -512,20 +578,46 @@ public class GridJettyRestHandler extends AbstractHandler {
 
                 restReq0.cacheName((String)params.get("cacheName"));
 
+                if (cmd == EXECUTE_SQL_QUERY)
+                    restReq0.queryType(RestQueryRequest.QueryType.SQL);
+                else
+                    restReq0.queryType(RestQueryRequest.QueryType.SQL_FIELDS);
+
+                restReq = restReq0;
+
+                break;
+            }
+
+            case EXECUTE_SCAN_QUERY: {
+                RestQueryRequest restReq0 = new RestQueryRequest();
+
+                restReq0.sqlQuery((String)params.get("qry"));
+
+                String pageSize = (String)params.get("pageSize");
+
+                if (pageSize != null)
+                    restReq0.pageSize(Integer.parseInt(pageSize));
+
+                restReq0.cacheName((String)params.get("cacheName"));
+
+                restReq0.className((String)params.get("classname"));
+
+                restReq0.queryType(RestQueryRequest.QueryType.SCAN);
+
                 restReq = restReq0;
 
                 break;
             }
 
             case FETCH_SQL_QUERY: {
-                RestSqlQueryRequest restReq0 = new RestSqlQueryRequest();
+                RestQueryRequest restReq0 = new RestQueryRequest();
 
                 String qryId = (String) params.get("qryId");
 
                 if (qryId != null)
                     restReq0.queryId(Long.parseLong(qryId));
 
-                String pageSize = (String) params.get("pageSize");
+                String pageSize = (String)params.get("pageSize");
 
                 if (pageSize != null)
                     restReq0.pageSize(Integer.parseInt(pageSize));
@@ -538,7 +630,7 @@ public class GridJettyRestHandler extends AbstractHandler {
             }
 
             case CLOSE_SQL_QUERY: {
-                RestSqlQueryRequest restReq0 = new RestSqlQueryRequest();
+                RestQueryRequest restReq0 = new RestQueryRequest();
 
                 String qryId = (String) params.get("qryId");
 
@@ -601,74 +693,6 @@ public class GridJettyRestHandler extends AbstractHandler {
     }
 
     /**
-     * Retrieves long value from parameters map.
-     *
-     * @param key Key.
-     * @param params Parameters map.
-     * @param dfltVal Default value.
-     * @return Long value from parameters map or {@code dfltVal} if null
-     *     or not exists.
-     * @throws IgniteCheckedException If parsing failed.
-     */
-    @Nullable private static Long longValue(String key, Map<String, Object> params, Long dfltVal) throws IgniteCheckedException {
-        assert key != null;
-
-        String val = (String) params.get(key);
-
-        try {
-            return val == null ? dfltVal : Long.valueOf(val);
-        }
-        catch (NumberFormatException ignore) {
-            throw new IgniteCheckedException("Failed to parse parameter of Long type [" + key + "=" + val + "]");
-        }
-    }
-
-    /**
-     * Retrieves int value from parameters map.
-     *
-     * @param key Key.
-     * @param params Parameters map.
-     * @param dfltVal Default value.
-     * @return Integer value from parameters map or {@code dfltVal} if null
-     *     or not exists.
-     * @throws IgniteCheckedException If parsing failed.
-     */
-    @Nullable private static Integer intValue(String key, Map<String, Object> params, Integer dfltVal) throws IgniteCheckedException {
-        assert key != null;
-
-        String val = (String) params.get(key);
-
-        try {
-            return val == null ? dfltVal : Integer.valueOf(val);
-        }
-        catch (NumberFormatException ignore) {
-            throw new IgniteCheckedException("Failed to parse parameter of Integer type [" + key + "=" + val + "]");
-        }
-    }
-
-    /**
-     * Retrieves UUID value from parameters map.
-     *
-     * @param key Key.
-     * @param params Parameters map.
-     * @return UUID value from parameters map or {@code null} if null
-     *     or not exists.
-     * @throws IgniteCheckedException If parsing failed.
-     */
-    @Nullable private static UUID uuidValue(String key, Map<String, Object> params) throws IgniteCheckedException {
-        assert key != null;
-
-        String val = (String) params.get(key);
-
-        try {
-            return val == null ? null : UUID.fromString(val);
-        }
-        catch (NumberFormatException ignore) {
-            throw new IgniteCheckedException("Failed to parse parameter of UUID type [" + key + "=" + val + "]");
-        }
-    }
-
-    /**
      * Gets values referenced by sequential keys, e.g. {@code key1...keyN}.
      *
      * @param keyPrefix Key prefix, e.g. {@code key} for {@code key1...keyN}.
@@ -736,4 +760,4 @@ public class GridJettyRestHandler extends AbstractHandler {
 
         return null;
     }
-}
\ No newline at end of file
+}


[06/50] [abbrv] ignite git commit: ignite-1526: full support of IBM JDK by Ignite

Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/5fc682f1/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
index dfbb0ae..04d7893 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
@@ -22,7 +22,6 @@ import java.util.Collection;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
-import java.util.UUID;
 import java.util.concurrent.locks.Lock;
 import javax.cache.CacheException;
 import javax.cache.CacheManager;
@@ -35,7 +34,6 @@ import javax.cache.processor.EntryProcessorResult;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.IgniteCompute;
-import org.apache.ignite.Ignition;
 import org.apache.ignite.cache.CacheEntryProcessor;
 import org.apache.ignite.cache.CacheMetrics;
 import org.apache.ignite.cache.CachePeekMode;
@@ -47,8 +45,8 @@ import org.apache.ignite.internal.util.future.IgniteFinishedFutureImpl;
 import org.apache.ignite.lang.IgniteBiPredicate;
 import org.apache.ignite.lang.IgniteCallable;
 import org.apache.ignite.lang.IgniteFuture;
-import org.apache.ignite.lang.IgniteRunnable;
 import org.apache.ignite.mxbean.CacheMetricsMXBean;
+import org.apache.ignite.resources.IgniteInstanceResource;
 import org.jetbrains.annotations.Nullable;
 
 /**
@@ -62,9 +60,6 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
     /** Cache name. */
     private final String cacheName;
 
-    /** Grid id. */
-    private final UUID gridId;
-
     /** With async. */
     private final boolean isAsync;
 
@@ -81,31 +76,16 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
 
     /**
      * @param name Name.
-     * @param async
+     * @param async Async flag.
      * @param proxy Ignite Process Proxy.
      */
     public IgniteCacheProcessProxy(String name, boolean async, IgniteProcessProxy proxy) {
         cacheName = name;
         isAsync = async;
-        gridId = proxy.getId();
         igniteProxy = proxy;
         compute = proxy.remoteCompute();
     }
 
-    /**
-     * Returns cache instance. Method to be called from closure at another JVM.
-     *
-     * @return Cache.
-     */
-    private IgniteCache<Object, Object> cache() {
-        IgniteCache cache = Ignition.ignite(gridId).cache(cacheName);
-
-        if (isAsync)
-            cache = cache.withAsync();
-
-        return cache;
-    }
-
     /** {@inheritDoc} */
     @Override public IgniteCache<K, V> withAsync() {
         return new IgniteCacheProcessProxy<>(cacheName, true, igniteProxy);
@@ -123,14 +103,8 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
     }
 
     /** {@inheritDoc} */
-    @Override public <C extends Configuration<K, V>> C getConfiguration(final Class<C> clazz) {
-        final Class cl = clazz;
-
-        return (C)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return cache().getConfiguration(cl);
-            }
-        });
+    @Override public <C extends Configuration<K, V>> C getConfiguration(Class<C> clazz) {
+        return compute.call(new GetConfigurationTask<>(cacheName, isAsync, clazz));
     }
 
     /** {@inheritDoc} */
@@ -148,33 +122,26 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
         throw new UnsupportedOperationException("Method should be supported.");
     }
 
+    /** {@inheritDoc} */
     @Override public IgniteCache<K, V> withNoRetries() {
         throw new UnsupportedOperationException("Method should be supported.");
     }
 
     /** {@inheritDoc} */
-    @Override public void loadCache(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args) throws CacheException {
+    @Override public void loadCache(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args)
+        throws CacheException {
         throw new UnsupportedOperationException("Method should be supported.");
     }
 
     /** {@inheritDoc} */
-    @Override public void localLoadCache(@Nullable final IgniteBiPredicate<K, V> p, @Nullable final Object... args) throws CacheException {
-        final IgniteBiPredicate pCopy = p;
-
-        compute.run(new IgniteRunnable() {
-            @Override public void run() {
-                cache().localLoadCache(pCopy, args);
-            }
-        });
+    @Override public void localLoadCache(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args)
+        throws CacheException {
+        compute.call(new LocalLoadCacheTask<>(cacheName, isAsync, p, args));
     }
 
     /** {@inheritDoc} */
-    @Override public V getAndPutIfAbsent(final K key, final V val) throws CacheException {
-        return (V)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return cache().getAndPutIfAbsent(key, val);
-            }
-        });
+    @Override public V getAndPutIfAbsent(K key, V val) throws CacheException {
+        return compute.call(new GetAndPutIfAbsentTask<>(cacheName, isAsync, key, val));
     }
 
     /** {@inheritDoc} */
@@ -188,12 +155,8 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
     }
 
     /** {@inheritDoc} */
-    @Override public boolean isLocalLocked(final K key, final boolean byCurrThread) {
-        return compute.call(new IgniteCallable<Boolean>() {
-            @Override public Boolean call() throws Exception {
-                return cache().isLocalLocked(key, byCurrThread);
-            }
-        });
+    @Override public boolean isLocalLocked(K key, boolean byCurrThread) {
+        return compute.call(new IsLocalLockedTask<>(cacheName, isAsync, key, byCurrThread));
     }
 
     /** {@inheritDoc} */
@@ -202,18 +165,8 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
     }
 
     /** {@inheritDoc} */
-    @SuppressWarnings("unchecked")
-    @Override public Iterable<Entry<K, V>> localEntries(final CachePeekMode... peekModes) throws CacheException {
-        return (Iterable<Entry<K, V>>)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                Collection<Entry> res = new ArrayList<>();
-
-                for (Entry e : cache().localEntries(peekModes))
-                    res.add(e);
-
-                return res;
-            }
-        });
+    @Override public Iterable<Entry<K, V>> localEntries(CachePeekMode... peekModes) throws CacheException {
+        return compute.call(new LocalEntriesTask<K, V>(cacheName, isAsync, peekModes));
     }
 
     /** {@inheritDoc} */
@@ -222,21 +175,13 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
     }
 
     /** {@inheritDoc} */
-    @Override public void localEvict(final Collection<? extends K> keys) {
-        compute.run(new IgniteRunnable() {
-            @Override public void run() {
-                cache().localEvict(keys);
-            }
-        });
+    @Override public void localEvict(Collection<? extends K> keys) {
+        compute.call(new LocalEvictTask<>(cacheName, isAsync, keys));
     }
 
     /** {@inheritDoc} */
-    @Override public V localPeek(final K key, final CachePeekMode... peekModes) {
-        return (V)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return cache().localPeek(key, peekModes);
-            }
-        });
+    @Override public V localPeek(K key, CachePeekMode... peekModes) {
+        return compute.call(new LocalPeekTask<K, V>(cacheName, isAsync, key, peekModes));
     }
 
     /** {@inheritDoc} */
@@ -245,274 +190,160 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
     }
 
     /** {@inheritDoc} */
-    @Override public int size(final CachePeekMode... peekModes) throws CacheException {
-        return (int)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return cache().size(peekModes);
-            }
-        });
+    @Override public int size(CachePeekMode... peekModes) throws CacheException {
+        return compute.call(new SizeTask(cacheName, isAsync, peekModes, false));
     }
 
     /** {@inheritDoc} */
-    @Override public int localSize(final CachePeekMode... peekModes) {
-        return (int)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return cache().localSize(peekModes);
-            }
-        });
+    @Override public int localSize(CachePeekMode... peekModes) {
+        return compute.call(new SizeTask(cacheName, isAsync, peekModes, true));
     }
 
     /** {@inheritDoc} */
-    @Override  public <T> Map<K, EntryProcessorResult<T>> invokeAll(Map<? extends K, ? extends EntryProcessor<K, V, T>> map,
-        Object... args) {
+    @Override  public <T> Map<K, EntryProcessorResult<T>> invokeAll(
+        Map<? extends K, ? extends EntryProcessor<K, V, T>> map,
+        Object... args)
+    {
         throw new UnsupportedOperationException("Method should be supported.");
     }
 
     /** {@inheritDoc} */
-    @Override public V get(final K key) {
-        return (V)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return cache().get(key);
-            }
-        });
+    @Override public V get(K key) {
+        return compute.call(new GetTask<K, V>(cacheName, isAsync, key));
     }
 
     /** {@inheritDoc} */
-    @Override public Map<K, V> getAll(final Set<? extends K> keys) {
-        return (Map<K, V>)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return cache().getAll(keys);
-            }
-        });
+    @Override public Map<K, V> getAll(Set<? extends K> keys) {
+        return compute.call(new GetAllTask<K, V>(cacheName, isAsync, keys));
     }
 
-    @Override public Map<K, V> getAllOutTx(final Set<? extends K> keys) {
-        return (Map<K, V>)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return cache().getAllOutTx(keys);
-            }
-        });
+    /** {@inheritDoc} */
+    @Override public Map<K, V> getAllOutTx(Set<? extends K> keys) {
+        return compute.call(new GetAllOutTxTask<K, V>(cacheName, isAsync, keys));
     }
 
     /** {@inheritDoc} */
-    @Override public boolean containsKey(final K key) {
-        return (boolean)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return cache().containsKey(key);
-            }
-        });
+    @Override public boolean containsKey(K key) {
+        return compute.call(new ContainsKeyTask<>(cacheName, isAsync, key));
     }
 
     /** {@inheritDoc} */
-    @Override  public void loadAll(Set<? extends K> keys, boolean replaceExistingValues, CompletionListener completionLsnr) {
+    @Override  public void loadAll(Set<? extends K> keys, boolean replaceExistVals, CompletionListener completionLsnr) {
         throw new UnsupportedOperationException("Oparetion can't be supported automatically.");
     }
 
     /** {@inheritDoc} */
-    @Override public boolean containsKeys(final Set<? extends K> keys) {
-        return (boolean)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return cache().containsKeys(keys);
-            }
-        });
+    @Override public boolean containsKeys(Set<? extends K> keys) {
+        return compute.call(new ContainsKeysTask<>(cacheName, isAsync, keys));
     }
 
     /** {@inheritDoc} */
-    @Override public void put(final K key, final V val) {;
-        compute.run(new IgniteRunnable() {
-            @Override public void run() {
-                cache().put(key, val);
-            }
-        });
+    @Override public void put(K key, V val) {
+        compute.call(new PutTask<>(cacheName, isAsync, key, val));
     }
 
     /** {@inheritDoc} */
-    @Override public V getAndPut(final K key, final V val) {
-        return (V)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return cache().getAndPut(key, val);
-            }
-        });
+    @Override public V getAndPut(K key, V val) {
+        return compute.call(new GetAndPutTask<>(cacheName, isAsync, key, val));
     }
 
     /** {@inheritDoc} */
-    @Override public void putAll(final Map<? extends K, ? extends V> map) {
-        compute.run(new IgniteRunnable() {
-            @Override public void run() {
-                cache().putAll(map);
-            }
-        });
+    @Override public void putAll(Map<? extends K, ? extends V> map) {
+        compute.call(new PutAllTask<>(cacheName, isAsync, map));
     }
 
     /** {@inheritDoc} */
-    @Override public boolean putIfAbsent(final K key, final V val) {
-        return (boolean)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return cache().putIfAbsent(key, val);
-            }
-        });
+    @Override public boolean putIfAbsent(K key, V val) {
+        return compute.call(new PutIfAbsentTask<>(cacheName, isAsync, key, val));
     }
 
     /** {@inheritDoc} */
-    @Override public boolean remove(final K key) {
-        return (boolean)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return cache().remove(key);
-            }
-        });
+    @Override public boolean remove(K key) {
+        return compute.call(new RemoveTask<>(cacheName, isAsync, key));
     }
 
     /** {@inheritDoc} */
-    @Override public boolean remove(final K key, final V oldVal) {
-        return (boolean)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return cache().remove(key, oldVal);
-            }
-        });
+    @Override public boolean remove(K key, V oldVal) {
+        return compute.call(new RemoveIfExistsTask<>(cacheName, isAsync, key, oldVal));
     }
 
     /** {@inheritDoc} */
-    @Override public V getAndRemove(final K key) {
-        return (V)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return cache().getAndRemove(key);
-            }
-        });
+    @Override public V getAndRemove(K key) {
+        return compute.call(new GetAndRemoveTask<K, V>(cacheName, isAsync, key));
     }
 
     /** {@inheritDoc} */
-    @Override public boolean replace(final K key, final V oldVal, final V newVal) {
-        return (boolean)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return cache().replace(key, oldVal, newVal);
-            }
-        });
+    @Override public boolean replace(K key, V oldVal, V newVal) {
+        return compute.call(new ReplaceIfExistsTask<>(cacheName, isAsync, key, oldVal, newVal));
     }
 
     /** {@inheritDoc} */
-    @Override public boolean replace(final K key, final V val) {
-        return (boolean)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return cache().replace(key, val);
-            }
-        });
+    @Override public boolean replace(K key, V val) {
+        return compute.call(new ReplaceTask<>(cacheName, isAsync, key, val));
     }
 
     /** {@inheritDoc} */
-    @Override public V getAndReplace(final K key, final V val) {
-        return (V)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return cache().getAndReplace(key, val);
-            }
-        });
+    @Override public V getAndReplace(K key, V val) {
+        return compute.call(new GetAndReplaceTask<>(cacheName, isAsync, key, val));
     }
 
     /** {@inheritDoc} */
-    @Override public void removeAll(final Set<? extends K> keys) {
-        compute.run(new IgniteRunnable() {
-            @Override public void run() {
-                cache().removeAll(keys);
-            }
-        });
+    @Override public void removeAll(Set<? extends K> keys) {
+        compute.call(new RemoveAllKeysTask<>(cacheName, isAsync, keys));
     }
 
     /** {@inheritDoc} */
     @Override public void removeAll() {
-        compute.run(new IgniteRunnable() {
-            @Override public void run() {
-                IgniteCache<Object, Object> cache = cache();
-
-                cache.removeAll();
-
-                if (isAsync)
-                    cache.future().get();
-            }
-        });
+        compute.call(new RemoveAllTask<K, V>(cacheName, isAsync));
     }
 
     /** {@inheritDoc} */
     @Override public void clear() {
-        compute.run(new IgniteRunnable() {
-            @Override public void run() {
-                cache().clear();
-            }
-        });
+        compute.call(new ClearTask(cacheName, isAsync));
     }
 
     /** {@inheritDoc} */
-    @Override public void clear(final K key) {
-        compute.run(new IgniteRunnable() {
-            @Override public void run() {
-                cache().clear(key);
-            }
-        });
+    @Override public void clear(K key) {
+        compute.call(new ClearKeyTask<>(cacheName, isAsync, false, key));
     }
 
     /** {@inheritDoc} */
-    @Override public void clearAll(final Set<? extends K> keys) {
-        compute.run(new IgniteRunnable() {
-            @Override public void run() {
-                cache().clearAll(keys);
-            }
-        });
+    @Override public void clearAll(Set<? extends K> keys) {
+        compute.call(new ClearAllKeys<>(cacheName, isAsync, false, keys));
     }
 
     /** {@inheritDoc} */
-    @Override public void localClear(final K key) {
-        compute.run(new IgniteRunnable() {
-            @Override public void run() {
-                cache().localClear(key);
-            }
-        });
+    @Override public void localClear(K key) {
+        compute.call(new ClearKeyTask<>(cacheName, isAsync, true, key));
     }
 
     /** {@inheritDoc} */
-    @Override public void localClearAll(final Set<? extends K> keys) {
-        compute.run(new IgniteRunnable() {
-            @Override public void run() {
-                cache().localClearAll(keys);
-            }
-        });
+    @Override public void localClearAll(Set<? extends K> keys) {
+        compute.call(new ClearAllKeys<>(cacheName, isAsync, true, keys));
     }
 
     /** {@inheritDoc} */
-    @Override public <T> T invoke(final K key, final EntryProcessor<K, V, T> entryProcessor, final Object... arguments) {
-        return (T)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return cache().invoke(key,
-                    (EntryProcessor<Object, Object, Object>)entryProcessor, arguments);
-            }
-        });
+    @Override public <T> T invoke(K key, EntryProcessor<K, V, T> processor, Object... args) {
+        return compute.call(new InvokeTask<>(cacheName, isAsync, key, processor, args));
     }
 
     /** {@inheritDoc} */
-    @Override public <T> T invoke(final K key, final CacheEntryProcessor<K, V, T> entryProcessor, final Object... arguments) {
-        return (T)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return cache().invoke(key,
-                    (CacheEntryProcessor<Object, Object, Object>)entryProcessor, arguments);
-            }
-        });
+    @Override public <T> T invoke(K key, CacheEntryProcessor<K, V, T> processor, Object... args) {
+        return compute.call(new InvokeTask<>(cacheName, isAsync, key, processor, args));
     }
 
     /** {@inheritDoc} */
-    @Override  public <T> Map<K, EntryProcessorResult<T>> invokeAll(final Set<? extends K> keys, final EntryProcessor<K, V, T> entryProcessor,
-        final Object... args) {
-        return (Map<K, EntryProcessorResult<T>>)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return cache().invokeAll(keys,
-                    (EntryProcessor<Object, Object, Object>)entryProcessor, args);
-            }
-        });
+    @Override  public <T> Map<K, EntryProcessorResult<T>> invokeAll(
+        Set<? extends K> keys,
+        EntryProcessor<K, V, T> processor,
+        Object... args)
+    {
+        return compute.call(new InvokeAllTask<>(cacheName, isAsync, keys, processor, args));
     }
 
     /** {@inheritDoc} */
     @Override public String getName() {
-        return (String)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return cache().getName();
-            }
-        });
+        return compute.call(new GetNameTask(cacheName, isAsync));
     }
 
     /** {@inheritDoc} */
@@ -522,72 +353,47 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
 
     /** {@inheritDoc} */
     @Override public void close() {
-        compute.run(new IgniteRunnable() {
-            @Override public void run() {
-                cache().close();
-            }
-        });
+        compute.call(new CloseTask(cacheName, isAsync));
     }
 
     /** {@inheritDoc} */
     @Override public void destroy() {
-        compute.run(new IgniteRunnable() {
-            @Override public void run() {
-                cache().destroy();
-            }
-        });
+        compute.call(new DestroyTask(cacheName, isAsync));
     }
 
     /** {@inheritDoc} */
     @Override public boolean isClosed() {
-        return (boolean)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return cache().isClosed();
-            }
-        });
+        return compute.call(new IsClosedTask(cacheName, isAsync));
     }
 
     /** {@inheritDoc} */
-    @Override public <T> T unwrap(final Class<T> clazz) {
+    @SuppressWarnings("unchecked")
+    @Override public <T> T unwrap(Class<T> clazz) {
         if (Ignite.class.equals(clazz))
             return (T)igniteProxy;
 
         try {
-            return (T)compute.call(new IgniteCallable<Object>() {
-                @Override public Object call() throws Exception {
-                    return cache().unwrap(clazz);
-                }
-            });
+            return compute.call(new UnwrapTask<>(cacheName, isAsync, clazz));
         }
         catch (Exception e) {
-            throw new IllegalArgumentException("Looks like class " + clazz + " is unmarshallable. Exception type:" + e.getClass(), e);
+            throw new IllegalArgumentException("Looks like class " + clazz +
+                " is unmarshallable. Exception type:" + e.getClass(), e);
         }
     }
 
     /** {@inheritDoc} */
-    @Override  public void registerCacheEntryListener(CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration) {
+    @Override  public void registerCacheEntryListener(CacheEntryListenerConfiguration<K, V> lsnrCfg) {
         throw new UnsupportedOperationException("Method should be supported.");
     }
 
     /** {@inheritDoc} */
-    @Override  public void deregisterCacheEntryListener(CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration) {
+    @Override  public void deregisterCacheEntryListener(CacheEntryListenerConfiguration<K, V> lsnrCfg) {
         throw new UnsupportedOperationException("Method should be supported.");
     }
 
     /** {@inheritDoc} */
     @Override public Iterator<Entry<K, V>> iterator() {
-        final Collection<Entry<K, V>> col = (Collection<Entry<K, V>>)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                Collection res = new ArrayList();
-
-                for (Object o : cache())
-                    res.add(o);
-
-                return res;
-            }
-        });
-
-        return col.iterator();
+        return compute.call(new IteratorTask<K, V>(cacheName, isAsync)).iterator();
     }
 
     /** {@inheritDoc} */
@@ -615,4 +421,968 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
     @Override public CacheMetricsMXBean mxBean() {
         throw new UnsupportedOperationException("Method should be supported.");
     }
-}
\ No newline at end of file
+
+    /**
+     *
+     */
+    private static class GetConfigurationTask<K, V, C extends Configuration<K, V>> extends CacheTaskAdapter<K, V, C> {
+        /** Clazz. */
+        private final Class<C> clazz;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param clazz Clazz.
+         */
+        public GetConfigurationTask(String cacheName, boolean async, Class<C> clazz) {
+            super(cacheName, async);
+            this.clazz = clazz;
+        }
+
+        /** {@inheritDoc} */
+        @Override public C call() throws Exception {
+            return cache().getConfiguration(clazz);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class LocalLoadCacheTask<K, V> extends CacheTaskAdapter<K, V, Void> {
+        /** Predicate. */
+        private final IgniteBiPredicate<K, V> p;
+
+        /** Args. */
+        private final Object[] args;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param p P.
+         * @param args Args.
+         */
+        public LocalLoadCacheTask(String cacheName, boolean async, IgniteBiPredicate<K, V> p, Object[] args) {
+            super(cacheName, async);
+            this.p = p;
+            this.args = args;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Void call() {
+            cache().localLoadCache(p, args);
+
+            return null;
+        }
+    }
+
+    /**
+     *
+     */
+    private static class GetAndPutIfAbsentTask<K, V> extends CacheTaskAdapter<K, V, V> {
+        /** Key. */
+        private final K key;
+
+        /** Value. */
+        private final V val;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param key Key.
+         * @param val Value.
+         */
+        public GetAndPutIfAbsentTask(String cacheName, boolean async, K key, V val) {
+            super(cacheName, async);
+            this.key = key;
+            this.val = val;
+        }
+
+        /** {@inheritDoc} */
+        @Override public V call() throws Exception {
+            return cache().getAndPutIfAbsent(key, val);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class IsLocalLockedTask<K> extends CacheTaskAdapter<K, Void, Boolean> {
+        /** Key. */
+        private final K key;
+
+        /** By current thread. */
+        private final boolean byCurrThread;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param key Key.
+         * @param byCurrThread By current thread.
+         */
+        public IsLocalLockedTask(String cacheName, boolean async, K key, boolean byCurrThread) {
+            super(cacheName, async);
+            this.key = key;
+            this.byCurrThread = byCurrThread;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Boolean call() throws Exception {
+            return cache().isLocalLocked(key, byCurrThread);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class LocalEntriesTask<K, V> extends CacheTaskAdapter<K, V, Iterable<Entry<K, V>>> {
+        /** Peek modes. */
+        private final CachePeekMode[] peekModes;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param peekModes Peek modes.
+         */
+        public LocalEntriesTask(String cacheName, boolean async, CachePeekMode[] peekModes) {
+            super(cacheName, async);
+            this.peekModes = peekModes;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Iterable<Entry<K, V>> call() throws Exception {
+            Collection<Entry<K, V>> res = new ArrayList<>();
+
+            for (Entry<K, V> e : cache().localEntries(peekModes))
+                res.add(new CacheEntryImpl<>(e.getKey(), e.getValue()));
+
+            return res;
+        }
+    }
+
+    /**
+     *
+     */
+    private static class LocalEvictTask<K> extends CacheTaskAdapter<K, Void, Void> {
+        /** Keys. */
+        private final Collection<? extends K> keys;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param keys Keys.
+         */
+        public LocalEvictTask(String cacheName, boolean async, Collection<? extends K> keys) {
+            super(cacheName, async);
+            this.keys = keys;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Void call() {
+            cache().localEvict(keys);
+
+            return null;
+        }
+    }
+
+    /**
+     *
+     */
+    private static class LocalPeekTask<K, V> extends CacheTaskAdapter<K, V, V> {
+        /** Key. */
+        private final K key;
+
+        /** Peek modes. */
+        private final CachePeekMode[] peekModes;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param key Key.
+         * @param peekModes Peek modes.
+         */
+        public LocalPeekTask(String cacheName, boolean async, K key, CachePeekMode[] peekModes) {
+            super(cacheName, async);
+            this.key = key;
+            this.peekModes = peekModes;
+        }
+
+        /** {@inheritDoc} */
+        @Override public V call() throws Exception {
+            return cache().localPeek(key, peekModes);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class SizeTask extends CacheTaskAdapter<Void, Void, Integer> {
+        /** Peek modes. */
+        private final CachePeekMode[] peekModes;
+
+        /** Local. */
+        private final boolean loc;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param peekModes Peek modes.
+         * @param loc Local.
+         */
+        public SizeTask(String cacheName, boolean async, CachePeekMode[] peekModes, boolean loc) {
+            super(cacheName, async);
+            this.loc = loc;
+            this.peekModes = peekModes;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Integer call() throws Exception {
+            return loc ? cache().localSize(peekModes) : cache().size(peekModes);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class GetTask<K, V> extends CacheTaskAdapter<K, V, V> {
+        /** Key. */
+        private final K key;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param key Key.
+         */
+        public GetTask(String cacheName, boolean async, K key) {
+            super(cacheName, async);
+            this.key = key;
+        }
+
+        /** {@inheritDoc} */
+        @Override public V call() throws Exception {
+            return cache().get(key);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class RemoveAllTask<K, V> extends CacheTaskAdapter<K, V, Void> {
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         */
+        public RemoveAllTask(String cacheName, boolean async) {
+            super(cacheName, async);
+        }
+
+        /** {@inheritDoc} */
+        @Override public Void call() {
+            IgniteCache<K, V> cache = cache();
+
+            cache.removeAll();
+
+            if (async)
+                cache.future().get();
+
+            return null;
+        }
+    }
+
+    /**
+     *
+     */
+    private static class PutTask<K, V> extends CacheTaskAdapter<K, V, Void> {
+        /** Key. */
+        private final K key;
+
+        /** Value. */
+        private final V val;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param key Key.
+         * @param val Value.
+         */
+        public PutTask(String cacheName, boolean async, K key, V val) {
+            super(cacheName, async);
+            this.key = key;
+            this.val = val;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Void call() {
+            cache().put(key, val);
+
+            return null;
+        }
+    }
+
+    /**
+     *
+     */
+    private static class ContainsKeyTask<K> extends CacheTaskAdapter<K, Object, Boolean> {
+        /** Key. */
+        private final K key;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param key Key.
+         */
+        public ContainsKeyTask(String cacheName, boolean async, K key) {
+            super(cacheName, async);
+            this.key = key;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Boolean call() throws Exception {
+            return cache().containsKey(key);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class ClearTask extends CacheTaskAdapter<Object, Object, Void> {
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         */
+        public ClearTask(String cacheName, boolean async) {
+            super(cacheName, async);
+        }
+
+        /** {@inheritDoc} */
+        @Override public Void call() {
+            cache().clear();
+
+            return null;
+        }
+    }
+
+    /**
+     *
+     */
+    private static class IteratorTask<K, V> extends CacheTaskAdapter<K, V, Collection<Entry<K, V>>> {
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         */
+        public IteratorTask(String cacheName, boolean async) {
+            super(cacheName, async);
+        }
+
+        /** {@inheritDoc} */
+        @Override public Collection<Entry<K, V>> call() throws Exception {
+            Collection<Entry<K, V>> res = new ArrayList<>();
+
+            for (Entry<K, V> o : cache())
+                res.add(o);
+
+            return res;
+        }
+    }
+
+    /**
+     *
+     */
+    private static class ReplaceTask<K, V> extends CacheTaskAdapter<K, V, Boolean> {
+        /** Key. */
+        private final K key;
+
+        /** Value. */
+        private final V val;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param key Key.
+         * @param val Value.
+         */
+        public ReplaceTask(String cacheName, boolean async, K key, V val) {
+            super(cacheName, async);
+            this.key = key;
+            this.val = val;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Boolean call() throws Exception {
+            return cache().replace(key, val);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class GetNameTask extends CacheTaskAdapter<Void, Void, String> {
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         */
+        public GetNameTask(String cacheName, boolean async) {
+            super(cacheName, async);
+        }
+
+        /** {@inheritDoc} */
+        @Override public String call() throws Exception {
+            return cache().getName();
+        }
+    }
+
+    /**
+     *
+     */
+    private static class RemoveTask<K> extends CacheTaskAdapter<K, Void, Boolean> {
+        /** Key. */
+        private final K key;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param key Key.
+         */
+        public RemoveTask(String cacheName, boolean async, K key) {
+            super(cacheName, async);
+            this.key = key;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Boolean call() throws Exception {
+            return cache().remove(key);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class PutAllTask<K, V> extends CacheTaskAdapter<K, V, Void> {
+        /** Map. */
+        private final Map<? extends K, ? extends V> map;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param map Map.
+         */
+        public PutAllTask(String cacheName, boolean async, Map<? extends K, ? extends V> map) {
+            super(cacheName, async);
+            this.map = map;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Void call() {
+            cache().putAll(map);
+
+            return null;
+        }
+    }
+
+    /**
+     *
+     */
+    private static class RemoveAllKeysTask<K> extends CacheTaskAdapter<K, Void, Void> {
+        /** Keys. */
+        private final Set<? extends K> keys;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param keys Keys.
+         */
+        public RemoveAllKeysTask(String cacheName, boolean async, Set<? extends K> keys) {
+            super(cacheName, async);
+            this.keys = keys;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Void call() {
+            cache().removeAll(keys);
+
+            return null;
+        }
+    }
+
+    /**
+     *
+     */
+    private static class GetAllTask<K, V> extends CacheTaskAdapter<K, V, Map<K, V>> {
+        /** Keys. */
+        private final Set<? extends K> keys;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param keys Keys.
+         */
+        public GetAllTask(String cacheName, boolean async, Set<? extends K> keys) {
+            super(cacheName, async);
+            this.keys = keys;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Map<K, V> call() throws Exception {
+            return cache().getAll(keys);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class GetAllOutTxTask<K, V> extends CacheTaskAdapter<K, V, Map<K, V>> {
+        /** Keys. */
+        private final Set<? extends K> keys;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param keys Keys.
+         */
+        public GetAllOutTxTask(String cacheName, boolean async, Set<? extends K> keys) {
+            super(cacheName, async);
+            this.keys = keys;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Map<K, V> call() throws Exception {
+            return cache().getAllOutTx(keys);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class ContainsKeysTask<K, V> extends CacheTaskAdapter<K, V, Boolean> {
+        /** Keys. */
+        private final Set<? extends K> keys;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param keys Keys.
+         */
+        public ContainsKeysTask(String cacheName, boolean async, Set<? extends K> keys) {
+            super(cacheName, async);
+            this.keys = keys;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Boolean call() throws Exception {
+            return cache().containsKeys(keys);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class GetAndPutTask<K, V> extends CacheTaskAdapter<K, V, V> {
+        /** Key. */
+        private final K key;
+
+        /** Value. */
+        private final V val;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param key Key.
+         * @param val Value.
+         */
+        public GetAndPutTask(String cacheName, boolean async, K key, V val) {
+            super(cacheName, async);
+            this.key = key;
+            this.val = val;
+        }
+
+        /** {@inheritDoc} */
+        @Override public V call() throws Exception {
+            return cache().getAndPut(key, val);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class PutIfAbsentTask<K, V> extends CacheTaskAdapter<K, V, Boolean> {
+        /** Key. */
+        private final K key;
+
+        /** Value. */
+        private final V val;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param key Key.
+         * @param val Value.
+         */
+        public PutIfAbsentTask(String cacheName, boolean async, K key, V val) {
+            super(cacheName, async);
+            this.key = key;
+            this.val = val;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Boolean call() throws Exception {
+            return cache().putIfAbsent(key, val);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class RemoveIfExistsTask<K, V> extends CacheTaskAdapter<K, V, Boolean> {
+        /** Key. */
+        private final K key;
+
+        /** Old value. */
+        private final V oldVal;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param key Key.
+         * @param oldVal Old value.
+         */
+        public RemoveIfExistsTask(String cacheName, boolean async, K key, V oldVal) {
+            super(cacheName, async);
+            this.key = key;
+            this.oldVal = oldVal;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Boolean call() throws Exception {
+            return cache().remove(key, oldVal);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class GetAndRemoveTask<K, V> extends CacheTaskAdapter<K, V, V> {
+        /** Key. */
+        private final K key;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param key Key.
+         */
+        public GetAndRemoveTask(String cacheName, boolean async, K key) {
+            super(cacheName, async);
+            this.key = key;
+        }
+
+        /** {@inheritDoc} */
+        @Override public V call() throws Exception {
+            return cache().getAndRemove(key);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class ReplaceIfExistsTask<K, V> extends CacheTaskAdapter<K, V, Boolean> {
+        /** Key. */
+        private final K key;
+
+        /** Old value. */
+        private final V oldVal;
+
+        /** New value. */
+        private final V newVal;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param key Key.
+         * @param oldVal Old value.
+         * @param newVal New value.
+         */
+        public ReplaceIfExistsTask(String cacheName, boolean async, K key, V oldVal, V newVal) {
+            super(cacheName, async);
+            this.key = key;
+            this.oldVal = oldVal;
+            this.newVal = newVal;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Boolean call() throws Exception {
+            return cache().replace(key, oldVal, newVal);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class GetAndReplaceTask<K, V> extends CacheTaskAdapter<K, V, V> {
+        /** Key. */
+        private final K key;
+
+        /** Value. */
+        private final V val;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param key Key.
+         * @param val Value.
+         */
+        public GetAndReplaceTask(String cacheName, boolean async, K key, V val) {
+            super(cacheName, async);
+            this.key = key;
+            this.val = val;
+        }
+
+        /** {@inheritDoc} */
+        @Override public V call() throws Exception {
+            return cache().getAndReplace(key, val);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class ClearKeyTask<K> extends CacheTaskAdapter<K, Void, Void> {
+        /** Key. */
+        private final K key;
+
+        /** Local. */
+        private final boolean loc;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param key Key.
+         */
+        public ClearKeyTask(String cacheName, boolean async, boolean loc, K key) {
+            super(cacheName, async);
+            this.key = key;
+            this.loc = loc;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Void call() {
+            if (loc)
+                cache().localClear(key);
+            else
+                cache().clear(key);
+
+            return null;
+        }
+    }
+
+    /**
+     *
+     */
+    private static class ClearAllKeys<K> extends CacheTaskAdapter<K, Void, Void> {
+        /** Keys. */
+        private final Set<? extends K> keys;
+
+        /** Local. */
+        private final boolean loc;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param keys Keys.
+         */
+        public ClearAllKeys(String cacheName, boolean async, boolean loc, Set<? extends K> keys) {
+            super(cacheName, async);
+            this.keys = keys;
+            this.loc = loc;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Void call() {
+            if (loc)
+                cache().localClearAll(keys);
+            else
+                cache().clearAll(keys);
+
+            return null;
+        }
+    }
+
+    /**
+     *
+     */
+    private static class InvokeTask<K, V, R> extends CacheTaskAdapter<K, V, R> {
+        /** Key. */
+        private final K key;
+
+        /** Processor. */
+        private final EntryProcessor<K, V, R> processor;
+
+        /** Args. */
+        private final Object[] args;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param key Key.
+         * @param processor Processor.
+         * @param args Args.
+         */
+        public InvokeTask(String cacheName, boolean async, K key, EntryProcessor<K, V, R> processor,
+            Object[] args) {
+            super(cacheName, async);
+            this.args = args;
+            this.key = key;
+            this.processor = processor;
+        }
+
+        /** {@inheritDoc} */
+        @Override public R call() throws Exception {
+            return cache().invoke(key, processor, args);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class InvokeAllTask<K, V, T> extends CacheTaskAdapter<K, V, Map<K, EntryProcessorResult<T>>> {
+        /** Keys. */
+        private final Set<? extends K> keys;
+
+        /** Processor. */
+        private final EntryProcessor<K, V, T> processor;
+
+        /** Args. */
+        private final Object[] args;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param keys Keys.
+         * @param processor Processor.
+         * @param args Args.
+         */
+        public InvokeAllTask(String cacheName, boolean async, Set<? extends K> keys,
+            EntryProcessor<K, V, T> processor, Object[] args) {
+            super(cacheName, async);
+            this.args = args;
+            this.keys = keys;
+            this.processor = processor;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Map<K, EntryProcessorResult<T>> call() throws Exception {
+            return cache().invokeAll(keys, processor, args);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class CloseTask extends CacheTaskAdapter<Void, Void, Void> {
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         */
+        public CloseTask(String cacheName, boolean async) {
+            super(cacheName, async);
+        }
+
+        /** {@inheritDoc} */
+        @Override public Void call() {
+            cache().close();
+
+            return null;
+        }
+    }
+
+    /**
+     *
+     */
+    private static class DestroyTask extends CacheTaskAdapter<Void, Void, Void> {
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         */
+        public DestroyTask(String cacheName, boolean async) {
+            super(cacheName, async);
+        }
+
+        /** {@inheritDoc} */
+        @Override public Void call() {
+            cache().destroy();
+
+            return null;
+        }
+    }
+
+    /**
+     *
+     */
+    private static class IsClosedTask extends CacheTaskAdapter<Void, Void, Boolean> {
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         */
+        public IsClosedTask(String cacheName, boolean async) {
+            super(cacheName, async);
+        }
+
+        /** {@inheritDoc} */
+        @Override public Boolean call() throws Exception {
+            return cache().isClosed();
+        }
+    }
+
+    /**
+     *
+     */
+    private static class UnwrapTask<R> extends CacheTaskAdapter<Void, Void, R> {
+        /** Clazz. */
+        private final Class<R> clazz;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param clazz Clazz.
+         */
+        public UnwrapTask(String cacheName, boolean async, Class<R> clazz) {
+            super(cacheName, async);
+            this.clazz = clazz;
+        }
+
+        /** {@inheritDoc} */
+        @Override public R call() throws Exception {
+            return cache().unwrap(clazz);
+        }
+    }
+
+    /**
+     *
+     */
+    private static abstract class CacheTaskAdapter<K, V, R> implements IgniteCallable<R> {
+        /** Ignite. */
+        @IgniteInstanceResource
+        protected Ignite ignite;
+
+        /** Cache name. */
+        protected final String cacheName;
+
+        /** Async. */
+        protected final boolean async;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         */
+        public CacheTaskAdapter(String cacheName, boolean async) {
+            this.async = async;
+            this.cacheName = cacheName;
+        }
+
+        /**
+         * Returns cache instance.
+         */
+        protected IgniteCache<K, V> cache() {
+            IgniteCache<K, V> cache = ignite.cache(cacheName);
+
+            return async ? cache.withAsync() : cache;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/5fc682f1/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteClusterProcessProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteClusterProcessProxy.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteClusterProcessProxy.java
index 05d6533..633e9d0 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteClusterProcessProxy.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteClusterProcessProxy.java
@@ -26,7 +26,6 @@ import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCluster;
 import org.apache.ignite.IgniteCompute;
 import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
 import org.apache.ignite.cluster.ClusterGroup;
 import org.apache.ignite.cluster.ClusterMetrics;
 import org.apache.ignite.cluster.ClusterNode;
@@ -36,6 +35,7 @@ import org.apache.ignite.internal.cluster.IgniteClusterEx;
 import org.apache.ignite.lang.IgniteCallable;
 import org.apache.ignite.lang.IgniteFuture;
 import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.resources.IgniteInstanceResource;
 import org.jetbrains.annotations.Nullable;
 
 /**
@@ -43,9 +43,6 @@ import org.jetbrains.annotations.Nullable;
  */
 @SuppressWarnings("TransientFieldInNonSerializableClass")
 public class IgniteClusterProcessProxy implements IgniteClusterEx {
-    /** Grid id. */
-    private final UUID gridId;
-
     /** Compute. */
     private final transient IgniteCompute compute;
 
@@ -57,21 +54,11 @@ public class IgniteClusterProcessProxy implements IgniteClusterEx {
      */
     public IgniteClusterProcessProxy(IgniteProcessProxy proxy) {
         this.proxy = proxy;
-        gridId = proxy.getId();
         compute = proxy.remoteCompute();
     }
 
-    /**
-     * Returns cluster instance. Method to be called from closure at another JVM.
-     *
-     * @return Cache.
-     */
-    private IgniteClusterEx cluster() {
-        return (IgniteClusterEx)Ignition.ignite(gridId).cluster();
-    }
-
     /** {@inheritDoc} */
-    @Override public ClusterGroupEx forSubjectId(final UUID subjId) {
+    @Override public ClusterGroupEx forSubjectId(UUID subjId) {
         throw new UnsupportedOperationException("Operation is not supported yet.");
     }
 
@@ -83,11 +70,7 @@ public class IgniteClusterProcessProxy implements IgniteClusterEx {
 
     /** {@inheritDoc} */
     @Override public ClusterNode localNode() {
-        return compute.call(new IgniteCallable<ClusterNode>() {
-            @Override public ClusterNode call() throws Exception {
-                return cluster().localNode();
-            }
-        });
+        return compute.call(new LocalNodeTask());
     }
 
     /** {@inheritDoc} */
@@ -285,38 +268,22 @@ public class IgniteClusterProcessProxy implements IgniteClusterEx {
 
     /** {@inheritDoc} */
     @Override public Collection<ClusterNode> nodes() {
-        return compute.call(new IgniteCallable<Collection<ClusterNode>>() {
-            @Override public Collection<ClusterNode> call() throws Exception {
-                return cluster().nodes();
-            }
-        });
+        return compute.call(new NodesTask());
     }
 
     /** {@inheritDoc} */
-    @Override public ClusterNode node(final UUID nid) {
-        return compute.call(new IgniteCallable<ClusterNode>() {
-            @Override public ClusterNode call() throws Exception {
-                return cluster().node(nid);
-            }
-        });
+    @Override public ClusterNode node(UUID nid) {
+        return compute.call(new NodeTask(nid));
     }
 
     /** {@inheritDoc} */
     @Override public ClusterNode node() {
-        return compute.call(new IgniteCallable<ClusterNode>() {
-            @Override public ClusterNode call() throws Exception {
-                return cluster().node();
-            }
-        });
+        return compute.call(new NodeTask(null));
     }
 
     /** {@inheritDoc} */
     @Override public Collection<String> hostNames() {
-        return compute.call(new IgniteCallable<Collection<String>>() {
-            @Override public Collection<String> call() throws Exception {
-                return cluster().hostNames();
-            }
-        });
+        return compute.call(new HostNamesTask());
     }
 
     /** {@inheritDoc} */
@@ -333,4 +300,70 @@ public class IgniteClusterProcessProxy implements IgniteClusterEx {
     @Nullable @Override public IgniteFuture<?> clientReconnectFuture() {
         throw new UnsupportedOperationException("Operation is not supported yet.");
     }
+
+    /**
+     *
+     */
+    private static class LocalNodeTask extends ClusterTaskAdapter<ClusterNode> {
+        /** {@inheritDoc} */
+        @Override public ClusterNode call() throws Exception {
+            return cluster().localNode();
+        }
+    }
+
+    /**
+     *
+     */
+    private static class NodesTask extends ClusterTaskAdapter<Collection<ClusterNode>> {
+        /** {@inheritDoc} */
+        @Override public Collection<ClusterNode> call() throws Exception {
+            return cluster().nodes();
+        }
+    }
+
+    /**
+     *
+     */
+    private static class NodeTask extends ClusterTaskAdapter<ClusterNode> {
+        /** Node id. */
+        private final UUID nodeId;
+
+        /**
+         * @param nodeId Node id.
+         */
+        public NodeTask(UUID nodeId) {
+            this.nodeId = nodeId;
+        }
+
+        /** {@inheritDoc} */
+        @Override public ClusterNode call() throws Exception {
+            return nodeId == null ? cluster().node() : cluster().node(nodeId);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class HostNamesTask extends ClusterTaskAdapter<Collection<String>> {
+        /** {@inheritDoc} */
+        @Override public Collection<String> call() throws Exception {
+            return cluster().hostNames();
+        }
+    }
+
+    /**
+     *
+     */
+    private abstract static class ClusterTaskAdapter<R> implements IgniteCallable<R> {
+        /** Ignite. */
+        @IgniteInstanceResource
+        protected Ignite ignite;
+
+        /**
+         *
+         */
+        protected IgniteCluster cluster() {
+            return ignite.cluster();
+        }
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/5fc682f1/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteEventsProcessProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteEventsProcessProxy.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteEventsProcessProxy.java
index 860f889..d5af81e 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteEventsProcessProxy.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteEventsProcessProxy.java
@@ -20,15 +20,16 @@ package org.apache.ignite.testframework.junits.multijvm;
 import java.util.Collection;
 import java.util.List;
 import java.util.UUID;
+import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteEvents;
 import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
 import org.apache.ignite.cluster.ClusterGroup;
 import org.apache.ignite.events.Event;
 import org.apache.ignite.lang.IgniteBiPredicate;
 import org.apache.ignite.lang.IgniteFuture;
 import org.apache.ignite.lang.IgnitePredicate;
 import org.apache.ignite.lang.IgniteRunnable;
+import org.apache.ignite.resources.IgniteInstanceResource;
 import org.jetbrains.annotations.Nullable;
 
 /**
@@ -39,23 +40,11 @@ public class IgniteEventsProcessProxy implements IgniteEvents {
     /** Ignite proxy. */
     private final transient IgniteProcessProxy igniteProxy;
 
-    /** Grid id. */
-    private final UUID gridId;
-
     /**
      * @param igniteProxy Ignite proxy.
      */
     public IgniteEventsProcessProxy(IgniteProcessProxy igniteProxy) {
         this.igniteProxy = igniteProxy;
-
-        gridId = igniteProxy.getId();
-    }
-
-    /**
-     * @return Events instance.
-     */
-    private IgniteEvents events() {
-        return Ignition.ignite(gridId).events();
     }
 
     /** {@inheritDoc} */
@@ -105,11 +94,7 @@ public class IgniteEventsProcessProxy implements IgniteEvents {
 
     /** {@inheritDoc} */
     @Override public void localListen(final IgnitePredicate<? extends Event> lsnr, final int... types) {
-        igniteProxy.remoteCompute().run(new IgniteRunnable() {
-            @Override public void run() {
-                events().localListen(lsnr, types);
-            }
-        });
+        igniteProxy.remoteCompute().run(new LocalListenTask(lsnr, types));
     }
 
     /** {@inheritDoc} */
@@ -151,4 +136,33 @@ public class IgniteEventsProcessProxy implements IgniteEvents {
     @Override public <R> IgniteFuture<R> future() {
         throw new UnsupportedOperationException("Operation isn't supported yet.");
     }
+
+    /**
+     *
+     */
+    private static class LocalListenTask implements IgniteRunnable {
+        /** Ignite. */
+        @IgniteInstanceResource
+        private Ignite ignite;
+
+        /** Listener. */
+        private final IgnitePredicate<? extends Event> lsnr;
+
+        /** Types. */
+        private final int[] types;
+
+        /**
+         * @param lsnr Listener.
+         * @param types Types.
+         */
+        public LocalListenTask(IgnitePredicate<? extends Event> lsnr, int[] types) {
+            this.lsnr = lsnr;
+            this.types = types;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void run() {
+            ignite.events().localListen(lsnr, types);
+        }
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/5fc682f1/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteNodeRunner.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteNodeRunner.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteNodeRunner.java
index f46e8e9..0597eda 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteNodeRunner.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteNodeRunner.java
@@ -25,13 +25,12 @@ import java.io.FileOutputStream;
 import java.io.FileReader;
 import java.io.IOException;
 import java.io.OutputStream;
-import java.lang.reflect.Field;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Set;
 import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.Ignition;
 import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.internal.IgniteEx;
@@ -39,8 +38,9 @@ import org.apache.ignite.internal.processors.cache.GridCacheAbstractFullApiSelfT
 import org.apache.ignite.internal.util.GridJavaProcess;
 import org.apache.ignite.internal.util.typedef.X;
 import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.marshaller.optimized.OptimizedMarshaller;
+import org.apache.ignite.marshaller.Marshaller;
 import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.testframework.junits.IgniteTestResources;
 import sun.jvmstat.monitor.HostIdentifier;
 import sun.jvmstat.monitor.MonitoredHost;
 import sun.jvmstat.monitor.MonitoredVm;
@@ -99,30 +99,6 @@ public class IgniteNodeRunner {
     public static String storeToFile(IgniteConfiguration cfg) throws IOException {
         String fileName = IGNITE_CONFIGURATION_FILE + cfg.getNodeId();
 
-        // Check marshaller configuration, because read configuration method expect specific marshaller.
-        if (cfg.getMarshaller() instanceof OptimizedMarshaller){
-            OptimizedMarshaller marsh = (OptimizedMarshaller)cfg.getMarshaller();
-
-            try {
-                Field isRequireFiled = marsh.getClass().getDeclaredField("requireSer");
-
-                isRequireFiled.setAccessible(true);
-
-                boolean isRequireSer = isRequireFiled.getBoolean(marsh);
-
-                if (isRequireSer)
-                    throw new UnsupportedOperationException("Unsupported marshaller configuration. " +
-                        "readCfgFromFileAndDeleteFile method expect " + OptimizedMarshaller.class.getSimpleName() +
-                        "with requireSerializeble flag in 'false'.");
-            }
-            catch (NoSuchFieldException|IllegalAccessException e) {
-                throw new IgniteException("Failed to check filed of " + OptimizedMarshaller.class.getSimpleName(), e);
-            }
-        }
-        else
-            throw new UnsupportedOperationException("Unsupported marshaller. " +
-                "readCfgFromFileAndDeleteFile method expect " + OptimizedMarshaller.class.getSimpleName());
-
         try(OutputStream out = new BufferedOutputStream(new FileOutputStream(fileName))) {
             cfg.setMBeanServer(null);
             cfg.setMarshaller(null);
@@ -143,11 +119,16 @@ public class IgniteNodeRunner {
      * @throws IOException If failed.
      * @see #storeToFile(IgniteConfiguration)
      */
-    private static IgniteConfiguration readCfgFromFileAndDeleteFile(String fileName) throws IOException {
+    private static IgniteConfiguration readCfgFromFileAndDeleteFile(String fileName)
+        throws IOException, IgniteCheckedException {
         try(BufferedReader cfgReader = new BufferedReader(new FileReader(fileName))) {
             IgniteConfiguration cfg = (IgniteConfiguration)new XStream().fromXML(cfgReader);
 
-            cfg.setMarshaller(new OptimizedMarshaller(false));
+            Marshaller marsh = IgniteTestResources.getMarshaller();
+
+            cfg.setMarshaller(marsh);
+
+            X.println("Configured marshaller class: " + marsh.getClass().getName());
 
             TcpDiscoverySpi disco = new TcpDiscoverySpi();
             disco.setIpFinder(GridCacheAbstractFullApiSelfTest.LOCAL_IP_FINDER);

http://git-wip-us.apache.org/repos/asf/ignite/blob/5fc682f1/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java
index ec7dab7..aa1d470 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java
@@ -41,13 +41,11 @@ import org.apache.ignite.IgniteFileSystem;
 import org.apache.ignite.IgniteIllegalStateException;
 import org.apache.ignite.IgniteLogger;
 import org.apache.ignite.IgniteMessaging;
-import org.apache.ignite.internal.portable.api.IgnitePortables;
 import org.apache.ignite.IgniteQueue;
 import org.apache.ignite.IgniteScheduler;
 import org.apache.ignite.IgniteServices;
 import org.apache.ignite.IgniteSet;
 import org.apache.ignite.IgniteTransactions;
-import org.apache.ignite.Ignition;
 import org.apache.ignite.cache.affinity.Affinity;
 import org.apache.ignite.cluster.ClusterGroup;
 import org.apache.ignite.cluster.ClusterNode;
@@ -62,6 +60,7 @@ import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.IgniteEx;
 import org.apache.ignite.internal.IgniteInterruptedCheckedException;
 import org.apache.ignite.internal.cluster.IgniteClusterEx;
+import org.apache.ignite.internal.portable.api.IgnitePortables;
 import org.apache.ignite.internal.processors.cache.GridCacheUtilityKey;
 import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
 import org.apache.ignite.internal.processors.hadoop.Hadoop;
@@ -78,6 +77,8 @@ import org.apache.ignite.lang.IgniteProductVersion;
 import org.apache.ignite.lang.IgniteRunnable;
 import org.apache.ignite.plugin.IgnitePlugin;
 import org.apache.ignite.plugin.PluginNotFoundException;
+import org.apache.ignite.resources.IgniteInstanceResource;
+import org.apache.ignite.testframework.junits.IgniteTestResources;
 import org.jetbrains.annotations.Nullable;
 
 /**
@@ -88,6 +89,9 @@ public class IgniteProcessProxy implements IgniteEx {
     /** Grid proxies. */
     private static final transient ConcurrentMap<String, IgniteProcessProxy> gridProxies = new ConcurrentHashMap<>();
 
+    /** Property that specify alternative {@code JAVA_HOME}. */
+    private static final String TEST_MULTIJVM_JAVA_HOME = "test.multijvm.java.home";
+
     /** Jvm process with ignite instance. */
     private final transient GridJavaProcess proc;
 
@@ -108,7 +112,7 @@ public class IgniteProcessProxy implements IgniteEx {
      * @param log Logger.
      * @param locJvmGrid Local JVM grid.
      */
-    public IgniteProcessProxy(final IgniteConfiguration cfg, final IgniteLogger log, final Ignite locJvmGrid)
+    public IgniteProcessProxy(IgniteConfiguration cfg, IgniteLogger log, Ignite locJvmGrid)
         throws Exception {
         this.cfg = cfg;
         this.locJvmGrid = locJvmGrid;
@@ -121,7 +125,9 @@ public class IgniteProcessProxy implements IgniteEx {
         Collection<String> filteredJvmArgs = new ArrayList<>();
 
         for (String arg : jvmArgs) {
-            if(!arg.toLowerCase().startsWith("-agentlib"))
+            if(arg.startsWith("-Xmx") || arg.startsWith("-Xms") ||
+                arg.startsWith("-cp") || arg.startsWith("-classpath") ||
+                arg.startsWith("-D" + IgniteTestResources.MARSH_CLASS_NAME))
                 filteredJvmArgs.add(arg);
         }
 
@@ -130,7 +136,7 @@ public class IgniteProcessProxy implements IgniteEx {
         locJvmGrid.events().localListen(new NodeStartedListener(id, rmtNodeStartedLatch), EventType.EVT_NODE_JOINED);
 
         proc = GridJavaProcess.exec(
-            IgniteNodeRunner.class,
+            IgniteNodeRunner.class.getCanonicalName(),
             cfgFileName, // Params.
             this.log,
             // Optional closure to be called each time wrapped process prints line to system.out or system.err.
@@ -140,6 +146,7 @@ public class IgniteProcessProxy implements IgniteEx {
                 }
             },
             null,
+            System.getProperty(TEST_MULTIJVM_JAVA_HOME),
             filteredJvmArgs, // JVM Args.
             System.getProperty("surefire.test.class.path")
         );
@@ -149,11 +156,7 @@ public class IgniteProcessProxy implements IgniteEx {
         IgniteProcessProxy prevVal = gridProxies.putIfAbsent(cfg.getGridName(), this);
 
         if (prevVal != null) {
-            remoteCompute().run(new IgniteRunnable() {
-                @Override public void run() {
-                    G.stop(cfg.getGridName(), true);
-                }
-            });
+            remoteCompute().run(new StopGridTask(cfg.getGridName(), true));
 
             throw new IllegalStateException("There was found instance assotiated with " + cfg.getGridName() +
                 ", instance= " + prevVal + ". New started node was stopped.");
@@ -208,30 +211,17 @@ public class IgniteProcessProxy implements IgniteEx {
      * @param gridName Grid name.
      * @param cancel Cacnel flag.
      */
-    public static void stop(final String gridName, final boolean cancel) {
+    public static void stop(String gridName, boolean cancel) {
         IgniteProcessProxy proxy = gridProxies.get(gridName);
 
         if (proxy != null) {
-            proxy.remoteCompute().run(new IgniteRunnable() {
-                @Override public void run() {
-                    G.stop(gridName, cancel);
-                }
-            });
+            proxy.remoteCompute().run(new StopGridTask(gridName, cancel));
 
             gridProxies.remove(gridName, proxy);
         }
     }
 
     /**
-     * For usage in closures.
-     *
-     * @return Ignite instance.
-     */
-    private Ignite igniteById() {
-        return Ignition.ignite(id);
-    }
-
-    /**
      * @param locNodeId ID of local node the requested grid instance is managing.
      * @return An instance of named grid. This method never returns {@code null}.
      * @throws IgniteIllegalStateException Thrown if grid was not properly initialized or grid instance was stopped or
@@ -357,11 +347,7 @@ public class IgniteProcessProxy implements IgniteEx {
 
     /** {@inheritDoc} */
     @Override public ClusterNode localNode() {
-        return remoteCompute().call(new IgniteCallable<ClusterNode>() {
-            @Override public ClusterNode call() throws Exception {
-                return ((IgniteEx)Ignition.ignite(id)).localNode();
-            }
-        });
+        return remoteCompute().call(new NodeTask());
     }
 
     /** {@inheritDoc} */
@@ -467,7 +453,10 @@ public class IgniteProcessProxy implements IgniteEx {
     }
 
     /** {@inheritDoc} */
-    @Override  public <K, V> IgniteCache<K, V> createNearCache(@Nullable String cacheName, NearCacheConfiguration<K, V> nearCfg) {
+    @Override  public <K, V> IgniteCache<K, V> createNearCache(
+        @Nullable String cacheName,
+        NearCacheConfiguration<K, V> nearCfg)
+    {
         throw new UnsupportedOperationException("Operation isn't supported yet.");
     }
 
@@ -508,7 +497,8 @@ public class IgniteProcessProxy implements IgniteEx {
     }
 
     /** {@inheritDoc} */
-    @Override  public IgniteAtomicSequence atomicSequence(String name, long initVal, boolean create) throws IgniteException {
+    @Override  public IgniteAtomicSequence atomicSequence(String name, long initVal, boolean create)
+        throws IgniteException {
         throw new UnsupportedOperationException("Operation isn't supported yet.");
     }
 
@@ -524,8 +514,12 @@ public class IgniteProcessProxy implements IgniteEx {
     }
 
     /** {@inheritDoc} */
-    @Override  public <T, S> IgniteAtomicStamped<T, S> atomicStamped(String name, @Nullable T initVal, @Nullable S initStamp,
-        boolean create) throws IgniteException {
+    @Override  public <T, S> IgniteAtomicStamped<T, S> atomicStamped(
+        String name,
+        @Nullable T initVal,
+        @Nullable S initStamp,
+        boolean create) throws IgniteException
+    {
         throw new UnsupportedOperationException("Operation isn't supported yet.");
     }
 
@@ -572,11 +566,7 @@ public class IgniteProcessProxy implements IgniteEx {
             }
         }, EventType.EVT_NODE_LEFT, EventType.EVT_NODE_FAILED);
 
-        compute().run(new IgniteRunnable() {
-            @Override public void run() {
-                igniteById().close();
-            }
-        });
+        compute().run(new StopGridTask(localJvmGrid().name(), true));
 
         try {
             assert U.await(rmtNodeStoppedLatch, 15, TimeUnit.SECONDS) : "NodeId=" + id;
@@ -616,4 +606,43 @@ public class IgniteProcessProxy implements IgniteEx {
 
         return locJvmGrid.compute(grp);
     }
+
+    /**
+     *
+     */
+    private static class StopGridTask implements IgniteRunnable {
+        /** Grid name. */
+        private final String gridName;
+
+        /** Cancel. */
+        private final boolean cancel;
+
+        /**
+         * @param gridName Grid name.
+         * @param cancel Cancel.
+         */
+        public StopGridTask(String gridName, boolean cancel) {
+            this.gridName = gridName;
+            this.cancel = cancel;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void run() {
+            G.stop(gridName, cancel);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class NodeTask implements IgniteCallable<ClusterNode> {
+        /** Ignite. */
+        @IgniteInstanceResource
+        private Ignite ignite;
+
+        /** {@inheritDoc} */
+        @Override public ClusterNode call() throws Exception {
+            return ((IgniteEx)ignite).localNode();
+        }
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/5fc682f1/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationP2PTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationP2PTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationP2PTest.java
index 5298dd4..3777154 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationP2PTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationP2PTest.java
@@ -103,6 +103,7 @@ public class CacheConfigurationP2PTest extends GridCommonAbstractTest {
                         }
                     },
                     null,
+                    null,
                     jvmArgs,
                     null
                 );
@@ -119,6 +120,7 @@ public class CacheConfigurationP2PTest extends GridCommonAbstractTest {
                         }
                     },
                     null,
+                    null,
                     jvmArgs,
                     null
                 );
@@ -139,6 +141,7 @@ public class CacheConfigurationP2PTest extends GridCommonAbstractTest {
                         }
                     },
                     null,
+                    null,
                     jvmArgs,
                     cp
                 );


[45/50] [abbrv] ignite git commit: Muted GridReplicatedTxPreloadTest#testLocalTxPreloadingOptimistic test

Posted by ag...@apache.org.
Muted GridReplicatedTxPreloadTest#testLocalTxPreloadingOptimistic test


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

Branch: refs/heads/ignite-1016
Commit: 0acb5db8e9b740d0e1109d0dba0e247e20267610
Parents: 43b40f4
Author: ashutak <as...@gridgain.com>
Authored: Wed Oct 21 13:48:12 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Wed Oct 21 13:48:12 2015 +0300

----------------------------------------------------------------------
 .../distributed/replicated/GridReplicatedTxPreloadTest.java   | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/0acb5db8/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridReplicatedTxPreloadTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridReplicatedTxPreloadTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridReplicatedTxPreloadTest.java
index 4da7734..e7560c7 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridReplicatedTxPreloadTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridReplicatedTxPreloadTest.java
@@ -30,4 +30,9 @@ public class GridReplicatedTxPreloadTest extends IgniteTxPreloadAbstractTest {
     @Override protected CacheMode cacheMode() {
         return REPLICATED;
     }
-}
\ No newline at end of file
+
+    /** {@inheritDoc} */
+    @Override public void testLocalTxPreloadingOptimistic() throws Exception {
+        fail("https://issues.apache.org/jira/browse/IGNITE-1755");
+    }
+}


[10/50] [abbrv] ignite git commit: ignite-1168 Added support for metadata, scan commands in rest.

Posted by ag...@apache.org.
ignite-1168 Added support for metadata, scan commands in rest.


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

Branch: refs/heads/ignite-1016
Commit: 1223525478a80f527abcce7327a4d8b92c8b085a
Parents: a1e5cc5
Author: Andrey <an...@gridgain.com>
Authored: Mon Oct 12 15:51:48 2015 +0700
Committer: Andrey <an...@gridgain.com>
Committed: Mon Oct 12 15:51:48 2015 +0700

----------------------------------------------------------------------
 .../JettyRestProcessorAbstractSelfTest.java     | 225 ++++++++
 .../discovery/GridDiscoveryManager.java         | 515 ++++++++++++++++++-
 .../processors/cache/GridCacheProcessor.java    |  48 +-
 .../cache/query/GridCacheQueryManager.java      |  74 ++-
 .../cache/query/GridCacheSqlIndexMetadata.java  |   7 +-
 .../cache/query/GridCacheSqlMetadata.java       |  22 +-
 .../processors/rest/GridRestCommand.java        |   8 +-
 .../processors/rest/GridRestProcessor.java      |  63 ++-
 .../handlers/cache/GridCacheCommandHandler.java | 362 +++++++------
 .../handlers/query/QueryCommandHandler.java     | 195 +++++--
 .../top/GridTopologyCommandHandler.java         | 160 +++++-
 .../rest/request/RestQueryRequest.java          | 175 +++++++
 .../rest/request/RestSqlQueryRequest.java       | 125 -----
 .../http/jetty/GridJettyJsonConfig.java         | 158 +++++-
 .../http/jetty/GridJettyRestHandler.java        | 186 ++++---
 15 files changed, 1849 insertions(+), 474 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/12235254/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 ac0edff..bb6e67e 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
@@ -24,6 +24,7 @@ import java.io.Serializable;
 import java.net.URL;
 import java.net.URLConnection;
 import java.net.URLEncoder;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -31,14 +32,24 @@ import java.util.Map;
 import java.util.UUID;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.regex.Pattern;
+import net.sf.json.JSONNull;
 import net.sf.json.JSONObject;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.cache.CachePeekMode;
 import org.apache.ignite.cache.query.SqlQuery;
 import org.apache.ignite.cache.query.annotations.QuerySqlField;
+import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.internal.processors.cache.GridCacheProcessor;
+import org.apache.ignite.internal.processors.cache.IgniteCacheProxy;
+import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
+import org.apache.ignite.internal.processors.cache.query.GridCacheSqlIndexMetadata;
+import org.apache.ignite.internal.processors.cache.query.GridCacheSqlMetadata;
 import org.apache.ignite.internal.processors.rest.handlers.GridRestCommandHandler;
 import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.CU;
+import org.apache.ignite.lang.IgniteBiPredicate;
+import org.apache.ignite.lang.IgnitePredicate;
 import org.apache.ignite.testframework.GridTestUtils;
 
 import static org.apache.ignite.IgniteSystemProperties.IGNITE_JETTY_PORT;
@@ -907,6 +918,106 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
     }
 
     /**
+     * @param meta Metadata for Ignite cache.
+     * @throws Exception If failed.
+     */
+    private void testMetadata(GridCacheSqlMetadata meta) throws Exception {
+        Map<String, String> params = F.asMap("cmd", GridRestCommand.CACHE_METADATA.key());
+
+        if (meta.cacheName() != null)
+            params.put("cacheName", meta.cacheName());
+
+        String ret = content(params);
+
+        assertNotNull(ret);
+        assertTrue(!ret.isEmpty());
+
+        info("Cache metadata result: " + ret);
+
+        jsonEquals(ret, pattern("\\{.+\\}", true));
+
+        Map res = (Map)JSONObject.fromObject(ret).get("response");
+
+        Collection types = (Collection)res.get("types");
+
+        assertNotNull(types);
+        assertEqualsCollections(meta.types(), types);
+
+        Map keyClasses = (Map)res.get("keyClasses");
+
+        assertNotNull(keyClasses);
+        assertTrue(meta.keyClasses().equals(keyClasses));
+
+        Map valClasses = (Map)res.get("valClasses");
+
+        assertNotNull(valClasses);
+        assertTrue(meta.valClasses().equals(valClasses));
+
+        Map fields = (Map)res.get("fields");
+
+        assertNotNull(fields);
+        assertTrue(meta.fields().equals(fields));
+
+        Map indexesByType = (Map)res.get("indexes");
+
+        assertNotNull(indexesByType);
+        assertEquals(meta.indexes().size(), indexesByType.size());
+
+        for (Map.Entry<String, Collection<GridCacheSqlIndexMetadata>> metaIndexes : meta.indexes().entrySet()) {
+            Collection<Map> indexes = (Collection<Map>)indexesByType.get(metaIndexes.getKey());
+
+            assertNotNull(indexes);
+            assertEquals(metaIndexes.getValue().size(), indexes.size());
+
+            for (final GridCacheSqlIndexMetadata metaIdx : metaIndexes.getValue()) {
+                Map idx = F.find(indexes, null, new IgnitePredicate<Map>() {
+                    @Override public boolean apply(Map map) {
+                        return metaIdx.name().equals(map.get("name"));
+                    }
+                });
+
+                assertNotNull(idx);
+
+                assertEqualsCollections(metaIdx.fields(), (Collection)idx.get("fields"));
+                assertEqualsCollections(metaIdx.descendings(), (Collection)idx.get("descendings"));
+                assertEquals(metaIdx.unique(), idx.get("unique"));
+            }
+        }
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testMetadataLocal() throws Exception {
+        GridCacheProcessor cacheProc = grid(0).context().cache();
+
+        for (IgniteInternalCache<?, ?> cache : cacheProc.caches()) {
+            if (CU.isSystemCache(cache.name()))
+                continue;
+
+            GridCacheSqlMetadata meta = F.first(cache.context().queries().sqlMetadata());
+
+            testMetadata(meta);
+        }
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testMetadataRemote() throws Exception {
+        CacheConfiguration<Integer, String> partialCacheCfg = new CacheConfiguration<>("partial");
+
+        partialCacheCfg.setIndexedTypes(Integer.class, String.class);
+        partialCacheCfg.setNodeFilter(new NodeIdFilter(grid(1).localNode().id()));
+
+        IgniteCacheProxy<Integer, String> c = (IgniteCacheProxy<Integer, String>)grid(1).createCache(partialCacheCfg);
+
+        GridCacheSqlMetadata meta = F.first(c.context().queries().sqlMetadata());
+
+        testMetadata(meta);
+    }
+
+    /**
      * @throws Exception If failed.
      */
     public void testTopology() throws Exception {
@@ -918,6 +1029,23 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
         info("Topology command result: " + ret);
 
         jsonEquals(ret, pattern("\\[\\{.+\\}\\]", true));
+
+        JSONObject json = JSONObject.fromObject(ret);
+
+        Collection<Map> nodes = (Collection)json.get("response");
+
+        assertEquals(GRID_CNT, nodes.size());
+
+        for (Map node : nodes) {
+            assertEquals(JSONNull.getInstance(), node.get("attributes"));
+            assertEquals(JSONNull.getInstance(), node.get("metrics"));
+
+            assertEquals("PARTITIONED", node.get("defaultCacheMode"));
+
+            Map caches = (Map)node.get("caches");
+
+            assertEquals(F.asMap("person", "PARTITIONED"), caches);
+        }
     }
 
     /**
@@ -1056,6 +1184,75 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
     /**
      * @throws Exception If failed.
      */
+    public void testQueryScan() throws Exception {
+        Map<String, String> params = new HashMap<>();
+        params.put("cmd", GridRestCommand.EXECUTE_SCAN_QUERY.key());
+        params.put("pageSize", "10");
+        params.put("cacheName", "person");
+
+        String ret = content(params);
+
+        assertNotNull(ret);
+        assertTrue(!ret.isEmpty());
+
+        JSONObject json = JSONObject.fromObject(ret);
+
+        List items = (List)((Map)json.get("response")).get("items");
+
+        assertEquals(4, items.size());
+
+        assertFalse(queryCursorFound());
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testFilterQueryScan() throws Exception {
+        Map<String, String> params = new HashMap<>();
+        params.put("cmd", GridRestCommand.EXECUTE_SCAN_QUERY.key());
+        params.put("pageSize", "10");
+        params.put("cacheName", "person");
+        params.put("classname", ScanFilter.class.getName());
+
+        String ret = content(params);
+
+        assertNotNull(ret);
+        assertTrue(!ret.isEmpty());
+
+        JSONObject json = JSONObject.fromObject(ret);
+
+        List items = (List)((Map)json.get("response")).get("items");
+
+        assertEquals(2, items.size());
+
+        assertFalse(queryCursorFound());
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testIncorrectFilterQueryScan() throws Exception {
+        Map<String, String> params = new HashMap<>();
+        params.put("cmd", GridRestCommand.EXECUTE_SCAN_QUERY.key());
+        params.put("pageSize", "10");
+        params.put("cacheName", "person");
+        params.put("classname", ScanFilter.class.getName() + 1);
+
+        String ret = content(params);
+
+        assertNotNull(ret);
+        assertTrue(!ret.isEmpty());
+
+        JSONObject json = JSONObject.fromObject(ret);
+
+        String err = (String)json.get("error");
+
+        assertTrue(err.contains("Failed to find target class"));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
     public void testQuery() throws Exception {
         grid(0).cache(null).put("1", "1");
         grid(0).cache(null).put("2", "2");
@@ -1323,4 +1520,32 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
             return id;
         }
     }
+
+    /**
+     * Test filter for scan query.
+     */
+    public static class ScanFilter implements IgniteBiPredicate<Integer, Person> {
+        /** {@inheritDoc} */
+        @Override public boolean apply(Integer integer, Person person) {
+            return person.salary > 1000;
+        }
+    }
+
+    /** Filter by node ID. */
+    private static class NodeIdFilter implements IgnitePredicate<ClusterNode> {
+        /** */
+        private final UUID nid;
+
+        /**
+         * @param nid Node ID where cache should be started.
+         */
+        NodeIdFilter(UUID nid) {
+            this.nid = nid;
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean apply(ClusterNode n) {
+            return n.id().equals(nid);
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/12235254/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 2ed4520..9e54f6f 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
@@ -56,6 +56,7 @@ import org.apache.ignite.IgniteClientDisconnectedException;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.IgniteInterruptedException;
 import org.apache.ignite.cache.CacheMetrics;
+import org.apache.ignite.cache.CacheMode;
 import org.apache.ignite.cluster.ClusterMetrics;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.events.DiscoveryEvent;
@@ -299,16 +300,16 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
      * @param cacheName Cache name.
      * @param filter Cache filter.
      * @param nearEnabled Near enabled flag.
-     * @param loc {@code True} if cache is local.
+     * @param cacheMode Cache mode.
      */
     public void setCacheFilter(
         String cacheName,
         IgnitePredicate<ClusterNode> filter,
         boolean nearEnabled,
-        boolean loc
+        CacheMode cacheMode
     ) {
         if (!registeredCaches.containsKey(cacheName))
-            registeredCaches.put(cacheName, new CachePredicate(filter, nearEnabled, loc));
+            registeredCaches.put(cacheName, new CachePredicate(filter, nearEnabled, cacheMode));
     }
 
     /**
@@ -1592,6 +1593,25 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
     }
 
     /**
+     * @param node Node to check.
+     * @return Cache names accessible on the given node.
+     */
+    public Map<String, CacheMode> nodeCaches(ClusterNode node) {
+        Map<String, CacheMode> caches = U.newHashMap(registeredCaches.size());
+
+        for (Map.Entry<String, CachePredicate> entry : registeredCaches.entrySet()) {
+            String cacheName = entry.getKey();
+
+            CachePredicate pred = entry.getValue();
+
+            if (pred != null && pred.cacheNode(node))
+                caches.put(cacheName, pred.cacheMode);
+        }
+
+        return caches;
+    }
+
+    /**
      * Checks if cache with given name has at least one node with near cache enabled.
      *
      * @param cacheName Cache name.
@@ -2822,7 +2842,484 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
         }
     }
 
-    /**
+    /** Cache for discovery collections. */
+    private class DiscoCache {
+        /** Remote nodes. */
+        private final List<ClusterNode> rmtNodes;
+
+        /** All nodes. */
+        private final List<ClusterNode> allNodes;
+
+        /** All nodes with at least one cache configured. */
+        @GridToStringInclude
+        private final Collection<ClusterNode> allNodesWithCaches;
+
+        /** All nodes with at least one cache configured. */
+        @GridToStringInclude
+        private final Collection<ClusterNode> rmtNodesWithCaches;
+
+        /** Cache nodes by cache name. */
+        @GridToStringInclude
+        private final Map<String, Collection<ClusterNode>> allCacheNodes;
+
+        /** Remote cache nodes by cache name. */
+        @GridToStringInclude
+        private final Map<String, Collection<ClusterNode>> rmtCacheNodes;
+
+        /** Cache nodes by cache name. */
+        @GridToStringInclude
+        private final Map<String, Collection<ClusterNode>> affCacheNodes;
+
+        /** Caches where at least one node has near cache enabled. */
+        @GridToStringInclude
+        private final Set<String> nearEnabledCaches;
+
+        /** Nodes grouped by version. */
+        private final NavigableMap<IgniteProductVersion, Collection<ClusterNode>> nodesByVer;
+
+        /** Daemon nodes. */
+        private final List<ClusterNode> daemonNodes;
+
+        /** Node map. */
+        private final Map<UUID, ClusterNode> nodeMap;
+
+        /** Local node. */
+        private final ClusterNode loc;
+
+        /** Highest node order. */
+        private final long maxOrder;
+
+        /**
+         * Cached alive nodes list. As long as this collection doesn't accept {@code null}s use {@link
+         * #maskNull(String)} before passing raw cache names to it.
+         */
+        private final ConcurrentMap<String, Collection<ClusterNode>> aliveCacheNodes;
+
+        /**
+         * Cached alive remote nodes list. As long as this collection doesn't accept {@code null}s use {@link
+         * #maskNull(String)} before passing raw cache names to it.
+         */
+        private final ConcurrentMap<String, Collection<ClusterNode>> aliveRmtCacheNodes;
+
+        /**
+         * Cached alive remote nodes with caches.
+         */
+        private final Collection<ClusterNode> aliveNodesWithCaches;
+
+        /**
+         * Cached alive server remote nodes with caches.
+         */
+        private final Collection<ClusterNode> aliveSrvNodesWithCaches;
+
+        /**
+         * Cached alive remote server nodes with caches.
+         */
+        private final Collection<ClusterNode> aliveRmtSrvNodesWithCaches;
+
+        /**
+         * @param loc Local node.
+         * @param rmts Remote nodes.
+         */
+        private DiscoCache(ClusterNode loc, Collection<ClusterNode> rmts) {
+            this.loc = loc;
+
+            rmtNodes = Collections.unmodifiableList(new ArrayList<>(F.view(rmts, daemonFilter)));
+
+            assert !rmtNodes.contains(loc) : "Remote nodes collection shouldn't contain local node" +
+                " [rmtNodes=" + rmtNodes + ", loc=" + loc + ']';
+
+            List<ClusterNode> all = new ArrayList<>(rmtNodes.size() + 1);
+
+            if (!loc.isDaemon())
+                all.add(loc);
+
+            all.addAll(rmtNodes);
+
+            Collections.sort(all, GridNodeOrderComparator.INSTANCE);
+
+            allNodes = Collections.unmodifiableList(all);
+
+            Map<String, Collection<ClusterNode>> cacheMap = new HashMap<>(allNodes.size(), 1.0f);
+            Map<String, Collection<ClusterNode>> rmtCacheMap = new HashMap<>(allNodes.size(), 1.0f);
+            Map<String, Collection<ClusterNode>> dhtNodesMap = new HashMap<>(allNodes.size(), 1.0f);
+            Collection<ClusterNode> nodesWithCaches = new HashSet<>(allNodes.size());
+            Collection<ClusterNode> rmtNodesWithCaches = new HashSet<>(allNodes.size());
+
+            aliveCacheNodes = new ConcurrentHashMap8<>(allNodes.size(), 1.0f);
+            aliveRmtCacheNodes = new ConcurrentHashMap8<>(allNodes.size(), 1.0f);
+            aliveNodesWithCaches = new ConcurrentSkipListSet<>();
+            aliveSrvNodesWithCaches = new ConcurrentSkipListSet<>();
+            aliveRmtSrvNodesWithCaches = new ConcurrentSkipListSet<>();
+            nodesByVer = new TreeMap<>();
+
+            long maxOrder0 = 0;
+
+            Set<String> nearEnabledSet = new HashSet<>();
+
+            for (ClusterNode node : allNodes) {
+                assert node.order() != 0 : "Invalid node order [locNode=" + loc + ", node=" + node + ']';
+
+                if (node.order() > maxOrder0)
+                    maxOrder0 = node.order();
+
+                boolean hasCaches = false;
+
+                for (Map.Entry<String, CachePredicate> entry : registeredCaches.entrySet()) {
+                    String cacheName = entry.getKey();
+
+                    CachePredicate filter = entry.getValue();
+
+                    if (filter.cacheNode(node)) {
+                        nodesWithCaches.add(node);
+
+                        if (!loc.id().equals(node.id()))
+                            rmtNodesWithCaches.add(node);
+
+                        addToMap(cacheMap, cacheName, node);
+
+                        if (alive(node.id()))
+                            addToMap(aliveCacheNodes, maskNull(cacheName), node);
+
+                        if (filter.dataNode(node))
+                            addToMap(dhtNodesMap, cacheName, node);
+
+                        if (filter.nearNode(node))
+                            nearEnabledSet.add(cacheName);
+
+                        if (!loc.id().equals(node.id())) {
+                            addToMap(rmtCacheMap, cacheName, node);
+
+                            if (alive(node.id()))
+                                addToMap(aliveRmtCacheNodes, maskNull(cacheName), node);
+                        }
+
+                        hasCaches = true;
+                    }
+                }
+
+                if (hasCaches) {
+                    if (alive(node.id())) {
+                        aliveNodesWithCaches.add(node);
+
+                        if (!CU.clientNode(node)) {
+                            aliveSrvNodesWithCaches.add(node);
+
+                            if (!loc.id().equals(node.id()))
+                                aliveRmtSrvNodesWithCaches.add(node);
+                        }
+                    }
+                }
+
+                IgniteProductVersion nodeVer = U.productVersion(node);
+
+                // Create collection for this version if it does not exist.
+                Collection<ClusterNode> nodes = nodesByVer.get(nodeVer);
+
+                if (nodes == null) {
+                    nodes = new ArrayList<>(allNodes.size());
+
+                    nodesByVer.put(nodeVer, nodes);
+                }
+
+                nodes.add(node);
+            }
+
+            // Need second iteration to add this node to all previous node versions.
+            for (ClusterNode node : allNodes) {
+                IgniteProductVersion nodeVer = U.productVersion(node);
+
+                // Get all versions lower or equal node's version.
+                NavigableMap<IgniteProductVersion, Collection<ClusterNode>> updateView =
+                    nodesByVer.headMap(nodeVer, false);
+
+                for (Collection<ClusterNode> prevVersions : updateView.values())
+                    prevVersions.add(node);
+            }
+
+            maxOrder = maxOrder0;
+
+            allCacheNodes = Collections.unmodifiableMap(cacheMap);
+            rmtCacheNodes = Collections.unmodifiableMap(rmtCacheMap);
+            affCacheNodes = Collections.unmodifiableMap(dhtNodesMap);
+            allNodesWithCaches = Collections.unmodifiableCollection(nodesWithCaches);
+            this.rmtNodesWithCaches = Collections.unmodifiableCollection(rmtNodesWithCaches);
+            nearEnabledCaches = Collections.unmodifiableSet(nearEnabledSet);
+
+            daemonNodes = Collections.unmodifiableList(new ArrayList<>(
+                F.view(F.concat(false, loc, rmts), F0.not(daemonFilter))));
+
+            Map<UUID, ClusterNode> nodeMap = new HashMap<>(allNodes().size() + daemonNodes.size(), 1.0f);
+
+            for (ClusterNode n : F.concat(false, allNodes(), daemonNodes()))
+                nodeMap.put(n.id(), n);
+
+            this.nodeMap = nodeMap;
+        }
+
+        /**
+         * Adds node to map.
+         *
+         * @param cacheMap Map to add to.
+         * @param cacheName Cache name.
+         * @param rich Node to add
+         */
+        private void addToMap(Map<String, Collection<ClusterNode>> cacheMap, String cacheName, ClusterNode rich) {
+            Collection<ClusterNode> cacheNodes = cacheMap.get(cacheName);
+
+            if (cacheNodes == null) {
+                cacheNodes = new ArrayList<>(allNodes.size());
+
+                cacheMap.put(cacheName, cacheNodes);
+            }
+
+            cacheNodes.add(rich);
+        }
+
+        /** @return Local node. */
+        ClusterNode localNode() {
+            return loc;
+        }
+
+        /** @return Remote nodes. */
+        Collection<ClusterNode> remoteNodes() {
+            return rmtNodes;
+        }
+
+        /** @return All nodes. */
+        Collection<ClusterNode> allNodes() {
+            return allNodes;
+        }
+
+        /**
+         * Gets collection of nodes which have version equal or greater than {@code ver}.
+         *
+         * @param ver Version to check.
+         * @return Collection of nodes with version equal or greater than {@code ver}.
+         */
+        Collection<ClusterNode> elderNodes(IgniteProductVersion ver) {
+            Map.Entry<IgniteProductVersion, Collection<ClusterNode>> entry = nodesByVer.ceilingEntry(ver);
+
+            if (entry == null)
+                return Collections.emptyList();
+
+            return entry.getValue();
+        }
+
+        /**
+         * @return Versions map.
+         */
+        NavigableMap<IgniteProductVersion, Collection<ClusterNode>> versionsMap() {
+            return nodesByVer;
+        }
+
+        /**
+         * Gets collection of nodes with at least one cache configured.
+         *
+         * @param topVer Topology version (maximum allowed node order).
+         * @return Collection of nodes.
+         */
+        Collection<ClusterNode> allNodesWithCaches(final long topVer) {
+            return filter(topVer, allNodesWithCaches);
+        }
+
+        /**
+         * Gets all nodes that have cache with given name.
+         *
+         * @param cacheName Cache name.
+         * @param topVer Topology version.
+         * @return Collection of nodes.
+         */
+        Collection<ClusterNode> cacheNodes(@Nullable String cacheName, final long topVer) {
+            return filter(topVer, allCacheNodes.get(cacheName));
+        }
+
+        /**
+         * Gets all remote nodes that have cache with given name.
+         *
+         * @param cacheName Cache name.
+         * @param topVer Topology version.
+         * @return Collection of nodes.
+         */
+        Collection<ClusterNode> remoteCacheNodes(@Nullable String cacheName, final long topVer) {
+            return filter(topVer, rmtCacheNodes.get(cacheName));
+        }
+
+        /**
+         * Gets all remote nodes that have at least one cache configured.
+         *
+         * @param topVer Topology version.
+         * @return Collection of nodes.
+         */
+        Collection<ClusterNode> remoteCacheNodes(final long topVer) {
+            return filter(topVer, rmtNodesWithCaches);
+        }
+
+        /**
+         * Gets all nodes that have cache with given name and should participate in affinity calculation. With
+         * partitioned cache nodes with near-only cache do not participate in affinity node calculation.
+         *
+         * @param cacheName Cache name.
+         * @param topVer Topology version.
+         * @return Collection of nodes.
+         */
+        Collection<ClusterNode> cacheAffinityNodes(@Nullable String cacheName, final long topVer) {
+            return filter(topVer, affCacheNodes.get(cacheName));
+        }
+
+        /**
+         * Gets all alive nodes that have cache with given name.
+         *
+         * @param cacheName Cache name.
+         * @param topVer Topology version.
+         * @return Collection of nodes.
+         */
+        Collection<ClusterNode> aliveCacheNodes(@Nullable String cacheName, final long topVer) {
+            return filter(topVer, aliveCacheNodes.get(maskNull(cacheName)));
+        }
+
+        /**
+         * Gets all alive remote nodes that have cache with given name.
+         *
+         * @param cacheName Cache name.
+         * @param topVer Topology version.
+         * @return Collection of nodes.
+         */
+        Collection<ClusterNode> aliveRemoteCacheNodes(@Nullable String cacheName, final long topVer) {
+            return filter(topVer, aliveRmtCacheNodes.get(maskNull(cacheName)));
+        }
+
+        /**
+         * Gets all alive remote server nodes with at least one cache configured.
+         *
+         * @param topVer Topology version.
+         * @return Collection of nodes.
+         */
+        Collection<ClusterNode> aliveRemoteServerNodesWithCaches(final long topVer) {
+            return filter(topVer, aliveRmtSrvNodesWithCaches);
+        }
+
+        /**
+         * Gets all alive server nodes with at least one cache configured.
+         *
+         * @param topVer Topology version.
+         * @return Collection of nodes.
+         */
+        Collection<ClusterNode> aliveServerNodesWithCaches(final long topVer) {
+            return filter(topVer, aliveSrvNodesWithCaches);
+        }
+
+        /**
+         * Gets all alive remote nodes with at least one cache configured.
+         *
+         * @param topVer Topology version.
+         * @return Collection of nodes.
+         */
+        Collection<ClusterNode> aliveNodesWithCaches(final long topVer) {
+            return filter(topVer, aliveNodesWithCaches);
+        }
+
+        /**
+         * Checks if cache with given name has at least one node with near cache enabled.
+         *
+         * @param cacheName Cache name.
+         * @return {@code True} if cache with given name has at least one node with near cache enabled.
+         */
+        boolean hasNearCache(@Nullable String cacheName) {
+            return nearEnabledCaches.contains(cacheName);
+        }
+
+        /**
+         * Removes left node from cached alives lists.
+         *
+         * @param leftNode Left node.
+         */
+        void updateAlives(ClusterNode leftNode) {
+            if (leftNode.order() > maxOrder)
+                return;
+
+            filterNodeMap(aliveCacheNodes, leftNode);
+
+            filterNodeMap(aliveRmtCacheNodes, leftNode);
+
+            aliveNodesWithCaches.remove(leftNode);
+            aliveSrvNodesWithCaches.remove(leftNode);
+            aliveRmtSrvNodesWithCaches.remove(leftNode);
+        }
+
+        /**
+         * Creates a copy of nodes map without the given node.
+         *
+         * @param map Map to copy.
+         * @param exclNode Node to exclude.
+         */
+        private void filterNodeMap(ConcurrentMap<String, Collection<ClusterNode>> map, final ClusterNode exclNode) {
+            for (String cacheName : registeredCaches.keySet()) {
+                String maskedName = maskNull(cacheName);
+
+                while (true) {
+                    Collection<ClusterNode> oldNodes = map.get(maskedName);
+
+                    if (oldNodes == null || oldNodes.isEmpty())
+                        break;
+
+                    Collection<ClusterNode> newNodes = new ArrayList<>(oldNodes);
+
+                    if (!newNodes.remove(exclNode))
+                        break;
+
+                    if (map.replace(maskedName, oldNodes, newNodes))
+                        break;
+                }
+            }
+        }
+
+        /**
+         * Replaces {@code null} with {@code NULL_CACHE_NAME}.
+         *
+         * @param cacheName Cache name.
+         * @return Masked name.
+         */
+        private String maskNull(@Nullable String cacheName) {
+            return cacheName == null ? NULL_CACHE_NAME : cacheName;
+        }
+
+        /**
+         * @param topVer Topology version.
+         * @param nodes Nodes.
+         * @return Filtered collection (potentially empty, but never {@code null}).
+         */
+        private Collection<ClusterNode> filter(final long topVer, @Nullable Collection<ClusterNode> nodes) {
+            if (nodes == null)
+                return Collections.emptyList();
+
+            // If no filtering needed, return original collection.
+            return nodes.isEmpty() || topVer < 0 || topVer >= maxOrder ?
+                nodes :
+                F.view(nodes, new P1<ClusterNode>() {
+                    @Override public boolean apply(ClusterNode node) {
+                        return node.order() <= topVer;
+                    }
+                });
+        }
+
+        /** @return Daemon nodes. */
+        Collection<ClusterNode> daemonNodes() {
+            return daemonNodes;
+        }
+
+        /**
+         * @param id Node ID.
+         * @return Node.
+         */
+        @Nullable ClusterNode node(UUID id) {
+            return nodeMap.get(id);
+        }
+
+        /** {@inheritDoc} */
+        @Override public String toString() {
+            return S.toString(DiscoCache.class, this, "allNodesWithDaemons", U.toShortString(allNodes));
+        }
+    }    /**
      * Cache predicate.
      */
     private static class CachePredicate {
@@ -2832,8 +3329,8 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
         /** If near cache is enabled on data nodes. */
         private final boolean nearEnabled;
 
-        /** Flag indicating if cache is local. */
-        private final boolean loc;
+        /** Cache mode. */
+        private final CacheMode cacheMode;
 
         /** Collection of client near nodes. */
         private final ConcurrentHashMap<UUID, Boolean> clientNodes;
@@ -2841,14 +3338,14 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
         /**
          * @param cacheFilter Cache filter.
          * @param nearEnabled Near enabled flag.
-         * @param loc {@code True} if cache is local.
+         * @param cacheMode Cache mode.
          */
-        private CachePredicate(IgnitePredicate<ClusterNode> cacheFilter, boolean nearEnabled, boolean loc) {
+        private CachePredicate(IgnitePredicate<ClusterNode> cacheFilter, boolean nearEnabled, CacheMode cacheMode) {
             assert cacheFilter != null;
 
             this.cacheFilter = cacheFilter;
             this.nearEnabled = nearEnabled;
-            this.loc = loc;
+            this.cacheMode = cacheMode;
 
             clientNodes = new ConcurrentHashMap<>();
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/12235254/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 daa4475..736e630 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
@@ -689,7 +689,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
                     cfg.getName(),
                     cfg.getNodeFilter(),
                     cfg.getNearConfiguration() != null && cfg.getCacheMode() == PARTITIONED,
-                    cfg.getCacheMode() == LOCAL);
+                    cfg.getCacheMode());
 
                 ctx.discovery().addClientNode(cfg.getName(),
                     ctx.localNodeId(),
@@ -1941,7 +1941,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
                                     req.cacheName(),
                                     ccfg.getNodeFilter(),
                                     ccfg.getNearConfiguration() != null,
-                                    ccfg.getCacheMode() == LOCAL);
+                                    ccfg.getCacheMode());
                             }
                         }
                         else {
@@ -1968,7 +1968,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
                                 req.cacheName(),
                                 ccfg.getNodeFilter(),
                                 ccfg.getNearConfiguration() != null,
-                                ccfg.getCacheMode() == LOCAL);
+                                ccfg.getCacheMode());
                         }
                     }
                 }
@@ -2468,7 +2468,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
                             ccfg.getName(),
                             ccfg.getNodeFilter(),
                             ccfg.getNearConfiguration() != null,
-                            ccfg.getCacheMode() == LOCAL);
+                            ccfg.getCacheMode());
 
                         ctx.discovery().addClientNode(req.cacheName(),
                             req.initiatingNodeId(),
@@ -3482,6 +3482,46 @@ public class GridCacheProcessor extends GridProcessorAdapter {
     /**
      *
      */
+    @SuppressWarnings("ExternalizableWithoutPublicNoArgConstructor")
+    private class TemplateConfigurationFuture extends GridFutureAdapter<Object> {
+        /** Start ID. */
+        @GridToStringInclude
+        private IgniteUuid deploymentId;
+
+        /** Cache name. */
+        private String cacheName;
+
+        /**
+         * @param cacheName Cache name.
+         * @param deploymentId Deployment ID.
+         */
+        private TemplateConfigurationFuture(String cacheName, IgniteUuid deploymentId) {
+            this.deploymentId = deploymentId;
+            this.cacheName = cacheName;
+        }
+
+        /**
+         * @return Start ID.
+         */
+        public IgniteUuid deploymentId() {
+            return deploymentId;
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean onDone(@Nullable Object res, @Nullable Throwable err) {
+            // Make sure to remove future before completion.
+            pendingTemplateFuts.remove(maskNull(cacheName), this);
+
+            return super.onDone(res, err);
+        }
+
+        /** {@inheritDoc} */
+        @Override public String toString() {
+            return S.toString(TemplateConfigurationFuture.class, this);
+        }
+    }    /**
+     *
+     */
     private static class LocalAffinityFunction implements AffinityFunction {
         /** */
         private static final long serialVersionUID = 0L;

http://git-wip-us.apache.org/repos/asf/ignite/blob/12235254/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
index 25ace1b..698b035 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
@@ -2229,6 +2229,26 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
         }
 
         /** {@inheritDoc} */
+        @Override public Map<String, String> keyClasses() {
+            return keyClasses;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Map<String, String> valClasses() {
+            return valClasses;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Map<String, Map<String, String>> fields() {
+            return fields;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Map<String, Collection<GridCacheSqlIndexMetadata>> indexes() {
+            return indexes;
+        }
+
+        /** {@inheritDoc} */
         @Override public Collection<GridCacheSqlIndexMetadata> indexes(String type) {
             return indexes.get(type);
         }
@@ -2319,6 +2339,11 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
         }
 
         /** {@inheritDoc} */
+        @Override public Collection<String> descendings() {
+            return descendings;
+        }
+
+        /** {@inheritDoc} */
         @Override public boolean unique() {
             return unique;
         }
@@ -2687,15 +2712,13 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
      * Cached result.
      */
     private abstract static class CachedResult<R> extends GridFutureAdapter<IgniteSpiCloseableIterator<R>> {
+        /** Absolute position of each recipient. */
+        private final Map<Object, QueueIterator> recipients = new GridLeanMap<>(1);
         /** */
         private CircularQueue<R> queue;
-
         /** */
         private int pruned;
 
-        /** Absolute position of each recipient. */
-        private final Map<Object, QueueIterator> recipients = new GridLeanMap<>(1);
-
         /**
          * @param rcpt ID of the recipient.
          */
@@ -3059,6 +3082,47 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
     }
 
     /**
+     *
+     */
+    private class OffheapIteratorClosure
+        extends CX2<T2<Long, Integer>, T2<Long, Integer>, IgniteBiTuple<K, V>> {
+        /** */
+        private static final long serialVersionUID = 7410163202728985912L;
+
+        /** */
+        private IgniteBiPredicate<K, V> filter;
+
+        /** */
+        private boolean keepPortable;
+
+        /**
+         * @param filter Filter.
+         * @param keepPortable Keep portable flag.
+         */
+        private OffheapIteratorClosure(
+            @Nullable IgniteBiPredicate<K, V> filter,
+            boolean keepPortable) {
+            assert filter != null;
+
+            this.filter = filter;
+            this.keepPortable = keepPortable;
+        }
+
+        /** {@inheritDoc} */
+        @Nullable @Override public IgniteBiTuple<K, V> applyx(T2<Long, Integer> keyPtr,
+            T2<Long, Integer> valPtr)
+            throws IgniteCheckedException {
+            LazyOffheapEntry e = new LazyOffheapEntry(keyPtr, valPtr);
+
+            K key = (K)cctx.unwrapPortableIfNeeded(e.key(), keepPortable);
+            V val = (V)cctx.unwrapPortableIfNeeded(e.value(), keepPortable);
+
+            if (!filter.apply(key, val))
+                return null;
+
+            return new IgniteBiTuple<>(e.key(), (V)cctx.unwrapTemporary(e.value()));
+        }
+    }    /**
      * Creates user's SQL fields query for given clause. For more information refer to {@link CacheQuery}
      * documentation.
      *
@@ -3078,4 +3142,4 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
             false,
             keepPortable);
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/12235254/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlIndexMetadata.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlIndexMetadata.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlIndexMetadata.java
index 6b3ed68..539a156 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlIndexMetadata.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlIndexMetadata.java
@@ -51,9 +51,14 @@ public interface GridCacheSqlIndexMetadata extends Externalizable {
     public boolean descending(String field);
 
     /**
+     * @return Descendings.
+     */
+    public Collection<String> descendings();
+
+    /**
      * Gets whether this is a unique index.
      *
      * @return {@code True} if index is unique, {@code false} otherwise.
      */
     public boolean unique();
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/12235254/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlMetadata.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlMetadata.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlMetadata.java
index dae034c..724962e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlMetadata.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheSqlMetadata.java
@@ -78,6 +78,26 @@ public interface GridCacheSqlMetadata extends Externalizable {
     @Nullable public Map<String, String> fields(String type);
 
     /**
+     * @return Key classes.
+     */
+    public Map<String, String> keyClasses();
+
+    /**
+     * @return Value classes.
+     */
+    public Map<String, String> valClasses();
+
+    /**
+     * @return Fields.
+     */
+    public Map<String, Map<String, String>> fields();
+
+    /**
+     * @return Indexes.
+     */
+    public Map<String, Collection<GridCacheSqlIndexMetadata>> indexes();
+
+    /**
      * Gets descriptors of indexes created for provided type.
      * See {@link GridCacheSqlIndexMetadata} javadoc for more information.
      *
@@ -86,4 +106,4 @@ public interface GridCacheSqlMetadata extends Externalizable {
      * @see GridCacheSqlIndexMetadata
      */
     public Collection<GridCacheSqlIndexMetadata> indexes(String type);
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/12235254/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestCommand.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestCommand.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestCommand.java
index 4f9b3ae..8282d3a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestCommand.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestCommand.java
@@ -96,6 +96,9 @@ public enum GridRestCommand {
     /** Cache size. */
     CACHE_SIZE("size"),
 
+    /** Cache metadata. */
+    CACHE_METADATA("metadata"),
+
     /** Increment. */
     ATOMIC_INCREMENT("incr"),
 
@@ -141,6 +144,9 @@ public enum GridRestCommand {
     /** Execute sql fields query. */
     EXECUTE_SQL_FIELDS_QUERY("qryfldexe"),
 
+    /** Execute scan query. */
+    EXECUTE_SCAN_QUERY("qryscanexe"),
+
     /** Fetch query results. */
     FETCH_SQL_QUERY("qryfetch"),
 
@@ -193,4 +199,4 @@ public enum GridRestCommand {
     public String key() {
         return key;
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/12235254/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
index d54c8bb..df79232 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
@@ -51,7 +51,7 @@ import org.apache.ignite.internal.processors.rest.protocols.tcp.GridTcpRestProto
 import org.apache.ignite.internal.processors.rest.request.GridRestCacheRequest;
 import org.apache.ignite.internal.processors.rest.request.GridRestRequest;
 import org.apache.ignite.internal.processors.rest.request.GridRestTaskRequest;
-import org.apache.ignite.internal.processors.rest.request.RestSqlQueryRequest;
+import org.apache.ignite.internal.processors.rest.request.RestQueryRequest;
 import org.apache.ignite.internal.processors.security.SecurityContext;
 import org.apache.ignite.internal.util.GridSpinReadWriteLock;
 import org.apache.ignite.internal.util.future.GridFinishedFuture;
@@ -565,6 +565,53 @@ public class GridRestProcessor extends GridProcessorAdapter {
     }
 
     /**
+     * Applies {@link ConnectorMessageInterceptor}
+     * from {@link ConnectorConfiguration#getMessageInterceptor()} ()}
+     * to all user parameters in the request.
+     *
+     * @param req Client request.
+     */
+    private void interceptRequest(GridRestRequest req) {
+        ConnectorMessageInterceptor interceptor = config().getMessageInterceptor();
+
+        if (interceptor == null)
+            return;
+
+        if (req instanceof GridRestCacheRequest) {
+            GridRestCacheRequest req0 = (GridRestCacheRequest) req;
+
+            req0.key(interceptor.onReceive(req0.key()));
+            req0.value(interceptor.onReceive(req0.value()));
+            req0.value2(interceptor.onReceive(req0.value2()));
+
+            Map<Object, Object> oldVals = req0.values();
+
+            if (oldVals != null) {
+                Map<Object, Object> newVals = U.newHashMap(oldVals.size());
+
+                for (Map.Entry<Object, Object> e : oldVals.entrySet())
+                    newVals.put(interceptor.onReceive(e.getKey()), interceptor.onReceive(e.getValue()));
+
+                req0.values(U.sealMap(newVals));
+            }
+        }
+        else if (req instanceof GridRestTaskRequest) {
+            GridRestTaskRequest req0 = (GridRestTaskRequest) req;
+
+            List<Object> oldParams = req0.params();
+
+            if (oldParams != null) {
+                Collection<Object> newParams = new ArrayList<>(oldParams.size());
+
+                for (Object o : oldParams)
+                    newParams.add(interceptor.onReceive(o));
+
+                req0.params(U.sealList(newParams));
+            }
+        }
+    }
+
+    /**
      * Applies {@link ConnectorMessageInterceptor} from
      * {@link ConnectorConfiguration#getMessageInterceptor()}
      * to all user objects in the response.
@@ -609,9 +656,7 @@ public class GridRestProcessor extends GridProcessorAdapter {
                     break;
             }
         }
-    }
-
-    /**
+    }    /**
      * Applies interceptor to a response object.
      * Specially handler {@link Map} and {@link Collection} responses.
      *
@@ -715,10 +760,11 @@ public class GridRestProcessor extends GridProcessorAdapter {
 
             case EXECUTE_SQL_QUERY:
             case EXECUTE_SQL_FIELDS_QUERY:
+            case EXECUTE_SCAN_QUERY:
             case CLOSE_SQL_QUERY:
             case FETCH_SQL_QUERY:
                 perm = SecurityPermission.CACHE_READ;
-                name = ((RestSqlQueryRequest)req).cacheName();
+                name = ((RestQueryRequest)req).cacheName();
 
                 break;
 
@@ -764,6 +810,7 @@ public class GridRestProcessor extends GridProcessorAdapter {
 
             case CACHE_METRICS:
             case CACHE_SIZE:
+            case CACHE_METADATA:
             case TOPOLOGY:
             case NODE:
             case VERSION:
@@ -884,15 +931,13 @@ public class GridRestProcessor extends GridProcessorAdapter {
 
         /** Session token id. */
         private final UUID sesId;
-
-        /** Security context. */
-        private volatile SecurityContext secCtx;
-
         /**
          * Time when session is used last time.
          * If this time was set at TIMEDOUT_FLAG, then it should never be changed.
          */
         private final AtomicLong lastTouchTime = new AtomicLong(U.currentTimeMillis());
+        /** Security context. */
+        private volatile SecurityContext secCtx;
 
         /**
          * @param clientId Client ID.

http://git-wip-us.apache.org/repos/asf/ignite/blob/12235254/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandler.java
index 9d32c17..1bbc754 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandler.java
@@ -40,6 +40,7 @@ import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.IgniteKernal;
 import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
 import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
+import org.apache.ignite.internal.processors.cache.query.GridCacheSqlMetadata;
 import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
 import org.apache.ignite.internal.processors.rest.GridRestCommand;
 import org.apache.ignite.internal.processors.rest.GridRestResponse;
@@ -73,6 +74,7 @@ import static org.apache.ignite.internal.processors.rest.GridRestCommand.CACHE_G
 import static org.apache.ignite.internal.processors.rest.GridRestCommand.CACHE_GET_AND_PUT_IF_ABSENT;
 import static org.apache.ignite.internal.processors.rest.GridRestCommand.CACHE_GET_AND_REMOVE;
 import static org.apache.ignite.internal.processors.rest.GridRestCommand.CACHE_GET_AND_REPLACE;
+import static org.apache.ignite.internal.processors.rest.GridRestCommand.CACHE_METADATA;
 import static org.apache.ignite.internal.processors.rest.GridRestCommand.CACHE_METRICS;
 import static org.apache.ignite.internal.processors.rest.GridRestCommand.CACHE_PREPEND;
 import static org.apache.ignite.internal.processors.rest.GridRestCommand.CACHE_PUT;
@@ -119,7 +121,8 @@ public class GridCacheCommandHandler extends GridRestCommandHandlerAdapter {
         CACHE_APPEND,
         CACHE_PREPEND,
         CACHE_METRICS,
-        CACHE_SIZE
+        CACHE_SIZE,
+        CACHE_METADATA
     );
 
     /** Requests with required parameter {@code key}. */
@@ -151,11 +154,6 @@ public class GridCacheCommandHandler extends GridRestCommandHandlerAdapter {
         super(ctx);
     }
 
-    /** {@inheritDoc} */
-    @Override public Collection<GridRestCommand> supportedCommands() {
-        return SUPPORTED_COMMANDS;
-    }
-
     /**
      * Retrieves cache flags from corresponding bits.
      *
@@ -172,6 +170,153 @@ public class GridCacheCommandHandler extends GridRestCommandHandlerAdapter {
         return false;
     }
 
+    /**
+     * Handles append and prepend commands.
+     *
+     * @param ctx Kernal context.
+     * @param cache Cache.
+     * @param key Key.
+     * @param req Request.
+     * @param prepend Whether to prepend.
+     * @return Future of operation result.
+     * @throws IgniteCheckedException In case of any exception.
+     */
+    private static IgniteInternalFuture<?> appendOrPrepend(
+        final GridKernalContext ctx,
+        final IgniteInternalCache<Object, Object> cache,
+        final Object key, GridRestCacheRequest req, final boolean prepend) throws IgniteCheckedException {
+        assert cache != null;
+        assert key != null;
+        assert req != null;
+
+        final Object val = req.value();
+
+        if (val == null)
+            throw new IgniteCheckedException(GridRestCommandHandlerAdapter.missingParameter("val"));
+
+        return ctx.closure().callLocalSafe(new Callable<Object>() {
+            @Override public Object call() throws Exception {
+                try (IgniteInternalTx tx = cache.txStartEx(PESSIMISTIC, REPEATABLE_READ)) {
+                    Object curVal = cache.get(key);
+
+                    if (curVal == null)
+                        return false;
+
+                    // Modify current value with appendix one.
+                    Object newVal = appendOrPrepend(curVal, val, !prepend);
+
+                    // Put new value asynchronously.
+                    cache.put(key, newVal);
+
+                    tx.commit();
+                }
+
+                return true;
+            }
+        }, false);
+    }
+
+    /**
+     * Append or prepend new value to the current one.
+     *
+     * @param origVal Original value.
+     * @param appendVal Appendix value to add to the original one.
+     * @param appendPlc Append or prepend policy flag.
+     * @return Resulting value.
+     * @throws IgniteCheckedException In case of grid exceptions.
+     */
+    private static Object appendOrPrepend(Object origVal, Object appendVal, boolean appendPlc) throws IgniteCheckedException {
+        // Strings.
+        if (appendVal instanceof String && origVal instanceof String)
+            return appendPlc ? origVal + (String)appendVal : (String)appendVal + origVal;
+
+        // Maps.
+        if (appendVal instanceof Map && origVal instanceof Map) {
+            Map<Object, Object> origMap = (Map<Object, Object>)origVal;
+            Map<Object, Object> appendMap = (Map<Object, Object>)appendVal;
+
+            Map<Object, Object> map = X.cloneObject(origMap, false, true);
+
+            if (appendPlc)
+                map.putAll(appendMap); // Append.
+            else {
+                map.clear();
+                map.putAll(appendMap); // Prepend.
+                map.putAll(origMap);
+            }
+
+            for (Map.Entry<Object, Object> e : appendMap.entrySet()) // Remove zero-valued entries.
+                if (e.getValue() == null && map.get(e.getKey()) == null)
+                    map.remove(e.getKey());
+
+            return map;
+        }
+
+        // Generic collection.
+        if (appendVal instanceof Collection<?> && origVal instanceof Collection<?>) {
+            Collection<Object> origCol = (Collection<Object>)origVal;
+            Collection<Object> appendCol = (Collection<Object>)appendVal;
+
+            Collection<Object> col = X.cloneObject(origCol, false, true);
+
+            if (appendPlc)
+                col.addAll(appendCol); // Append.
+            else {
+                col.clear();
+                col.addAll(appendCol); // Prepend.
+                col.addAll(origCol);
+            }
+
+            return col;
+        }
+
+        throw new IgniteCheckedException("Incompatible types [appendVal=" + appendVal + ", old=" + origVal + ']');
+    }
+
+    /**
+     * Creates a transformation function from {@link CacheCommand}'s results into {@link GridRestResponse}.
+     *
+     * @param c Cache instance to obtain affinity data.
+     * @param key Affinity key for previous operation.
+     * @return Rest response.
+     */
+    private static IgniteClosure<IgniteInternalFuture<?>, GridRestResponse> resultWrapper(
+        final IgniteInternalCache<Object, Object> c, @Nullable final Object key) {
+        return new CX1<IgniteInternalFuture<?>, GridRestResponse>() {
+            @Override public GridRestResponse applyx(IgniteInternalFuture<?> f) throws IgniteCheckedException {
+                GridCacheRestResponse resp = new GridCacheRestResponse();
+
+                resp.setResponse(f.get());
+
+                if (key != null)
+                    resp.setAffinityNodeId(c.cache().affinity().mapKeyToNode(key).id().toString());
+
+                return resp;
+            }
+        };
+    }
+
+    /**
+     * @param ignite Grid instance.
+     * @param cacheName Name of the cache.
+     * @return Instance on the named cache.
+     * @throws IgniteCheckedException If cache not found.
+     */
+    private static IgniteInternalCache<Object, Object> cache(Ignite ignite, String cacheName) throws IgniteCheckedException {
+        IgniteInternalCache<Object, Object> cache = ((IgniteKernal)ignite).getCache(cacheName);
+
+        if (cache == null)
+            throw new IgniteCheckedException(
+                "Failed to find cache for given cache name (null for default cache): " + cacheName);
+
+        return cache;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Collection<GridRestCommand> supportedCommands() {
+        return SUPPORTED_COMMANDS;
+    }
+
     /** {@inheritDoc} */
     @Override public IgniteInternalFuture<GridRestResponse> handleAsync(final GridRestRequest req) {
         assert req instanceof GridRestCacheRequest : "Invalid command for topology handler: " + req;
@@ -224,6 +369,25 @@ public class GridCacheCommandHandler extends GridRestCommandHandlerAdapter {
                     break;
                 }
 
+                case CACHE_METADATA: {
+                    IgniteInternalCache<?, ?> cache = ctx.cache().cache(cacheName);
+
+                    if (cache != null) {
+                        GridCacheSqlMetadata res = F.first(cache.context().queries().sqlMetadata());
+
+                        fut = new GridFinishedFuture<>(new GridRestResponse(res));
+                    }
+                    else {
+                        ClusterGroup prj = ctx.grid().cluster().forDataNodes(cacheName);
+
+                        ctx.task().setThreadContext(TC_NO_FAILOVER, true);
+
+                        fut = ctx.closure().callAsync(BALANCE, new MetadataCommand(cacheName), prj.nodes());
+                    }
+
+                    break;
+                }
+
                 case CACHE_CONTAINS_KEYS: {
                     fut = executeCommand(req.destinationId(), req.clientId(), cacheName, skipStore, key,
                         new ContainsKeysCommand(getKeys(req0)));
@@ -545,138 +709,12 @@ public class GridCacheCommandHandler extends GridRestCommandHandlerAdapter {
         }
     }
 
-    /**
-     * Handles append and prepend commands.
-     *
-     * @param ctx Kernal context.
-     * @param cache Cache.
-     * @param key Key.
-     * @param req Request.
-     * @param prepend Whether to prepend.
-     * @return Future of operation result.
-     * @throws IgniteCheckedException In case of any exception.
-     */
-    private static IgniteInternalFuture<?> appendOrPrepend(
-        final GridKernalContext ctx,
-        final IgniteInternalCache<Object, Object> cache,
-        final Object key, GridRestCacheRequest req, final boolean prepend) throws IgniteCheckedException {
-        assert cache != null;
-        assert key != null;
-        assert req != null;
-
-        final Object val = req.value();
-
-        if (val == null)
-            throw new IgniteCheckedException(GridRestCommandHandlerAdapter.missingParameter("val"));
-
-        return ctx.closure().callLocalSafe(new Callable<Object>() {
-            @Override public Object call() throws Exception {
-                try (IgniteInternalTx tx = cache.txStartEx(PESSIMISTIC, REPEATABLE_READ)) {
-                    Object curVal = cache.get(key);
-
-                    if (curVal == null)
-                        return false;
-
-                    // Modify current value with appendix one.
-                    Object newVal = appendOrPrepend(curVal, val, !prepend);
-
-                    // Put new value asynchronously.
-                    cache.put(key, newVal);
-
-                    tx.commit();
-                }
-
-                return true;
-            }
-        }, false);
-    }
-
-    /**
-     * Append or prepend new value to the current one.
-     *
-     * @param origVal Original value.
-     * @param appendVal Appendix value to add to the original one.
-     * @param appendPlc Append or prepend policy flag.
-     * @return Resulting value.
-     * @throws IgniteCheckedException In case of grid exceptions.
-     */
-    private static Object appendOrPrepend(Object origVal, Object appendVal, boolean appendPlc) throws IgniteCheckedException {
-        // Strings.
-        if (appendVal instanceof String && origVal instanceof String)
-            return appendPlc ? origVal + (String)appendVal : (String)appendVal + origVal;
-
-        // Maps.
-        if (appendVal instanceof Map && origVal instanceof Map) {
-            Map<Object, Object> origMap = (Map<Object, Object>)origVal;
-            Map<Object, Object> appendMap = (Map<Object, Object>)appendVal;
-
-            Map<Object, Object> map = X.cloneObject(origMap, false, true);
-
-            if (appendPlc)
-                map.putAll(appendMap); // Append.
-            else {
-                map.clear();
-                map.putAll(appendMap); // Prepend.
-                map.putAll(origMap);
-            }
-
-            for (Map.Entry<Object, Object> e : appendMap.entrySet()) // Remove zero-valued entries.
-                if (e.getValue() == null && map.get(e.getKey()) == null)
-                    map.remove(e.getKey());
-
-            return map;
-        }
-
-        // Generic collection.
-        if (appendVal instanceof Collection<?> && origVal instanceof Collection<?>) {
-            Collection<Object> origCol = (Collection<Object>)origVal;
-            Collection<Object> appendCol = (Collection<Object>)appendVal;
-
-            Collection<Object> col = X.cloneObject(origCol, false, true);
-
-            if (appendPlc)
-                col.addAll(appendCol); // Append.
-            else {
-                col.clear();
-                col.addAll(appendCol); // Prepend.
-                col.addAll(origCol);
-            }
-
-            return col;
-        }
-
-        throw new IgniteCheckedException("Incompatible types [appendVal=" + appendVal + ", old=" + origVal + ']');
-    }
-
     /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(GridCacheCommandHandler.class, this);
     }
 
     /**
-     * Creates a transformation function from {@link CacheCommand}'s results into {@link GridRestResponse}.
-     *
-     * @param c Cache instance to obtain affinity data.
-     * @param key Affinity key for previous operation.
-     * @return Rest response.
-     */
-    private static IgniteClosure<IgniteInternalFuture<?>, GridRestResponse> resultWrapper(
-        final IgniteInternalCache<Object, Object> c, @Nullable final Object key) {
-        return new CX1<IgniteInternalFuture<?>, GridRestResponse>() {
-            @Override public GridRestResponse applyx(IgniteInternalFuture<?> f) throws IgniteCheckedException {
-                GridCacheRestResponse resp = new GridCacheRestResponse();
-
-                resp.setResponse(f.get());
-
-                if (key != null)
-                    resp.setAffinityNodeId(c.cache().affinity().mapKeyToNode(key).id().toString());
-
-                return resp;
-            }
-        };
-    }
-
-    /**
      * @param cacheName Cache name.
      * @return If replicated cache with given name is locally available.
      */
@@ -702,22 +740,6 @@ public class GridCacheCommandHandler extends GridRestCommandHandlerAdapter {
     }
 
     /**
-     * @param ignite Grid instance.
-     * @param cacheName Name of the cache.
-     * @return Instance on the named cache.
-     * @throws IgniteCheckedException If cache not found.
-     */
-    private static IgniteInternalCache<Object, Object> cache(Ignite ignite, String cacheName) throws IgniteCheckedException {
-        IgniteInternalCache<Object, Object> cache = ((IgniteKernal)ignite).getCache(cacheName);
-
-        if (cache == null)
-            throw new IgniteCheckedException(
-                "Failed to find cache for given cache name (null for default cache): " + cacheName);
-
-        return cache;
-    }
-
-    /**
      * Fixed result closure.
      */
     private static final class FixedResult extends CX1<IgniteInternalFuture<?>, Object> {
@@ -771,22 +793,16 @@ public class GridCacheCommandHandler extends GridRestCommandHandlerAdapter {
     private static class FlaggedCacheOperationCallable implements Callable<GridRestResponse>, Serializable {
         /** */
         private static final long serialVersionUID = 0L;
-
-        /** Client ID. */
-        private UUID clientId;
-
         /** */
         private final String cacheName;
-
         /** */
         private final boolean skipStore;
-
         /** */
         private final CacheProjectionCommand op;
-
         /** */
         private final Object key;
-
+        /** Client ID. */
+        private UUID clientId;
         /** */
         @IgniteInstanceResource
         private Ignite g;
@@ -829,19 +845,14 @@ public class GridCacheCommandHandler extends GridRestCommandHandlerAdapter {
     private static class CacheOperationCallable implements Callable<GridRestResponse>, Serializable {
         /** */
         private static final long serialVersionUID = 0L;
-
-        /** Client ID. */
-        private UUID clientId;
-
         /** */
         private final String cacheName;
-
         /** */
         private final CacheCommand op;
-
         /** */
         private final Object key;
-
+        /** Client ID. */
+        private UUID clientId;
         /** */
         @IgniteInstanceResource
         private Ignite g;
@@ -892,6 +903,31 @@ public class GridCacheCommandHandler extends GridRestCommandHandlerAdapter {
     }
 
     /** */
+    private static class MetadataCommand implements Callable<GridRestResponse>, Serializable {
+        /** */
+        private static final long serialVersionUID = 0L;
+
+        /** */
+        private final String cacheName;
+
+        /** */
+        @IgniteInstanceResource
+        private Ignite g;
+
+        /**
+         * @param cacheName Cache name.
+         */
+        private MetadataCommand(String cacheName) {
+            this.cacheName = cacheName;
+        }
+
+        /** {@inheritDoc} */
+        @Override public GridRestResponse call() throws Exception {
+            return  new GridRestResponse(F.first(cache(g, cacheName).context().queries().sqlMetadata()));
+        }
+    }
+
+    /** */
     private static class ContainsKeysCommand extends CacheProjectionCommand {
         /** */
         private static final long serialVersionUID = 0L;

http://git-wip-us.apache.org/repos/asf/ignite/blob/12235254/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/query/QueryCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/query/QueryCommandHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/query/QueryCommandHandler.java
index 64c7673..f4ddd59 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/query/QueryCommandHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/query/QueryCommandHandler.java
@@ -17,6 +17,8 @@
 
 package org.apache.ignite.internal.processors.rest.handlers.query;
 
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Iterator;
@@ -25,8 +27,10 @@ import java.util.concurrent.Callable;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.atomic.AtomicLong;
 import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteException;
 import org.apache.ignite.cache.query.Query;
 import org.apache.ignite.cache.query.QueryCursor;
+import org.apache.ignite.cache.query.ScanQuery;
 import org.apache.ignite.cache.query.SqlFieldsQuery;
 import org.apache.ignite.cache.query.SqlQuery;
 import org.apache.ignite.internal.GridKernalContext;
@@ -37,12 +41,14 @@ import org.apache.ignite.internal.processors.rest.GridRestCommand;
 import org.apache.ignite.internal.processors.rest.GridRestResponse;
 import org.apache.ignite.internal.processors.rest.handlers.GridRestCommandHandlerAdapter;
 import org.apache.ignite.internal.processors.rest.request.GridRestRequest;
-import org.apache.ignite.internal.processors.rest.request.RestSqlQueryRequest;
+import org.apache.ignite.internal.processors.rest.request.RestQueryRequest;
 import org.apache.ignite.internal.util.future.GridFinishedFuture;
 import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteBiPredicate;
 import org.apache.ignite.lang.IgniteBiTuple;
 
 import static org.apache.ignite.internal.processors.rest.GridRestCommand.CLOSE_SQL_QUERY;
+import static org.apache.ignite.internal.processors.rest.GridRestCommand.EXECUTE_SCAN_QUERY;
 import static org.apache.ignite.internal.processors.rest.GridRestCommand.EXECUTE_SQL_FIELDS_QUERY;
 import static org.apache.ignite.internal.processors.rest.GridRestCommand.EXECUTE_SQL_QUERY;
 import static org.apache.ignite.internal.processors.rest.GridRestCommand.FETCH_SQL_QUERY;
@@ -54,6 +60,7 @@ public class QueryCommandHandler extends GridRestCommandHandlerAdapter {
     /** Supported commands. */
     private static final Collection<GridRestCommand> SUPPORTED_COMMANDS = U.sealList(EXECUTE_SQL_QUERY,
         EXECUTE_SQL_FIELDS_QUERY,
+        EXECUTE_SCAN_QUERY,
         FETCH_SQL_QUERY,
         CLOSE_SQL_QUERY);
 
@@ -70,6 +77,76 @@ public class QueryCommandHandler extends GridRestCommandHandlerAdapter {
         super(ctx);
     }
 
+    /**
+     * @param qryCurs Query cursors.
+     * @param cur Current cursor.
+     * @param req Sql request.
+     * @param qryId Query id.
+     * @return Query result with items.
+     */
+    private static CacheQueryResult createQueryResult(
+        ConcurrentHashMap<Long, IgniteBiTuple<QueryCursor, Iterator>> qryCurs,
+        Iterator cur, RestQueryRequest req, Long qryId) {
+        CacheQueryResult res = new CacheQueryResult();
+
+        List<Object> items = new ArrayList<>();
+
+        for (int i = 0; i < req.pageSize() && cur.hasNext(); ++i)
+            items.add(cur.next());
+
+        res.setItems(items);
+
+        res.setLast(!cur.hasNext());
+
+        res.setQueryId(qryId);
+
+        if (!cur.hasNext())
+            qryCurs.remove(qryId);
+
+        return res;
+    }
+
+    /**
+     * Creates class instance.
+     *
+     * @param cls Target class.
+     * @param clsName Implementing class name.
+     * @return Class instance.
+     * @throws IgniteException If failed.
+     */
+    private static <T> T instance(Class<? extends T> cls, String clsName) throws IgniteException {
+        try {
+            Class<?> implCls = Class.forName(clsName);
+
+            if (!cls.isAssignableFrom(implCls))
+                throw new IgniteException("Failed to create instance (target class does not extend or implement " +
+                    "required class or interface) [cls=" + cls.getName() + ", clsName=" + clsName + ']');
+
+            Constructor<?> ctor = implCls.getConstructor();
+
+            return (T)ctor.newInstance();
+        }
+        catch (ClassNotFoundException e) {
+            throw new IgniteException("Failed to find target class: " + clsName, e);
+        }
+        catch (NoSuchMethodException e) {
+            throw new IgniteException("Failed to find constructor for provided arguments " +
+                "[clsName=" + clsName + ']', e);
+        }
+        catch (InstantiationException e) {
+            throw new IgniteException("Failed to instantiate target class " +
+                "[clsName=" + clsName + ']', e);
+        }
+        catch (IllegalAccessException e) {
+            throw new IgniteException("Failed to instantiate class (constructor is not available) " +
+                "[clsName=" + clsName + ']', e);
+        }
+        catch (InvocationTargetException e) {
+            throw new IgniteException("Failed to instantiate class (constructor threw an exception) " +
+                "[clsName=" + clsName + ']', e.getCause());
+        }
+    }
+
     /** {@inheritDoc} */
     @Override public Collection<GridRestCommand> supportedCommands() {
         return SUPPORTED_COMMANDS;
@@ -80,23 +157,24 @@ public class QueryCommandHandler extends GridRestCommandHandlerAdapter {
         assert req != null;
 
         assert SUPPORTED_COMMANDS.contains(req.command());
-        assert req instanceof RestSqlQueryRequest : "Invalid type of query request.";
+        assert req instanceof RestQueryRequest : "Invalid type of query request.";
 
         switch (req.command()) {
             case EXECUTE_SQL_QUERY:
-            case EXECUTE_SQL_FIELDS_QUERY: {
+            case EXECUTE_SQL_FIELDS_QUERY:
+            case EXECUTE_SCAN_QUERY: {
                 return ctx.closure().callLocalSafe(
-                    new ExecuteQueryCallable(ctx, (RestSqlQueryRequest)req, qryCurs), false);
+                    new ExecuteQueryCallable(ctx, (RestQueryRequest)req, qryCurs), false);
             }
 
             case FETCH_SQL_QUERY: {
                 return ctx.closure().callLocalSafe(
-                    new FetchQueryCallable((RestSqlQueryRequest)req, qryCurs), false);
+                    new FetchQueryCallable(ctx, (RestQueryRequest)req, qryCurs), false);
             }
 
             case CLOSE_SQL_QUERY: {
                 return ctx.closure().callLocalSafe(
-                    new CloseQueryCallable((RestSqlQueryRequest)req, qryCurs), false);
+                    new CloseQueryCallable((RestQueryRequest)req, qryCurs), false);
             }
         }
 
@@ -111,7 +189,7 @@ public class QueryCommandHandler extends GridRestCommandHandlerAdapter {
         private GridKernalContext ctx;
 
         /** Execute query request. */
-        private RestSqlQueryRequest req;
+        private RestQueryRequest req;
 
         /** Queries cursors. */
         private ConcurrentHashMap<Long, IgniteBiTuple<QueryCursor, Iterator>> qryCurs;
@@ -121,7 +199,7 @@ public class QueryCommandHandler extends GridRestCommandHandlerAdapter {
          * @param req Execute query request.
          * @param qryCurs Queries cursors.
          */
-        public ExecuteQueryCallable(GridKernalContext ctx, RestSqlQueryRequest req,
+        public ExecuteQueryCallable(GridKernalContext ctx, RestQueryRequest req,
             ConcurrentHashMap<Long, IgniteBiTuple<QueryCursor, Iterator>> qryCurs) {
             this.ctx = ctx;
             this.req = req;
@@ -135,15 +213,33 @@ public class QueryCommandHandler extends GridRestCommandHandlerAdapter {
             try {
                 Query qry;
 
-                if (req.typeName() != null) {
-                    qry = new SqlQuery(req.typeName(), req.sqlQuery());
+                switch (req.queryType()) {
+                    case SQL:
+                        qry = new SqlQuery(req.typeName(), req.sqlQuery());
 
-                    ((SqlQuery)qry).setArgs(req.arguments());
-                }
-                else {
-                    qry = new SqlFieldsQuery(req.sqlQuery());
+                        ((SqlQuery)qry).setArgs(req.arguments());
+
+                        break;
+
+                    case SQL_FIELDS:
+                        qry = new SqlFieldsQuery(req.sqlQuery());
+
+                        ((SqlFieldsQuery)qry).setArgs(req.arguments());
 
-                    ((SqlFieldsQuery)qry).setArgs(req.arguments());
+                        break;
+
+                    case SCAN:
+                        IgniteBiPredicate pred = null;
+
+                        if (req.className() != null)
+                            pred = instance(IgniteBiPredicate.class, req.className());
+
+                        qry = new ScanQuery(pred);
+
+                        break;
+
+                    default:
+                        throw new IgniteException("Incorrect query type [type=" + req.queryType() + "]");
                 }
 
                 IgniteCache<Object, Object> cache = ctx.grid().cache(req.cacheName());
@@ -160,9 +256,25 @@ public class QueryCommandHandler extends GridRestCommandHandlerAdapter {
 
                 CacheQueryResult res = createQueryResult(qryCurs, cur, req, qryId);
 
-                List<GridQueryFieldMetadata> fieldsMeta = ((QueryCursorImpl<?>) qryCur).fieldsMeta();
+                switch (req.queryType()) {
+                    case SQL:
+                    case SQL_FIELDS:
+                        List<GridQueryFieldMetadata> fieldsMeta = ((QueryCursorImpl) qryCur).fieldsMeta();
+
+                        res.setFieldsMetadata(convertMetadata(fieldsMeta));
 
-                res.setFieldsMetadata(convertMetadata(fieldsMeta));
+                        break;
+                    case SCAN:
+                        CacheQueryFieldsMetaResult keyField = new CacheQueryFieldsMetaResult();
+                        keyField.setFieldName("key");
+
+                        CacheQueryFieldsMetaResult valField = new CacheQueryFieldsMetaResult();
+                        valField.setFieldName("value");
+
+                        res.setFieldsMetadata(U.sealList(keyField, valField));
+
+                        break;
+                }
 
                 return new GridRestResponse(res);
             }
@@ -193,17 +305,16 @@ public class QueryCommandHandler extends GridRestCommandHandlerAdapter {
      * Close query callable.
      */
     private static class CloseQueryCallable implements Callable<GridRestResponse> {
-        /** Execute query request. */
-        private RestSqlQueryRequest req;
-
         /** Queries cursors. */
         private final ConcurrentHashMap<Long, IgniteBiTuple<QueryCursor, Iterator>> qryCurs;
+        /** Execute query request. */
+        private RestQueryRequest req;
 
         /**
          * @param req Execute query request.
          * @param qryCurs Queries cursors.
          */
-        public CloseQueryCallable(RestSqlQueryRequest req,
+        public CloseQueryCallable(RestQueryRequest req,
             ConcurrentHashMap<Long, IgniteBiTuple<QueryCursor, Iterator>> qryCurs) {
             this.req = req;
             this.qryCurs = qryCurs;
@@ -236,18 +347,21 @@ public class QueryCommandHandler extends GridRestCommandHandlerAdapter {
      * Fetch query callable.
      */
     private static class FetchQueryCallable implements Callable<GridRestResponse> {
-        /** Execute query request. */
-        private RestSqlQueryRequest req;
-
         /** Queries cursors. */
         private final ConcurrentHashMap<Long, IgniteBiTuple<QueryCursor, Iterator>> qryCurs;
+        /** Grid kernal context. */
+        private final GridKernalContext ctx;
+        /** Execute query request. */
+        private RestQueryRequest req;
 
         /**
+         * @param ctx Grid kernal context.
          * @param req Execute query request.
          * @param qryCurs Queries cursors.
          */
-        public FetchQueryCallable(RestSqlQueryRequest req,
+        public FetchQueryCallable(GridKernalContext ctx, RestQueryRequest req,
             ConcurrentHashMap<Long, IgniteBiTuple<QueryCursor, Iterator>> qryCurs) {
+            this.ctx = ctx;
             this.req = req;
             this.qryCurs = qryCurs;
         }
@@ -272,33 +386,4 @@ public class QueryCommandHandler extends GridRestCommandHandlerAdapter {
             }
         }
     }
-
-    /**
-     * @param qryCurs Query cursors.
-     * @param cur Current cursor.
-     * @param req Sql request.
-     * @param qryId Query id.
-     * @return Query result with items.
-     */
-    private static CacheQueryResult createQueryResult(
-        ConcurrentHashMap<Long, IgniteBiTuple<QueryCursor, Iterator>> qryCurs,
-        Iterator cur, RestSqlQueryRequest req, Long qryId) {
-        CacheQueryResult res = new CacheQueryResult();
-
-        List<Object> items = new ArrayList<>();
-
-        for (int i = 0; i < req.pageSize() && cur.hasNext(); ++i)
-            items.add(cur.next());
-
-        res.setItems(items);
-
-        res.setLast(!cur.hasNext());
-
-        res.setQueryId(qryId);
-
-        if (!cur.hasNext())
-            qryCurs.remove(qryId);
-
-        return res;
-    }
-}
\ No newline at end of file
+}


[29/50] [abbrv] ignite git commit: fix compilation under java7

Posted by ag...@apache.org.
fix compilation under java7


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

Branch: refs/heads/ignite-1016
Commit: 4d1c02669602bef6e696494ccd7382c967d2f962
Parents: 077af17
Author: ashutak <as...@gridgain.com>
Authored: Thu Oct 15 17:09:27 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Thu Oct 15 17:09:27 2015 +0300

----------------------------------------------------------------------
 .../CacheNearDisabledTransactionalWriteReadRestartSelfTest.java    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/4d1c0266/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNearDisabledTransactionalWriteReadRestartSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNearDisabledTransactionalWriteReadRestartSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNearDisabledTransactionalWriteReadRestartSelfTest.java
index 875aef3..148a95db 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNearDisabledTransactionalWriteReadRestartSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNearDisabledTransactionalWriteReadRestartSelfTest.java
@@ -69,7 +69,7 @@ public class CacheNearDisabledTransactionalWriteReadRestartSelfTest extends Cach
     }
 
     /** {@inheritDoc} */
-    @Override protected void updateCache(IgniteEx ignite, IgniteCache cache) throws Exception {
+    @Override protected void updateCache(IgniteEx ignite, final IgniteCache cache) throws Exception {
         final int k = ThreadLocalRandom.current().nextInt(RANGE);
 
         final String[] keys = new String[KEYS_CNT];


[47/50] [abbrv] ignite git commit: Muted CacheHibernateBlobStoreSelfTest.testSimpleMultithreading muted

Posted by ag...@apache.org.
Muted CacheHibernateBlobStoreSelfTest.testSimpleMultithreading muted


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

Branch: refs/heads/ignite-1016
Commit: c28af3c43b172279c4c25d46bca471ecea9d4c36
Parents: 9ffe402
Author: ashutak <as...@gridgain.com>
Authored: Wed Oct 21 15:03:28 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Wed Oct 21 15:03:28 2015 +0300

----------------------------------------------------------------------
 .../cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/c28af3c4/modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java b/modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java
index c900405..d3d2b52 100644
--- a/modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java
+++ b/modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java
@@ -106,4 +106,8 @@ public class CacheHibernateBlobStoreSelfTest extends
         // Store will be implicitly initialized.
         store.load("key");
     }
-}
\ No newline at end of file
+
+    @Override public void testSimpleMultithreading() throws Exception {
+        fail("https://issues.apache.org/jira/browse/IGNITE-1757");
+    }
+}


[08/50] [abbrv] ignite git commit: ignite-1526: fixed merging conflicts

Posted by ag...@apache.org.
ignite-1526: fixed merging conflicts


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

Branch: refs/heads/ignite-1016
Commit: 6afc2fc3ca390dad7834105b53804b89f50aecf2
Parents: 5fc682f
Author: Andrey Gura <ag...@gridgain.com>
Authored: Fri Oct 9 14:23:34 2015 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Fri Oct 9 14:23:34 2015 +0300

----------------------------------------------------------------------
 .../testframework/junits/multijvm/IgniteCacheProcessProxy.java     | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/6afc2fc3/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
index 04d7893..02c6a26 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
@@ -553,7 +553,7 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
             Collection<Entry<K, V>> res = new ArrayList<>();
 
             for (Entry<K, V> e : cache().localEntries(peekModes))
-                res.add(new CacheEntryImpl<>(e.getKey(), e.getValue()));
+                res.add(e);
 
             return res;
         }


[13/50] [abbrv] ignite git commit: ignite-1.4.2 - review and minor changes.

Posted by ag...@apache.org.
ignite-1.4.2 - review and minor changes.


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

Branch: refs/heads/ignite-1016
Commit: 155edd8d254fa56c4fcc1666fe014c116e649a39
Parents: 4ee154c
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Mon Oct 12 12:41:59 2015 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Mon Oct 12 12:41:59 2015 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheIoManager.java    |   9 +-
 .../GridDhtPartitionDemandMessage.java          |   1 -
 .../GridDhtPartitionsExchangeFuture.java        |  16 +-
 .../preloader/GridDhtPartitionsFullMessage.java |   1 -
 .../multijvm/IgniteCacheProcessProxy.java       | 966 +------------------
 .../Properties/AssemblyInfo.cs                  |   2 +-
 .../Apache.Ignite/Properties/AssemblyInfo.cs    |   2 +-
 .../Properties/AssemblyInfo.cs                  |   2 +-
 .../Properties/AssemblyInfo.cs                  |   2 +-
 9 files changed, 12 insertions(+), 989 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/155edd8d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
index ae3eb22..476a96c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
@@ -24,7 +24,6 @@ import java.util.Map;
 import java.util.UUID;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicLong;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
@@ -57,8 +56,6 @@ import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxPr
 import org.apache.ignite.internal.util.F0;
 import org.apache.ignite.internal.util.GridLeanSet;
 import org.apache.ignite.internal.util.GridSpinReadWriteLock;
-import org.apache.ignite.internal.util.future.GridFinishedFuture;
-import org.apache.ignite.internal.util.lang.GridPlainRunnable;
 import org.apache.ignite.internal.util.typedef.CI1;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.P1;
@@ -99,9 +96,6 @@ public class GridCacheIoManager extends GridCacheSharedManagerAdapter {
     /** Stopping flag. */
     private boolean stopping;
 
-    /** Error flag. */
-    private final AtomicBoolean startErr = new AtomicBoolean();
-
     /** Mutex. */
     private final GridSpinReadWriteLock rw = new GridSpinReadWriteLock();
 
@@ -944,10 +938,9 @@ public class GridCacheIoManager extends GridCacheSharedManagerAdapter {
     /**
      * @param nodeId Sender node ID.
      * @param cacheMsg Message.
-     * @throws IgniteCheckedException If failed.
      */
     @SuppressWarnings({"ErrorNotRethrown", "unchecked"})
-    private void unmarshall(UUID nodeId, GridCacheMessage cacheMsg) throws IgniteCheckedException {
+    private void unmarshall(UUID nodeId, GridCacheMessage cacheMsg) {
         if (cctx.localNodeId().equals(nodeId))
             return;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/155edd8d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java
index 156c37f..848ad87 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java
@@ -27,7 +27,6 @@ import org.apache.ignite.internal.GridDirectTransient;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
 import org.apache.ignite.internal.processors.cache.GridCacheMessage;
 import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
-import org.apache.ignite.internal.util.tostring.GridToStringInclude;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.plugin.extensions.communication.MessageCollectionItemType;
 import org.apache.ignite.plugin.extensions.communication.MessageReader;

http://git-wip-us.apache.org/repos/asf/ignite/blob/155edd8d/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 eaa5584..77e47a7 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
@@ -193,6 +193,9 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
     /** */
     private boolean clientOnlyExchange;
 
+    /** Init timestamp. Used to track the amount of time spent to complete the future. */
+    private long initTs;
+
     /**
      * Dummy future created to trigger reassignments if partition
      * topology changed while preloading.
@@ -475,9 +478,6 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
         busyLock.readLock().unlock();
     }
 
-    // TODO remove
-    long inited;
-
     /**
      * Starts activity.
      *
@@ -491,7 +491,7 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
             if (isDone())
                 return;
 
-            inited = U.currentTimeMillis();
+            initTs = U.currentTimeMillis();
 
             try {
                 // Wait for event to occur to make sure that discovery
@@ -1065,7 +1065,7 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
         if (super.onDone(res, err) && !dummy && !forcePreload) {
             if (log.isDebugEnabled())
                 log.debug("Completed partition exchange [localNode=" + cctx.localNodeId() + ", exchange= " + this +
-                    "duration=" + duration() + ", durationFromInit=" + (U.currentTimeMillis() - inited) + ']');
+                    "duration=" + duration() + ", durationFromInit=" + (U.currentTimeMillis() - initTs) + ']');
 
             initFut.onDone(err == null);
 
@@ -1196,8 +1196,6 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
                     if (match) {
                         boolean allReceived;
 
-                        long start = U.currentTimeMillis();
-
                         synchronized (rcvdIds) {
                             if (rcvdIds.add(nodeId))
                                 updatePartitionSingleMap(msg);
@@ -1205,8 +1203,6 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
                             allReceived = allReceived();
                         }
 
-                        long end = U.currentTimeMillis();
-
                         // If got all replies, and initialization finished, and reply has not been sent yet.
                         if (allReceived && ready.get() && replied.compareAndSet(false, true)) {
                             spreadPartitions();
@@ -1216,7 +1212,7 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
                         else if (log.isDebugEnabled())
                             log.debug("Exchange future full map is not sent [allReceived=" + allReceived() +
                                 ", ready=" + ready + ", replied=" + replied.get() + ", init=" + init.get() +
-                                ", fut=" + GridDhtPartitionsExchangeFuture.this + ", updateDur=" + (end - start) + ']');
+                                ", fut=" + GridDhtPartitionsExchangeFuture.this + ']');
                     }
                 }
             });

http://git-wip-us.apache.org/repos/asf/ignite/blob/155edd8d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java
index 5429538..c06d773 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java
@@ -203,4 +203,3 @@ public class GridDhtPartitionsFullMessage extends GridDhtPartitionsAbstractMessa
             "super", super.toString());
     }
 }
-

http://git-wip-us.apache.org/repos/asf/ignite/blob/155edd8d/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
index ddce314..d89e397 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
@@ -1386,968 +1386,4 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
             return async ? cache.withAsync() : cache;
         }
     }
-
-    /**
-     *
-     */
-    private static class GetConfigurationTask<K, V, C extends Configuration<K, V>> extends CacheTaskAdapter<K, V, C> {
-        /** Clazz. */
-        private final Class<C> clazz;
-
-        /**
-         * @param cacheName Cache name.
-         * @param async Async.
-         * @param clazz Clazz.
-         */
-        public GetConfigurationTask(String cacheName, boolean async, Class<C> clazz) {
-            super(cacheName, async);
-            this.clazz = clazz;
-        }
-
-        /** {@inheritDoc} */
-        @Override public C call() throws Exception {
-            return cache().getConfiguration(clazz);
-        }
-    }
-
-    /**
-     *
-     */
-    private static class LocalLoadCacheTask<K, V> extends CacheTaskAdapter<K, V, Void> {
-        /** Predicate. */
-        private final IgniteBiPredicate<K, V> p;
-
-        /** Args. */
-        private final Object[] args;
-
-        /**
-         * @param cacheName Cache name.
-         * @param async Async.
-         * @param p P.
-         * @param args Args.
-         */
-        public LocalLoadCacheTask(String cacheName, boolean async, IgniteBiPredicate<K, V> p, Object[] args) {
-            super(cacheName, async);
-            this.p = p;
-            this.args = args;
-        }
-
-        /** {@inheritDoc} */
-        @Override public Void call() {
-            cache().localLoadCache(p, args);
-
-            return null;
-        }
-    }
-
-    /**
-     *
-     */
-    private static class GetAndPutIfAbsentTask<K, V> extends CacheTaskAdapter<K, V, V> {
-        /** Key. */
-        private final K key;
-
-        /** Value. */
-        private final V val;
-
-        /**
-         * @param cacheName Cache name.
-         * @param async Async.
-         * @param key Key.
-         * @param val Value.
-         */
-        public GetAndPutIfAbsentTask(String cacheName, boolean async, K key, V val) {
-            super(cacheName, async);
-            this.key = key;
-            this.val = val;
-        }
-
-        /** {@inheritDoc} */
-        @Override public V call() throws Exception {
-            return cache().getAndPutIfAbsent(key, val);
-        }
-    }
-
-    /**
-     *
-     */
-    private static class IsLocalLockedTask<K> extends CacheTaskAdapter<K, Void, Boolean> {
-        /** Key. */
-        private final K key;
-
-        /** By current thread. */
-        private final boolean byCurrThread;
-
-        /**
-         * @param cacheName Cache name.
-         * @param async Async.
-         * @param key Key.
-         * @param byCurrThread By current thread.
-         */
-        public IsLocalLockedTask(String cacheName, boolean async, K key, boolean byCurrThread) {
-            super(cacheName, async);
-            this.key = key;
-            this.byCurrThread = byCurrThread;
-        }
-
-        /** {@inheritDoc} */
-        @Override public Boolean call() throws Exception {
-            return cache().isLocalLocked(key, byCurrThread);
-        }
-    }
-
-    /**
-     *
-     */
-    private static class LocalEntriesTask<K, V> extends CacheTaskAdapter<K, V, Iterable<Entry<K, V>>> {
-        /** Peek modes. */
-        private final CachePeekMode[] peekModes;
-
-        /**
-         * @param cacheName Cache name.
-         * @param async Async.
-         * @param peekModes Peek modes.
-         */
-        public LocalEntriesTask(String cacheName, boolean async, CachePeekMode[] peekModes) {
-            super(cacheName, async);
-            this.peekModes = peekModes;
-        }
-
-        /** {@inheritDoc} */
-        @Override public Iterable<Entry<K, V>> call() throws Exception {
-            Collection<Entry<K, V>> res = new ArrayList<>();
-
-            for (Entry<K, V> e : cache().localEntries(peekModes))
-                res.add(e);
-
-            return res;
-        }
-    }
-
-    /**
-     *
-     */
-    private static class LocalEvictTask<K> extends CacheTaskAdapter<K, Void, Void> {
-        /** Keys. */
-        private final Collection<? extends K> keys;
-
-        /**
-         * @param cacheName Cache name.
-         * @param async Async.
-         * @param keys Keys.
-         */
-        public LocalEvictTask(String cacheName, boolean async, Collection<? extends K> keys) {
-            super(cacheName, async);
-            this.keys = keys;
-        }
-
-        /** {@inheritDoc} */
-        @Override public Void call() {
-            cache().localEvict(keys);
-
-            return null;
-        }
-    }
-
-    /**
-     *
-     */
-    private static class LocalPeekTask<K, V> extends CacheTaskAdapter<K, V, V> {
-        /** Key. */
-        private final K key;
-
-        /** Peek modes. */
-        private final CachePeekMode[] peekModes;
-
-        /**
-         * @param cacheName Cache name.
-         * @param async Async.
-         * @param key Key.
-         * @param peekModes Peek modes.
-         */
-        public LocalPeekTask(String cacheName, boolean async, K key, CachePeekMode[] peekModes) {
-            super(cacheName, async);
-            this.key = key;
-            this.peekModes = peekModes;
-        }
-
-        /** {@inheritDoc} */
-        @Override public V call() throws Exception {
-            return cache().localPeek(key, peekModes);
-        }
-    }
-
-    /**
-     *
-     */
-    private static class SizeTask extends CacheTaskAdapter<Void, Void, Integer> {
-        /** Peek modes. */
-        private final CachePeekMode[] peekModes;
-
-        /** Local. */
-        private final boolean loc;
-
-        /**
-         * @param cacheName Cache name.
-         * @param async Async.
-         * @param peekModes Peek modes.
-         * @param loc Local.
-         */
-        public SizeTask(String cacheName, boolean async, CachePeekMode[] peekModes, boolean loc) {
-            super(cacheName, async);
-            this.loc = loc;
-            this.peekModes = peekModes;
-        }
-
-        /** {@inheritDoc} */
-        @Override public Integer call() throws Exception {
-            return loc ? cache().localSize(peekModes) : cache().size(peekModes);
-        }
-    }
-
-    /**
-     *
-     */
-    private static class GetTask<K, V> extends CacheTaskAdapter<K, V, V> {
-        /** Key. */
-        private final K key;
-
-        /**
-         * @param cacheName Cache name.
-         * @param async Async.
-         * @param key Key.
-         */
-        public GetTask(String cacheName, boolean async, K key) {
-            super(cacheName, async);
-            this.key = key;
-        }
-
-        /** {@inheritDoc} */
-        @Override public V call() throws Exception {
-            return cache().get(key);
-        }
-    }
-
-    /**
-     *
-     */
-    private static class RemoveAllTask<K, V> extends CacheTaskAdapter<K, V, Void> {
-        /**
-         * @param cacheName Cache name.
-         * @param async Async.
-         */
-        public RemoveAllTask(String cacheName, boolean async) {
-            super(cacheName, async);
-        }
-
-        /** {@inheritDoc} */
-        @Override public Void call() {
-            IgniteCache<K, V> cache = cache();
-
-            cache.removeAll();
-
-            if (async)
-                cache.future().get();
-
-            return null;
-        }
-    }
-
-    /**
-     *
-     */
-    private static class PutTask<K, V> extends CacheTaskAdapter<K, V, Void> {
-        /** Key. */
-        private final K key;
-
-        /** Value. */
-        private final V val;
-
-        /**
-         * @param cacheName Cache name.
-         * @param async Async.
-         * @param key Key.
-         * @param val Value.
-         */
-        public PutTask(String cacheName, boolean async, K key, V val) {
-            super(cacheName, async);
-            this.key = key;
-            this.val = val;
-        }
-
-        /** {@inheritDoc} */
-        @Override public Void call() {
-            cache().put(key, val);
-
-            return null;
-        }
-    }
-
-    /**
-     *
-     */
-    private static class ContainsKeyTask<K> extends CacheTaskAdapter<K, Object, Boolean> {
-        /** Key. */
-        private final K key;
-
-        /**
-         * @param cacheName Cache name.
-         * @param async Async.
-         * @param key Key.
-         */
-        public ContainsKeyTask(String cacheName, boolean async, K key) {
-            super(cacheName, async);
-            this.key = key;
-        }
-
-        /** {@inheritDoc} */
-        @Override public Boolean call() throws Exception {
-            return cache().containsKey(key);
-        }
-    }
-
-    /**
-     *
-     */
-    private static class ClearTask extends CacheTaskAdapter<Object, Object, Void> {
-        /**
-         * @param cacheName Cache name.
-         * @param async Async.
-         */
-        public ClearTask(String cacheName, boolean async) {
-            super(cacheName, async);
-        }
-
-        /** {@inheritDoc} */
-        @Override public Void call() {
-            cache().clear();
-
-            return null;
-        }
-    }
-
-    /**
-     *
-     */
-    private static class IteratorTask<K, V> extends CacheTaskAdapter<K, V, Collection<Entry<K, V>>> {
-        /**
-         * @param cacheName Cache name.
-         * @param async Async.
-         */
-        public IteratorTask(String cacheName, boolean async) {
-            super(cacheName, async);
-        }
-
-        /** {@inheritDoc} */
-        @Override public Collection<Entry<K, V>> call() throws Exception {
-            Collection<Entry<K, V>> res = new ArrayList<>();
-
-            for (Entry<K, V> o : cache())
-                res.add(o);
-
-            return res;
-        }
-    }
-
-    /**
-     *
-     */
-    private static class ReplaceTask<K, V> extends CacheTaskAdapter<K, V, Boolean> {
-        /** Key. */
-        private final K key;
-
-        /** Value. */
-        private final V val;
-
-        /**
-         * @param cacheName Cache name.
-         * @param async Async.
-         * @param key Key.
-         * @param val Value.
-         */
-        public ReplaceTask(String cacheName, boolean async, K key, V val) {
-            super(cacheName, async);
-            this.key = key;
-            this.val = val;
-        }
-
-        /** {@inheritDoc} */
-        @Override public Boolean call() throws Exception {
-            return cache().replace(key, val);
-        }
-    }
-
-    /**
-     *
-     */
-    private static class GetNameTask extends CacheTaskAdapter<Void, Void, String> {
-        /**
-         * @param cacheName Cache name.
-         * @param async Async.
-         */
-        public GetNameTask(String cacheName, boolean async) {
-            super(cacheName, async);
-        }
-
-        /** {@inheritDoc} */
-        @Override public String call() throws Exception {
-            return cache().getName();
-        }
-    }
-
-    /**
-     *
-     */
-    private static class RemoveTask<K> extends CacheTaskAdapter<K, Void, Boolean> {
-        /** Key. */
-        private final K key;
-
-        /**
-         * @param cacheName Cache name.
-         * @param async Async.
-         * @param key Key.
-         */
-        public RemoveTask(String cacheName, boolean async, K key) {
-            super(cacheName, async);
-            this.key = key;
-        }
-
-        /** {@inheritDoc} */
-        @Override public Boolean call() throws Exception {
-            return cache().remove(key);
-        }
-    }
-
-    /**
-     *
-     */
-    private static class PutAllTask<K, V> extends CacheTaskAdapter<K, V, Void> {
-        /** Map. */
-        private final Map<? extends K, ? extends V> map;
-
-        /**
-         * @param cacheName Cache name.
-         * @param async Async.
-         * @param map Map.
-         */
-        public PutAllTask(String cacheName, boolean async, Map<? extends K, ? extends V> map) {
-            super(cacheName, async);
-            this.map = map;
-        }
-
-        /** {@inheritDoc} */
-        @Override public Void call() {
-            cache().putAll(map);
-
-            return null;
-        }
-    }
-
-    /**
-     *
-     */
-    private static class RemoveAllKeysTask<K> extends CacheTaskAdapter<K, Void, Void> {
-        /** Keys. */
-        private final Set<? extends K> keys;
-
-        /**
-         * @param cacheName Cache name.
-         * @param async Async.
-         * @param keys Keys.
-         */
-        public RemoveAllKeysTask(String cacheName, boolean async, Set<? extends K> keys) {
-            super(cacheName, async);
-            this.keys = keys;
-        }
-
-        /** {@inheritDoc} */
-        @Override public Void call() {
-            cache().removeAll(keys);
-
-            return null;
-        }
-    }
-
-    /**
-     *
-     */
-    private static class GetAllTask<K, V> extends CacheTaskAdapter<K, V, Map<K, V>> {
-        /** Keys. */
-        private final Set<? extends K> keys;
-
-        /**
-         * @param cacheName Cache name.
-         * @param async Async.
-         * @param keys Keys.
-         */
-        public GetAllTask(String cacheName, boolean async, Set<? extends K> keys) {
-            super(cacheName, async);
-            this.keys = keys;
-        }
-
-        /** {@inheritDoc} */
-        @Override public Map<K, V> call() throws Exception {
-            return cache().getAll(keys);
-        }
-    }
-
-    /**
-     *
-     */
-    private static class GetAllOutTxTask<K, V> extends CacheTaskAdapter<K, V, Map<K, V>> {
-        /** Keys. */
-        private final Set<? extends K> keys;
-
-        /**
-         * @param cacheName Cache name.
-         * @param async Async.
-         * @param keys Keys.
-         */
-        public GetAllOutTxTask(String cacheName, boolean async, Set<? extends K> keys) {
-            super(cacheName, async);
-            this.keys = keys;
-        }
-
-        /** {@inheritDoc} */
-        @Override public Map<K, V> call() throws Exception {
-            return cache().getAllOutTx(keys);
-        }
-    }
-
-    /**
-     *
-     */
-    private static class ContainsKeysTask<K, V> extends CacheTaskAdapter<K, V, Boolean> {
-        /** Keys. */
-        private final Set<? extends K> keys;
-
-        /**
-         * @param cacheName Cache name.
-         * @param async Async.
-         * @param keys Keys.
-         */
-        public ContainsKeysTask(String cacheName, boolean async, Set<? extends K> keys) {
-            super(cacheName, async);
-            this.keys = keys;
-        }
-
-        /** {@inheritDoc} */
-        @Override public Boolean call() throws Exception {
-            return cache().containsKeys(keys);
-        }
-    }
-
-    /**
-     *
-     */
-    private static class GetAndPutTask<K, V> extends CacheTaskAdapter<K, V, V> {
-        /** Key. */
-        private final K key;
-
-        /** Value. */
-        private final V val;
-
-        /**
-         * @param cacheName Cache name.
-         * @param async Async.
-         * @param key Key.
-         * @param val Value.
-         */
-        public GetAndPutTask(String cacheName, boolean async, K key, V val) {
-            super(cacheName, async);
-            this.key = key;
-            this.val = val;
-        }
-
-        /** {@inheritDoc} */
-        @Override public V call() throws Exception {
-            return cache().getAndPut(key, val);
-        }
-    }
-
-    /**
-     *
-     */
-    private static class PutIfAbsentTask<K, V> extends CacheTaskAdapter<K, V, Boolean> {
-        /** Key. */
-        private final K key;
-
-        /** Value. */
-        private final V val;
-
-        /**
-         * @param cacheName Cache name.
-         * @param async Async.
-         * @param key Key.
-         * @param val Value.
-         */
-        public PutIfAbsentTask(String cacheName, boolean async, K key, V val) {
-            super(cacheName, async);
-            this.key = key;
-            this.val = val;
-        }
-
-        /** {@inheritDoc} */
-        @Override public Boolean call() throws Exception {
-            return cache().putIfAbsent(key, val);
-        }
-    }
-
-    /**
-     *
-     */
-    private static class RemoveIfExistsTask<K, V> extends CacheTaskAdapter<K, V, Boolean> {
-        /** Key. */
-        private final K key;
-
-        /** Old value. */
-        private final V oldVal;
-
-        /**
-         * @param cacheName Cache name.
-         * @param async Async.
-         * @param key Key.
-         * @param oldVal Old value.
-         */
-        public RemoveIfExistsTask(String cacheName, boolean async, K key, V oldVal) {
-            super(cacheName, async);
-            this.key = key;
-            this.oldVal = oldVal;
-        }
-
-        /** {@inheritDoc} */
-        @Override public Boolean call() throws Exception {
-            return cache().remove(key, oldVal);
-        }
-    }
-
-    /**
-     *
-     */
-    private static class GetAndRemoveTask<K, V> extends CacheTaskAdapter<K, V, V> {
-        /** Key. */
-        private final K key;
-
-        /**
-         * @param cacheName Cache name.
-         * @param async Async.
-         * @param key Key.
-         */
-        public GetAndRemoveTask(String cacheName, boolean async, K key) {
-            super(cacheName, async);
-            this.key = key;
-        }
-
-        /** {@inheritDoc} */
-        @Override public V call() throws Exception {
-            return cache().getAndRemove(key);
-        }
-    }
-
-    /**
-     *
-     */
-    private static class ReplaceIfExistsTask<K, V> extends CacheTaskAdapter<K, V, Boolean> {
-        /** Key. */
-        private final K key;
-
-        /** Old value. */
-        private final V oldVal;
-
-        /** New value. */
-        private final V newVal;
-
-        /**
-         * @param cacheName Cache name.
-         * @param async Async.
-         * @param key Key.
-         * @param oldVal Old value.
-         * @param newVal New value.
-         */
-        public ReplaceIfExistsTask(String cacheName, boolean async, K key, V oldVal, V newVal) {
-            super(cacheName, async);
-            this.key = key;
-            this.oldVal = oldVal;
-            this.newVal = newVal;
-        }
-
-        /** {@inheritDoc} */
-        @Override public Boolean call() throws Exception {
-            return cache().replace(key, oldVal, newVal);
-        }
-    }
-
-    /**
-     *
-     */
-    private static class GetAndReplaceTask<K, V> extends CacheTaskAdapter<K, V, V> {
-        /** Key. */
-        private final K key;
-
-        /** Value. */
-        private final V val;
-
-        /**
-         * @param cacheName Cache name.
-         * @param async Async.
-         * @param key Key.
-         * @param val Value.
-         */
-        public GetAndReplaceTask(String cacheName, boolean async, K key, V val) {
-            super(cacheName, async);
-            this.key = key;
-            this.val = val;
-        }
-
-        /** {@inheritDoc} */
-        @Override public V call() throws Exception {
-            return cache().getAndReplace(key, val);
-        }
-    }
-
-    /**
-     *
-     */
-    private static class ClearKeyTask<K> extends CacheTaskAdapter<K, Void, Void> {
-        /** Key. */
-        private final K key;
-
-        /** Local. */
-        private final boolean loc;
-
-        /**
-         * @param cacheName Cache name.
-         * @param async Async.
-         * @param key Key.
-         */
-        public ClearKeyTask(String cacheName, boolean async, boolean loc, K key) {
-            super(cacheName, async);
-            this.key = key;
-            this.loc = loc;
-        }
-
-        /** {@inheritDoc} */
-        @Override public Void call() {
-            if (loc)
-                cache().localClear(key);
-            else
-                cache().clear(key);
-
-            return null;
-        }
-    }
-
-    /**
-     *
-     */
-    private static class ClearAllKeys<K> extends CacheTaskAdapter<K, Void, Void> {
-        /** Keys. */
-        private final Set<? extends K> keys;
-
-        /** Local. */
-        private final boolean loc;
-
-        /**
-         * @param cacheName Cache name.
-         * @param async Async.
-         * @param keys Keys.
-         */
-        public ClearAllKeys(String cacheName, boolean async, boolean loc, Set<? extends K> keys) {
-            super(cacheName, async);
-            this.keys = keys;
-            this.loc = loc;
-        }
-
-        /** {@inheritDoc} */
-        @Override public Void call() {
-            if (loc)
-                cache().localClearAll(keys);
-            else
-                cache().clearAll(keys);
-
-            return null;
-        }
-    }
-
-    /**
-     *
-     */
-    private static class InvokeTask<K, V, R> extends CacheTaskAdapter<K, V, R> {
-        /** Key. */
-        private final K key;
-
-        /** Processor. */
-        private final EntryProcessor<K, V, R> processor;
-
-        /** Args. */
-        private final Object[] args;
-
-        /**
-         * @param cacheName Cache name.
-         * @param async Async.
-         * @param key Key.
-         * @param processor Processor.
-         * @param args Args.
-         */
-        public InvokeTask(String cacheName, boolean async, K key, EntryProcessor<K, V, R> processor,
-            Object[] args) {
-            super(cacheName, async);
-            this.args = args;
-            this.key = key;
-            this.processor = processor;
-        }
-
-        /** {@inheritDoc} */
-        @Override public R call() throws Exception {
-            return cache().invoke(key, processor, args);
-        }
-    }
-
-    /**
-     *
-     */
-    private static class InvokeAllTask<K, V, T> extends CacheTaskAdapter<K, V, Map<K, EntryProcessorResult<T>>> {
-        /** Keys. */
-        private final Set<? extends K> keys;
-
-        /** Processor. */
-        private final EntryProcessor<K, V, T> processor;
-
-        /** Args. */
-        private final Object[] args;
-
-        /**
-         * @param cacheName Cache name.
-         * @param async Async.
-         * @param keys Keys.
-         * @param processor Processor.
-         * @param args Args.
-         */
-        public InvokeAllTask(String cacheName, boolean async, Set<? extends K> keys,
-            EntryProcessor<K, V, T> processor, Object[] args) {
-            super(cacheName, async);
-            this.args = args;
-            this.keys = keys;
-            this.processor = processor;
-        }
-
-        /** {@inheritDoc} */
-        @Override public Map<K, EntryProcessorResult<T>> call() throws Exception {
-            return cache().invokeAll(keys, processor, args);
-        }
-    }
-
-    /**
-     *
-     */
-    private static class CloseTask extends CacheTaskAdapter<Void, Void, Void> {
-        /**
-         * @param cacheName Cache name.
-         * @param async Async.
-         */
-        public CloseTask(String cacheName, boolean async) {
-            super(cacheName, async);
-        }
-
-        /** {@inheritDoc} */
-        @Override public Void call() {
-            cache().close();
-
-            return null;
-        }
-    }
-
-    /**
-     *
-     */
-    private static class DestroyTask extends CacheTaskAdapter<Void, Void, Void> {
-        /**
-         * @param cacheName Cache name.
-         * @param async Async.
-         */
-        public DestroyTask(String cacheName, boolean async) {
-            super(cacheName, async);
-        }
-
-        /** {@inheritDoc} */
-        @Override public Void call() {
-            cache().destroy();
-
-            return null;
-        }
-    }
-
-    /**
-     *
-     */
-    private static class IsClosedTask extends CacheTaskAdapter<Void, Void, Boolean> {
-        /**
-         * @param cacheName Cache name.
-         * @param async Async.
-         */
-        public IsClosedTask(String cacheName, boolean async) {
-            super(cacheName, async);
-        }
-
-        /** {@inheritDoc} */
-        @Override public Boolean call() throws Exception {
-            return cache().isClosed();
-        }
-    }
-
-    /**
-     *
-     */
-    private static class UnwrapTask<R> extends CacheTaskAdapter<Void, Void, R> {
-        /** Clazz. */
-        private final Class<R> clazz;
-
-        /**
-         * @param cacheName Cache name.
-         * @param async Async.
-         * @param clazz Clazz.
-         */
-        public UnwrapTask(String cacheName, boolean async, Class<R> clazz) {
-            super(cacheName, async);
-            this.clazz = clazz;
-        }
-
-        /** {@inheritDoc} */
-        @Override public R call() throws Exception {
-            return cache().unwrap(clazz);
-        }
-    }
-
-    /**
-     *
-     */
-    private static abstract class CacheTaskAdapter<K, V, R> implements IgniteCallable<R> {
-        /** Ignite. */
-        @IgniteInstanceResource
-        protected Ignite ignite;
-
-        /** Cache name. */
-        protected final String cacheName;
-
-        /** Async. */
-        protected final boolean async;
-
-        /**
-         * @param cacheName Cache name.
-         * @param async Async.
-         */
-        public CacheTaskAdapter(String cacheName, boolean async) {
-            this.async = async;
-            this.cacheName = cacheName;
-        }
-
-        /**
-         * Returns cache instance.
-         */
-        protected IgniteCache<K, V> cache() {
-            IgniteCache<K, V> cache = ignite.cache(cacheName);
-
-            return async ? cache.withAsync() : cache;
-        }
-    }
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/155edd8d/modules/platform/src/main/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs
index 7425cb6..1876e24 100644
--- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs
+++ b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs
@@ -1,4 +1,4 @@
-/*
+/*
  * 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.

http://git-wip-us.apache.org/repos/asf/ignite/blob/155edd8d/modules/platform/src/main/dotnet/Apache.Ignite/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/dotnet/Apache.Ignite/Properties/AssemblyInfo.cs b/modules/platform/src/main/dotnet/Apache.Ignite/Properties/AssemblyInfo.cs
index 198cfa6..03f7fb9 100644
--- a/modules/platform/src/main/dotnet/Apache.Ignite/Properties/AssemblyInfo.cs
+++ b/modules/platform/src/main/dotnet/Apache.Ignite/Properties/AssemblyInfo.cs
@@ -1,4 +1,4 @@
-/*
+/*
  * 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.

http://git-wip-us.apache.org/repos/asf/ignite/blob/155edd8d/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests.TestDll/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests.TestDll/Properties/AssemblyInfo.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests.TestDll/Properties/AssemblyInfo.cs
index a45f421..22d74c9 100644
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests.TestDll/Properties/AssemblyInfo.cs
+++ b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests.TestDll/Properties/AssemblyInfo.cs
@@ -1,4 +1,4 @@
-/*
+/*
  * 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.

http://git-wip-us.apache.org/repos/asf/ignite/blob/155edd8d/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Properties/AssemblyInfo.cs b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Properties/AssemblyInfo.cs
index db88e3b..1ebcf24 100644
--- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Properties/AssemblyInfo.cs
+++ b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Properties/AssemblyInfo.cs
@@ -1,4 +1,4 @@
-/*
+/*
  * 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.


[30/50] [abbrv] ignite git commit: Merge remote-tracking branch 'apache/master'

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


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

Branch: refs/heads/ignite-1016
Commit: 8217be6a0f7a3a0e564203e9ace52697833863ed
Parents: 4d1c026 f4d8ea9
Author: ashutak <as...@gridgain.com>
Authored: Thu Oct 15 17:12:53 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Thu Oct 15 17:12:53 2015 +0300

----------------------------------------------------------------------
 assembly/release-fabric-lgpl.xml                |  63 +++++
 assembly/release-hadoop-lgpl.xml                |  39 +++
 examples-lgpl/README.txt                        |  27 ++
 examples-lgpl/config/example-cache.xml          |  73 ++++++
 examples-lgpl/config/example-ignite.xml         |  83 +++++++
 examples-lgpl/config/filesystem/README.txt      |   8 +
 examples-lgpl/config/filesystem/core-site.xml   |  42 ++++
 .../config/filesystem/example-igfs.xml          | 151 ++++++++++++
 examples-lgpl/config/hibernate/README.txt       |   8 +
 .../hibernate/example-hibernate-L2-cache.xml    |  64 +++++
 examples-lgpl/config/servlet/README.txt         |   8 +
 examples-lgpl/config/servlet/WEB-INF/web.xml    |  36 +++
 examples-lgpl/pom-standalone.xml                | 141 +++++++++++
 examples-lgpl/pom.xml                           | 128 ++++++++++
 .../hibernate/HibernateL2CacheExample.java      | 245 +++++++++++++++++++
 .../examples/datagrid/hibernate/Post.java       | 130 ++++++++++
 .../examples/datagrid/hibernate/User.java       | 154 ++++++++++++
 .../datagrid/hibernate/package-info.java        |  22 ++
 .../hibernate/CacheHibernatePersonStore.java    | 122 +++++++++
 .../hibernate/CacheHibernateStoreExample.java   | 151 ++++++++++++
 .../datagrid/store/hibernate/Person.hbm.xml     |  34 +++
 .../datagrid/store/hibernate/hibernate.cfg.xml  |  41 ++++
 .../datagrid/store/hibernate/package-info.java  |  22 ++
 .../java8/cluster/ClusterGroupExample.java      |  86 +++++++
 .../examples/java8/cluster/package-info.java    |  22 ++
 .../java8/computegrid/ComputeAsyncExample.java  |  75 ++++++
 .../computegrid/ComputeBroadcastExample.java    | 102 ++++++++
 .../computegrid/ComputeCallableExample.java     |  75 ++++++
 .../computegrid/ComputeClosureExample.java      |  71 ++++++
 .../computegrid/ComputeRunnableExample.java     |  64 +++++
 .../java8/computegrid/package-info.java         |  22 ++
 .../java8/datagrid/CacheAffinityExample.java    | 137 +++++++++++
 .../java8/datagrid/CacheApiExample.java         | 105 ++++++++
 .../java8/datagrid/CacheAsyncApiExample.java    |  85 +++++++
 .../examples/java8/datagrid/package-info.java   |  22 ++
 .../IgniteExecutorServiceExample.java           |  70 ++++++
 .../java8/datastructures/package-info.java      |  22 ++
 .../examples/java8/events/EventsExample.java    | 135 ++++++++++
 .../examples/java8/events/package-info.java     |  22 ++
 .../java8/messaging/MessagingExample.java       | 166 +++++++++++++
 .../messaging/MessagingPingPongExample.java     | 113 +++++++++
 .../examples/java8/messaging/package-info.java  |  22 ++
 .../misc/schedule/ComputeScheduleExample.java   |  68 +++++
 .../java8/misc/schedule/package-info.java       |  22 ++
 .../ignite/examples/java8/package-info.java     |  23 ++
 .../streaming/StreamTransformerExample.java     | 101 ++++++++
 .../java8/streaming/StreamVisitorExample.java   | 172 +++++++++++++
 .../examples/java8/streaming/package-info.java  |  22 ++
 ...ibernateL2CacheExampleMultiNodeSelfTest.java |  31 +++
 .../HibernateL2CacheExampleSelfTest.java        |  33 +++
 .../IgniteLgplExamplesSelfTestSuite.java        |  48 ++++
 ...ibernateL2CacheExampleMultiNodeSelfTest.java |  29 +++
 .../HibernateL2CacheExampleSelfTest.java        |  37 +++
 .../IgniteLgplExamplesJ8SelfTestSuite.java      |  46 ++++
 examples/pom-standalone.xml                     |  12 -
 examples/pom.xml                                |  12 -
 .../hibernate/HibernateL2CacheExample.java      | 245 -------------------
 .../examples/datagrid/hibernate/Post.java       | 130 ----------
 .../examples/datagrid/hibernate/User.java       | 154 ------------
 .../datagrid/hibernate/package-info.java        |  22 --
 .../hibernate/CacheHibernatePersonStore.java    | 122 ---------
 .../hibernate/CacheHibernateStoreExample.java   | 151 ------------
 .../datagrid/store/hibernate/Person.hbm.xml     |  34 ---
 .../datagrid/store/hibernate/hibernate.cfg.xml  |  41 ----
 .../datagrid/store/hibernate/package-info.java  |  22 --
 ...ibernateL2CacheExampleMultiNodeSelfTest.java |  31 ---
 .../HibernateL2CacheExampleSelfTest.java        |  33 ---
 .../testsuites/IgniteExamplesSelfTestSuite.java |   4 -
 ...ibernateL2CacheExampleMultiNodeSelfTest.java |  29 ---
 .../HibernateL2CacheExampleSelfTest.java        |  37 ---
 pom.xml                                         |  65 ++++-
 71 files changed, 3904 insertions(+), 1080 deletions(-)
----------------------------------------------------------------------



[04/50] [abbrv] ignite git commit: ignite-1526: full support of IBM JDK by Ignite

Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/a1e5cc57/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
index ac8c5af..d89e397 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
@@ -22,7 +22,6 @@ import java.util.Collection;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
-import java.util.UUID;
 import java.util.concurrent.locks.Lock;
 import javax.cache.CacheException;
 import javax.cache.CacheManager;
@@ -35,7 +34,6 @@ import javax.cache.processor.EntryProcessorResult;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.IgniteCompute;
-import org.apache.ignite.Ignition;
 import org.apache.ignite.cache.CacheEntryProcessor;
 import org.apache.ignite.cache.CacheMetrics;
 import org.apache.ignite.cache.CachePeekMode;
@@ -48,8 +46,8 @@ import org.apache.ignite.internal.util.future.IgniteFinishedFutureImpl;
 import org.apache.ignite.lang.IgniteBiPredicate;
 import org.apache.ignite.lang.IgniteCallable;
 import org.apache.ignite.lang.IgniteFuture;
-import org.apache.ignite.lang.IgniteRunnable;
 import org.apache.ignite.mxbean.CacheMetricsMXBean;
+import org.apache.ignite.resources.IgniteInstanceResource;
 import org.jetbrains.annotations.Nullable;
 
 /**
@@ -63,9 +61,6 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
     /** Cache name. */
     private final String cacheName;
 
-    /** Grid id. */
-    private final UUID gridId;
-
     /** With async. */
     private final boolean isAsync;
 
@@ -82,31 +77,16 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
 
     /**
      * @param name Name.
-     * @param async
+     * @param async Async flag.
      * @param proxy Ignite Process Proxy.
      */
     public IgniteCacheProcessProxy(String name, boolean async, IgniteProcessProxy proxy) {
         cacheName = name;
         isAsync = async;
-        gridId = proxy.getId();
         igniteProxy = proxy;
         compute = proxy.remoteCompute();
     }
 
-    /**
-     * Returns cache instance. Method to be called from closure at another JVM.
-     *
-     * @return Cache.
-     */
-    private IgniteCache<Object, Object> cache() {
-        IgniteCache cache = Ignition.ignite(gridId).cache(cacheName);
-
-        if (isAsync)
-            cache = cache.withAsync();
-
-        return cache;
-    }
-
     /** {@inheritDoc} */
     @Override public IgniteCache<K, V> withAsync() {
         return new IgniteCacheProcessProxy<>(cacheName, true, igniteProxy);
@@ -124,14 +104,8 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
     }
 
     /** {@inheritDoc} */
-    @Override public <C extends Configuration<K, V>> C getConfiguration(final Class<C> clazz) {
-        final Class cl = clazz;
-
-        return (C)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return cache().getConfiguration(cl);
-            }
-        });
+    @Override public <C extends Configuration<K, V>> C getConfiguration(Class<C> clazz) {
+        return compute.call(new GetConfigurationTask<>(cacheName, isAsync, clazz));
     }
 
     /** {@inheritDoc} */
@@ -149,33 +123,26 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
         throw new UnsupportedOperationException("Method should be supported.");
     }
 
+    /** {@inheritDoc} */
     @Override public IgniteCache<K, V> withNoRetries() {
         throw new UnsupportedOperationException("Method should be supported.");
     }
 
     /** {@inheritDoc} */
-    @Override public void loadCache(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args) throws CacheException {
+    @Override public void loadCache(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args)
+        throws CacheException {
         throw new UnsupportedOperationException("Method should be supported.");
     }
 
     /** {@inheritDoc} */
-    @Override public void localLoadCache(@Nullable final IgniteBiPredicate<K, V> p, @Nullable final Object... args) throws CacheException {
-        final IgniteBiPredicate pCopy = p;
-
-        compute.run(new IgniteRunnable() {
-            @Override public void run() {
-                cache().localLoadCache(pCopy, args);
-            }
-        });
+    @Override public void localLoadCache(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args)
+        throws CacheException {
+        compute.call(new LocalLoadCacheTask<>(cacheName, isAsync, p, args));
     }
 
     /** {@inheritDoc} */
-    @Override public V getAndPutIfAbsent(final K key, final V val) throws CacheException {
-        return (V)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return cache().getAndPutIfAbsent(key, val);
-            }
-        });
+    @Override public V getAndPutIfAbsent(K key, V val) throws CacheException {
+        return compute.call(new GetAndPutIfAbsentTask<>(cacheName, isAsync, key, val));
     }
 
     /** {@inheritDoc} */
@@ -189,12 +156,8 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
     }
 
     /** {@inheritDoc} */
-    @Override public boolean isLocalLocked(final K key, final boolean byCurrThread) {
-        return compute.call(new IgniteCallable<Boolean>() {
-            @Override public Boolean call() throws Exception {
-                return cache().isLocalLocked(key, byCurrThread);
-            }
-        });
+    @Override public boolean isLocalLocked(K key, boolean byCurrThread) {
+        return compute.call(new IsLocalLockedTask<>(cacheName, isAsync, key, byCurrThread));
     }
 
     /** {@inheritDoc} */
@@ -203,18 +166,8 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
     }
 
     /** {@inheritDoc} */
-    @SuppressWarnings("unchecked")
-    @Override public Iterable<Entry<K, V>> localEntries(final CachePeekMode... peekModes) throws CacheException {
-        return (Iterable<Entry<K, V>>)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                Collection<Entry> res = new ArrayList<>();
-
-                for (Entry e : cache().localEntries(peekModes))
-                    res.add(new CacheEntryImpl(e.getKey(), e.getValue()));
-
-                return res;
-            }
-        });
+    @Override public Iterable<Entry<K, V>> localEntries(CachePeekMode... peekModes) throws CacheException {
+        return compute.call(new LocalEntriesTask<K, V>(cacheName, isAsync, peekModes));
     }
 
     /** {@inheritDoc} */
@@ -223,21 +176,13 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
     }
 
     /** {@inheritDoc} */
-    @Override public void localEvict(final Collection<? extends K> keys) {
-        compute.run(new IgniteRunnable() {
-            @Override public void run() {
-                cache().localEvict(keys);
-            }
-        });
+    @Override public void localEvict(Collection<? extends K> keys) {
+        compute.call(new LocalEvictTask<>(cacheName, isAsync, keys));
     }
 
     /** {@inheritDoc} */
-    @Override public V localPeek(final K key, final CachePeekMode... peekModes) {
-        return (V)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return cache().localPeek(key, peekModes);
-            }
-        });
+    @Override public V localPeek(K key, CachePeekMode... peekModes) {
+        return compute.call(new LocalPeekTask<K, V>(cacheName, isAsync, key, peekModes));
     }
 
     /** {@inheritDoc} */
@@ -246,274 +191,160 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
     }
 
     /** {@inheritDoc} */
-    @Override public int size(final CachePeekMode... peekModes) throws CacheException {
-        return (int)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return cache().size(peekModes);
-            }
-        });
+    @Override public int size(CachePeekMode... peekModes) throws CacheException {
+        return compute.call(new SizeTask(cacheName, isAsync, peekModes, false));
     }
 
     /** {@inheritDoc} */
-    @Override public int localSize(final CachePeekMode... peekModes) {
-        return (int)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return cache().localSize(peekModes);
-            }
-        });
+    @Override public int localSize(CachePeekMode... peekModes) {
+        return compute.call(new SizeTask(cacheName, isAsync, peekModes, true));
     }
 
     /** {@inheritDoc} */
-    @Override  public <T> Map<K, EntryProcessorResult<T>> invokeAll(Map<? extends K, ? extends EntryProcessor<K, V, T>> map,
-        Object... args) {
+    @Override  public <T> Map<K, EntryProcessorResult<T>> invokeAll(
+        Map<? extends K, ? extends EntryProcessor<K, V, T>> map,
+        Object... args)
+    {
         throw new UnsupportedOperationException("Method should be supported.");
     }
 
     /** {@inheritDoc} */
-    @Override public V get(final K key) {
-        return (V)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return cache().get(key);
-            }
-        });
+    @Override public V get(K key) {
+        return compute.call(new GetTask<K, V>(cacheName, isAsync, key));
     }
 
     /** {@inheritDoc} */
-    @Override public Map<K, V> getAll(final Set<? extends K> keys) {
-        return (Map<K, V>)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return cache().getAll(keys);
-            }
-        });
+    @Override public Map<K, V> getAll(Set<? extends K> keys) {
+        return compute.call(new GetAllTask<K, V>(cacheName, isAsync, keys));
     }
 
-    @Override public Map<K, V> getAllOutTx(final Set<? extends K> keys) {
-        return (Map<K, V>)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return cache().getAllOutTx(keys);
-            }
-        });
+    /** {@inheritDoc} */
+    @Override public Map<K, V> getAllOutTx(Set<? extends K> keys) {
+        return compute.call(new GetAllOutTxTask<K, V>(cacheName, isAsync, keys));
     }
 
     /** {@inheritDoc} */
-    @Override public boolean containsKey(final K key) {
-        return (boolean)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return cache().containsKey(key);
-            }
-        });
+    @Override public boolean containsKey(K key) {
+        return compute.call(new ContainsKeyTask<>(cacheName, isAsync, key));
     }
 
     /** {@inheritDoc} */
-    @Override  public void loadAll(Set<? extends K> keys, boolean replaceExistingValues, CompletionListener completionLsnr) {
+    @Override  public void loadAll(Set<? extends K> keys, boolean replaceExistVals, CompletionListener completionLsnr) {
         throw new UnsupportedOperationException("Oparetion can't be supported automatically.");
     }
 
     /** {@inheritDoc} */
-    @Override public boolean containsKeys(final Set<? extends K> keys) {
-        return (boolean)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return cache().containsKeys(keys);
-            }
-        });
+    @Override public boolean containsKeys(Set<? extends K> keys) {
+        return compute.call(new ContainsKeysTask<>(cacheName, isAsync, keys));
     }
 
     /** {@inheritDoc} */
-    @Override public void put(final K key, final V val) {;
-        compute.run(new IgniteRunnable() {
-            @Override public void run() {
-                cache().put(key, val);
-            }
-        });
+    @Override public void put(K key, V val) {
+        compute.call(new PutTask<>(cacheName, isAsync, key, val));
     }
 
     /** {@inheritDoc} */
-    @Override public V getAndPut(final K key, final V val) {
-        return (V)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return cache().getAndPut(key, val);
-            }
-        });
+    @Override public V getAndPut(K key, V val) {
+        return compute.call(new GetAndPutTask<>(cacheName, isAsync, key, val));
     }
 
     /** {@inheritDoc} */
-    @Override public void putAll(final Map<? extends K, ? extends V> map) {
-        compute.run(new IgniteRunnable() {
-            @Override public void run() {
-                cache().putAll(map);
-            }
-        });
+    @Override public void putAll(Map<? extends K, ? extends V> map) {
+        compute.call(new PutAllTask<>(cacheName, isAsync, map));
     }
 
     /** {@inheritDoc} */
-    @Override public boolean putIfAbsent(final K key, final V val) {
-        return (boolean)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return cache().putIfAbsent(key, val);
-            }
-        });
+    @Override public boolean putIfAbsent(K key, V val) {
+        return compute.call(new PutIfAbsentTask<>(cacheName, isAsync, key, val));
     }
 
     /** {@inheritDoc} */
-    @Override public boolean remove(final K key) {
-        return (boolean)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return cache().remove(key);
-            }
-        });
+    @Override public boolean remove(K key) {
+        return compute.call(new RemoveTask<>(cacheName, isAsync, key));
     }
 
     /** {@inheritDoc} */
-    @Override public boolean remove(final K key, final V oldVal) {
-        return (boolean)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return cache().remove(key, oldVal);
-            }
-        });
+    @Override public boolean remove(K key, V oldVal) {
+        return compute.call(new RemoveIfExistsTask<>(cacheName, isAsync, key, oldVal));
     }
 
     /** {@inheritDoc} */
-    @Override public V getAndRemove(final K key) {
-        return (V)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return cache().getAndRemove(key);
-            }
-        });
+    @Override public V getAndRemove(K key) {
+        return compute.call(new GetAndRemoveTask<K, V>(cacheName, isAsync, key));
     }
 
     /** {@inheritDoc} */
-    @Override public boolean replace(final K key, final V oldVal, final V newVal) {
-        return (boolean)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return cache().replace(key, oldVal, newVal);
-            }
-        });
+    @Override public boolean replace(K key, V oldVal, V newVal) {
+        return compute.call(new ReplaceIfExistsTask<>(cacheName, isAsync, key, oldVal, newVal));
     }
 
     /** {@inheritDoc} */
-    @Override public boolean replace(final K key, final V val) {
-        return (boolean)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return cache().replace(key, val);
-            }
-        });
+    @Override public boolean replace(K key, V val) {
+        return compute.call(new ReplaceTask<>(cacheName, isAsync, key, val));
     }
 
     /** {@inheritDoc} */
-    @Override public V getAndReplace(final K key, final V val) {
-        return (V)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return cache().getAndReplace(key, val);
-            }
-        });
+    @Override public V getAndReplace(K key, V val) {
+        return compute.call(new GetAndReplaceTask<>(cacheName, isAsync, key, val));
     }
 
     /** {@inheritDoc} */
-    @Override public void removeAll(final Set<? extends K> keys) {
-        compute.run(new IgniteRunnable() {
-            @Override public void run() {
-                cache().removeAll(keys);
-            }
-        });
+    @Override public void removeAll(Set<? extends K> keys) {
+        compute.call(new RemoveAllKeysTask<>(cacheName, isAsync, keys));
     }
 
     /** {@inheritDoc} */
     @Override public void removeAll() {
-        compute.run(new IgniteRunnable() {
-            @Override public void run() {
-                IgniteCache<Object, Object> cache = cache();
-
-                cache.removeAll();
-
-                if (isAsync)
-                    cache.future().get();
-            }
-        });
+        compute.call(new RemoveAllTask<K, V>(cacheName, isAsync));
     }
 
     /** {@inheritDoc} */
     @Override public void clear() {
-        compute.run(new IgniteRunnable() {
-            @Override public void run() {
-                cache().clear();
-            }
-        });
+        compute.call(new ClearTask(cacheName, isAsync));
     }
 
     /** {@inheritDoc} */
-    @Override public void clear(final K key) {
-        compute.run(new IgniteRunnable() {
-            @Override public void run() {
-                cache().clear(key);
-            }
-        });
+    @Override public void clear(K key) {
+        compute.call(new ClearKeyTask<>(cacheName, isAsync, false, key));
     }
 
     /** {@inheritDoc} */
-    @Override public void clearAll(final Set<? extends K> keys) {
-        compute.run(new IgniteRunnable() {
-            @Override public void run() {
-                cache().clearAll(keys);
-            }
-        });
+    @Override public void clearAll(Set<? extends K> keys) {
+        compute.call(new ClearAllKeys<>(cacheName, isAsync, false, keys));
     }
 
     /** {@inheritDoc} */
-    @Override public void localClear(final K key) {
-        compute.run(new IgniteRunnable() {
-            @Override public void run() {
-                cache().localClear(key);
-            }
-        });
+    @Override public void localClear(K key) {
+        compute.call(new ClearKeyTask<>(cacheName, isAsync, true, key));
     }
 
     /** {@inheritDoc} */
-    @Override public void localClearAll(final Set<? extends K> keys) {
-        compute.run(new IgniteRunnable() {
-            @Override public void run() {
-                cache().localClearAll(keys);
-            }
-        });
+    @Override public void localClearAll(Set<? extends K> keys) {
+        compute.call(new ClearAllKeys<>(cacheName, isAsync, true, keys));
     }
 
     /** {@inheritDoc} */
-    @Override public <T> T invoke(final K key, final EntryProcessor<K, V, T> entryProcessor, final Object... arguments) {
-        return (T)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return cache().invoke(key,
-                    (EntryProcessor<Object, Object, Object>)entryProcessor, arguments);
-            }
-        });
+    @Override public <T> T invoke(K key, EntryProcessor<K, V, T> processor, Object... args) {
+        return compute.call(new InvokeTask<>(cacheName, isAsync, key, processor, args));
     }
 
     /** {@inheritDoc} */
-    @Override public <T> T invoke(final K key, final CacheEntryProcessor<K, V, T> entryProcessor, final Object... arguments) {
-        return (T)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return cache().invoke(key,
-                    (CacheEntryProcessor<Object, Object, Object>)entryProcessor, arguments);
-            }
-        });
+    @Override public <T> T invoke(K key, CacheEntryProcessor<K, V, T> processor, Object... args) {
+        return compute.call(new InvokeTask<>(cacheName, isAsync, key, processor, args));
     }
 
     /** {@inheritDoc} */
-    @Override  public <T> Map<K, EntryProcessorResult<T>> invokeAll(final Set<? extends K> keys, final EntryProcessor<K, V, T> entryProcessor,
-        final Object... args) {
-        return (Map<K, EntryProcessorResult<T>>)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return cache().invokeAll(keys,
-                    (EntryProcessor<Object, Object, Object>)entryProcessor, args);
-            }
-        });
+    @Override  public <T> Map<K, EntryProcessorResult<T>> invokeAll(
+        Set<? extends K> keys,
+        EntryProcessor<K, V, T> processor,
+        Object... args)
+    {
+        return compute.call(new InvokeAllTask<>(cacheName, isAsync, keys, processor, args));
     }
 
     /** {@inheritDoc} */
     @Override public String getName() {
-        return (String)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return cache().getName();
-            }
-        });
+        return compute.call(new GetNameTask(cacheName, isAsync));
     }
 
     /** {@inheritDoc} */
@@ -523,72 +354,47 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
 
     /** {@inheritDoc} */
     @Override public void close() {
-        compute.run(new IgniteRunnable() {
-            @Override public void run() {
-                cache().close();
-            }
-        });
+        compute.call(new CloseTask(cacheName, isAsync));
     }
 
     /** {@inheritDoc} */
     @Override public void destroy() {
-        compute.run(new IgniteRunnable() {
-            @Override public void run() {
-                cache().destroy();
-            }
-        });
+        compute.call(new DestroyTask(cacheName, isAsync));
     }
 
     /** {@inheritDoc} */
     @Override public boolean isClosed() {
-        return (boolean)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return cache().isClosed();
-            }
-        });
+        return compute.call(new IsClosedTask(cacheName, isAsync));
     }
 
     /** {@inheritDoc} */
-    @Override public <T> T unwrap(final Class<T> clazz) {
+    @SuppressWarnings("unchecked")
+    @Override public <T> T unwrap(Class<T> clazz) {
         if (Ignite.class.equals(clazz))
             return (T)igniteProxy;
 
         try {
-            return (T)compute.call(new IgniteCallable<Object>() {
-                @Override public Object call() throws Exception {
-                    return cache().unwrap(clazz);
-                }
-            });
+            return compute.call(new UnwrapTask<>(cacheName, isAsync, clazz));
         }
         catch (Exception e) {
-            throw new IllegalArgumentException("Looks like class " + clazz + " is unmarshallable. Exception type:" + e.getClass(), e);
+            throw new IllegalArgumentException("Looks like class " + clazz +
+                " is unmarshallable. Exception type:" + e.getClass(), e);
         }
     }
 
     /** {@inheritDoc} */
-    @Override  public void registerCacheEntryListener(CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration) {
+    @Override  public void registerCacheEntryListener(CacheEntryListenerConfiguration<K, V> lsnrCfg) {
         throw new UnsupportedOperationException("Method should be supported.");
     }
 
     /** {@inheritDoc} */
-    @Override  public void deregisterCacheEntryListener(CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration) {
+    @Override  public void deregisterCacheEntryListener(CacheEntryListenerConfiguration<K, V> lsnrCfg) {
         throw new UnsupportedOperationException("Method should be supported.");
     }
 
     /** {@inheritDoc} */
     @Override public Iterator<Entry<K, V>> iterator() {
-        final Collection<Entry<K, V>> col = (Collection<Entry<K, V>>)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                Collection res = new ArrayList();
-
-                for (Object o : cache())
-                    res.add(o);
-
-                return res;
-            }
-        });
-
-        return col.iterator();
+        return compute.call(new IteratorTask<K, V>(cacheName, isAsync)).iterator();
     }
 
     /** {@inheritDoc} */
@@ -616,4 +422,968 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
     @Override public CacheMetricsMXBean mxBean() {
         throw new UnsupportedOperationException("Method should be supported.");
     }
+
+    /**
+     *
+     */
+    private static class GetConfigurationTask<K, V, C extends Configuration<K, V>> extends CacheTaskAdapter<K, V, C> {
+        /** Clazz. */
+        private final Class<C> clazz;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param clazz Clazz.
+         */
+        public GetConfigurationTask(String cacheName, boolean async, Class<C> clazz) {
+            super(cacheName, async);
+            this.clazz = clazz;
+        }
+
+        /** {@inheritDoc} */
+        @Override public C call() throws Exception {
+            return cache().getConfiguration(clazz);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class LocalLoadCacheTask<K, V> extends CacheTaskAdapter<K, V, Void> {
+        /** Predicate. */
+        private final IgniteBiPredicate<K, V> p;
+
+        /** Args. */
+        private final Object[] args;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param p P.
+         * @param args Args.
+         */
+        public LocalLoadCacheTask(String cacheName, boolean async, IgniteBiPredicate<K, V> p, Object[] args) {
+            super(cacheName, async);
+            this.p = p;
+            this.args = args;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Void call() {
+            cache().localLoadCache(p, args);
+
+            return null;
+        }
+    }
+
+    /**
+     *
+     */
+    private static class GetAndPutIfAbsentTask<K, V> extends CacheTaskAdapter<K, V, V> {
+        /** Key. */
+        private final K key;
+
+        /** Value. */
+        private final V val;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param key Key.
+         * @param val Value.
+         */
+        public GetAndPutIfAbsentTask(String cacheName, boolean async, K key, V val) {
+            super(cacheName, async);
+            this.key = key;
+            this.val = val;
+        }
+
+        /** {@inheritDoc} */
+        @Override public V call() throws Exception {
+            return cache().getAndPutIfAbsent(key, val);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class IsLocalLockedTask<K> extends CacheTaskAdapter<K, Void, Boolean> {
+        /** Key. */
+        private final K key;
+
+        /** By current thread. */
+        private final boolean byCurrThread;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param key Key.
+         * @param byCurrThread By current thread.
+         */
+        public IsLocalLockedTask(String cacheName, boolean async, K key, boolean byCurrThread) {
+            super(cacheName, async);
+            this.key = key;
+            this.byCurrThread = byCurrThread;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Boolean call() throws Exception {
+            return cache().isLocalLocked(key, byCurrThread);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class LocalEntriesTask<K, V> extends CacheTaskAdapter<K, V, Iterable<Entry<K, V>>> {
+        /** Peek modes. */
+        private final CachePeekMode[] peekModes;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param peekModes Peek modes.
+         */
+        public LocalEntriesTask(String cacheName, boolean async, CachePeekMode[] peekModes) {
+            super(cacheName, async);
+            this.peekModes = peekModes;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Iterable<Entry<K, V>> call() throws Exception {
+            Collection<Entry<K, V>> res = new ArrayList<>();
+
+            for (Entry<K, V> e : cache().localEntries(peekModes))
+                res.add(new CacheEntryImpl<>(e.getKey(), e.getValue()));
+
+            return res;
+        }
+    }
+
+    /**
+     *
+     */
+    private static class LocalEvictTask<K> extends CacheTaskAdapter<K, Void, Void> {
+        /** Keys. */
+        private final Collection<? extends K> keys;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param keys Keys.
+         */
+        public LocalEvictTask(String cacheName, boolean async, Collection<? extends K> keys) {
+            super(cacheName, async);
+            this.keys = keys;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Void call() {
+            cache().localEvict(keys);
+
+            return null;
+        }
+    }
+
+    /**
+     *
+     */
+    private static class LocalPeekTask<K, V> extends CacheTaskAdapter<K, V, V> {
+        /** Key. */
+        private final K key;
+
+        /** Peek modes. */
+        private final CachePeekMode[] peekModes;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param key Key.
+         * @param peekModes Peek modes.
+         */
+        public LocalPeekTask(String cacheName, boolean async, K key, CachePeekMode[] peekModes) {
+            super(cacheName, async);
+            this.key = key;
+            this.peekModes = peekModes;
+        }
+
+        /** {@inheritDoc} */
+        @Override public V call() throws Exception {
+            return cache().localPeek(key, peekModes);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class SizeTask extends CacheTaskAdapter<Void, Void, Integer> {
+        /** Peek modes. */
+        private final CachePeekMode[] peekModes;
+
+        /** Local. */
+        private final boolean loc;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param peekModes Peek modes.
+         * @param loc Local.
+         */
+        public SizeTask(String cacheName, boolean async, CachePeekMode[] peekModes, boolean loc) {
+            super(cacheName, async);
+            this.loc = loc;
+            this.peekModes = peekModes;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Integer call() throws Exception {
+            return loc ? cache().localSize(peekModes) : cache().size(peekModes);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class GetTask<K, V> extends CacheTaskAdapter<K, V, V> {
+        /** Key. */
+        private final K key;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param key Key.
+         */
+        public GetTask(String cacheName, boolean async, K key) {
+            super(cacheName, async);
+            this.key = key;
+        }
+
+        /** {@inheritDoc} */
+        @Override public V call() throws Exception {
+            return cache().get(key);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class RemoveAllTask<K, V> extends CacheTaskAdapter<K, V, Void> {
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         */
+        public RemoveAllTask(String cacheName, boolean async) {
+            super(cacheName, async);
+        }
+
+        /** {@inheritDoc} */
+        @Override public Void call() {
+            IgniteCache<K, V> cache = cache();
+
+            cache.removeAll();
+
+            if (async)
+                cache.future().get();
+
+            return null;
+        }
+    }
+
+    /**
+     *
+     */
+    private static class PutTask<K, V> extends CacheTaskAdapter<K, V, Void> {
+        /** Key. */
+        private final K key;
+
+        /** Value. */
+        private final V val;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param key Key.
+         * @param val Value.
+         */
+        public PutTask(String cacheName, boolean async, K key, V val) {
+            super(cacheName, async);
+            this.key = key;
+            this.val = val;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Void call() {
+            cache().put(key, val);
+
+            return null;
+        }
+    }
+
+    /**
+     *
+     */
+    private static class ContainsKeyTask<K> extends CacheTaskAdapter<K, Object, Boolean> {
+        /** Key. */
+        private final K key;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param key Key.
+         */
+        public ContainsKeyTask(String cacheName, boolean async, K key) {
+            super(cacheName, async);
+            this.key = key;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Boolean call() throws Exception {
+            return cache().containsKey(key);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class ClearTask extends CacheTaskAdapter<Object, Object, Void> {
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         */
+        public ClearTask(String cacheName, boolean async) {
+            super(cacheName, async);
+        }
+
+        /** {@inheritDoc} */
+        @Override public Void call() {
+            cache().clear();
+
+            return null;
+        }
+    }
+
+    /**
+     *
+     */
+    private static class IteratorTask<K, V> extends CacheTaskAdapter<K, V, Collection<Entry<K, V>>> {
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         */
+        public IteratorTask(String cacheName, boolean async) {
+            super(cacheName, async);
+        }
+
+        /** {@inheritDoc} */
+        @Override public Collection<Entry<K, V>> call() throws Exception {
+            Collection<Entry<K, V>> res = new ArrayList<>();
+
+            for (Entry<K, V> o : cache())
+                res.add(o);
+
+            return res;
+        }
+    }
+
+    /**
+     *
+     */
+    private static class ReplaceTask<K, V> extends CacheTaskAdapter<K, V, Boolean> {
+        /** Key. */
+        private final K key;
+
+        /** Value. */
+        private final V val;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param key Key.
+         * @param val Value.
+         */
+        public ReplaceTask(String cacheName, boolean async, K key, V val) {
+            super(cacheName, async);
+            this.key = key;
+            this.val = val;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Boolean call() throws Exception {
+            return cache().replace(key, val);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class GetNameTask extends CacheTaskAdapter<Void, Void, String> {
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         */
+        public GetNameTask(String cacheName, boolean async) {
+            super(cacheName, async);
+        }
+
+        /** {@inheritDoc} */
+        @Override public String call() throws Exception {
+            return cache().getName();
+        }
+    }
+
+    /**
+     *
+     */
+    private static class RemoveTask<K> extends CacheTaskAdapter<K, Void, Boolean> {
+        /** Key. */
+        private final K key;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param key Key.
+         */
+        public RemoveTask(String cacheName, boolean async, K key) {
+            super(cacheName, async);
+            this.key = key;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Boolean call() throws Exception {
+            return cache().remove(key);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class PutAllTask<K, V> extends CacheTaskAdapter<K, V, Void> {
+        /** Map. */
+        private final Map<? extends K, ? extends V> map;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param map Map.
+         */
+        public PutAllTask(String cacheName, boolean async, Map<? extends K, ? extends V> map) {
+            super(cacheName, async);
+            this.map = map;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Void call() {
+            cache().putAll(map);
+
+            return null;
+        }
+    }
+
+    /**
+     *
+     */
+    private static class RemoveAllKeysTask<K> extends CacheTaskAdapter<K, Void, Void> {
+        /** Keys. */
+        private final Set<? extends K> keys;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param keys Keys.
+         */
+        public RemoveAllKeysTask(String cacheName, boolean async, Set<? extends K> keys) {
+            super(cacheName, async);
+            this.keys = keys;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Void call() {
+            cache().removeAll(keys);
+
+            return null;
+        }
+    }
+
+    /**
+     *
+     */
+    private static class GetAllTask<K, V> extends CacheTaskAdapter<K, V, Map<K, V>> {
+        /** Keys. */
+        private final Set<? extends K> keys;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param keys Keys.
+         */
+        public GetAllTask(String cacheName, boolean async, Set<? extends K> keys) {
+            super(cacheName, async);
+            this.keys = keys;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Map<K, V> call() throws Exception {
+            return cache().getAll(keys);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class GetAllOutTxTask<K, V> extends CacheTaskAdapter<K, V, Map<K, V>> {
+        /** Keys. */
+        private final Set<? extends K> keys;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param keys Keys.
+         */
+        public GetAllOutTxTask(String cacheName, boolean async, Set<? extends K> keys) {
+            super(cacheName, async);
+            this.keys = keys;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Map<K, V> call() throws Exception {
+            return cache().getAllOutTx(keys);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class ContainsKeysTask<K, V> extends CacheTaskAdapter<K, V, Boolean> {
+        /** Keys. */
+        private final Set<? extends K> keys;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param keys Keys.
+         */
+        public ContainsKeysTask(String cacheName, boolean async, Set<? extends K> keys) {
+            super(cacheName, async);
+            this.keys = keys;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Boolean call() throws Exception {
+            return cache().containsKeys(keys);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class GetAndPutTask<K, V> extends CacheTaskAdapter<K, V, V> {
+        /** Key. */
+        private final K key;
+
+        /** Value. */
+        private final V val;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param key Key.
+         * @param val Value.
+         */
+        public GetAndPutTask(String cacheName, boolean async, K key, V val) {
+            super(cacheName, async);
+            this.key = key;
+            this.val = val;
+        }
+
+        /** {@inheritDoc} */
+        @Override public V call() throws Exception {
+            return cache().getAndPut(key, val);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class PutIfAbsentTask<K, V> extends CacheTaskAdapter<K, V, Boolean> {
+        /** Key. */
+        private final K key;
+
+        /** Value. */
+        private final V val;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param key Key.
+         * @param val Value.
+         */
+        public PutIfAbsentTask(String cacheName, boolean async, K key, V val) {
+            super(cacheName, async);
+            this.key = key;
+            this.val = val;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Boolean call() throws Exception {
+            return cache().putIfAbsent(key, val);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class RemoveIfExistsTask<K, V> extends CacheTaskAdapter<K, V, Boolean> {
+        /** Key. */
+        private final K key;
+
+        /** Old value. */
+        private final V oldVal;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param key Key.
+         * @param oldVal Old value.
+         */
+        public RemoveIfExistsTask(String cacheName, boolean async, K key, V oldVal) {
+            super(cacheName, async);
+            this.key = key;
+            this.oldVal = oldVal;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Boolean call() throws Exception {
+            return cache().remove(key, oldVal);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class GetAndRemoveTask<K, V> extends CacheTaskAdapter<K, V, V> {
+        /** Key. */
+        private final K key;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param key Key.
+         */
+        public GetAndRemoveTask(String cacheName, boolean async, K key) {
+            super(cacheName, async);
+            this.key = key;
+        }
+
+        /** {@inheritDoc} */
+        @Override public V call() throws Exception {
+            return cache().getAndRemove(key);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class ReplaceIfExistsTask<K, V> extends CacheTaskAdapter<K, V, Boolean> {
+        /** Key. */
+        private final K key;
+
+        /** Old value. */
+        private final V oldVal;
+
+        /** New value. */
+        private final V newVal;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param key Key.
+         * @param oldVal Old value.
+         * @param newVal New value.
+         */
+        public ReplaceIfExistsTask(String cacheName, boolean async, K key, V oldVal, V newVal) {
+            super(cacheName, async);
+            this.key = key;
+            this.oldVal = oldVal;
+            this.newVal = newVal;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Boolean call() throws Exception {
+            return cache().replace(key, oldVal, newVal);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class GetAndReplaceTask<K, V> extends CacheTaskAdapter<K, V, V> {
+        /** Key. */
+        private final K key;
+
+        /** Value. */
+        private final V val;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param key Key.
+         * @param val Value.
+         */
+        public GetAndReplaceTask(String cacheName, boolean async, K key, V val) {
+            super(cacheName, async);
+            this.key = key;
+            this.val = val;
+        }
+
+        /** {@inheritDoc} */
+        @Override public V call() throws Exception {
+            return cache().getAndReplace(key, val);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class ClearKeyTask<K> extends CacheTaskAdapter<K, Void, Void> {
+        /** Key. */
+        private final K key;
+
+        /** Local. */
+        private final boolean loc;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param key Key.
+         */
+        public ClearKeyTask(String cacheName, boolean async, boolean loc, K key) {
+            super(cacheName, async);
+            this.key = key;
+            this.loc = loc;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Void call() {
+            if (loc)
+                cache().localClear(key);
+            else
+                cache().clear(key);
+
+            return null;
+        }
+    }
+
+    /**
+     *
+     */
+    private static class ClearAllKeys<K> extends CacheTaskAdapter<K, Void, Void> {
+        /** Keys. */
+        private final Set<? extends K> keys;
+
+        /** Local. */
+        private final boolean loc;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param keys Keys.
+         */
+        public ClearAllKeys(String cacheName, boolean async, boolean loc, Set<? extends K> keys) {
+            super(cacheName, async);
+            this.keys = keys;
+            this.loc = loc;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Void call() {
+            if (loc)
+                cache().localClearAll(keys);
+            else
+                cache().clearAll(keys);
+
+            return null;
+        }
+    }
+
+    /**
+     *
+     */
+    private static class InvokeTask<K, V, R> extends CacheTaskAdapter<K, V, R> {
+        /** Key. */
+        private final K key;
+
+        /** Processor. */
+        private final EntryProcessor<K, V, R> processor;
+
+        /** Args. */
+        private final Object[] args;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param key Key.
+         * @param processor Processor.
+         * @param args Args.
+         */
+        public InvokeTask(String cacheName, boolean async, K key, EntryProcessor<K, V, R> processor,
+            Object[] args) {
+            super(cacheName, async);
+            this.args = args;
+            this.key = key;
+            this.processor = processor;
+        }
+
+        /** {@inheritDoc} */
+        @Override public R call() throws Exception {
+            return cache().invoke(key, processor, args);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class InvokeAllTask<K, V, T> extends CacheTaskAdapter<K, V, Map<K, EntryProcessorResult<T>>> {
+        /** Keys. */
+        private final Set<? extends K> keys;
+
+        /** Processor. */
+        private final EntryProcessor<K, V, T> processor;
+
+        /** Args. */
+        private final Object[] args;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param keys Keys.
+         * @param processor Processor.
+         * @param args Args.
+         */
+        public InvokeAllTask(String cacheName, boolean async, Set<? extends K> keys,
+            EntryProcessor<K, V, T> processor, Object[] args) {
+            super(cacheName, async);
+            this.args = args;
+            this.keys = keys;
+            this.processor = processor;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Map<K, EntryProcessorResult<T>> call() throws Exception {
+            return cache().invokeAll(keys, processor, args);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class CloseTask extends CacheTaskAdapter<Void, Void, Void> {
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         */
+        public CloseTask(String cacheName, boolean async) {
+            super(cacheName, async);
+        }
+
+        /** {@inheritDoc} */
+        @Override public Void call() {
+            cache().close();
+
+            return null;
+        }
+    }
+
+    /**
+     *
+     */
+    private static class DestroyTask extends CacheTaskAdapter<Void, Void, Void> {
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         */
+        public DestroyTask(String cacheName, boolean async) {
+            super(cacheName, async);
+        }
+
+        /** {@inheritDoc} */
+        @Override public Void call() {
+            cache().destroy();
+
+            return null;
+        }
+    }
+
+    /**
+     *
+     */
+    private static class IsClosedTask extends CacheTaskAdapter<Void, Void, Boolean> {
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         */
+        public IsClosedTask(String cacheName, boolean async) {
+            super(cacheName, async);
+        }
+
+        /** {@inheritDoc} */
+        @Override public Boolean call() throws Exception {
+            return cache().isClosed();
+        }
+    }
+
+    /**
+     *
+     */
+    private static class UnwrapTask<R> extends CacheTaskAdapter<Void, Void, R> {
+        /** Clazz. */
+        private final Class<R> clazz;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         * @param clazz Clazz.
+         */
+        public UnwrapTask(String cacheName, boolean async, Class<R> clazz) {
+            super(cacheName, async);
+            this.clazz = clazz;
+        }
+
+        /** {@inheritDoc} */
+        @Override public R call() throws Exception {
+            return cache().unwrap(clazz);
+        }
+    }
+
+    /**
+     *
+     */
+    private static abstract class CacheTaskAdapter<K, V, R> implements IgniteCallable<R> {
+        /** Ignite. */
+        @IgniteInstanceResource
+        protected Ignite ignite;
+
+        /** Cache name. */
+        protected final String cacheName;
+
+        /** Async. */
+        protected final boolean async;
+
+        /**
+         * @param cacheName Cache name.
+         * @param async Async.
+         */
+        public CacheTaskAdapter(String cacheName, boolean async) {
+            this.async = async;
+            this.cacheName = cacheName;
+        }
+
+        /**
+         * Returns cache instance.
+         */
+        protected IgniteCache<K, V> cache() {
+            IgniteCache<K, V> cache = ignite.cache(cacheName);
+
+            return async ? cache.withAsync() : cache;
+        }
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/a1e5cc57/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteClusterProcessProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteClusterProcessProxy.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteClusterProcessProxy.java
index 05d6533..633e9d0 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteClusterProcessProxy.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteClusterProcessProxy.java
@@ -26,7 +26,6 @@ import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCluster;
 import org.apache.ignite.IgniteCompute;
 import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
 import org.apache.ignite.cluster.ClusterGroup;
 import org.apache.ignite.cluster.ClusterMetrics;
 import org.apache.ignite.cluster.ClusterNode;
@@ -36,6 +35,7 @@ import org.apache.ignite.internal.cluster.IgniteClusterEx;
 import org.apache.ignite.lang.IgniteCallable;
 import org.apache.ignite.lang.IgniteFuture;
 import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.resources.IgniteInstanceResource;
 import org.jetbrains.annotations.Nullable;
 
 /**
@@ -43,9 +43,6 @@ import org.jetbrains.annotations.Nullable;
  */
 @SuppressWarnings("TransientFieldInNonSerializableClass")
 public class IgniteClusterProcessProxy implements IgniteClusterEx {
-    /** Grid id. */
-    private final UUID gridId;
-
     /** Compute. */
     private final transient IgniteCompute compute;
 
@@ -57,21 +54,11 @@ public class IgniteClusterProcessProxy implements IgniteClusterEx {
      */
     public IgniteClusterProcessProxy(IgniteProcessProxy proxy) {
         this.proxy = proxy;
-        gridId = proxy.getId();
         compute = proxy.remoteCompute();
     }
 
-    /**
-     * Returns cluster instance. Method to be called from closure at another JVM.
-     *
-     * @return Cache.
-     */
-    private IgniteClusterEx cluster() {
-        return (IgniteClusterEx)Ignition.ignite(gridId).cluster();
-    }
-
     /** {@inheritDoc} */
-    @Override public ClusterGroupEx forSubjectId(final UUID subjId) {
+    @Override public ClusterGroupEx forSubjectId(UUID subjId) {
         throw new UnsupportedOperationException("Operation is not supported yet.");
     }
 
@@ -83,11 +70,7 @@ public class IgniteClusterProcessProxy implements IgniteClusterEx {
 
     /** {@inheritDoc} */
     @Override public ClusterNode localNode() {
-        return compute.call(new IgniteCallable<ClusterNode>() {
-            @Override public ClusterNode call() throws Exception {
-                return cluster().localNode();
-            }
-        });
+        return compute.call(new LocalNodeTask());
     }
 
     /** {@inheritDoc} */
@@ -285,38 +268,22 @@ public class IgniteClusterProcessProxy implements IgniteClusterEx {
 
     /** {@inheritDoc} */
     @Override public Collection<ClusterNode> nodes() {
-        return compute.call(new IgniteCallable<Collection<ClusterNode>>() {
-            @Override public Collection<ClusterNode> call() throws Exception {
-                return cluster().nodes();
-            }
-        });
+        return compute.call(new NodesTask());
     }
 
     /** {@inheritDoc} */
-    @Override public ClusterNode node(final UUID nid) {
-        return compute.call(new IgniteCallable<ClusterNode>() {
-            @Override public ClusterNode call() throws Exception {
-                return cluster().node(nid);
-            }
-        });
+    @Override public ClusterNode node(UUID nid) {
+        return compute.call(new NodeTask(nid));
     }
 
     /** {@inheritDoc} */
     @Override public ClusterNode node() {
-        return compute.call(new IgniteCallable<ClusterNode>() {
-            @Override public ClusterNode call() throws Exception {
-                return cluster().node();
-            }
-        });
+        return compute.call(new NodeTask(null));
     }
 
     /** {@inheritDoc} */
     @Override public Collection<String> hostNames() {
-        return compute.call(new IgniteCallable<Collection<String>>() {
-            @Override public Collection<String> call() throws Exception {
-                return cluster().hostNames();
-            }
-        });
+        return compute.call(new HostNamesTask());
     }
 
     /** {@inheritDoc} */
@@ -333,4 +300,70 @@ public class IgniteClusterProcessProxy implements IgniteClusterEx {
     @Nullable @Override public IgniteFuture<?> clientReconnectFuture() {
         throw new UnsupportedOperationException("Operation is not supported yet.");
     }
+
+    /**
+     *
+     */
+    private static class LocalNodeTask extends ClusterTaskAdapter<ClusterNode> {
+        /** {@inheritDoc} */
+        @Override public ClusterNode call() throws Exception {
+            return cluster().localNode();
+        }
+    }
+
+    /**
+     *
+     */
+    private static class NodesTask extends ClusterTaskAdapter<Collection<ClusterNode>> {
+        /** {@inheritDoc} */
+        @Override public Collection<ClusterNode> call() throws Exception {
+            return cluster().nodes();
+        }
+    }
+
+    /**
+     *
+     */
+    private static class NodeTask extends ClusterTaskAdapter<ClusterNode> {
+        /** Node id. */
+        private final UUID nodeId;
+
+        /**
+         * @param nodeId Node id.
+         */
+        public NodeTask(UUID nodeId) {
+            this.nodeId = nodeId;
+        }
+
+        /** {@inheritDoc} */
+        @Override public ClusterNode call() throws Exception {
+            return nodeId == null ? cluster().node() : cluster().node(nodeId);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class HostNamesTask extends ClusterTaskAdapter<Collection<String>> {
+        /** {@inheritDoc} */
+        @Override public Collection<String> call() throws Exception {
+            return cluster().hostNames();
+        }
+    }
+
+    /**
+     *
+     */
+    private abstract static class ClusterTaskAdapter<R> implements IgniteCallable<R> {
+        /** Ignite. */
+        @IgniteInstanceResource
+        protected Ignite ignite;
+
+        /**
+         *
+         */
+        protected IgniteCluster cluster() {
+            return ignite.cluster();
+        }
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/a1e5cc57/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteEventsProcessProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteEventsProcessProxy.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteEventsProcessProxy.java
index 860f889..d5af81e 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteEventsProcessProxy.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteEventsProcessProxy.java
@@ -20,15 +20,16 @@ package org.apache.ignite.testframework.junits.multijvm;
 import java.util.Collection;
 import java.util.List;
 import java.util.UUID;
+import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteEvents;
 import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
 import org.apache.ignite.cluster.ClusterGroup;
 import org.apache.ignite.events.Event;
 import org.apache.ignite.lang.IgniteBiPredicate;
 import org.apache.ignite.lang.IgniteFuture;
 import org.apache.ignite.lang.IgnitePredicate;
 import org.apache.ignite.lang.IgniteRunnable;
+import org.apache.ignite.resources.IgniteInstanceResource;
 import org.jetbrains.annotations.Nullable;
 
 /**
@@ -39,23 +40,11 @@ public class IgniteEventsProcessProxy implements IgniteEvents {
     /** Ignite proxy. */
     private final transient IgniteProcessProxy igniteProxy;
 
-    /** Grid id. */
-    private final UUID gridId;
-
     /**
      * @param igniteProxy Ignite proxy.
      */
     public IgniteEventsProcessProxy(IgniteProcessProxy igniteProxy) {
         this.igniteProxy = igniteProxy;
-
-        gridId = igniteProxy.getId();
-    }
-
-    /**
-     * @return Events instance.
-     */
-    private IgniteEvents events() {
-        return Ignition.ignite(gridId).events();
     }
 
     /** {@inheritDoc} */
@@ -105,11 +94,7 @@ public class IgniteEventsProcessProxy implements IgniteEvents {
 
     /** {@inheritDoc} */
     @Override public void localListen(final IgnitePredicate<? extends Event> lsnr, final int... types) {
-        igniteProxy.remoteCompute().run(new IgniteRunnable() {
-            @Override public void run() {
-                events().localListen(lsnr, types);
-            }
-        });
+        igniteProxy.remoteCompute().run(new LocalListenTask(lsnr, types));
     }
 
     /** {@inheritDoc} */
@@ -151,4 +136,33 @@ public class IgniteEventsProcessProxy implements IgniteEvents {
     @Override public <R> IgniteFuture<R> future() {
         throw new UnsupportedOperationException("Operation isn't supported yet.");
     }
+
+    /**
+     *
+     */
+    private static class LocalListenTask implements IgniteRunnable {
+        /** Ignite. */
+        @IgniteInstanceResource
+        private Ignite ignite;
+
+        /** Listener. */
+        private final IgnitePredicate<? extends Event> lsnr;
+
+        /** Types. */
+        private final int[] types;
+
+        /**
+         * @param lsnr Listener.
+         * @param types Types.
+         */
+        public LocalListenTask(IgnitePredicate<? extends Event> lsnr, int[] types) {
+            this.lsnr = lsnr;
+            this.types = types;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void run() {
+            ignite.events().localListen(lsnr, types);
+        }
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/a1e5cc57/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteNodeRunner.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteNodeRunner.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteNodeRunner.java
index f46e8e9..0597eda 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteNodeRunner.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteNodeRunner.java
@@ -25,13 +25,12 @@ import java.io.FileOutputStream;
 import java.io.FileReader;
 import java.io.IOException;
 import java.io.OutputStream;
-import java.lang.reflect.Field;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Set;
 import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.Ignition;
 import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.internal.IgniteEx;
@@ -39,8 +38,9 @@ import org.apache.ignite.internal.processors.cache.GridCacheAbstractFullApiSelfT
 import org.apache.ignite.internal.util.GridJavaProcess;
 import org.apache.ignite.internal.util.typedef.X;
 import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.marshaller.optimized.OptimizedMarshaller;
+import org.apache.ignite.marshaller.Marshaller;
 import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.testframework.junits.IgniteTestResources;
 import sun.jvmstat.monitor.HostIdentifier;
 import sun.jvmstat.monitor.MonitoredHost;
 import sun.jvmstat.monitor.MonitoredVm;
@@ -99,30 +99,6 @@ public class IgniteNodeRunner {
     public static String storeToFile(IgniteConfiguration cfg) throws IOException {
         String fileName = IGNITE_CONFIGURATION_FILE + cfg.getNodeId();
 
-        // Check marshaller configuration, because read configuration method expect specific marshaller.
-        if (cfg.getMarshaller() instanceof OptimizedMarshaller){
-            OptimizedMarshaller marsh = (OptimizedMarshaller)cfg.getMarshaller();
-
-            try {
-                Field isRequireFiled = marsh.getClass().getDeclaredField("requireSer");
-
-                isRequireFiled.setAccessible(true);
-
-                boolean isRequireSer = isRequireFiled.getBoolean(marsh);
-
-                if (isRequireSer)
-                    throw new UnsupportedOperationException("Unsupported marshaller configuration. " +
-                        "readCfgFromFileAndDeleteFile method expect " + OptimizedMarshaller.class.getSimpleName() +
-                        "with requireSerializeble flag in 'false'.");
-            }
-            catch (NoSuchFieldException|IllegalAccessException e) {
-                throw new IgniteException("Failed to check filed of " + OptimizedMarshaller.class.getSimpleName(), e);
-            }
-        }
-        else
-            throw new UnsupportedOperationException("Unsupported marshaller. " +
-                "readCfgFromFileAndDeleteFile method expect " + OptimizedMarshaller.class.getSimpleName());
-
         try(OutputStream out = new BufferedOutputStream(new FileOutputStream(fileName))) {
             cfg.setMBeanServer(null);
             cfg.setMarshaller(null);
@@ -143,11 +119,16 @@ public class IgniteNodeRunner {
      * @throws IOException If failed.
      * @see #storeToFile(IgniteConfiguration)
      */
-    private static IgniteConfiguration readCfgFromFileAndDeleteFile(String fileName) throws IOException {
+    private static IgniteConfiguration readCfgFromFileAndDeleteFile(String fileName)
+        throws IOException, IgniteCheckedException {
         try(BufferedReader cfgReader = new BufferedReader(new FileReader(fileName))) {
             IgniteConfiguration cfg = (IgniteConfiguration)new XStream().fromXML(cfgReader);
 
-            cfg.setMarshaller(new OptimizedMarshaller(false));
+            Marshaller marsh = IgniteTestResources.getMarshaller();
+
+            cfg.setMarshaller(marsh);
+
+            X.println("Configured marshaller class: " + marsh.getClass().getName());
 
             TcpDiscoverySpi disco = new TcpDiscoverySpi();
             disco.setIpFinder(GridCacheAbstractFullApiSelfTest.LOCAL_IP_FINDER);

http://git-wip-us.apache.org/repos/asf/ignite/blob/a1e5cc57/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java
index ec7dab7..aa1d470 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java
@@ -41,13 +41,11 @@ import org.apache.ignite.IgniteFileSystem;
 import org.apache.ignite.IgniteIllegalStateException;
 import org.apache.ignite.IgniteLogger;
 import org.apache.ignite.IgniteMessaging;
-import org.apache.ignite.internal.portable.api.IgnitePortables;
 import org.apache.ignite.IgniteQueue;
 import org.apache.ignite.IgniteScheduler;
 import org.apache.ignite.IgniteServices;
 import org.apache.ignite.IgniteSet;
 import org.apache.ignite.IgniteTransactions;
-import org.apache.ignite.Ignition;
 import org.apache.ignite.cache.affinity.Affinity;
 import org.apache.ignite.cluster.ClusterGroup;
 import org.apache.ignite.cluster.ClusterNode;
@@ -62,6 +60,7 @@ import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.IgniteEx;
 import org.apache.ignite.internal.IgniteInterruptedCheckedException;
 import org.apache.ignite.internal.cluster.IgniteClusterEx;
+import org.apache.ignite.internal.portable.api.IgnitePortables;
 import org.apache.ignite.internal.processors.cache.GridCacheUtilityKey;
 import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
 import org.apache.ignite.internal.processors.hadoop.Hadoop;
@@ -78,6 +77,8 @@ import org.apache.ignite.lang.IgniteProductVersion;
 import org.apache.ignite.lang.IgniteRunnable;
 import org.apache.ignite.plugin.IgnitePlugin;
 import org.apache.ignite.plugin.PluginNotFoundException;
+import org.apache.ignite.resources.IgniteInstanceResource;
+import org.apache.ignite.testframework.junits.IgniteTestResources;
 import org.jetbrains.annotations.Nullable;
 
 /**
@@ -88,6 +89,9 @@ public class IgniteProcessProxy implements IgniteEx {
     /** Grid proxies. */
     private static final transient ConcurrentMap<String, IgniteProcessProxy> gridProxies = new ConcurrentHashMap<>();
 
+    /** Property that specify alternative {@code JAVA_HOME}. */
+    private static final String TEST_MULTIJVM_JAVA_HOME = "test.multijvm.java.home";
+
     /** Jvm process with ignite instance. */
     private final transient GridJavaProcess proc;
 
@@ -108,7 +112,7 @@ public class IgniteProcessProxy implements IgniteEx {
      * @param log Logger.
      * @param locJvmGrid Local JVM grid.
      */
-    public IgniteProcessProxy(final IgniteConfiguration cfg, final IgniteLogger log, final Ignite locJvmGrid)
+    public IgniteProcessProxy(IgniteConfiguration cfg, IgniteLogger log, Ignite locJvmGrid)
         throws Exception {
         this.cfg = cfg;
         this.locJvmGrid = locJvmGrid;
@@ -121,7 +125,9 @@ public class IgniteProcessProxy implements IgniteEx {
         Collection<String> filteredJvmArgs = new ArrayList<>();
 
         for (String arg : jvmArgs) {
-            if(!arg.toLowerCase().startsWith("-agentlib"))
+            if(arg.startsWith("-Xmx") || arg.startsWith("-Xms") ||
+                arg.startsWith("-cp") || arg.startsWith("-classpath") ||
+                arg.startsWith("-D" + IgniteTestResources.MARSH_CLASS_NAME))
                 filteredJvmArgs.add(arg);
         }
 
@@ -130,7 +136,7 @@ public class IgniteProcessProxy implements IgniteEx {
         locJvmGrid.events().localListen(new NodeStartedListener(id, rmtNodeStartedLatch), EventType.EVT_NODE_JOINED);
 
         proc = GridJavaProcess.exec(
-            IgniteNodeRunner.class,
+            IgniteNodeRunner.class.getCanonicalName(),
             cfgFileName, // Params.
             this.log,
             // Optional closure to be called each time wrapped process prints line to system.out or system.err.
@@ -140,6 +146,7 @@ public class IgniteProcessProxy implements IgniteEx {
                 }
             },
             null,
+            System.getProperty(TEST_MULTIJVM_JAVA_HOME),
             filteredJvmArgs, // JVM Args.
             System.getProperty("surefire.test.class.path")
         );
@@ -149,11 +156,7 @@ public class IgniteProcessProxy implements IgniteEx {
         IgniteProcessProxy prevVal = gridProxies.putIfAbsent(cfg.getGridName(), this);
 
         if (prevVal != null) {
-            remoteCompute().run(new IgniteRunnable() {
-                @Override public void run() {
-                    G.stop(cfg.getGridName(), true);
-                }
-            });
+            remoteCompute().run(new StopGridTask(cfg.getGridName(), true));
 
             throw new IllegalStateException("There was found instance assotiated with " + cfg.getGridName() +
                 ", instance= " + prevVal + ". New started node was stopped.");
@@ -208,30 +211,17 @@ public class IgniteProcessProxy implements IgniteEx {
      * @param gridName Grid name.
      * @param cancel Cacnel flag.
      */
-    public static void stop(final String gridName, final boolean cancel) {
+    public static void stop(String gridName, boolean cancel) {
         IgniteProcessProxy proxy = gridProxies.get(gridName);
 
         if (proxy != null) {
-            proxy.remoteCompute().run(new IgniteRunnable() {
-                @Override public void run() {
-                    G.stop(gridName, cancel);
-                }
-            });
+            proxy.remoteCompute().run(new StopGridTask(gridName, cancel));
 
             gridProxies.remove(gridName, proxy);
         }
     }
 
     /**
-     * For usage in closures.
-     *
-     * @return Ignite instance.
-     */
-    private Ignite igniteById() {
-        return Ignition.ignite(id);
-    }
-
-    /**
      * @param locNodeId ID of local node the requested grid instance is managing.
      * @return An instance of named grid. This method never returns {@code null}.
      * @throws IgniteIllegalStateException Thrown if grid was not properly initialized or grid instance was stopped or
@@ -357,11 +347,7 @@ public class IgniteProcessProxy implements IgniteEx {
 
     /** {@inheritDoc} */
     @Override public ClusterNode localNode() {
-        return remoteCompute().call(new IgniteCallable<ClusterNode>() {
-            @Override public ClusterNode call() throws Exception {
-                return ((IgniteEx)Ignition.ignite(id)).localNode();
-            }
-        });
+        return remoteCompute().call(new NodeTask());
     }
 
     /** {@inheritDoc} */
@@ -467,7 +453,10 @@ public class IgniteProcessProxy implements IgniteEx {
     }
 
     /** {@inheritDoc} */
-    @Override  public <K, V> IgniteCache<K, V> createNearCache(@Nullable String cacheName, NearCacheConfiguration<K, V> nearCfg) {
+    @Override  public <K, V> IgniteCache<K, V> createNearCache(
+        @Nullable String cacheName,
+        NearCacheConfiguration<K, V> nearCfg)
+    {
         throw new UnsupportedOperationException("Operation isn't supported yet.");
     }
 
@@ -508,7 +497,8 @@ public class IgniteProcessProxy implements IgniteEx {
     }
 
     /** {@inheritDoc} */
-    @Override  public IgniteAtomicSequence atomicSequence(String name, long initVal, boolean create) throws IgniteException {
+    @Override  public IgniteAtomicSequence atomicSequence(String name, long initVal, boolean create)
+        throws IgniteException {
         throw new UnsupportedOperationException("Operation isn't supported yet.");
     }
 
@@ -524,8 +514,12 @@ public class IgniteProcessProxy implements IgniteEx {
     }
 
     /** {@inheritDoc} */
-    @Override  public <T, S> IgniteAtomicStamped<T, S> atomicStamped(String name, @Nullable T initVal, @Nullable S initStamp,
-        boolean create) throws IgniteException {
+    @Override  public <T, S> IgniteAtomicStamped<T, S> atomicStamped(
+        String name,
+        @Nullable T initVal,
+        @Nullable S initStamp,
+        boolean create) throws IgniteException
+    {
         throw new UnsupportedOperationException("Operation isn't supported yet.");
     }
 
@@ -572,11 +566,7 @@ public class IgniteProcessProxy implements IgniteEx {
             }
         }, EventType.EVT_NODE_LEFT, EventType.EVT_NODE_FAILED);
 
-        compute().run(new IgniteRunnable() {
-            @Override public void run() {
-                igniteById().close();
-            }
-        });
+        compute().run(new StopGridTask(localJvmGrid().name(), true));
 
         try {
             assert U.await(rmtNodeStoppedLatch, 15, TimeUnit.SECONDS) : "NodeId=" + id;
@@ -616,4 +606,43 @@ public class IgniteProcessProxy implements IgniteEx {
 
         return locJvmGrid.compute(grp);
     }
+
+    /**
+     *
+     */
+    private static class StopGridTask implements IgniteRunnable {
+        /** Grid name. */
+        private final String gridName;
+
+        /** Cancel. */
+        private final boolean cancel;
+
+        /**
+         * @param gridName Grid name.
+         * @param cancel Cancel.
+         */
+        public StopGridTask(String gridName, boolean cancel) {
+            this.gridName = gridName;
+            this.cancel = cancel;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void run() {
+            G.stop(gridName, cancel);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class NodeTask implements IgniteCallable<ClusterNode> {
+        /** Ignite. */
+        @IgniteInstanceResource
+        private Ignite ignite;
+
+        /** {@inheritDoc} */
+        @Override public ClusterNode call() throws Exception {
+            return ((IgniteEx)ignite).localNode();
+        }
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/a1e5cc57/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationP2PTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationP2PTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationP2PTest.java
index 5298dd4..3777154 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationP2PTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationP2PTest.java
@@ -103,6 +103,7 @@ public class CacheConfigurationP2PTest extends GridCommonAbstractTest {
                         }
                     },
                     null,
+                    null,
                     jvmArgs,
                     null
                 );
@@ -119,6 +120,7 @@ public class CacheConfigurationP2PTest extends GridCommonAbstractTest {
                         }
                     },
                     null,
+                    null,
                     jvmArgs,
                     null
                 );
@@ -139,6 +141,7 @@ public class CacheConfigurationP2PTest extends GridCommonAbstractTest {
                         }
                     },
                     null,
+                    null,
                     jvmArgs,
                     cp
                 );


[12/50] [abbrv] ignite git commit: IgniteTransactions javadoc updated

Posted by ag...@apache.org.
IgniteTransactions javadoc updated


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

Branch: refs/heads/ignite-1016
Commit: 075e7d06d55ba1c1249ce8b4d3b491aef7cbfd31
Parents: 1223525
Author: agura <ag...@gridgain.com>
Authored: Mon Oct 12 12:32:35 2015 +0300
Committer: agura <ag...@gridgain.com>
Committed: Mon Oct 12 12:33:12 2015 +0300

----------------------------------------------------------------------
 .../core/src/main/java/org/apache/ignite/IgniteTransactions.java | 4 ----
 1 file changed, 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/075e7d06/modules/core/src/main/java/org/apache/ignite/IgniteTransactions.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteTransactions.java b/modules/core/src/main/java/org/apache/ignite/IgniteTransactions.java
index bb88d4a..875b647 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteTransactions.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteTransactions.java
@@ -17,7 +17,6 @@
 
 package org.apache.ignite;
 
-import org.apache.ignite.cache.CacheAtomicityMode;
 import org.apache.ignite.cache.CacheMode;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.transactions.Transaction;
@@ -59,7 +58,6 @@ public interface IgniteTransactions {
      *
      * @return New transaction
      * @throws IllegalStateException If transaction is already started by this thread.
-     * @throws UnsupportedOperationException If cache is {@link CacheAtomicityMode#ATOMIC}.
      */
     public Transaction txStart() throws IllegalStateException;
 
@@ -70,7 +68,6 @@ public interface IgniteTransactions {
      * @param isolation Isolation.
      * @return New transaction.
      * @throws IllegalStateException If transaction is already started by this thread.
-     * @throws UnsupportedOperationException If cache is {@link CacheAtomicityMode#ATOMIC}.
      */
     public Transaction txStart(TransactionConcurrency concurrency, TransactionIsolation isolation);
 
@@ -84,7 +81,6 @@ public interface IgniteTransactions {
      * @param txSize Number of entries participating in transaction (may be approximate).
      * @return New transaction.
      * @throws IllegalStateException If transaction is already started by this thread.
-     * @throws UnsupportedOperationException If cache is {@link CacheAtomicityMode#ATOMIC}.
      */
     public Transaction txStart(TransactionConcurrency concurrency, TransactionIsolation isolation, long timeout,
         int txSize);


[03/50] [abbrv] ignite git commit: ignite-master Minor fix in visorcmd.

Posted by ag...@apache.org.
ignite-master Minor fix in visorcmd.


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

Branch: refs/heads/ignite-1016
Commit: d9177333814450ad5a7b2ea88464bbbb2664b959
Parents: 3036c8d
Author: Andrey <an...@gridgain.com>
Authored: Fri Oct 9 10:13:19 2015 +0700
Committer: Andrey <an...@gridgain.com>
Committed: Fri Oct 9 10:13:19 2015 +0700

----------------------------------------------------------------------
 .../org/apache/ignite/visor/commands/kill/VisorKillCommand.scala   | 2 +-
 .../src/main/scala/org/apache/ignite/visor/visor.scala             | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/d9177333/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/kill/VisorKillCommand.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/kill/VisorKillCommand.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/kill/VisorKillCommand.scala
index 6cd1ffa..dffd5f1 100644
--- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/kill/VisorKillCommand.scala
+++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/kill/VisorKillCommand.scala
@@ -131,7 +131,7 @@ class VisorKillCommand extends VisorConsoleCommand {
             if (kill && restart)
                 scold("Only one of '-k' or '-r' can be specified.")
             else if (!kill && !restart)
-                scold("Invalid command arguments: " + args)
+                scold("Missing '-k' or '-r' option in command: " + args)
             else if (id8.isDefined && id.isDefined)
                 scold("Only one of -id8 or -id is allowed.")
             else {

http://git-wip-us.apache.org/repos/asf/ignite/blob/d9177333/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala
index 7bd6818..28ef0d7 100644
--- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala
+++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala
@@ -461,7 +461,6 @@ object visor extends VisorTag {
         shortInfo = "Starts or stops grid-wide events logging.",
         longInfo = Seq(
             "Logging of discovery and failure grid-wide events.",
-            "Logging starts by default when Visor starts.",
             " ",
             "Events are logged to a file. If path is not provided,",
             "it will log into '<Ignite home folder>/work/visor/visor-log'.",


[20/50] [abbrv] ignite git commit: CPP common: Disabled incremental linking.

Posted by ag...@apache.org.
CPP common: Disabled incremental linking.


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

Branch: refs/heads/ignite-1016
Commit: 49a5cc5d68a62602bb485b342dca9225c0a23193
Parents: 1dc3936
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Thu Oct 15 12:10:59 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Thu Oct 15 12:10:59 2015 +0300

----------------------------------------------------------------------
 modules/platform/src/main/cpp/common/project/vs/common.vcxproj | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/49a5cc5d/modules/platform/src/main/cpp/common/project/vs/common.vcxproj
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/cpp/common/project/vs/common.vcxproj b/modules/platform/src/main/cpp/common/project/vs/common.vcxproj
index b7cfb8a..c5c790e 100644
--- a/modules/platform/src/main/cpp/common/project/vs/common.vcxproj
+++ b/modules/platform/src/main/cpp/common/project/vs/common.vcxproj
@@ -67,7 +67,7 @@
   </ImportGroup>
   <PropertyGroup Label="UserMacros" />
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
-    <LinkIncremental>true</LinkIncremental>
+    <LinkIncremental>false</LinkIncremental>
     <TargetName>ignite.common</TargetName>
     <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
     <IntDir>$(Platform)\$(Configuration)\</IntDir>
@@ -76,7 +76,7 @@
     <TargetName>ignite.common</TargetName>
     <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
     <IntDir>$(Platform)\$(Configuration)\</IntDir>
-    <LinkIncremental>true</LinkIncremental>
+    <LinkIncremental>false</LinkIncremental>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
     <LinkIncremental>false</LinkIncremental>


[40/50] [abbrv] ignite git commit: IGNITE-1733

Posted by ag...@apache.org.
IGNITE-1733


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

Branch: refs/heads/ignite-1016
Commit: 10ef06a14245c73cbfe66b744406a0391c4a9c08
Parents: 10cf673
Author: Anton Vinogradov <av...@apache.org>
Authored: Mon Oct 19 18:59:55 2015 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Mon Oct 19 18:59:55 2015 +0300

----------------------------------------------------------------------
 examples-lgpl/pom-standalone.xml                | 45 +++++++++++++
 .../scalar/examples/ScalarScheduleExample.scala | 66 ++++++++++++++++++++
 .../ScalarLgplExamplesMultiNodeSelfTest.scala   | 33 ++++++++++
 .../examples/ScalarLgplExamplesSelfTest.scala   | 36 +++++++++++
 .../ScalarLgplExamplesSelfTestSuite.scala       | 37 +++++++++++
 .../scalar/examples/ScalarScheduleExample.scala | 66 --------------------
 .../tests/examples/ScalarExamplesSelfTest.scala |  5 --
 7 files changed, 217 insertions(+), 71 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/10ef06a1/examples-lgpl/pom-standalone.xml
----------------------------------------------------------------------
diff --git a/examples-lgpl/pom-standalone.xml b/examples-lgpl/pom-standalone.xml
index d2a00d1..2e3bf8f 100644
--- a/examples-lgpl/pom-standalone.xml
+++ b/examples-lgpl/pom-standalone.xml
@@ -137,5 +137,50 @@
                 </plugins>
             </build>
         </profile>
+
+        <profile>
+            <id>scala</id>
+
+            <dependencies>
+                <dependency>
+                    <groupId>org.apache.ignite</groupId>
+                    <artifactId>ignite-scalar</artifactId>
+                    <version>to_be_replaced_by_ignite_version</version>
+                </dependency>
+            </dependencies>
+
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>net.alchim31.maven</groupId>
+                        <artifactId>scala-maven-plugin</artifactId>
+                        <version>3.2.0</version>
+                        <configuration>
+                            <jvmArgs>
+                                <jvmArg>-Xms512m</jvmArg>
+                                <jvmArg>-Xmx1024m</jvmArg>
+                            </jvmArgs>
+                        </configuration>
+                        <executions>
+                            <execution>
+                                <id>scala-compile-first</id>
+                                <phase>process-resources</phase>
+                                <goals>
+                                    <goal>add-source</goal>
+                                    <goal>compile</goal>
+                                </goals>
+                            </execution>
+                            <execution>
+                                <id>scala-test-compile</id>
+                                <phase>process-test-resources</phase>
+                                <goals>
+                                    <goal>testCompile</goal>
+                                </goals>
+                            </execution>
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
     </profiles>
 </project>

http://git-wip-us.apache.org/repos/asf/ignite/blob/10ef06a1/examples-lgpl/src/main/scala/org/apache/ignite/scalar/examples/ScalarScheduleExample.scala
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/scala/org/apache/ignite/scalar/examples/ScalarScheduleExample.scala b/examples-lgpl/src/main/scala/org/apache/ignite/scalar/examples/ScalarScheduleExample.scala
new file mode 100644
index 0000000..8734a23
--- /dev/null
+++ b/examples-lgpl/src/main/scala/org/apache/ignite/scalar/examples/ScalarScheduleExample.scala
@@ -0,0 +1,66 @@
+/*
+ * 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.scalar.examples
+
+import org.apache.ignite.scalar.scalar
+import org.apache.ignite.scalar.scalar._
+
+/**
+ * Demonstrates a cron-based `Runnable` execution scheduling.
+ * Test runnable object broadcasts a phrase to all cluster nodes every minute
+ * three times with initial scheduling delay equal to five seconds.
+ * <p/>
+ * Remote nodes should always be started with special configuration file which
+ * enables P2P class loading: `'ignite.{sh|bat} examples/config/example-ignite.xml'`.
+ * <p/>
+ * Alternatively you can run `ExampleNodeStartup` in another JVM which will
+ * start node with `examples/config/example-ignite.xml` configuration.
+ */
+object ScalarScheduleExample extends App {
+    scalar("examples/config/example-ignite.xml") {
+        println()
+        println("Compute schedule example started.")
+
+        val g = ignite$
+
+        var invocations = 0
+
+        // Schedule callable that returns incremented value each time.
+        val fut = ignite$.scheduleLocalCall(
+            () => {
+                invocations += 1
+
+                g.bcastRun(() => {
+                    println()
+                    println("Howdy! :)")
+                }, null)
+
+                invocations
+            },
+            "{5, 3} * * * * *" // Cron expression.
+        )
+
+        while (!fut.isDone)
+            println(">>> Invocation #: " + fut.get)
+
+        // Prints.
+        println()
+        println(">>> Schedule future is done and has been unscheduled.")
+        println(">>> Check all nodes for hello message output.")
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/10ef06a1/examples-lgpl/src/test/scala/org/apache/ignite/scalar/tests/examples/ScalarLgplExamplesMultiNodeSelfTest.scala
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/test/scala/org/apache/ignite/scalar/tests/examples/ScalarLgplExamplesMultiNodeSelfTest.scala b/examples-lgpl/src/test/scala/org/apache/ignite/scalar/tests/examples/ScalarLgplExamplesMultiNodeSelfTest.scala
new file mode 100644
index 0000000..fca44e3
--- /dev/null
+++ b/examples-lgpl/src/test/scala/org/apache/ignite/scalar/tests/examples/ScalarLgplExamplesMultiNodeSelfTest.scala
@@ -0,0 +1,33 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.ignite.scalar.tests.examples
+
+/**
+ * Scalar examples multi-node self test.
+ */
+class ScalarLgplExamplesMultiNodeSelfTest extends ScalarExamplesSelfTest {
+    /** */
+    protected override def beforeTest() {
+        startRemoteNodes()
+    }
+
+    /** */
+    protected override def getTestTimeout: Long = {
+        10 * 60 * 1000
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/10ef06a1/examples-lgpl/src/test/scala/org/apache/ignite/scalar/tests/examples/ScalarLgplExamplesSelfTest.scala
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/test/scala/org/apache/ignite/scalar/tests/examples/ScalarLgplExamplesSelfTest.scala b/examples-lgpl/src/test/scala/org/apache/ignite/scalar/tests/examples/ScalarLgplExamplesSelfTest.scala
new file mode 100644
index 0000000..25a5fe4
--- /dev/null
+++ b/examples-lgpl/src/test/scala/org/apache/ignite/scalar/tests/examples/ScalarLgplExamplesSelfTest.scala
@@ -0,0 +1,36 @@
+/*
+ *  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.scalar.tests.examples
+
+import org.apache.ignite.scalar.examples._
+import org.apache.ignite.scalar.scalar
+import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest
+import org.scalatest.junit.JUnitSuiteLike
+
+/**
+ * Scalar examples self test.
+ */
+class ScalarLgplExamplesSelfTest extends GridAbstractExamplesTest with JUnitSuiteLike {
+    /** */
+    private def EMPTY_ARGS = Array.empty[String]
+
+    /** */
+    def testScalarScheduleCallableExample() {
+        ScalarScheduleExample.main(EMPTY_ARGS)
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/10ef06a1/examples-lgpl/src/test/scala/org/apache/ignite/scalar/testsuites/ScalarLgplExamplesSelfTestSuite.scala
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/test/scala/org/apache/ignite/scalar/testsuites/ScalarLgplExamplesSelfTestSuite.scala b/examples-lgpl/src/test/scala/org/apache/ignite/scalar/testsuites/ScalarLgplExamplesSelfTestSuite.scala
new file mode 100644
index 0000000..4f3195e
--- /dev/null
+++ b/examples-lgpl/src/test/scala/org/apache/ignite/scalar/testsuites/ScalarLgplExamplesSelfTestSuite.scala
@@ -0,0 +1,37 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.ignite.scalar.testsuites
+
+import org.apache.ignite.IgniteSystemProperties._
+import org.apache.ignite.scalar.tests.examples.{ScalarExamplesMultiNodeSelfTest, ScalarExamplesSelfTest}
+import org.apache.ignite.testframework.GridTestUtils
+import org.junit.runner.RunWith
+import org.scalatest._
+import org.scalatest.junit.JUnitRunner
+
+/**
+ *
+ */
+@RunWith(classOf[JUnitRunner])
+class ScalarLgplExamplesSelfTestSuite extends Suites(
+    new ScalarLgplExamplesSelfTest,
+    new ScalarLgplExamplesMultiNodeSelfTest
+) {
+    System.setProperty(IGNITE_OVERRIDE_MCAST_GRP,
+        GridTestUtils.getNextMulticastGroup(classOf[ScalarLgplExamplesSelfTest]))
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/10ef06a1/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarScheduleExample.scala
----------------------------------------------------------------------
diff --git a/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarScheduleExample.scala b/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarScheduleExample.scala
deleted file mode 100644
index 8734a23..0000000
--- a/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarScheduleExample.scala
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.scalar.examples
-
-import org.apache.ignite.scalar.scalar
-import org.apache.ignite.scalar.scalar._
-
-/**
- * Demonstrates a cron-based `Runnable` execution scheduling.
- * Test runnable object broadcasts a phrase to all cluster nodes every minute
- * three times with initial scheduling delay equal to five seconds.
- * <p/>
- * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: `'ignite.{sh|bat} examples/config/example-ignite.xml'`.
- * <p/>
- * Alternatively you can run `ExampleNodeStartup` in another JVM which will
- * start node with `examples/config/example-ignite.xml` configuration.
- */
-object ScalarScheduleExample extends App {
-    scalar("examples/config/example-ignite.xml") {
-        println()
-        println("Compute schedule example started.")
-
-        val g = ignite$
-
-        var invocations = 0
-
-        // Schedule callable that returns incremented value each time.
-        val fut = ignite$.scheduleLocalCall(
-            () => {
-                invocations += 1
-
-                g.bcastRun(() => {
-                    println()
-                    println("Howdy! :)")
-                }, null)
-
-                invocations
-            },
-            "{5, 3} * * * * *" // Cron expression.
-        )
-
-        while (!fut.isDone)
-            println(">>> Invocation #: " + fut.get)
-
-        // Prints.
-        println()
-        println(">>> Schedule future is done and has been unscheduled.")
-        println(">>> Check all nodes for hello message output.")
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/10ef06a1/examples/src/test/scala/org/apache/ignite/scalar/tests/examples/ScalarExamplesSelfTest.scala
----------------------------------------------------------------------
diff --git a/examples/src/test/scala/org/apache/ignite/scalar/tests/examples/ScalarExamplesSelfTest.scala b/examples/src/test/scala/org/apache/ignite/scalar/tests/examples/ScalarExamplesSelfTest.scala
index 52d5ce1..ef56434 100644
--- a/examples/src/test/scala/org/apache/ignite/scalar/tests/examples/ScalarExamplesSelfTest.scala
+++ b/examples/src/test/scala/org/apache/ignite/scalar/tests/examples/ScalarExamplesSelfTest.scala
@@ -77,11 +77,6 @@ class ScalarExamplesSelfTest extends GridAbstractExamplesTest with JUnitSuiteLik
     }
 
     /** */
-    def testScalarScheduleCallableExample() {
-        ScalarScheduleExample.main(EMPTY_ARGS)
-    }
-
-    /** */
     def testScalarTaskExample() {
         ScalarTaskExample.main(EMPTY_ARGS)
     }


[02/50] [abbrv] ignite git commit: ignite-1183 Fixed data structures create/destroy from client node

Posted by ag...@apache.org.
ignite-1183 Fixed data structures create/destroy from client node


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

Branch: refs/heads/ignite-1016
Commit: 3036c8d85db223a26f48f273ad08b6ea87e2e2ba
Parents: f025714
Author: sboikov <sb...@gridgain.com>
Authored: Thu Oct 8 16:33:53 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Thu Oct 8 16:33:53 2015 +0300

----------------------------------------------------------------------
 .../dht/atomic/GridNearAtomicUpdateFuture.java  |   8 +-
 .../colocated/GridDhtColocatedLockFuture.java   |  11 +-
 .../distributed/near/GridNearLockFuture.java    |  11 +-
 .../near/GridNearOptimisticTxPrepareFuture.java |  24 +--
 .../datastructures/DataStructuresProcessor.java |  48 ++++--
 .../CacheGetFutureHangsSelfTest.java            |   3 +
 ...niteCacheClientNodeChangingTopologyTest.java |   6 +-
 ...gniteAtomicLongChangingTopologySelfTest.java | 155 +++++++++++++++++--
 8 files changed, 216 insertions(+), 50 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/3036c8d8/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java
index 41df53a..97aa646 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java
@@ -585,8 +585,12 @@ public class GridNearAtomicUpdateFuture extends GridFutureAdapter<Object>
                 if (req != null) {
                     res = new GridNearAtomicUpdateResponse(cctx.cacheId(), nodeId, req.futureVersion());
 
-                    res.addFailedKeys(req.keys(), new ClusterTopologyCheckedException("Primary node left grid before " +
-                        "response is received: " + nodeId));
+                    ClusterTopologyCheckedException e = new ClusterTopologyCheckedException("Primary node left grid " +
+                        "before response is received: " + nodeId);
+
+                    e.retryReadyFuture(cctx.shared().nextAffinityReadyFuture(req.topologyVersion()));
+
+                    res.addFailedKeys(req.keys(), e);
                 }
             }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/3036c8d8/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
index 33a5cbd..be09f54 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
@@ -598,7 +598,7 @@ public final class GridDhtColocatedLockFuture extends GridCompoundIdentityFuture
             // Continue mapping on the same topology version as it was before.
             this.topVer.compareAndSet(null, topVer);
 
-            map(keys, false);
+            map(keys, false, true);
 
             markInitialized();
 
@@ -654,7 +654,7 @@ public final class GridDhtColocatedLockFuture extends GridCompoundIdentityFuture
                     this.topVer.compareAndSet(null, topVer);
                 }
 
-                map(keys, remap);
+                map(keys, remap, false);
 
                 if (c != null)
                     c.run();
@@ -691,8 +691,9 @@ public final class GridDhtColocatedLockFuture extends GridCompoundIdentityFuture
      *
      * @param keys Keys.
      * @param remap Remap flag.
+     * @param topLocked {@code True} if thread already acquired lock preventing topology change.
      */
-    private void map(Collection<KeyCacheObject> keys, boolean remap) {
+    private void map(Collection<KeyCacheObject> keys, boolean remap, boolean topLocked) {
         try {
             AffinityTopologyVersion topVer = this.topVer.get();
 
@@ -819,7 +820,9 @@ public final class GridDhtColocatedLockFuture extends GridCompoundIdentityFuture
                                     boolean clientFirst = false;
 
                                     if (first) {
-                                        clientFirst = clientNode && (tx == null || !tx.hasRemoteLocks());
+                                        clientFirst = clientNode &&
+                                            !topLocked &&
+                                            (tx == null || !tx.hasRemoteLocks());
 
                                         first = false;
                                     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/3036c8d8/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
index dcc8da6..e6b1e02 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
@@ -718,7 +718,7 @@ public final class GridNearLockFuture extends GridCompoundIdentityFuture<Boolean
             // Continue mapping on the same topology version as it was before.
             this.topVer.compareAndSet(null, topVer);
 
-            map(keys, false);
+            map(keys, false, true);
 
             markInitialized();
 
@@ -773,7 +773,7 @@ public final class GridNearLockFuture extends GridCompoundIdentityFuture<Boolean
                     this.topVer.compareAndSet(null, topVer);
                 }
 
-                map(keys, remap);
+                map(keys, remap, false);
 
                 markInitialized();
             }
@@ -807,8 +807,9 @@ public final class GridNearLockFuture extends GridCompoundIdentityFuture<Boolean
      *
      * @param keys Keys.
      * @param remap Remap flag.
+     * @param topLocked {@code True} if thread already acquired lock preventing topology change.
      */
-    private void map(Iterable<KeyCacheObject> keys, boolean remap) {
+    private void map(Iterable<KeyCacheObject> keys, boolean remap, boolean topLocked) {
         try {
             AffinityTopologyVersion topVer = this.topVer.get();
 
@@ -938,7 +939,9 @@ public final class GridNearLockFuture extends GridCompoundIdentityFuture<Boolean
                                         boolean clientFirst = false;
 
                                         if (first) {
-                                            clientFirst = clientNode && (tx == null || !tx.hasRemoteLocks());
+                                            clientFirst = clientNode &&
+                                                !topLocked &&
+                                                (tx == null || !tx.hasRemoteLocks());
 
                                             first = false;
                                         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/3036c8d8/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 25028c4..1fb33a2 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
@@ -271,7 +271,7 @@ public class GridNearOptimisticTxPrepareFuture extends GridNearTxPrepareFutureAd
 
             cctx.mvcc().addFuture(this);
 
-            prepare0(false);
+            prepare0(false, true);
 
             return;
         }
@@ -338,7 +338,7 @@ public class GridNearOptimisticTxPrepareFuture extends GridNearTxPrepareFutureAd
                 return;
             }
 
-            prepare0(remap);
+            prepare0(remap, false);
 
             if (c != null)
                 c.run();
@@ -428,8 +428,9 @@ public class GridNearOptimisticTxPrepareFuture extends GridNearTxPrepareFutureAd
      * Initializes future.
      *
      * @param remap Remap flag.
+     * @param topLocked {@code True} if thread already acquired lock preventing topology change.
      */
-    private void prepare0(boolean remap) {
+    private void prepare0(boolean remap, boolean topLocked) {
         try {
             boolean txStateCheck = remap ? tx.state() == PREPARING : tx.state(PREPARING);
 
@@ -451,7 +452,8 @@ public class GridNearOptimisticTxPrepareFuture extends GridNearTxPrepareFutureAd
 
             prepare(
                 tx.optimistic() && tx.serializable() ? tx.readEntries() : Collections.<IgniteTxEntry>emptyList(),
-                tx.writeEntries());
+                tx.writeEntries(),
+                topLocked);
 
             markInitialized();
         }
@@ -466,11 +468,13 @@ public class GridNearOptimisticTxPrepareFuture extends GridNearTxPrepareFutureAd
     /**
      * @param reads Read entries.
      * @param writes Write entries.
+     * @param topLocked {@code True} if thread already acquired lock preventing topology change.
      * @throws IgniteCheckedException If failed.
      */
     private void prepare(
         Iterable<IgniteTxEntry> reads,
-        Iterable<IgniteTxEntry> writes
+        Iterable<IgniteTxEntry> writes,
+        boolean topLocked
     ) throws IgniteCheckedException {
         AffinityTopologyVersion topVer = tx.topologyVersion();
 
@@ -497,7 +501,7 @@ public class GridNearOptimisticTxPrepareFuture extends GridNearTxPrepareFutureAd
         GridDistributedTxMapping cur = null;
 
         for (IgniteTxEntry read : reads) {
-            GridDistributedTxMapping updated = map(read, topVer, cur, false);
+            GridDistributedTxMapping updated = map(read, topVer, cur, false, topLocked);
 
             if (cur != updated) {
                 mappings.offer(updated);
@@ -514,7 +518,7 @@ public class GridNearOptimisticTxPrepareFuture extends GridNearTxPrepareFutureAd
         }
 
         for (IgniteTxEntry write : writes) {
-            GridDistributedTxMapping updated = map(write, topVer, cur, true);
+            GridDistributedTxMapping updated = map(write, topVer, cur, true, topLocked);
 
             if (cur != updated) {
                 mappings.offer(updated);
@@ -647,13 +651,15 @@ public class GridNearOptimisticTxPrepareFuture extends GridNearTxPrepareFutureAd
      * @param topVer Topology version.
      * @param cur Current mapping.
      * @param waitLock Wait lock flag.
+     * @param topLocked {@code True} if thread already acquired lock preventing topology change.
      * @return Mapping.
      */
     private GridDistributedTxMapping map(
         IgniteTxEntry entry,
         AffinityTopologyVersion topVer,
         @Nullable GridDistributedTxMapping cur,
-        boolean waitLock
+        boolean waitLock,
+        boolean topLocked
     ) {
         GridCacheContext cacheCtx = entry.context();
 
@@ -685,7 +691,7 @@ public class GridNearOptimisticTxPrepareFuture extends GridNearTxPrepareFutureAd
         }
 
         if (cur == null || !cur.node().id().equals(primary.id()) || cur.near() != cacheCtx.isNear()) {
-            boolean clientFirst = cur == null && cctx.kernalContext().clientNode();
+            boolean clientFirst = cur == null && !topLocked && cctx.kernalContext().clientNode();
 
             cur = new GridDistributedTxMapping(primary);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/3036c8d8/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
index ef2c543..7c5e97c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
@@ -505,14 +505,20 @@ public final class DataStructuresProcessor extends GridProcessorAdapter {
 
                 return dataStructure;
             }
-            catch (ClusterTopologyCheckedException e) {
-                IgniteInternalFuture<?> fut = e.retryReadyFuture();
-
-                fut.get();
-            }
             catch (IgniteTxRollbackCheckedException ignore) {
                 // Safe to retry right away.
             }
+            catch (IgniteCheckedException e) {
+                ClusterTopologyCheckedException topErr = e.getCause(ClusterTopologyCheckedException.class);
+
+                if (topErr == null)
+                    throw e;
+
+                IgniteInternalFuture<?> fut = topErr.retryReadyFuture();
+
+                if (fut != null)
+                    fut.get();
+            }
         }
     }
 
@@ -593,14 +599,20 @@ public final class DataStructuresProcessor extends GridProcessorAdapter {
                 if (afterRmv != null && rmvInfo != null)
                     afterRmv.applyx(rmvInfo);
             }
-            catch (ClusterTopologyCheckedException e) {
-                IgniteInternalFuture<?> fut = e.retryReadyFuture();
-
-                fut.get();
-            }
             catch (IgniteTxRollbackCheckedException ignore) {
                 // Safe to retry right away.
             }
+            catch (IgniteCheckedException e) {
+                ClusterTopologyCheckedException topErr = e.getCause(ClusterTopologyCheckedException.class);
+
+                if (topErr == null)
+                    throw e;
+
+                IgniteInternalFuture<?> fut = topErr.retryReadyFuture();
+
+                if (fut != null)
+                    fut.get();
+            }
         }
     }
 
@@ -995,14 +1007,20 @@ public final class DataStructuresProcessor extends GridProcessorAdapter {
 
                 return col;
             }
-            catch (ClusterTopologyCheckedException e) {
-                IgniteInternalFuture<?> fut = e.retryReadyFuture();
-
-                fut.get();
-            }
             catch (IgniteTxRollbackCheckedException ignore) {
                 // Safe to retry right away.
             }
+            catch (IgniteCheckedException e) {
+                ClusterTopologyCheckedException topErr = e.getCause(ClusterTopologyCheckedException.class);
+
+                if (topErr == null)
+                    throw e;
+
+                IgniteInternalFuture<?> fut = topErr.retryReadyFuture();
+
+                if (fut != null)
+                    fut.get();
+            }
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/3036c8d8/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheGetFutureHangsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheGetFutureHangsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheGetFutureHangsSelfTest.java
index e8622aa..51e76f6 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheGetFutureHangsSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheGetFutureHangsSelfTest.java
@@ -31,6 +31,7 @@ import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.util.typedef.T2;
 import org.apache.ignite.marshaller.optimized.OptimizedMarshaller;
+import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 import org.jetbrains.annotations.Nullable;
 
@@ -54,6 +55,8 @@ public class CacheGetFutureHangsSelfTest extends GridCommonAbstractTest {
     @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
         IgniteConfiguration cfg = super.getConfiguration(gridName);
 
+        ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1);
+
         OptimizedMarshaller marsh = new OptimizedMarshaller();
         marsh.setRequireSerializable(false);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/3036c8d8/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeChangingTopologyTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeChangingTopologyTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeChangingTopologyTest.java
index 2d29c49..1b3dc7a 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeChangingTopologyTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeChangingTopologyTest.java
@@ -118,7 +118,11 @@ public class IgniteCacheClientNodeChangingTopologyTest extends GridCommonAbstrac
 
         cfg.setClientMode(client);
 
-        cfg.setCommunicationSpi(new TestCommunicationSpi());
+        TestCommunicationSpi commSpi = new TestCommunicationSpi();
+
+        commSpi.setSharedMemoryPort(-1);
+
+        cfg.setCommunicationSpi(commSpi);
 
         cfg.setCacheConfiguration(ccfg);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/3036c8d8/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteAtomicLongChangingTopologySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteAtomicLongChangingTopologySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteAtomicLongChangingTopologySelfTest.java
index 337334e..32a86e4 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteAtomicLongChangingTopologySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteAtomicLongChangingTopologySelfTest.java
@@ -17,21 +17,37 @@
 
 package org.apache.ignite.internal.processors.cache.distributed.dht;
 
-import org.apache.ignite.*;
-import org.apache.ignite.cache.*;
-import org.apache.ignite.configuration.*;
-import org.apache.ignite.internal.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Queue;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ThreadLocalRandom;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicReferenceArray;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteAtomicLong;
+import org.apache.ignite.IgniteQueue;
+import org.apache.ignite.configuration.AtomicConfiguration;
+import org.apache.ignite.configuration.CollectionConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteInClosure;
 import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
-import org.apache.ignite.spi.discovery.tcp.*;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
-import org.apache.ignite.testframework.*;
-import org.apache.ignite.testframework.junits.common.*;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 
-import java.util.*;
-import java.util.concurrent.*;
-import java.util.concurrent.atomic.*;
+import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheMode.PARTITIONED;
 
 /**
  *
@@ -52,6 +68,9 @@ public class IgniteAtomicLongChangingTopologySelfTest extends GridCommonAbstract
     /** */
     private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
 
+    /** */
+    private boolean client;
+
     /** {@inheritDoc} */
     @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
         IgniteConfiguration cfg = super.getConfiguration(gridName);
@@ -60,16 +79,18 @@ public class IgniteAtomicLongChangingTopologySelfTest extends GridCommonAbstract
 
         discoSpi.setIpFinder(IP_FINDER);
 
-        cfg.setDiscoverySpi(discoSpi);
+        cfg.setDiscoverySpi(discoSpi).setNetworkTimeout(30_000);
 
         AtomicConfiguration atomicCfg = new AtomicConfiguration();
-        atomicCfg.setCacheMode(CacheMode.PARTITIONED);
+        atomicCfg.setCacheMode(PARTITIONED);
         atomicCfg.setBackups(1);
 
         cfg.setAtomicConfiguration(atomicCfg);
 
         ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1);
 
+        cfg.setClientMode(client);
+
         return cfg;
     }
 
@@ -111,6 +132,110 @@ public class IgniteAtomicLongChangingTopologySelfTest extends GridCommonAbstract
     /**
      * @throws Exception If failed.
      */
+    public void testClientAtomicLongCreateCloseFailover() throws Exception {
+        testFailoverWithClient(new IgniteInClosure<Ignite>() {
+            @Override public void apply(Ignite ignite) {
+                for (int i = 0; i < 100; i++) {
+                    IgniteAtomicLong l = ignite.atomicLong("long-" + 1, 0, true);
+
+                    l.close();
+                }
+            }
+        });
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testClientQueueCreateCloseFailover() throws Exception {
+        testFailoverWithClient(new IgniteInClosure<Ignite>() {
+            @Override public void apply(Ignite ignite) {
+                for (int i = 0; i < 100; i++) {
+                    CollectionConfiguration colCfg = new CollectionConfiguration();
+
+                    colCfg.setBackups(1);
+                    colCfg.setCacheMode(PARTITIONED);
+                    colCfg.setAtomicityMode(i % 2 == 0 ? TRANSACTIONAL : ATOMIC);
+
+                    IgniteQueue q = ignite.queue("q-" + i, 0, colCfg);
+
+                    q.close();
+                }
+            }
+        });
+    }
+
+    /**
+     * @param c Test iteration closure.
+     * @throws Exception If failed.
+     */
+    private void testFailoverWithClient(IgniteInClosure<Ignite> c) throws Exception {
+        startGridsMultiThreaded(GRID_CNT, false);
+
+        client = true;
+
+        Ignite ignite = startGrid(GRID_CNT);
+
+        assertTrue(ignite.configuration().isClientMode());
+
+        client = false;
+
+        final AtomicBoolean finished = new AtomicBoolean();
+
+        IgniteInternalFuture<?> fut = restartThread(finished);
+
+        long stop = System.currentTimeMillis() + 30_000;
+
+        try {
+            int iter = 0;
+
+            while (System.currentTimeMillis() < stop) {
+                log.info("Iteration: " + iter++);
+
+                c.apply(ignite);
+            }
+
+            finished.set(true);
+
+            fut.get();
+        }
+        finally {
+            finished.set(true);
+        }
+    }
+
+    /**
+     * @param finished Finished flag.
+     * @return Future.
+     */
+    private IgniteInternalFuture<?> restartThread(final AtomicBoolean finished) {
+        return GridTestUtils.runAsync(new Callable<Object>() {
+            @Override public Object call() throws Exception {
+                while (!finished.get()) {
+                    for (int i = 0; i < GRID_CNT; i++) {
+                        log.info("Stop node: " + i);
+
+                        stopGrid(i);
+
+                        U.sleep(500);
+
+                        log.info("Start node: " + i);
+
+                        startGrid(i);
+
+                        if (finished.get())
+                            break;
+                    }
+                }
+
+                return null;
+            }
+        }, "restart-thread");
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
     public void testIncrementConsistency() throws Exception {
         startGrids(GRID_CNT);
 


[33/50] [abbrv] ignite git commit: ignite-1559: UriDeploymentHttpScanner tests and javadoc

Posted by ag...@apache.org.
ignite-1559: UriDeploymentHttpScanner tests and javadoc


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

Branch: refs/heads/ignite-1016
Commit: 02b59e433bce7a4c3eece7a80e7a053ae0d69373
Parents: a228c24
Author: Artem SHutak <as...@gridgain.com>
Authored: Thu Oct 15 17:18:15 2015 -0700
Committer: Valentin Kulichenko <va...@gmail.com>
Committed: Thu Oct 15 17:18:15 2015 -0700

----------------------------------------------------------------------
 .../ignite/spi/deployment/DeploymentSpi.java    |   8 +-
 modules/core/src/test/config/tests.properties   |   3 +
 modules/extdata/uri/pom.xml                     |  11 +-
 .../spi/deployment/uri/UriDeploymentSpi.java    |  93 ++++++++-----
 .../scanners/http/UriDeploymentHttpScanner.java |  10 +-
 .../http/GridHttpDeploymentSelfTest.java        | 132 +++++++++++++++++--
 6 files changed, 204 insertions(+), 53 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/02b59e43/modules/core/src/main/java/org/apache/ignite/spi/deployment/DeploymentSpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/deployment/DeploymentSpi.java b/modules/core/src/main/java/org/apache/ignite/spi/deployment/DeploymentSpi.java
index 7a1f709..af09e48 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/deployment/DeploymentSpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/deployment/DeploymentSpi.java
@@ -46,13 +46,13 @@ import org.jetbrains.annotations.Nullable;
  * local deployment.
  * </strong>
  * <p>
- * Ignite provides the following {@code GridDeploymentSpi} implementations:
+ * Ignite provides following {@code GridDeploymentSpi} implementations out of the box:
  * <ul>
  * <li>{@link org.apache.ignite.spi.deployment.local.LocalDeploymentSpi}</li>
  * <li>{@ignitelink org.apache.ignite.spi.deployment.uri.UriDeploymentSpi}</li>
  * </ul>
- * <b>NOTE:</b> this SPI (i.e. methods in this interface) should never be used directly. SPIs provide
- * internal view on the subsystem and is used internally by Ignite kernal. In rare use cases when
+ * <b>NOTE:</b> SPI methods should never be used directly. SPIs provide
+ * internal view on the subsystem and is used internally by Ignite. In rare use cases when
  * access to a specific implementation of this SPI is required - an instance of this SPI can be obtained
  * via {@link org.apache.ignite.Ignite#configuration()} method to check its configuration properties or call other non-SPI
  * methods. Note again that calling methods from this interface on the obtained instance can lead
@@ -104,4 +104,4 @@ public interface DeploymentSpi extends IgniteSpi {
      * @param lsnr Listener for deployment events. {@code null} to unset the listener.
      */
     public void setListener(@Nullable DeploymentListener lsnr);
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/02b59e43/modules/core/src/test/config/tests.properties
----------------------------------------------------------------------
diff --git a/modules/core/src/test/config/tests.properties b/modules/core/src/test/config/tests.properties
index ce6d4d8..49e616e 100644
--- a/modules/core/src/test/config/tests.properties
+++ b/modules/core/src/test/config/tests.properties
@@ -67,7 +67,10 @@ ant.gar.srcdir=@{IGNITE_HOME}/modules/extdata/uri/target/classes/
 # GAR paths to use in URI deployment SPI tests
 ant.urideployment.gar.uri=file://freq=5000@localhost/EXTDATA/uri/target/deploy
 ant.urideployment.gar.file=modules/extdata/uri/target/deploy/uri.gar
+ant.urideployment.gar.libs-file=modules/extdata/uri/target/deploy/uri-libs.gar
+ant.urideployment.gar.classes-file=modules/extdata/uri/target/deploy/uri-classes.gar
 ant.urideployment.gar.path=modules/extdata/uri/target/deploy/
+ant.urideployment.gar.path.tmp=modules/extdata/uri/target/deploy_tmp/
 
 # Classpath directory for GridP2PUserVersionChangeSelfTest
 ant.userversion.class.dir=@{IGNITE_HOME}/modules/tests/java/

http://git-wip-us.apache.org/repos/asf/ignite/blob/02b59e43/modules/extdata/uri/pom.xml
----------------------------------------------------------------------
diff --git a/modules/extdata/uri/pom.xml b/modules/extdata/uri/pom.xml
index d9a9297..d5e6349 100644
--- a/modules/extdata/uri/pom.xml
+++ b/modules/extdata/uri/pom.xml
@@ -144,14 +144,23 @@
                                     </fileset>
                                 </copy>
 
-                                <copy file="${settings.localRepository}/com/sun/mail/javax.mail/1.5.2/javax.mail-1.5.2.jar" todir="${basedir}/target/classes/lib" />
+                                <copy file="${settings.localRepository}/com/sun/mail/javax.mail/1.5.2/javax.mail-1.5.2.jar" todir="${basedir}/target/libs" />
 
                                 <zip destfile="${basedir}/target/classes/lib/depend.jar" encoding="UTF-8">
                                     <zipfileset dir="modules/uri-dependency/target/classes" />
                                 </zip>
 
+                                <copy file="${basedir}/target/classes/lib/depend.jar" todir="${basedir}/target/libs" />
+
+                                <mkdir dir="${basedir}/target/deploy_tmp/"/>
+
                                 <taskdef name="gar" classname="org.apache.ignite.util.antgar.IgniteDeploymentGarAntTask" />
 
+                                <gar destfile="${basedir}/target/deploy/uri-classes.gar" basedir="${basedir}/target/classes" />
+                                <gar destfile="${basedir}/target/deploy/uri-libs.gar" basedir="${basedir}/target/libs" />
+
+                                <copy file="${settings.localRepository}/com/sun/mail/javax.mail/1.5.2/javax.mail-1.5.2.jar" todir="${basedir}/target/classes/lib" />
+
                                 <gar destfile="${basedir}/target/deploy/uri.gar" basedir="${basedir}/target/classes" />
 
                                 <!--

http://git-wip-us.apache.org/repos/asf/ignite/blob/02b59e43/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/UriDeploymentSpi.java
----------------------------------------------------------------------
diff --git a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/UriDeploymentSpi.java b/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/UriDeploymentSpi.java
index c48398d..5f65731 100644
--- a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/UriDeploymentSpi.java
+++ b/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/UriDeploymentSpi.java
@@ -80,7 +80,7 @@ import org.jetbrains.annotations.Nullable;
  * <p>
  * SPI tracks all changes of every given URI. This means that if any file is
  * changed or deleted, SPI will re-deploy or delete corresponding tasks.
- * Note that the very first apply to {@link #findResource(String)} findClassLoader(String)}
+ * Note that the very first apply to {@link #findResource(String)}
  * is blocked until SPI finishes scanning all URI's at least once.
  * <p>
  * There are several deployable unit types supported:
@@ -145,11 +145,33 @@ import org.jetbrains.annotations.Nullable;
  * URI 'path' field will be automatically encoded. By default this flag is
  * set to {@code true}.
  * <p>
+ * <h1 class="header">Code Example</h1>
+ * The following example demonstrates how the deployment SPI can be used. It expects that you have a GAR file
+ * in 'home/username/ignite/work/my_deployment/file' folder which contains 'myproject.HelloWorldTask' class.
+ * <pre name="code" class="java">
+ * IgniteConfiguration cfg = new IgniteConfiguration();
+ *
+ * DeploymentSpi deploymentSpi = new UriDeploymentSpi();
+ *
+ * deploymentSpi.setUriList(Arrays.asList("file:///home/username/ignite/work/my_deployment/file"));
+ *
+ * cfg.setDeploymentSpi(deploymentSpi);
+ *
+ * try (Ignite ignite = Ignition.start(cfg)) {
+ *     ignite.compute().execute("myproject.HelloWorldTask", "my args");
+ * }
+ * </pre>
  * <h1 class="header">Configuration</h1>
  * {@code UriDeploymentSpi} has the following optional configuration
  * parameters (there are no mandatory parameters):
  * <ul>
  * <li>
+ * Array of {@link UriDeploymentScanner}-s which will be used to deploy resources
+ * (see {@link #setScanners(UriDeploymentScanner...)}). If not specified, preconfigured {@link UriDeploymentFileScanner}
+ * and {@link UriDeploymentHttpScanner} are used. You can implement your own scanner
+ * by implementing {@link UriDeploymentScanner} interface.
+ * </li>
+ * <li>
  * Temporary directory path where scanned GAR files and directories are
  * copied to (see {@link #setTemporaryDirectoryPath(String) setTemporaryDirectoryPath(String)}).
  * </li>
@@ -163,25 +185,28 @@ import org.jetbrains.annotations.Nullable;
  * </li>
  * </ul>
  * <h1 class="header">Protocols</h1>
- * Following protocols are supported in SPI:
+ * Following protocols are supported by this SPI out of the box:
  * <ul>
  * <li><a href="#file">file://</a> - File protocol</li>
- * <li><a href="#classes">classes://</a> - Custom File protocol.</li>
  * <li><a href="#http">http://</a> - HTTP protocol</li>
  * <li><a href="#http">https://</a> - Secure HTTP protocol</li>
  * </ul>
+ * <strong>Custom Protocols.</strong>
+ * <p>
+ * You can add support for additional protocols if needed. To do this implement UriDeploymentScanner interface and
+ * plug your implementation into the SPI via {@link #setScanners(UriDeploymentScanner...)} method.
+ * <p>
  * In addition to SPI configuration parameters, all necessary configuration
  * parameters for selected URI should be defined in URI. Different protocols
  * have different configuration parameters described below. Parameters are
  * separated by '{@code ;}' character.
  * <p>
- * <a name="file"></a>
  * <h1 class="header">File</h1>
  * For this protocol SPI will scan folder specified by URI on file system and
  * download any GAR files or directories that end with .gar from source
  * directory defined in URI. For file system URI must have scheme equal to {@code file}.
  * <p>
- * Following parameters are supported for FILE protocol:
+ * Following parameters are supported:
  * <table class="doctable">
  *  <tr>
  *      <th>Parameter</th>
@@ -189,24 +214,29 @@ import org.jetbrains.annotations.Nullable;
  *      <th>Optional</th>
  *      <th>Default</th>
  *  </tr>
+ *  <tr>
+ *      <td>freq</td>
+ *      <td>Scanning frequency in milliseconds.</td>
+ *      <td>Yes</td>
+ *      <td>{@code 5000} ms specified in {@link UriDeploymentFileScanner#DFLT_SCAN_FREQ}.</td>
+ *  </tr>
  * </table>
  * <h2 class="header">File URI Example</h2>
  * The following example will scan {@code 'c:/Program files/ignite/deployment'}
- * folder on local box every {@code '5000'} milliseconds. Note that since path
+ * folder on local box every {@code '1000'} milliseconds. Note that since path
  * has spaces, {@link #setEncodeUri(boolean) setEncodeUri(boolean)} parameter must
  * be set to {@code true} (which is default behavior).
  * <blockquote class="snippet">
- * {@code file://freq=5000@localhost/c:/Program files/ignite/deployment}
+ * {@code file://freq=2000@localhost/c:/Program files/ignite/deployment}
  * </blockquote>
  * <a name="classes"></a>
- * <h1 class="header">Classes</h1>
- * For this protocol SPI will scan folder specified by URI on file system
- * looking for compiled classes that implement {@link org.apache.ignite.compute.ComputeTask} interface.
- * This protocol comes very handy during development, as it allows developer
- * to specify IDE compilation output folder as URI and all task classes
- * in that folder will be deployed automatically.
+ * <h2 class="header">HTTP/HTTPS</h2>
+ * URI deployment scanner tries to read DOM of the html it points to and parses out href attributes of all &lt;a&gt; tags
+ * - this becomes the collection of URLs to GAR files that should be deployed. It's important that HTTP scanner
+ * uses {@code URLConnection.getLastModified()} method to check if there were any changes since last iteration
+ * for each GAR-file before redeploying.
  * <p>
- * Following parameters are supported for CLASSES protocol:
+ * Following parameters are supported:
  * <table class="doctable">
  *  <tr>
  *      <th>Parameter</th>
@@ -214,20 +244,17 @@ import org.jetbrains.annotations.Nullable;
  *      <th>Optional</th>
  *      <th>Default</th>
  *  </tr>
+ *  <tr>
+ *      <td>freq</td>
+ *      <td>Scanning frequency in milliseconds.</td>
+ *      <td>Yes</td>
+ *      <td>{@code 300000} ms specified in {@link UriDeploymentHttpScanner#DFLT_SCAN_FREQ}.</td>
+ *  </tr>
  * </table>
- * <h2 class="header">Classes URI Example</h2>
- * The following example will scan {@code 'c:/Program files/ignite/deployment'}
- * folder on local box every {@code '5000'} milliseconds. Note that since path
- * has spaces, {@link #setEncodeUri(boolean) setEncodeUri(boolean)} parameter must
- * be set to {@code true} (which is default behavior).
- * <blockquote class="snippet">
- * {@code classes://freq=5000@localhost/c:/Program files/ignite/deployment}
- * </blockquote>
- * <a name="http"></a>
  * <h2 class="header">HTTP URI Example</h2>
- * The following example will scan {@code 'ignite/deployment'} folder with
- * on site {@code 'www.mysite.com'} using authentication
- * {@code 'username:password'} every {@code '10000'} milliseconds.
+ * The following example will download the page `www.mysite.com/ignite/deployment`, parse it and download and deploy
+ * all GAR files specified by href attributes of &lt;a&gt; elements on the page using authentication
+ * {@code 'username:password'} every '10000' milliseconds (only new/updated GAR-s).
  * <blockquote class="snippet">
  * {@code http://username:password;freq=10000@www.mysite.com:110/ignite/deployment}
  * </blockquote>
@@ -238,14 +265,9 @@ import org.jetbrains.annotations.Nullable;
  *
  * IgniteConfiguration cfg = new IgniteConfiguration();
  *
- * List&lt;String&gt; uris = new ArrayList&lt;String&gt;(5);
- *
- * uris.add("http://www.site.com/tasks");
- * uris.add("file://freq=20000@localhost/c:/Program files/gg-deployment");
- * uris.add("classes:///c:/Java_Projects/myproject/out");
- *
  * // Set URIs.
- * deploySpi.setUriList(uris);
+ * deploySpi.setUriList(Arrays.asList("http://www.site.com/tasks",
+ *     "file://freq=20000@localhost/c:/Program files/gg-deployment"));
  *
  * // Override temporary directory path.
  * deploySpi.setTemporaryDirectoryPath("c:/tmp/grid");
@@ -254,7 +276,7 @@ import org.jetbrains.annotations.Nullable;
  * cfg.setDeploymentSpi(deploySpi);
  *
  * //  Start grid.
- * G.start(cfg);
+ * Ignition.start(cfg);
  * </pre>
  * <p>
  * <h2 class="header">Spring Example</h2>
@@ -269,7 +291,6 @@ import org.jetbrains.annotations.Nullable;
  *                     &lt;list&gt;
  *                         &lt;value&gt;http://www.site.com/tasks&lt;/value&gt;
  *                         &lt;value&gt;file://freq=20000@localhost/c:/Program files/gg-deployment&lt;/value&gt;
- *                         &lt;value&gt;classes:///c:/Java_Projects/myproject/out&lt;/value&gt;
  *                     &lt;/list&gt;
  *                 &lt;/property&gt;
  *             &lt;/bean&gt;
@@ -1325,4 +1346,4 @@ public class UriDeploymentSpi extends IgniteSpiAdapter implements DeploymentSpi,
     @Override public String toString() {
         return S.toString(UriDeploymentSpi.class, this);
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/02b59e43/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/http/UriDeploymentHttpScanner.java
----------------------------------------------------------------------
diff --git a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/http/UriDeploymentHttpScanner.java b/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/http/UriDeploymentHttpScanner.java
index ef29752..48bfd7f 100644
--- a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/http/UriDeploymentHttpScanner.java
+++ b/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/scanners/http/UriDeploymentHttpScanner.java
@@ -60,11 +60,15 @@ import org.w3c.dom.NodeList;
 import org.w3c.tidy.Tidy;
 
 /**
- * URI deployment HTTP scanner.
+ * HTTP-based URI deployment scanner.
+ * <p>
+ * This scanner reads DOM of the HTML available via {@link UriDeploymentScannerContext#getUri()}
+ * and parses out href attributes of all {@code &lt;a&gt;} tags -
+ * they become the collection of URLs to GAR files that should be deployed.
  */
 public class UriDeploymentHttpScanner implements UriDeploymentScanner {
     /** Default scan frequency. */
-    private static final int DFLT_SCAN_FREQ = 300000;
+    public static final int DFLT_SCAN_FREQ = 300000;
 
     /** Secure socket protocol to use. */
     private static final String PROTOCOL = "TLS";
@@ -501,4 +505,4 @@ public class UriDeploymentHttpScanner implements UriDeploymentScanner {
             return true;
         }
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/02b59e43/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/scanners/http/GridHttpDeploymentSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/scanners/http/GridHttpDeploymentSelfTest.java b/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/scanners/http/GridHttpDeploymentSelfTest.java
index 216d0ab..c0044c3 100644
--- a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/scanners/http/GridHttpDeploymentSelfTest.java
+++ b/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/scanners/http/GridHttpDeploymentSelfTest.java
@@ -17,6 +17,8 @@
 
 package org.apache.ignite.spi.deployment.uri.scanners.http;
 
+import java.io.File;
+import java.io.IOException;
 import java.util.Collections;
 import java.util.List;
 import javax.servlet.http.HttpServletResponse;
@@ -38,8 +40,35 @@ import static org.eclipse.jetty.http.HttpHeader.LAST_MODIFIED;
  */
 @GridSpiTest(spi = UriDeploymentSpi.class, group = "Deployment SPI")
 public class GridHttpDeploymentSelfTest extends GridUriDeploymentAbstractSelfTest {
+    /** Frequency */
+    private static final int FREQ = 5000;
+
+    /** */
+    public static final String LIBS_GAR = "libs-file.gar";
+
+    /** */
+    public static final String CLASSES_GAR = "classes-file.gar";
+
+    /** */
+    public static final String ALL_GAR = "file.gar";
+
+    /** Gar-file which contains libs. */
+    public static final String LIBS_GAR_FILE_PATH = U.resolveIgnitePath(
+        GridTestProperties.getProperty("ant.urideployment.gar.libs-file")).getPath();
+
+    /** Gar-file which contains classes (cannot be used without libs). */
+    public static final String CLASSES_GAR_FILE_PATH = U.resolveIgnitePath(
+        GridTestProperties.getProperty("ant.urideployment.gar.classes-file")).getPath();
+
+    /** Gar-file which caontains both libs and classes. */
+    public static final String ALL_GAR_FILE_PATH = U.resolveIgnitePath(
+        GridTestProperties.getProperty("ant.urideployment.gar.file")).getPath();
+
     /** Jetty. */
-    private Server srv;
+    private static Server srv;
+
+    /** Resource base. */
+    private static String rsrcBase;
 
     /** {@inheritDoc} */
     @Override protected void beforeSpiStarted() throws Exception {
@@ -60,8 +89,12 @@ public class GridHttpDeploymentSelfTest extends GridUriDeploymentAbstractSelfTes
         };
 
         hnd.setDirectoriesListed(true);
-        hnd.setResourceBase(
-            U.resolveIgnitePath(GridTestProperties.getProperty("ant.urideployment.gar.path")).getPath());
+
+        File resourseBaseDir = U.resolveIgnitePath(GridTestProperties.getProperty("ant.urideployment.gar.path.tmp"));
+
+        rsrcBase = resourseBaseDir.getPath();
+
+        hnd.setResourceBase(rsrcBase);
 
         srv.setHandler(hnd);
 
@@ -82,11 +115,63 @@ public class GridHttpDeploymentSelfTest extends GridUriDeploymentAbstractSelfTes
     }
 
     /**
-     * @throws Exception if failed.
+     * @throws Exception If failed.
      */
-    public void testDeployment() throws Exception {
-        checkTask("org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestTask3");
-        checkTask("GridUriDeploymentTestWithNameTask3");
+    public void testDeployUndeploy2Files() throws Exception {
+        checkNoTask("org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestTask3");
+
+        try {
+            copyToResourceBase(LIBS_GAR_FILE_PATH, LIBS_GAR);
+
+            copyToResourceBase(CLASSES_GAR_FILE_PATH, CLASSES_GAR);
+
+            Thread.sleep(FREQ + 3000);
+
+            checkTask("org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestTask3");
+        }
+        catch (Exception e) {
+            e.printStackTrace();
+        }
+        finally {
+            deleteFromResourceBase(LIBS_GAR);
+            deleteFromResourceBase(CLASSES_GAR);
+
+            Thread.sleep(FREQ + 3000);
+
+            checkNoTask("org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestTask3");
+        }
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testSameContantFiles() throws Exception {
+        checkNoTask("org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestTask3");
+
+        try {
+            copyToResourceBase(ALL_GAR_FILE_PATH, ALL_GAR);
+
+            Thread.sleep(FREQ + 3000);
+
+            checkTask("org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestTask3");
+
+            copyToResourceBase(ALL_GAR_FILE_PATH, "file-copy.gar");
+
+            Thread.sleep(FREQ + 3000);
+
+            checkTask("org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestTask3");
+        }
+        catch (Throwable e) {
+            e.printStackTrace();
+        }
+        finally {
+            deleteFromResourceBase(ALL_GAR);
+            deleteFromResourceBase("file-copy.gar");
+
+            Thread.sleep(FREQ + 3000);
+
+            checkNoTask("org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestTask3");
+        }
     }
 
     /**
@@ -94,6 +179,35 @@ public class GridHttpDeploymentSelfTest extends GridUriDeploymentAbstractSelfTes
      */
     @GridSpiTestConfig
     public List<String> getUriList() {
-        return Collections.singletonList("http://freq=5000@localhost:8080/");
+        return Collections.singletonList("http://freq="+FREQ+"@localhost:8080/");
+    }
+
+    /**
+     * @param fileName File name.
+     */
+    private void deleteFromResourceBase(String fileName) {
+        File file = new File(rsrcBase + '/' + fileName);
+
+        if (!file.delete())
+            U.warn(log, "Could not delete file: " + file);
+    }
+
+    /**
+     * @param path Path to the file which should be copied.
+     * @param newFileName New file name.
+     * @throws IOException If exception.
+     */
+    private void copyToResourceBase(String path, String newFileName) throws IOException {
+        File file = new File(path);
+
+        assert file.exists() : "Test file not found [path=" + path + ']';
+
+        File newFile = new File(rsrcBase + '/' + newFileName);
+
+        assert !newFile.exists();
+
+        U.copy(file, newFile, false);
+
+        assert newFile.exists();
     }
-}
\ No newline at end of file
+}


[41/50] [abbrv] ignite git commit: Muted test IgniteCacheClientNodeChangingTopologyTest.testAtomicClockPutAllMultinode

Posted by ag...@apache.org.
Muted test IgniteCacheClientNodeChangingTopologyTest.testAtomicClockPutAllMultinode


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

Branch: refs/heads/ignite-1016
Commit: 75fb19deec4a4dfec8d93a27008faa1c90ebb780
Parents: 10ef06a
Author: ashutak <as...@gridgain.com>
Authored: Tue Oct 20 13:32:43 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Tue Oct 20 13:32:43 2015 +0300

----------------------------------------------------------------------
 .../distributed/IgniteCacheClientNodeChangingTopologyTest.java   | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/75fb19de/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeChangingTopologyTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeChangingTopologyTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeChangingTopologyTest.java
index 1b3dc7a..b6e86f2 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeChangingTopologyTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeChangingTopologyTest.java
@@ -1413,6 +1413,8 @@ public class IgniteCacheClientNodeChangingTopologyTest extends GridCommonAbstrac
      * @throws Exception If failed.
      */
     public void testAtomicClockPutAllMultinode() throws Exception {
+        fail("https://issues.apache.org/jira/browse/IGNITE-1685");
+
         multinode(CLOCK, TestType.PUT_ALL);
     }
 
@@ -1840,4 +1842,4 @@ public class IgniteCacheClientNodeChangingTopologyTest extends GridCommonAbstrac
         /** */
         LOCK
     }
-}
\ No newline at end of file
+}


[42/50] [abbrv] ignite git commit: IGNITE-1740: Node id in IGFS file lock id.

Posted by ag...@apache.org.
IGNITE-1740: Node id in IGFS file lock id.


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

Branch: refs/heads/ignite-1016
Commit: f619e094356959cf749243989e3c3c17daf93d50
Parents: 75fb19d
Author: iveselovskiy <iv...@gridgain.com>
Authored: Tue Oct 20 15:49:21 2015 +0300
Committer: thatcoach <pp...@list.ru>
Committed: Tue Oct 20 15:49:21 2015 +0300

----------------------------------------------------------------------
 .../ignite/internal/processors/igfs/IgfsMetaManager.java  | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/f619e094/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
index c016e46..e75fe51 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
@@ -526,7 +526,7 @@ public class IgfsMetaManager extends IgfsManager {
      * @return New file info with lock set, or null if the info passed in is already locked.
      * @throws IgniteCheckedException In case lock is already set on that file.
      */
-    private static @Nullable IgfsFileInfo lockInfo(IgfsFileInfo info, boolean isDeleteLock) {
+    private @Nullable IgfsFileInfo lockInfo(IgfsFileInfo info, boolean isDeleteLock) {
          assert info != null;
 
          if (info.lockId() != null)
@@ -537,12 +537,16 @@ public class IgfsMetaManager extends IgfsManager {
 
     /**
      * Gets a new lock id.
+     * The returned Id #globalId() method will return the Id of the node which locked the file.
      *
      * @param isDeleteLock if this is special delete lock.
      * @return The new lock id.
      */
-    private static IgniteUuid composeLockId(boolean isDeleteLock) {
-        return isDeleteLock ? DELETE_LOCK_ID : IgniteUuid.randomUuid();
+    private IgniteUuid composeLockId(boolean isDeleteLock) {
+        if (isDeleteLock)
+            return DELETE_LOCK_ID;
+
+        return IgniteUuid.fromUuid(locNode.id());
     }
 
     /**


[24/50] [abbrv] ignite git commit: ignite-1635, ignite-1616 Added unit-tests for the bugs.

Posted by ag...@apache.org.
ignite-1635, ignite-1616 Added unit-tests for the bugs.


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

Branch: refs/heads/ignite-1016
Commit: 077af17f7e62ed1c4d0f699c9fd39b9d8161ae1f
Parents: 3a29b97
Author: ashutak <as...@gridgain.com>
Authored: Thu Oct 15 16:58:23 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Thu Oct 15 16:58:23 2015 +0300

----------------------------------------------------------------------
 .../CacheAbstractRestartSelfTest.java           | 247 +++++++++++++++++++
 ...NearDisabledAtomicInvokeRestartSelfTest.java | 179 ++++++++++++++
 ...abledTransactionalInvokeRestartSelfTest.java | 173 +++++++++++++
 ...edTransactionalWriteReadRestartSelfTest.java | 124 ++++++++++
 .../IgniteCacheLoadConsistencyTestSuite.java    |  42 ++++
 5 files changed, 765 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/077af17f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAbstractRestartSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAbstractRestartSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAbstractRestartSelfTest.java
new file mode 100644
index 0000000..7537af1
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAbstractRestartSelfTest.java
@@ -0,0 +1,247 @@
+/*
+* 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;
+
+import java.util.ArrayList;
+import java.util.concurrent.Callable;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ThreadLocalRandom;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.processors.cache.IgniteCacheAbstractTest;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
+import org.apache.ignite.testframework.GridTestUtils;
+
+/**
+ * Abstract restart test.
+ */
+public abstract class CacheAbstractRestartSelfTest extends IgniteCacheAbstractTest {
+    /** */
+    private volatile CountDownLatch cacheCheckedLatch = new CountDownLatch(1);
+
+    /** */
+    private final ReentrantReadWriteLock rwl = new ReentrantReadWriteLock(true);
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        if (gridName.equals(getTestGridName(gridCount() - 1)))
+            cfg.setClientMode(true);
+
+        cfg.setPeerClassLoadingEnabled(false);
+
+        ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1);
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected long getTestTimeout() {
+        return 8 * 60_000;
+    }
+
+    /**
+     * @return Number of updaters threads.
+     */
+    protected int updatersNumber() {
+        return 64;
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testRestart() throws Exception {
+        final int clientGrid = gridCount() - 1;
+
+        assertTrue(ignite(clientGrid).configuration().isClientMode());
+
+        final IgniteEx grid = grid(clientGrid);
+
+        final IgniteCache cache = jcache(clientGrid);
+
+        updateCache(grid, cache);
+
+        final AtomicBoolean stop = new AtomicBoolean();
+
+        ArrayList<IgniteInternalFuture> updaterFuts = new ArrayList<>();
+
+        for (int i = 0; i < updatersNumber(); i++) {
+            final int threadIdx = i;
+
+            IgniteInternalFuture<?> updateFut = GridTestUtils.runAsync(new Callable<Void>() {
+                @Override public Void call() throws Exception {
+                    Thread.currentThread().setName("update-thread-" + threadIdx);
+
+                    assertTrue(cacheCheckedLatch.await(30_000, TimeUnit.MILLISECONDS));
+
+                    int iter = 0;
+
+                    while (!stop.get()) {
+                        log.info("Start update: " + iter);
+
+                        rwl.readLock().lock();
+
+                        try {
+                            updateCache(grid, cache);
+                        }
+                        finally {
+                            rwl.readLock().unlock();
+                        }
+
+                        log.info("End update: " + iter++);
+                    }
+
+                    log.info("Update iterations: " + iter);
+
+                    return null;
+                }
+            });
+
+            updaterFuts.add(updateFut);
+        }
+
+        IgniteInternalFuture<?> restartFut = GridTestUtils.runAsync(new Callable<Void>() {
+            @Override public Void call() throws Exception {
+                Thread.currentThread().setName("restart-thread");
+
+                ThreadLocalRandom rnd = ThreadLocalRandom.current();
+
+                while (!stop.get()) {
+                    assertTrue(cacheCheckedLatch.await(30_000, TimeUnit.MILLISECONDS));
+
+                    int node = rnd.nextInt(0, gridCount() - 1);
+
+                    log.info("Stop node: " + node);
+
+                    stopGrid(node);
+
+                    U.sleep(restartSleep());
+
+                    log.info("Start node: " + node);
+
+                    startGrid(node);
+
+                    cacheCheckedLatch = new CountDownLatch(1);
+
+                    U.sleep(restartDelay());
+
+                    awaitPartitionMapExchange();
+                }
+
+                return null;
+            }
+        });
+
+        long endTime = System.currentTimeMillis() + getTestDuration();
+
+        try {
+            int iter = 0;
+
+            while (System.currentTimeMillis() < endTime && !isAnyDone(updaterFuts) && !restartFut.isDone()) {
+                try {
+                    log.info("Start of cache checking: " + iter);
+
+                    rwl.writeLock().lock();
+
+                    try {
+                        checkCache(grid, cache);
+                    }
+                    finally {
+                        rwl.writeLock().unlock();
+                    }
+
+                    log.info("End of cache checking: " + iter++);
+                }
+                finally {
+                    cacheCheckedLatch.countDown();
+                }
+            }
+
+            log.info("Checking iteration: " + iter);
+        }
+        finally {
+            cacheCheckedLatch.countDown();
+
+            stop.set(true);
+        }
+
+        for (IgniteInternalFuture fut : updaterFuts)
+            fut.get();
+
+        restartFut.get();
+
+        checkCache(grid, cache);
+    }
+
+    /**
+     * @return Test duration.
+     * @see #getTestTimeout()
+     */
+    protected int getTestDuration() {
+        return 60_000;
+    }
+
+    /**
+     * @return Restart sleep in milliseconds.
+     */
+    private int restartSleep() {
+        return 100;
+    }
+
+    /**
+     * @return Restart delay in milliseconds.
+     */
+    private int restartDelay() {
+        return 100;
+    }
+
+    /**
+     * Checks cache in one thread. All update operations are not executed.
+     *
+     * @param cache Cache.
+     */
+    protected abstract void checkCache(IgniteEx grid, IgniteCache cache) throws Exception ;
+
+    /**
+     * Updates cache in many threads.
+     *
+     * @param grid Grid.
+     * @param cache Cache.
+     */
+    protected abstract void updateCache(IgniteEx grid, IgniteCache cache) throws Exception ;
+
+    /**
+     * @param futs Futers.
+     * @return {@code True} if all futures are done.
+     */
+    private static boolean isAnyDone(ArrayList<IgniteInternalFuture> futs) {
+        for (IgniteInternalFuture fut : futs) {
+            if (fut.isDone())
+                return true;
+        }
+
+        return false;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/077af17f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNearDisabledAtomicInvokeRestartSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNearDisabledAtomicInvokeRestartSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNearDisabledAtomicInvokeRestartSelfTest.java
new file mode 100644
index 0000000..90427f5
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNearDisabledAtomicInvokeRestartSelfTest.java
@@ -0,0 +1,179 @@
+/*
+ * 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;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ThreadLocalRandom;
+import java.util.concurrent.atomic.AtomicLong;
+import javax.cache.processor.EntryProcessorException;
+import javax.cache.processor.MutableEntry;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheAtomicWriteOrderMode;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheEntryProcessor;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.configuration.NearCacheConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.U;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
+import static org.apache.ignite.cache.CacheMode.PARTITIONED;
+
+/**
+ * Invoke retry consistency test.
+ */
+public class CacheNearDisabledAtomicInvokeRestartSelfTest extends CacheAbstractRestartSelfTest {
+    /** */
+    public static final int RANGE = 50;
+
+    /** */
+    private static final long FIRST_VAL = 1;
+
+    /** */
+    private final ConcurrentMap<String, AtomicLong> nextValMap = new ConcurrentHashMap<>();
+
+    /** {@inheritDoc} */
+    @Override protected int gridCount() {
+        return 4;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected CacheMode cacheMode() {
+        return PARTITIONED;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected CacheAtomicityMode atomicityMode() {
+        return ATOMIC;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected CacheAtomicWriteOrderMode atomicWriteOrderMode() {
+        return CacheAtomicWriteOrderMode.PRIMARY;
+    }
+
+    /** */
+    @Override protected NearCacheConfiguration nearConfiguration() {
+        return null;
+    }
+
+    /** {@inheritDoc} */
+    protected void checkCache(IgniteEx ignite, IgniteCache cache) throws Exception {
+        log.info("Start cache validation.");
+
+        long startTime = U.currentTimeMillis();
+
+        Map<String, Set> badCacheEntries = new HashMap<>();
+
+        for (Map.Entry<String, AtomicLong> e : nextValMap.entrySet()) {
+            String key = e.getKey();
+
+            Set set = (Set)cache.get(key);
+
+            if (set == null || e.getValue() == null || !Objects.equals(e.getValue().get(), (long)set.size()))
+                badCacheEntries.put(key, set);
+        }
+
+        if (!badCacheEntries.isEmpty()) {
+            // Print all usefull information and finish.
+            for (Map.Entry<String, Set> e : badCacheEntries.entrySet()) {
+                String key = e.getKey();
+
+                U.error(log, "Got unexpected set size [key='" + key + "', expSize=" + nextValMap.get(key)
+                    + ", cacheVal=" + e.getValue() + "]");
+            }
+
+            log.info("Next values map contant:");
+            for (Map.Entry<String, AtomicLong> e : nextValMap.entrySet())
+                log.info("Map Entry [key=" + e.getKey() + ", val=" + e.getValue() + "]");
+
+            log.info("Cache content:");
+
+            for (int k2 = 0; k2 < RANGE; k2++) {
+                String key2 = "key-" + k2;
+
+                Object val = cache.get(key2);
+
+                if (val != null)
+                    log.info("Cache Entry [key=" + key2 + ", val=" + val + "]");
+
+            }
+
+            fail("Cache and local map are in inconsistent state [badKeys=" + badCacheEntries.keySet() + ']');
+        }
+
+        log.info("Clearing all data.");
+
+        cache.removeAll();
+        nextValMap.clear();
+
+        log.info("Cache validation successfully finished in "
+            + (U.currentTimeMillis() - startTime) / 1000 + " sec.");
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void updateCache(IgniteEx ignite, IgniteCache cache) {
+        final int k = ThreadLocalRandom.current().nextInt(RANGE);
+
+        String key = "key-" + k;
+
+        AtomicLong nextAtomicVal = nextValMap.putIfAbsent(key, new AtomicLong(FIRST_VAL));
+
+        Long nextVal = FIRST_VAL;
+
+        if (nextAtomicVal != null)
+            nextVal = nextAtomicVal.incrementAndGet();
+
+        cache.invoke(key, new AddInSetEntryProcessor(), nextVal);
+    }
+
+    /**
+     */
+    private static class AddInSetEntryProcessor implements CacheEntryProcessor<String, Set, Object> {
+        /** */
+        private static final long serialVersionUID = 0;
+
+        /** {@inheritDoc} */
+        @Override public Object process(MutableEntry<String, Set> entry,
+            Object... arguments) throws EntryProcessorException {
+            assert !F.isEmpty(arguments);
+
+            Object val = arguments[0];
+
+            Set set;
+
+            if (!entry.exists())
+                set = new HashSet<>();
+            else
+                set = entry.getValue();
+
+            set.add(val);
+
+            entry.setValue(set);
+
+            return null;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/077af17f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNearDisabledTransactionalInvokeRestartSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNearDisabledTransactionalInvokeRestartSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNearDisabledTransactionalInvokeRestartSelfTest.java
new file mode 100644
index 0000000..f4eea6c
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNearDisabledTransactionalInvokeRestartSelfTest.java
@@ -0,0 +1,173 @@
+/*
+ * 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;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ThreadLocalRandom;
+import java.util.concurrent.atomic.AtomicLong;
+import javax.cache.processor.EntryProcessorException;
+import javax.cache.processor.MutableEntry;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheEntryProcessor;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.configuration.NearCacheConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.util.typedef.internal.U;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheMode.PARTITIONED;
+
+/**
+ * Invoke retry consistency test.
+ */
+public class CacheNearDisabledTransactionalInvokeRestartSelfTest extends CacheAbstractRestartSelfTest {
+    /** */
+    public static final int RANGE = 100;
+
+    /** */
+    private static final int KEYS_CNT = 5;
+
+    /** */
+    protected final ConcurrentMap<String, AtomicLong> map = new ConcurrentHashMap<>();
+
+    /** {@inheritDoc} */
+    @Override protected int gridCount() {
+        return 4;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected CacheMode cacheMode() {
+        return PARTITIONED;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected CacheAtomicityMode atomicityMode() {
+        return TRANSACTIONAL;
+    }
+
+    /** */
+    @Override protected NearCacheConfiguration nearConfiguration() {
+        return null;
+    }
+
+    /** {@inheritDoc} */
+    protected void checkCache(IgniteEx ignite, IgniteCache cache) {
+        log.info("Start cache validation.");
+
+        long startTime = U.currentTimeMillis();
+
+        Map<String, Long> notEqualsCacheVals = new HashMap<>();
+        Map<String, Long> notEqualsLocMapVals = new HashMap<>();
+
+        for (int k = 0; k < RANGE; k++) {
+            if (k % 10_000 == 0)
+                log.info("Start validation for keys like 'key-" + k + "-*'");
+
+            for (int i = 0; i < KEYS_CNT; i++) {
+                String key = "key-" + k + "-" + i;
+
+                Long cacheVal = (Long)cache.get(key);
+
+                AtomicLong aVal = map.get(key);
+                Long mapVal = aVal != null ? aVal.get() : null;
+
+                if (!Objects.equals(cacheVal, mapVal)) {
+                    notEqualsCacheVals.put(key, cacheVal);
+                    notEqualsLocMapVals.put(key, mapVal);
+                }
+            }
+        }
+
+        assert notEqualsCacheVals.size() == notEqualsLocMapVals.size() : "Invalid state " +
+            "[cacheMapVals=" + notEqualsCacheVals + ", mapVals=" + notEqualsLocMapVals + "]";
+
+        if (!notEqualsCacheVals.isEmpty()) {
+            // Print all usefull information and finish.
+            for (Map.Entry<String, Long> eLocMap : notEqualsLocMapVals.entrySet()) {
+                String key = eLocMap.getKey();
+                Long mapVal = eLocMap.getValue();
+                Long cacheVal = notEqualsCacheVals.get(key);
+
+                U.error(log, "Got different values [key='" + key
+                    + "', cacheVal=" + cacheVal + ", localMapVal=" + mapVal + "]");
+            }
+
+            log.info("Local driver map contant:\n " + map);
+
+            log.info("Cache content:");
+
+            for (int k2 = 0; k2 < RANGE; k2++) {
+                for (int i2 = 0; i2 < KEYS_CNT; i2++) {
+                    String key2 = "key-" + k2 + "-" + i2;
+
+                    Long val = (Long)cache.get(key2);
+
+                    if (val != null)
+                        log.info("Entry [key=" + key2 + ", val=" + val + "]");
+                }
+            }
+
+            throw new IllegalStateException("Cache and local map are in inconsistent state [badKeys="
+                + notEqualsCacheVals.keySet() + ']');
+        }
+
+        log.info("Cache validation successfully finished in "
+            + (U.currentTimeMillis() - startTime) / 1000 + " sec.");
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void updateCache(IgniteEx ignite, IgniteCache cache) {
+        final int k = ThreadLocalRandom.current().nextInt(RANGE);
+
+        final String[] keys = new String[KEYS_CNT];
+
+        for (int i = 0; i < keys.length; i++)
+            keys[i] = "key-" + k + "-" + i;
+
+        for (String key : keys) {
+            cache.invoke(key, new IncrementCacheEntryProcessor());
+
+            AtomicLong prevVal = map.putIfAbsent(key, new AtomicLong(0));
+
+            if (prevVal != null)
+                prevVal.incrementAndGet();
+        }
+    }
+
+    /**
+     */
+    private static class IncrementCacheEntryProcessor implements CacheEntryProcessor<String, Long, Long> {
+        /** */
+        private static final long serialVersionUID = 0;
+
+        /** {@inheritDoc} */
+        @Override public Long process(MutableEntry<String, Long> entry,
+            Object... arguments) throws EntryProcessorException {
+            long newVal = entry.getValue() == null ? 0 : entry.getValue() + 1;
+
+            entry.setValue(newVal);
+
+            return newVal;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/077af17f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNearDisabledTransactionalWriteReadRestartSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNearDisabledTransactionalWriteReadRestartSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNearDisabledTransactionalWriteReadRestartSelfTest.java
new file mode 100644
index 0000000..875aef3
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNearDisabledTransactionalWriteReadRestartSelfTest.java
@@ -0,0 +1,124 @@
+/*
+ * 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;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ThreadLocalRandom;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.configuration.NearCacheConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.util.typedef.internal.U;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheMode.PARTITIONED;
+
+/**
+ * Transactional write read consistency test.
+ */
+public class CacheNearDisabledTransactionalWriteReadRestartSelfTest extends CacheAbstractRestartSelfTest{
+    /** */
+    public static final int RANGE = 100;
+
+    /** */
+    private static final int KEYS_CNT = 5;
+
+    /** {@inheritDoc} */
+    @Override protected int gridCount() {
+        return 4;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected CacheMode cacheMode() {
+        return PARTITIONED;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected CacheAtomicityMode atomicityMode() {
+        return TRANSACTIONAL;
+    }
+
+    /** */
+    @Override protected NearCacheConfiguration nearConfiguration() {
+        return null;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void checkCache(IgniteEx ignite, IgniteCache cache) {
+        // No-op.
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void updateCache(IgniteEx ignite, IgniteCache cache) throws Exception {
+        final int k = ThreadLocalRandom.current().nextInt(RANGE);
+
+        final String[] keys = new String[KEYS_CNT];
+
+        for (int i = 0; i < keys.length; i++)
+            keys[i] = "key-" + k + "-" + i;
+
+        doInTransaction(ignite, new Callable<Void>() {
+            @Override public Void call() throws Exception {
+                Map<String, Long> map = new HashMap<>();
+
+                for (String key : keys) {
+                    Long val = (Long)cache.get(key);
+
+                    map.put(key, val);
+                }
+
+                Set<Long> values = new HashSet<>(map.values());
+
+                if (values.size() != 1) {
+                    // Print all usefull information and finish.
+                    U.error(log, "Got different values for keys [map=" + map + "]");
+
+                    log.info("Cache content:");
+
+                    for (int k = 0; k < RANGE; k++) {
+                        for (int i = 0; i < KEYS_CNT; i++) {
+                            String key = "key-" + k + "-" + i;
+
+                            Long val = (Long)cache.get(key);
+
+                            if (val != null)
+                                log.info("Entry [key=" + key + ", val=" + val + "]");
+                        }
+                    }
+
+                    throw new IllegalStateException("Found different values for keys (see above information) [map="
+                        + map + ']');
+                }
+
+                final Long oldVal = map.get(keys[0]);
+
+                final Long newVal = oldVal == null ? 0 : oldVal + 1;
+
+                for (String key : keys)
+                    cache.put(key, newVal);
+
+                return null;
+            }
+        });
+    }
+}

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


[14/50] [abbrv] ignite git commit: ignite-1.4.2 - review and minor changes.

Posted by ag...@apache.org.
ignite-1.4.2 - review and minor changes.


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

Branch: refs/heads/ignite-1016
Commit: 94f549f2ff03c5f1f3eca29eb337eabf7d566cad
Parents: 155edd8
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Mon Oct 12 13:32:36 2015 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Mon Oct 12 13:32:36 2015 +0300

----------------------------------------------------------------------
 .../discovery/GridDiscoveryManager.java         | 479 +------------------
 .../processors/cache/GridCacheProcessor.java    |  40 --
 .../cache/query/GridCacheQueryManager.java      |  41 --
 .../processors/rest/GridRestProcessor.java      |  47 --
 .../top/GridTopologyCommandHandler.java         | 129 -----
 5 files changed, 1 insertion(+), 735 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/94f549f2/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 9e54f6f..6aba211 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
@@ -2842,484 +2842,7 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
         }
     }
 
-    /** Cache for discovery collections. */
-    private class DiscoCache {
-        /** Remote nodes. */
-        private final List<ClusterNode> rmtNodes;
-
-        /** All nodes. */
-        private final List<ClusterNode> allNodes;
-
-        /** All nodes with at least one cache configured. */
-        @GridToStringInclude
-        private final Collection<ClusterNode> allNodesWithCaches;
-
-        /** All nodes with at least one cache configured. */
-        @GridToStringInclude
-        private final Collection<ClusterNode> rmtNodesWithCaches;
-
-        /** Cache nodes by cache name. */
-        @GridToStringInclude
-        private final Map<String, Collection<ClusterNode>> allCacheNodes;
-
-        /** Remote cache nodes by cache name. */
-        @GridToStringInclude
-        private final Map<String, Collection<ClusterNode>> rmtCacheNodes;
-
-        /** Cache nodes by cache name. */
-        @GridToStringInclude
-        private final Map<String, Collection<ClusterNode>> affCacheNodes;
-
-        /** Caches where at least one node has near cache enabled. */
-        @GridToStringInclude
-        private final Set<String> nearEnabledCaches;
-
-        /** Nodes grouped by version. */
-        private final NavigableMap<IgniteProductVersion, Collection<ClusterNode>> nodesByVer;
-
-        /** Daemon nodes. */
-        private final List<ClusterNode> daemonNodes;
-
-        /** Node map. */
-        private final Map<UUID, ClusterNode> nodeMap;
-
-        /** Local node. */
-        private final ClusterNode loc;
-
-        /** Highest node order. */
-        private final long maxOrder;
-
-        /**
-         * Cached alive nodes list. As long as this collection doesn't accept {@code null}s use {@link
-         * #maskNull(String)} before passing raw cache names to it.
-         */
-        private final ConcurrentMap<String, Collection<ClusterNode>> aliveCacheNodes;
-
-        /**
-         * Cached alive remote nodes list. As long as this collection doesn't accept {@code null}s use {@link
-         * #maskNull(String)} before passing raw cache names to it.
-         */
-        private final ConcurrentMap<String, Collection<ClusterNode>> aliveRmtCacheNodes;
-
-        /**
-         * Cached alive remote nodes with caches.
-         */
-        private final Collection<ClusterNode> aliveNodesWithCaches;
-
-        /**
-         * Cached alive server remote nodes with caches.
-         */
-        private final Collection<ClusterNode> aliveSrvNodesWithCaches;
-
-        /**
-         * Cached alive remote server nodes with caches.
-         */
-        private final Collection<ClusterNode> aliveRmtSrvNodesWithCaches;
-
-        /**
-         * @param loc Local node.
-         * @param rmts Remote nodes.
-         */
-        private DiscoCache(ClusterNode loc, Collection<ClusterNode> rmts) {
-            this.loc = loc;
-
-            rmtNodes = Collections.unmodifiableList(new ArrayList<>(F.view(rmts, daemonFilter)));
-
-            assert !rmtNodes.contains(loc) : "Remote nodes collection shouldn't contain local node" +
-                " [rmtNodes=" + rmtNodes + ", loc=" + loc + ']';
-
-            List<ClusterNode> all = new ArrayList<>(rmtNodes.size() + 1);
-
-            if (!loc.isDaemon())
-                all.add(loc);
-
-            all.addAll(rmtNodes);
-
-            Collections.sort(all, GridNodeOrderComparator.INSTANCE);
-
-            allNodes = Collections.unmodifiableList(all);
-
-            Map<String, Collection<ClusterNode>> cacheMap = new HashMap<>(allNodes.size(), 1.0f);
-            Map<String, Collection<ClusterNode>> rmtCacheMap = new HashMap<>(allNodes.size(), 1.0f);
-            Map<String, Collection<ClusterNode>> dhtNodesMap = new HashMap<>(allNodes.size(), 1.0f);
-            Collection<ClusterNode> nodesWithCaches = new HashSet<>(allNodes.size());
-            Collection<ClusterNode> rmtNodesWithCaches = new HashSet<>(allNodes.size());
-
-            aliveCacheNodes = new ConcurrentHashMap8<>(allNodes.size(), 1.0f);
-            aliveRmtCacheNodes = new ConcurrentHashMap8<>(allNodes.size(), 1.0f);
-            aliveNodesWithCaches = new ConcurrentSkipListSet<>();
-            aliveSrvNodesWithCaches = new ConcurrentSkipListSet<>();
-            aliveRmtSrvNodesWithCaches = new ConcurrentSkipListSet<>();
-            nodesByVer = new TreeMap<>();
-
-            long maxOrder0 = 0;
-
-            Set<String> nearEnabledSet = new HashSet<>();
-
-            for (ClusterNode node : allNodes) {
-                assert node.order() != 0 : "Invalid node order [locNode=" + loc + ", node=" + node + ']';
-
-                if (node.order() > maxOrder0)
-                    maxOrder0 = node.order();
-
-                boolean hasCaches = false;
-
-                for (Map.Entry<String, CachePredicate> entry : registeredCaches.entrySet()) {
-                    String cacheName = entry.getKey();
-
-                    CachePredicate filter = entry.getValue();
-
-                    if (filter.cacheNode(node)) {
-                        nodesWithCaches.add(node);
-
-                        if (!loc.id().equals(node.id()))
-                            rmtNodesWithCaches.add(node);
-
-                        addToMap(cacheMap, cacheName, node);
-
-                        if (alive(node.id()))
-                            addToMap(aliveCacheNodes, maskNull(cacheName), node);
-
-                        if (filter.dataNode(node))
-                            addToMap(dhtNodesMap, cacheName, node);
-
-                        if (filter.nearNode(node))
-                            nearEnabledSet.add(cacheName);
-
-                        if (!loc.id().equals(node.id())) {
-                            addToMap(rmtCacheMap, cacheName, node);
-
-                            if (alive(node.id()))
-                                addToMap(aliveRmtCacheNodes, maskNull(cacheName), node);
-                        }
-
-                        hasCaches = true;
-                    }
-                }
-
-                if (hasCaches) {
-                    if (alive(node.id())) {
-                        aliveNodesWithCaches.add(node);
-
-                        if (!CU.clientNode(node)) {
-                            aliveSrvNodesWithCaches.add(node);
-
-                            if (!loc.id().equals(node.id()))
-                                aliveRmtSrvNodesWithCaches.add(node);
-                        }
-                    }
-                }
-
-                IgniteProductVersion nodeVer = U.productVersion(node);
-
-                // Create collection for this version if it does not exist.
-                Collection<ClusterNode> nodes = nodesByVer.get(nodeVer);
-
-                if (nodes == null) {
-                    nodes = new ArrayList<>(allNodes.size());
-
-                    nodesByVer.put(nodeVer, nodes);
-                }
-
-                nodes.add(node);
-            }
-
-            // Need second iteration to add this node to all previous node versions.
-            for (ClusterNode node : allNodes) {
-                IgniteProductVersion nodeVer = U.productVersion(node);
-
-                // Get all versions lower or equal node's version.
-                NavigableMap<IgniteProductVersion, Collection<ClusterNode>> updateView =
-                    nodesByVer.headMap(nodeVer, false);
-
-                for (Collection<ClusterNode> prevVersions : updateView.values())
-                    prevVersions.add(node);
-            }
-
-            maxOrder = maxOrder0;
-
-            allCacheNodes = Collections.unmodifiableMap(cacheMap);
-            rmtCacheNodes = Collections.unmodifiableMap(rmtCacheMap);
-            affCacheNodes = Collections.unmodifiableMap(dhtNodesMap);
-            allNodesWithCaches = Collections.unmodifiableCollection(nodesWithCaches);
-            this.rmtNodesWithCaches = Collections.unmodifiableCollection(rmtNodesWithCaches);
-            nearEnabledCaches = Collections.unmodifiableSet(nearEnabledSet);
-
-            daemonNodes = Collections.unmodifiableList(new ArrayList<>(
-                F.view(F.concat(false, loc, rmts), F0.not(daemonFilter))));
-
-            Map<UUID, ClusterNode> nodeMap = new HashMap<>(allNodes().size() + daemonNodes.size(), 1.0f);
-
-            for (ClusterNode n : F.concat(false, allNodes(), daemonNodes()))
-                nodeMap.put(n.id(), n);
-
-            this.nodeMap = nodeMap;
-        }
-
-        /**
-         * Adds node to map.
-         *
-         * @param cacheMap Map to add to.
-         * @param cacheName Cache name.
-         * @param rich Node to add
-         */
-        private void addToMap(Map<String, Collection<ClusterNode>> cacheMap, String cacheName, ClusterNode rich) {
-            Collection<ClusterNode> cacheNodes = cacheMap.get(cacheName);
-
-            if (cacheNodes == null) {
-                cacheNodes = new ArrayList<>(allNodes.size());
-
-                cacheMap.put(cacheName, cacheNodes);
-            }
-
-            cacheNodes.add(rich);
-        }
-
-        /** @return Local node. */
-        ClusterNode localNode() {
-            return loc;
-        }
-
-        /** @return Remote nodes. */
-        Collection<ClusterNode> remoteNodes() {
-            return rmtNodes;
-        }
-
-        /** @return All nodes. */
-        Collection<ClusterNode> allNodes() {
-            return allNodes;
-        }
-
-        /**
-         * Gets collection of nodes which have version equal or greater than {@code ver}.
-         *
-         * @param ver Version to check.
-         * @return Collection of nodes with version equal or greater than {@code ver}.
-         */
-        Collection<ClusterNode> elderNodes(IgniteProductVersion ver) {
-            Map.Entry<IgniteProductVersion, Collection<ClusterNode>> entry = nodesByVer.ceilingEntry(ver);
-
-            if (entry == null)
-                return Collections.emptyList();
-
-            return entry.getValue();
-        }
-
-        /**
-         * @return Versions map.
-         */
-        NavigableMap<IgniteProductVersion, Collection<ClusterNode>> versionsMap() {
-            return nodesByVer;
-        }
-
-        /**
-         * Gets collection of nodes with at least one cache configured.
-         *
-         * @param topVer Topology version (maximum allowed node order).
-         * @return Collection of nodes.
-         */
-        Collection<ClusterNode> allNodesWithCaches(final long topVer) {
-            return filter(topVer, allNodesWithCaches);
-        }
-
-        /**
-         * Gets all nodes that have cache with given name.
-         *
-         * @param cacheName Cache name.
-         * @param topVer Topology version.
-         * @return Collection of nodes.
-         */
-        Collection<ClusterNode> cacheNodes(@Nullable String cacheName, final long topVer) {
-            return filter(topVer, allCacheNodes.get(cacheName));
-        }
-
-        /**
-         * Gets all remote nodes that have cache with given name.
-         *
-         * @param cacheName Cache name.
-         * @param topVer Topology version.
-         * @return Collection of nodes.
-         */
-        Collection<ClusterNode> remoteCacheNodes(@Nullable String cacheName, final long topVer) {
-            return filter(topVer, rmtCacheNodes.get(cacheName));
-        }
-
-        /**
-         * Gets all remote nodes that have at least one cache configured.
-         *
-         * @param topVer Topology version.
-         * @return Collection of nodes.
-         */
-        Collection<ClusterNode> remoteCacheNodes(final long topVer) {
-            return filter(topVer, rmtNodesWithCaches);
-        }
-
-        /**
-         * Gets all nodes that have cache with given name and should participate in affinity calculation. With
-         * partitioned cache nodes with near-only cache do not participate in affinity node calculation.
-         *
-         * @param cacheName Cache name.
-         * @param topVer Topology version.
-         * @return Collection of nodes.
-         */
-        Collection<ClusterNode> cacheAffinityNodes(@Nullable String cacheName, final long topVer) {
-            return filter(topVer, affCacheNodes.get(cacheName));
-        }
-
-        /**
-         * Gets all alive nodes that have cache with given name.
-         *
-         * @param cacheName Cache name.
-         * @param topVer Topology version.
-         * @return Collection of nodes.
-         */
-        Collection<ClusterNode> aliveCacheNodes(@Nullable String cacheName, final long topVer) {
-            return filter(topVer, aliveCacheNodes.get(maskNull(cacheName)));
-        }
-
-        /**
-         * Gets all alive remote nodes that have cache with given name.
-         *
-         * @param cacheName Cache name.
-         * @param topVer Topology version.
-         * @return Collection of nodes.
-         */
-        Collection<ClusterNode> aliveRemoteCacheNodes(@Nullable String cacheName, final long topVer) {
-            return filter(topVer, aliveRmtCacheNodes.get(maskNull(cacheName)));
-        }
-
-        /**
-         * Gets all alive remote server nodes with at least one cache configured.
-         *
-         * @param topVer Topology version.
-         * @return Collection of nodes.
-         */
-        Collection<ClusterNode> aliveRemoteServerNodesWithCaches(final long topVer) {
-            return filter(topVer, aliveRmtSrvNodesWithCaches);
-        }
-
-        /**
-         * Gets all alive server nodes with at least one cache configured.
-         *
-         * @param topVer Topology version.
-         * @return Collection of nodes.
-         */
-        Collection<ClusterNode> aliveServerNodesWithCaches(final long topVer) {
-            return filter(topVer, aliveSrvNodesWithCaches);
-        }
-
-        /**
-         * Gets all alive remote nodes with at least one cache configured.
-         *
-         * @param topVer Topology version.
-         * @return Collection of nodes.
-         */
-        Collection<ClusterNode> aliveNodesWithCaches(final long topVer) {
-            return filter(topVer, aliveNodesWithCaches);
-        }
-
-        /**
-         * Checks if cache with given name has at least one node with near cache enabled.
-         *
-         * @param cacheName Cache name.
-         * @return {@code True} if cache with given name has at least one node with near cache enabled.
-         */
-        boolean hasNearCache(@Nullable String cacheName) {
-            return nearEnabledCaches.contains(cacheName);
-        }
-
-        /**
-         * Removes left node from cached alives lists.
-         *
-         * @param leftNode Left node.
-         */
-        void updateAlives(ClusterNode leftNode) {
-            if (leftNode.order() > maxOrder)
-                return;
-
-            filterNodeMap(aliveCacheNodes, leftNode);
-
-            filterNodeMap(aliveRmtCacheNodes, leftNode);
-
-            aliveNodesWithCaches.remove(leftNode);
-            aliveSrvNodesWithCaches.remove(leftNode);
-            aliveRmtSrvNodesWithCaches.remove(leftNode);
-        }
-
-        /**
-         * Creates a copy of nodes map without the given node.
-         *
-         * @param map Map to copy.
-         * @param exclNode Node to exclude.
-         */
-        private void filterNodeMap(ConcurrentMap<String, Collection<ClusterNode>> map, final ClusterNode exclNode) {
-            for (String cacheName : registeredCaches.keySet()) {
-                String maskedName = maskNull(cacheName);
-
-                while (true) {
-                    Collection<ClusterNode> oldNodes = map.get(maskedName);
-
-                    if (oldNodes == null || oldNodes.isEmpty())
-                        break;
-
-                    Collection<ClusterNode> newNodes = new ArrayList<>(oldNodes);
-
-                    if (!newNodes.remove(exclNode))
-                        break;
-
-                    if (map.replace(maskedName, oldNodes, newNodes))
-                        break;
-                }
-            }
-        }
-
-        /**
-         * Replaces {@code null} with {@code NULL_CACHE_NAME}.
-         *
-         * @param cacheName Cache name.
-         * @return Masked name.
-         */
-        private String maskNull(@Nullable String cacheName) {
-            return cacheName == null ? NULL_CACHE_NAME : cacheName;
-        }
-
-        /**
-         * @param topVer Topology version.
-         * @param nodes Nodes.
-         * @return Filtered collection (potentially empty, but never {@code null}).
-         */
-        private Collection<ClusterNode> filter(final long topVer, @Nullable Collection<ClusterNode> nodes) {
-            if (nodes == null)
-                return Collections.emptyList();
-
-            // If no filtering needed, return original collection.
-            return nodes.isEmpty() || topVer < 0 || topVer >= maxOrder ?
-                nodes :
-                F.view(nodes, new P1<ClusterNode>() {
-                    @Override public boolean apply(ClusterNode node) {
-                        return node.order() <= topVer;
-                    }
-                });
-        }
-
-        /** @return Daemon nodes. */
-        Collection<ClusterNode> daemonNodes() {
-            return daemonNodes;
-        }
-
-        /**
-         * @param id Node ID.
-         * @return Node.
-         */
-        @Nullable ClusterNode node(UUID id) {
-            return nodeMap.get(id);
-        }
-
-        /** {@inheritDoc} */
-        @Override public String toString() {
-            return S.toString(DiscoCache.class, this, "allNodesWithDaemons", U.toShortString(allNodes));
-        }
-    }    /**
+    /**
      * Cache predicate.
      */
     private static class CachePredicate {

http://git-wip-us.apache.org/repos/asf/ignite/blob/94f549f2/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 736e630..8c96c0c 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
@@ -3482,46 +3482,6 @@ public class GridCacheProcessor extends GridProcessorAdapter {
     /**
      *
      */
-    @SuppressWarnings("ExternalizableWithoutPublicNoArgConstructor")
-    private class TemplateConfigurationFuture extends GridFutureAdapter<Object> {
-        /** Start ID. */
-        @GridToStringInclude
-        private IgniteUuid deploymentId;
-
-        /** Cache name. */
-        private String cacheName;
-
-        /**
-         * @param cacheName Cache name.
-         * @param deploymentId Deployment ID.
-         */
-        private TemplateConfigurationFuture(String cacheName, IgniteUuid deploymentId) {
-            this.deploymentId = deploymentId;
-            this.cacheName = cacheName;
-        }
-
-        /**
-         * @return Start ID.
-         */
-        public IgniteUuid deploymentId() {
-            return deploymentId;
-        }
-
-        /** {@inheritDoc} */
-        @Override public boolean onDone(@Nullable Object res, @Nullable Throwable err) {
-            // Make sure to remove future before completion.
-            pendingTemplateFuts.remove(maskNull(cacheName), this);
-
-            return super.onDone(res, err);
-        }
-
-        /** {@inheritDoc} */
-        @Override public String toString() {
-            return S.toString(TemplateConfigurationFuture.class, this);
-        }
-    }    /**
-     *
-     */
     private static class LocalAffinityFunction implements AffinityFunction {
         /** */
         private static final long serialVersionUID = 0L;

http://git-wip-us.apache.org/repos/asf/ignite/blob/94f549f2/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
index 698b035..1c8107e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
@@ -3082,47 +3082,6 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
     }
 
     /**
-     *
-     */
-    private class OffheapIteratorClosure
-        extends CX2<T2<Long, Integer>, T2<Long, Integer>, IgniteBiTuple<K, V>> {
-        /** */
-        private static final long serialVersionUID = 7410163202728985912L;
-
-        /** */
-        private IgniteBiPredicate<K, V> filter;
-
-        /** */
-        private boolean keepPortable;
-
-        /**
-         * @param filter Filter.
-         * @param keepPortable Keep portable flag.
-         */
-        private OffheapIteratorClosure(
-            @Nullable IgniteBiPredicate<K, V> filter,
-            boolean keepPortable) {
-            assert filter != null;
-
-            this.filter = filter;
-            this.keepPortable = keepPortable;
-        }
-
-        /** {@inheritDoc} */
-        @Nullable @Override public IgniteBiTuple<K, V> applyx(T2<Long, Integer> keyPtr,
-            T2<Long, Integer> valPtr)
-            throws IgniteCheckedException {
-            LazyOffheapEntry e = new LazyOffheapEntry(keyPtr, valPtr);
-
-            K key = (K)cctx.unwrapPortableIfNeeded(e.key(), keepPortable);
-            V val = (V)cctx.unwrapPortableIfNeeded(e.value(), keepPortable);
-
-            if (!filter.apply(key, val))
-                return null;
-
-            return new IgniteBiTuple<>(e.key(), (V)cctx.unwrapTemporary(e.value()));
-        }
-    }    /**
      * Creates user's SQL fields query for given clause. For more information refer to {@link CacheQuery}
      * documentation.
      *

http://git-wip-us.apache.org/repos/asf/ignite/blob/94f549f2/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
index df79232..4bb02c4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
@@ -565,53 +565,6 @@ public class GridRestProcessor extends GridProcessorAdapter {
     }
 
     /**
-     * Applies {@link ConnectorMessageInterceptor}
-     * from {@link ConnectorConfiguration#getMessageInterceptor()} ()}
-     * to all user parameters in the request.
-     *
-     * @param req Client request.
-     */
-    private void interceptRequest(GridRestRequest req) {
-        ConnectorMessageInterceptor interceptor = config().getMessageInterceptor();
-
-        if (interceptor == null)
-            return;
-
-        if (req instanceof GridRestCacheRequest) {
-            GridRestCacheRequest req0 = (GridRestCacheRequest) req;
-
-            req0.key(interceptor.onReceive(req0.key()));
-            req0.value(interceptor.onReceive(req0.value()));
-            req0.value2(interceptor.onReceive(req0.value2()));
-
-            Map<Object, Object> oldVals = req0.values();
-
-            if (oldVals != null) {
-                Map<Object, Object> newVals = U.newHashMap(oldVals.size());
-
-                for (Map.Entry<Object, Object> e : oldVals.entrySet())
-                    newVals.put(interceptor.onReceive(e.getKey()), interceptor.onReceive(e.getValue()));
-
-                req0.values(U.sealMap(newVals));
-            }
-        }
-        else if (req instanceof GridRestTaskRequest) {
-            GridRestTaskRequest req0 = (GridRestTaskRequest) req;
-
-            List<Object> oldParams = req0.params();
-
-            if (oldParams != null) {
-                Collection<Object> newParams = new ArrayList<>(oldParams.size());
-
-                for (Object o : oldParams)
-                    newParams.add(interceptor.onReceive(o));
-
-                req0.params(U.sealList(newParams));
-            }
-        }
-    }
-
-    /**
      * Applies {@link ConnectorMessageInterceptor} from
      * {@link ConnectorConfiguration#getMessageInterceptor()}
      * to all user objects in the response.

http://git-wip-us.apache.org/repos/asf/ignite/blob/94f549f2/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/top/GridTopologyCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/top/GridTopologyCommandHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/top/GridTopologyCommandHandler.java
index 3b36c6a..eea29d2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/top/GridTopologyCommandHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/top/GridTopologyCommandHandler.java
@@ -307,135 +307,6 @@ public class GridTopologyCommandHandler extends GridRestCommandHandlerAdapter {
     }
 
     /**
-     * Creates node bean out of grid node. Notice that cache attribute is handled separately.
-     *
-     * @param node Grid node.
-     * @param mtr {@code true} to add metrics.
-     * @param attr {@code true} to add attributes.
-     * @return Grid Node bean.
-     */
-    private GridClientNodeBean createNodeBean(ClusterNode node, boolean mtr, boolean attr) {
-        assert node != null;
-
-        GridClientNodeBean nodeBean = new GridClientNodeBean();
-
-        nodeBean.setNodeId(node.id());
-        nodeBean.setConsistentId(node.consistentId());
-        nodeBean.setTcpPort(attribute(node, ATTR_REST_TCP_PORT, 0));
-
-        nodeBean.setTcpAddresses(nonEmptyList(node.<Collection<String>>attribute(ATTR_REST_TCP_ADDRS)));
-        nodeBean.setTcpHostNames(nonEmptyList(node.<Collection<String>>attribute(ATTR_REST_TCP_HOST_NAMES)));
-
-        Map<String, CacheMode> nodeCaches = ctx.discovery().nodeCaches(node);
-
-        Map<String, String> cacheMap = U.newHashMap(nodeCaches.size());
-
-        for (Map.Entry<String, CacheMode> cache : nodeCaches.entrySet()) {
-            String cacheName = cache.getKey();
-
-            if (CU.isSystemCache(cacheName) || CU.isIgfsCache(ctx.config(), cacheName))
-                continue;
-
-            String mode = cache.getValue().toString();
-
-            if (cacheName != null)
-                cacheMap.put(cacheName, mode);
-            else
-                nodeBean.setDefaultCacheMode(mode);
-        }
-
-        nodeBean.setCaches(cacheMap);
-
-        if (mtr) {
-            ClusterMetrics metrics = node.metrics();
-
-            GridClientNodeMetricsBean metricsBean = new GridClientNodeMetricsBean();
-
-            metricsBean.setStartTime(metrics.getStartTime());
-            metricsBean.setAverageActiveJobs(metrics.getAverageActiveJobs());
-            metricsBean.setAverageCancelledJobs(metrics.getAverageCancelledJobs());
-            metricsBean.setAverageCpuLoad(metrics.getAverageCpuLoad());
-            metricsBean.setAverageJobExecuteTime(metrics.getAverageJobExecuteTime());
-            metricsBean.setAverageJobWaitTime(metrics.getAverageJobWaitTime());
-            metricsBean.setAverageRejectedJobs(metrics.getAverageRejectedJobs());
-            metricsBean.setAverageWaitingJobs(metrics.getAverageWaitingJobs());
-            metricsBean.setCurrentActiveJobs(metrics.getCurrentActiveJobs());
-            metricsBean.setCurrentCancelledJobs(metrics.getCurrentCancelledJobs());
-            metricsBean.setCurrentCpuLoad(metrics.getCurrentCpuLoad());
-            metricsBean.setCurrentGcCpuLoad(metrics.getCurrentGcCpuLoad());
-            metricsBean.setCurrentDaemonThreadCount(metrics.getCurrentDaemonThreadCount());
-            metricsBean.setCurrentIdleTime(metrics.getCurrentIdleTime());
-            metricsBean.setCurrentJobExecuteTime(metrics.getCurrentJobExecuteTime());
-            metricsBean.setCurrentJobWaitTime(metrics.getCurrentJobWaitTime());
-            metricsBean.setCurrentRejectedJobs(metrics.getCurrentRejectedJobs());
-            metricsBean.setCurrentThreadCount(metrics.getCurrentThreadCount());
-            metricsBean.setCurrentWaitingJobs(metrics.getCurrentWaitingJobs());
-            metricsBean.setHeapMemoryCommitted(metrics.getHeapMemoryCommitted());
-            metricsBean.setHeapMemoryInitialized(metrics.getHeapMemoryInitialized());
-            metricsBean.setHeapMemoryMaximum(metrics.getHeapMemoryMaximum());
-            metricsBean.setHeapMemoryUsed(metrics.getHeapMemoryUsed());
-            metricsBean.setLastDataVersion(metrics.getLastDataVersion());
-            metricsBean.setLastUpdateTime(metrics.getLastUpdateTime());
-            metricsBean.setMaximumActiveJobs(metrics.getMaximumActiveJobs());
-            metricsBean.setMaximumCancelledJobs(metrics.getMaximumCancelledJobs());
-            metricsBean.setMaximumJobExecuteTime(metrics.getMaximumJobExecuteTime());
-            metricsBean.setMaximumJobWaitTime(metrics.getMaximumJobWaitTime());
-            metricsBean.setMaximumRejectedJobs(metrics.getMaximumRejectedJobs());
-            metricsBean.setMaximumThreadCount(metrics.getMaximumThreadCount());
-            metricsBean.setMaximumWaitingJobs(metrics.getMaximumWaitingJobs());
-            metricsBean.setNodeStartTime(metrics.getNodeStartTime());
-            metricsBean.setNonHeapMemoryCommitted(metrics.getNonHeapMemoryCommitted());
-            metricsBean.setNonHeapMemoryInitialized(metrics.getNonHeapMemoryInitialized());
-            metricsBean.setNonHeapMemoryMaximum(metrics.getNonHeapMemoryMaximum());
-            metricsBean.setNonHeapMemoryUsed(metrics.getNonHeapMemoryUsed());
-            metricsBean.setStartTime(metrics.getStartTime());
-            metricsBean.setTotalCancelledJobs(metrics.getTotalCancelledJobs());
-            metricsBean.setTotalCpus(metrics.getTotalCpus());
-            metricsBean.setTotalExecutedJobs(metrics.getTotalExecutedJobs());
-            metricsBean.setTotalIdleTime(metrics.getTotalIdleTime());
-            metricsBean.setTotalRejectedJobs(metrics.getTotalRejectedJobs());
-            metricsBean.setTotalStartedThreadCount(metrics.getTotalStartedThreadCount());
-            metricsBean.setTotalExecutedTasks(metrics.getTotalExecutedTasks());
-            metricsBean.setSentMessagesCount(metrics.getSentMessagesCount());
-            metricsBean.setSentBytesCount(metrics.getSentBytesCount());
-            metricsBean.setReceivedMessagesCount(metrics.getReceivedMessagesCount());
-            metricsBean.setReceivedBytesCount(metrics.getReceivedBytesCount());
-            metricsBean.setUpTime(metrics.getUpTime());
-
-            nodeBean.setMetrics(metricsBean);
-        }
-
-        if (attr) {
-            Map<String, Object> attrs = new HashMap<>(node.attributes());
-
-            attrs.remove(ATTR_CACHE);
-            attrs.remove(ATTR_TX_CONFIG);
-            attrs.remove(ATTR_SECURITY_SUBJECT);
-            attrs.remove(ATTR_SECURITY_CREDENTIALS);
-
-            for (Iterator<Map.Entry<String, Object>> i = attrs.entrySet().iterator(); i.hasNext();) {
-                Map.Entry<String, Object> e = i.next();
-
-                if (!e.getKey().startsWith("org.apache.ignite.") && !e.getKey().startsWith("plugins.") &&
-                    System.getProperty(e.getKey()) == null) {
-                    i.remove();
-
-                    continue;
-                }
-
-                if (e.getValue() != null) {
-                  if (e.getValue().getClass().isEnum() || e.getValue() instanceof InetAddress)
-                      e.setValue(e.getValue().toString());
-                  else if (e.getValue().getClass().isArray())
-                      i.remove();
-                }
-            }
-
-            nodeBean.setAttributes(attrs);
-        }
-
-        return nodeBean;
-    }    /**
      * @param col Collection;
      * @return Non-empty list.
      */


[25/50] [abbrv] ignite git commit: IGNITE-1653

Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamVisitorExample.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamVisitorExample.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamVisitorExample.java
new file mode 100644
index 0000000..cef9f2f
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/StreamVisitorExample.java
@@ -0,0 +1,172 @@
+/*
+ *  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.examples.java8.streaming;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.Random;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteDataStreamer;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.cache.query.annotations.QuerySqlField;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.examples.ExampleNodeStartup;
+import org.apache.ignite.examples.ExamplesUtils;
+import org.apache.ignite.stream.StreamVisitor;
+
+/**
+ * Stream random numbers into the streaming cache.
+ * To start the example, you should:
+ * <ul>
+ *     <li>Start a few nodes using {@link ExampleNodeStartup} or by starting remote nodes as specified below.</li>
+ *     <li>Start streaming using {@link StreamVisitorExample}.</li>
+ * </ul>
+ * <p>
+ * You should start remote nodes by running {@link ExampleNodeStartup} in another JVM.
+ */
+public class StreamVisitorExample {
+    /** Random number generator. */
+    private static final Random RAND = new Random();
+
+    /** The list of instruments. */
+    private static final String[] INSTRUMENTS = {"IBM", "GOOG", "MSFT", "GE", "EBAY", "YHOO", "ORCL", "CSCO", "AMZN", "RHT"};
+
+    /** The list of initial instrument prices. */
+    private static final double[] INITIAL_PRICES = {194.9, 893.49, 34.21, 23.24, 57.93, 45.03, 44.41, 28.44, 378.49, 69.50};
+
+    public static void main(String[] args) throws Exception {
+        // Mark this cluster member as client.
+        Ignition.setClientMode(true);
+
+        try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
+            if (!ExamplesUtils.hasServerNodes(ignite))
+                return;
+
+            // Market data cache with default configuration.
+            CacheConfiguration<String, Double> mktDataCfg = new CacheConfiguration<>("marketTicks");
+
+            // Financial instrument cache configuration.
+            CacheConfiguration<String, Instrument> instCfg = new CacheConfiguration<>("instCache");
+
+            // Index key and value for querying financial instruments.
+            // Note that Instrument class has @QuerySqlField annotation for secondary field indexing.
+            instCfg.setIndexedTypes(String.class, Instrument.class);
+
+            // Auto-close caches at the end of the example.
+            try (
+                IgniteCache<String, Double> mktCache = ignite.getOrCreateCache(mktDataCfg);
+                IgniteCache<String, Instrument> instCache = ignite.getOrCreateCache(instCfg)
+            ) {
+                try (IgniteDataStreamer<String, Double> mktStmr = ignite.dataStreamer(mktCache.getName())) {
+                    // Note that we receive market data, but do not populate 'mktCache' (it remains empty).
+                    // Instead we update the instruments in the 'instCache'.
+                    // Since both, 'instCache' and 'mktCache' use the same key, updates are collocated.
+                    mktStmr.receiver(StreamVisitor.from((cache, e) -> {
+                        String symbol = e.getKey();
+                        Double tick = e.getValue();
+
+                        Instrument inst = instCache.get(symbol);
+
+                        if (inst == null)
+                            inst = new Instrument(symbol);
+
+                        // Don't populate market cache, as we don't use it for querying.
+                        // Update cached instrument based on the latest market tick.
+                        inst.update(tick);
+
+                        instCache.put(symbol, inst);
+                    }));
+
+                    // Stream 10 million market data ticks into the system.
+                    for (int i = 1; i <= 10_000_000; i++) {
+                        int idx = RAND.nextInt(INSTRUMENTS.length);
+
+                        // Use gaussian distribution to ensure that
+                        // numbers closer to 0 have higher probability.
+                        double price = round2(INITIAL_PRICES[idx] + RAND.nextGaussian());
+
+                        mktStmr.addData(INSTRUMENTS[idx], price);
+
+                        if (i % 500_000 == 0)
+                            System.out.println("Number of tuples streamed into Ignite: " + i);
+                    }
+                }
+
+                // Select top 3 best performing instruments.
+                SqlFieldsQuery top3qry = new SqlFieldsQuery(
+                    "select symbol, (latest - open) from Instrument order by (latest - open) desc limit 3");
+
+                // Execute queries.
+                List<List<?>> top3 = instCache.query(top3qry).getAll();
+
+                System.out.println("Top performing financial instruments: ");
+
+                // Print top 10 words.
+                ExamplesUtils.printQueryResults(top3);
+            }
+        }
+    }
+
+    /**
+     * Rounds double value to two significant signs.
+     *
+     * @param val value to be rounded.
+     * @return rounded double value.
+     */
+    private static double round2(double val) {
+        return Math.floor(100 * val + 0.5) / 100;
+    }
+
+    /**
+     * Financial instrument.
+     */
+    public static class Instrument implements Serializable {
+        /** Instrument symbol. */
+        @QuerySqlField(index = true)
+        private final String symbol;
+
+        /** Open price. */
+        @QuerySqlField(index = true)
+        private double open;
+
+        /** Close price. */
+        @QuerySqlField(index = true)
+        private double latest;
+
+        /**
+         * @param symbol Symbol.
+         */
+        public Instrument(String symbol) {
+            this.symbol = symbol;
+        }
+
+        /**
+         * Updates this instrument based on the latest market tick price.
+         *
+         * @param price Latest price.
+         */
+        public void update(double price) {
+            if (open == 0)
+                open = price;
+
+            this.latest = price;
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/package-info.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/package-info.java b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/package-info.java
new file mode 100644
index 0000000..d215d2f
--- /dev/null
+++ b/examples-lgpl/src/main/java8/org/apache/ignite/examples/java8/streaming/package-info.java
@@ -0,0 +1,22 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+ * <!-- Package description. -->
+ * Demonstrates usage of data streamer.
+ */
+package org.apache.ignite.examples.java8.streaming;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/test/java/org/apache/ignite/examples/HibernateL2CacheExampleMultiNodeSelfTest.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/test/java/org/apache/ignite/examples/HibernateL2CacheExampleMultiNodeSelfTest.java b/examples-lgpl/src/test/java/org/apache/ignite/examples/HibernateL2CacheExampleMultiNodeSelfTest.java
new file mode 100644
index 0000000..8a40d4a
--- /dev/null
+++ b/examples-lgpl/src/test/java/org/apache/ignite/examples/HibernateL2CacheExampleMultiNodeSelfTest.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.examples;
+
+import org.apache.ignite.examples.datagrid.hibernate.HibernateL2CacheExample;
+
+/**
+ * Multi-node test for {@link HibernateL2CacheExample}.
+ */
+public class HibernateL2CacheExampleMultiNodeSelfTest extends HibernateL2CacheExampleSelfTest {
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        for (int i = 0; i < RMT_NODES_CNT; i++)
+            startGrid("node-" + i, "examples/config/example-ignite.xml");
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/test/java/org/apache/ignite/examples/HibernateL2CacheExampleSelfTest.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/test/java/org/apache/ignite/examples/HibernateL2CacheExampleSelfTest.java b/examples-lgpl/src/test/java/org/apache/ignite/examples/HibernateL2CacheExampleSelfTest.java
new file mode 100644
index 0000000..68767d7
--- /dev/null
+++ b/examples-lgpl/src/test/java/org/apache/ignite/examples/HibernateL2CacheExampleSelfTest.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.examples;
+
+import org.apache.ignite.examples.datagrid.hibernate.HibernateL2CacheExample;
+import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
+
+/**
+ * Tests the {@link HibernateL2CacheExample}.
+ */
+public class HibernateL2CacheExampleSelfTest extends GridAbstractExamplesTest {
+    /**
+     * @throws Exception If failed.
+     */
+    public void testHibernateL2CacheExample() throws Exception {
+        HibernateL2CacheExample.main(EMPTY_ARGS);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/test/java/org/apache/ignite/testsuites/IgniteLgplExamplesSelfTestSuite.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/test/java/org/apache/ignite/testsuites/IgniteLgplExamplesSelfTestSuite.java b/examples-lgpl/src/test/java/org/apache/ignite/testsuites/IgniteLgplExamplesSelfTestSuite.java
new file mode 100644
index 0000000..7c99712
--- /dev/null
+++ b/examples-lgpl/src/test/java/org/apache/ignite/testsuites/IgniteLgplExamplesSelfTestSuite.java
@@ -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.
+ */
+
+package org.apache.ignite.testsuites;
+
+import junit.framework.TestSuite;
+import org.apache.ignite.examples.HibernateL2CacheExampleMultiNodeSelfTest;
+import org.apache.ignite.examples.HibernateL2CacheExampleSelfTest;
+import org.apache.ignite.testframework.GridTestUtils;
+
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_OVERRIDE_MCAST_GRP;
+
+/**
+ * Examples test suite. <p> Contains only Spring ignite examples tests.
+ */
+public class IgniteLgplExamplesSelfTestSuite extends TestSuite {
+    /**
+     * @return Suite.
+     * @throws Exception If failed.
+     */
+    public static TestSuite suite() throws Exception {
+        System.setProperty(IGNITE_OVERRIDE_MCAST_GRP,
+            GridTestUtils.getNextMulticastGroup(IgniteLgplExamplesSelfTestSuite.class));
+
+        TestSuite suite = new TestSuite("Ignite Examples Test Suite");
+
+        suite.addTest(new TestSuite(HibernateL2CacheExampleSelfTest.class));
+
+        // Multi-node.
+        suite.addTest(new TestSuite(HibernateL2CacheExampleMultiNodeSelfTest.class));
+
+        return suite;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/test/java8/org/apache/ignite/java8/examples/HibernateL2CacheExampleMultiNodeSelfTest.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/test/java8/org/apache/ignite/java8/examples/HibernateL2CacheExampleMultiNodeSelfTest.java b/examples-lgpl/src/test/java8/org/apache/ignite/java8/examples/HibernateL2CacheExampleMultiNodeSelfTest.java
new file mode 100644
index 0000000..edfba3d
--- /dev/null
+++ b/examples-lgpl/src/test/java8/org/apache/ignite/java8/examples/HibernateL2CacheExampleMultiNodeSelfTest.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.java8.examples;
+
+/**
+ * Multi-node test for {@link org.apache.ignite.examples.java8.datagrid.hibernate.HibernateL2CacheExample}.
+ */
+public class HibernateL2CacheExampleMultiNodeSelfTest extends HibernateL2CacheExampleSelfTest {
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        for (int i = 0; i < RMT_NODES_CNT; i++)
+            startGrid("node-" + i, "examples/config/example-ignite.xml");
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/test/java8/org/apache/ignite/java8/examples/HibernateL2CacheExampleSelfTest.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/test/java8/org/apache/ignite/java8/examples/HibernateL2CacheExampleSelfTest.java b/examples-lgpl/src/test/java8/org/apache/ignite/java8/examples/HibernateL2CacheExampleSelfTest.java
new file mode 100644
index 0000000..8c7a2de
--- /dev/null
+++ b/examples-lgpl/src/test/java8/org/apache/ignite/java8/examples/HibernateL2CacheExampleSelfTest.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.java8.examples;
+
+//import org.apache.ignite.examples.java8.datagrid.hibernate.*;
+
+import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
+
+/**
+ * Tests the {@link org.apache.ignite.examples.java8.datagrid.hibernate.HibernateL2CacheExample}.
+ */
+public class HibernateL2CacheExampleSelfTest extends GridAbstractExamplesTest {
+    /**
+     * TODO: IGNITE-711 next example(s) should be implemented for java 8
+     * or testing method(s) should be removed if example(s) does not applicable for java 8.
+     *
+     * @throws Exception If failed.
+     */
+//    public void testHibernateL2CacheExample() throws Exception {
+//        HibernateL2CacheExample.main(EMPTY_ARGS);
+//    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples-lgpl/src/test/java8/org/apache/ignite/java8/testsuites/IgniteLgplExamplesJ8SelfTestSuite.java
----------------------------------------------------------------------
diff --git a/examples-lgpl/src/test/java8/org/apache/ignite/java8/testsuites/IgniteLgplExamplesJ8SelfTestSuite.java b/examples-lgpl/src/test/java8/org/apache/ignite/java8/testsuites/IgniteLgplExamplesJ8SelfTestSuite.java
new file mode 100644
index 0000000..bdda5f6
--- /dev/null
+++ b/examples-lgpl/src/test/java8/org/apache/ignite/java8/testsuites/IgniteLgplExamplesJ8SelfTestSuite.java
@@ -0,0 +1,46 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.ignite.java8.testsuites;
+
+import junit.framework.TestSuite;
+import org.apache.ignite.testframework.GridTestUtils;
+
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_OVERRIDE_MCAST_GRP;
+
+/**
+ * Examples test suite. <p> Contains only Spring ignite examples tests.
+ */
+public class IgniteLgplExamplesJ8SelfTestSuite extends TestSuite {
+    /**
+     * @return Suite.
+     * @throws Exception If failed.
+     */
+    public static TestSuite suite() throws Exception {
+        System.setProperty(IGNITE_OVERRIDE_MCAST_GRP,
+            GridTestUtils.getNextMulticastGroup(IgniteLgplExamplesJ8SelfTestSuite.class));
+
+        TestSuite suite = new TestSuite("Ignite Examples Test Suite");
+
+//        suite.addTest(new TestSuite(HibernateL2CacheExampleSelfTest.class));
+
+        // Multi-node.
+//        suite.addTest(new TestSuite(HibernateL2CacheExampleMultiNodeSelfTest.class));
+
+        return suite;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples/pom-standalone.xml
----------------------------------------------------------------------
diff --git a/examples/pom-standalone.xml b/examples/pom-standalone.xml
index 996753e..e314acb 100644
--- a/examples/pom-standalone.xml
+++ b/examples/pom-standalone.xml
@@ -49,12 +49,6 @@
 
         <dependency>
             <groupId>org.apache.ignite</groupId>
-            <artifactId>ignite-hibernate</artifactId>
-            <version>to_be_replaced_by_ignite_version</version>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.ignite</groupId>
             <artifactId>ignite-spring</artifactId>
             <version>to_be_replaced_by_ignite_version</version>
         </dependency>
@@ -72,12 +66,6 @@
         </dependency>
 
         <dependency>
-            <groupId>org.apache.ignite</groupId>
-            <artifactId>ignite-schedule</artifactId>
-            <version>to_be_replaced_by_ignite_version</version>
-        </dependency>
-
-        <dependency>
             <groupId>com.google.code.simple-spring-memcached</groupId>
             <artifactId>spymemcached</artifactId>
             <version>2.7.3</version>

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples/pom.xml
----------------------------------------------------------------------
diff --git a/examples/pom.xml b/examples/pom.xml
index e4ec73a..34ba05a 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -45,12 +45,6 @@
 
         <dependency>
             <groupId>org.apache.ignite</groupId>
-            <artifactId>ignite-hibernate</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.ignite</groupId>
             <artifactId>ignite-spring</artifactId>
             <version>${project.version}</version>
         </dependency>
@@ -68,12 +62,6 @@
         </dependency>
 
         <dependency>
-            <groupId>org.apache.ignite</groupId>
-            <artifactId>ignite-schedule</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-
-        <dependency>
             <groupId>com.google.code.simple-spring-memcached</groupId>
             <artifactId>spymemcached</artifactId>
             <version>2.7.3</version>

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples/src/main/java/org/apache/ignite/examples/datagrid/hibernate/HibernateL2CacheExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/hibernate/HibernateL2CacheExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/hibernate/HibernateL2CacheExample.java
deleted file mode 100644
index 2f271c8..0000000
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/hibernate/HibernateL2CacheExample.java
+++ /dev/null
@@ -1,245 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.examples.datagrid.hibernate;
-
-import java.net.URL;
-import java.util.Arrays;
-import java.util.List;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.CacheAtomicityMode;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.examples.ExamplesUtils;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.Transaction;
-import org.hibernate.cache.spi.access.AccessType;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.service.ServiceRegistryBuilder;
-import org.hibernate.stat.SecondLevelCacheStatistics;
-
-import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
-import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
-import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
-
-/**
- * This example demonstrates the use of Ignite In-Memory Data Ignite cluster as a Hibernate
- * Second-Level cache provider.
- * <p>
- * The Hibernate Second-Level cache (or "L2 cache" shortly) lets you significantly
- * reduce the number of requests to the underlying SQL database. Because database
- * access is known to be an expansive operation, using L2 cache may improve
- * performance dramatically.
- * <p>
- * This example defines 2 entity classes: {@link User} and {@link Post}, with
- * 1 <-> N relation, and marks them with appropriate annotations for Hibernate
- * object-relational mapping to SQL tables of an underlying H2 in-memory database.
- * The example launches node in the same JVM and registers it in
- * Hibernate configuration as an L2 cache implementation. It then stores and
- * queries instances of the entity classes to and from the database, having
- * Hibernate SQL output, L2 cache statistics output, and Ignite cache metrics
- * output enabled.
- * <p>
- * When running example, it's easy to notice that when an object is first
- * put into a database, the L2 cache is not used and it's contents is empty.
- * However, when an object is first read from the database, it is immediately
- * stored in L2 cache (which is Ignite In-Memory Data Ignite cluster in fact), which can
- * be seen in stats output. Further requests of the same object only read the data
- * from L2 cache and do not hit the database.
- * <p>
- * In this example, the Hibernate query cache is also enabled. Query cache lets you
- * avoid hitting the database in case of repetitive queries with the same parameter
- * values. You may notice that when the example runs the same query repeatedly in
- * loop, only the first query hits the database and the successive requests take the
- * data from L2 cache.
- * <p>
- * Note: this example uses {@link AccessType#READ_ONLY} L2 cache access type, but you
- * can experiment with other access types by modifying the Hibernate configuration file
- * {@code IGNITE_HOME/examples/config/hibernate/example-hibernate-L2-cache.xml}, used by the example.
- * <p>
- * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will
- * start node with {@code examples/config/example-ignite.xml} configuration.
- */
-public class HibernateL2CacheExample {
-    /** JDBC URL for backing database (an H2 in-memory database is used). */
-    private static final String JDBC_URL = "jdbc:h2:mem:example;DB_CLOSE_DELAY=-1";
-
-    /** Path to hibernate configuration file (will be resolved from application {@code CLASSPATH}). */
-    private static final String HIBERNATE_CFG = "hibernate/example-hibernate-L2-cache.xml";
-
-    /** Entity names for stats output. */
-    private static final List<String> ENTITY_NAMES =
-        Arrays.asList(User.class.getName(), Post.class.getName(), User.class.getName() + ".posts");
-
-    /**
-     * Executes example.
-     *
-     * @param args Command line arguments, none required.
-     * @throws IgniteException If example execution failed.
-     */
-    public static void main(String[] args) throws IgniteException {
-        // Start the node, run the example, and stop the node when finished.
-        try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
-            // We use a single session factory, but create a dedicated session
-            // for each transaction or query. This way we ensure that L1 cache
-            // is not used (L1 cache has per-session scope only).
-            System.out.println();
-            System.out.println(">>> Hibernate L2 cache example started.");
-
-            try (
-                // Create all required caches.
-                IgniteCache c1 = createCache("org.hibernate.cache.spi.UpdateTimestampsCache", ATOMIC);
-                IgniteCache c2 = createCache("org.hibernate.cache.internal.StandardQueryCache", ATOMIC);
-                IgniteCache c3 = createCache("org.apache.ignite.examples.datagrid.hibernate.User", TRANSACTIONAL);
-                IgniteCache c4 = createCache("org.apache.ignite.examples.datagrid.hibernate.User.posts", TRANSACTIONAL);
-                IgniteCache c5 = createCache("org.apache.ignite.examples.datagrid.hibernate.Post", TRANSACTIONAL)
-            ) {
-                URL hibernateCfg = ExamplesUtils.url(HIBERNATE_CFG);
-
-                SessionFactory sesFactory = createHibernateSessionFactory(hibernateCfg);
-
-                System.out.println();
-                System.out.println(">>> Creating objects.");
-
-                final long userId;
-
-                Session ses = sesFactory.openSession();
-
-                try {
-                    Transaction tx = ses.beginTransaction();
-
-                    User user = new User("jedi", "Luke", "Skywalker");
-
-                    user.getPosts().add(new Post(user, "Let the Force be with you."));
-
-                    ses.save(user);
-
-                    tx.commit();
-
-                    // Create a user object, store it in DB, and save the database-generated
-                    // object ID. You may try adding more objects in a similar way.
-                    userId = user.getId();
-                }
-                finally {
-                    ses.close();
-                }
-
-                // Output L2 cache and Ignite cache stats. You may notice that
-                // at this point the object is not yet stored in L2 cache, because
-                // the read was not yet performed.
-                printStats(sesFactory);
-
-                System.out.println();
-                System.out.println(">>> Querying object by ID.");
-
-                // Query user by ID several times. First time we get an L2 cache
-                // miss, and the data is queried from DB, but it is then stored
-                // in cache and successive queries hit the cache and return
-                // immediately, no SQL query is made.
-                for (int i = 0; i < 3; i++) {
-                    ses = sesFactory.openSession();
-
-                    try {
-                        Transaction tx = ses.beginTransaction();
-
-                        User user = (User)ses.get(User.class, userId);
-
-                        System.out.println("User: " + user);
-
-                        for (Post post : user.getPosts())
-                            System.out.println("\tPost: " + post);
-
-                        tx.commit();
-                    }
-                    finally {
-                        ses.close();
-                    }
-                }
-
-                // Output the stats. We should see 1 miss and 2 hits for
-                // User and Collection object (stored separately in L2 cache).
-                // The Post is loaded with the collection, so it won't imply
-                // a miss.
-                printStats(sesFactory);
-            }
-        }
-    }
-
-    /**
-     * Creates cache.
-     *
-     * @param name Cache name.
-     * @param atomicityMode Atomicity mode.
-     * @return Cache configuration.
-     */
-    private static IgniteCache createCache(String name, CacheAtomicityMode atomicityMode) {
-        CacheConfiguration ccfg = new CacheConfiguration(name);
-
-        ccfg.setAtomicityMode(atomicityMode);
-        ccfg.setWriteSynchronizationMode(FULL_SYNC);
-
-        return Ignition.ignite().getOrCreateCache(ccfg);
-    }
-
-    /**
-     * Creates a new Hibernate {@link SessionFactory} using a programmatic
-     * configuration.
-     *
-     * @param hibernateCfg Hibernate configuration file.
-     * @return New Hibernate {@link SessionFactory}.
-     */
-    private static SessionFactory createHibernateSessionFactory(URL hibernateCfg) {
-        ServiceRegistryBuilder builder = new ServiceRegistryBuilder();
-
-        builder.applySetting("hibernate.connection.url", JDBC_URL);
-        builder.applySetting("hibernate.show_sql", true);
-
-        return new Configuration()
-            .configure(hibernateCfg)
-            .buildSessionFactory(builder.buildServiceRegistry());
-    }
-
-    /**
-     * Prints Hibernate L2 cache statistics to standard output.
-     *
-     * @param sesFactory Hibernate {@link SessionFactory}, for which to print
-     *                   statistics.
-     */
-    private static void printStats(SessionFactory sesFactory) {
-        System.out.println("=== Hibernate L2 cache statistics ===");
-
-        for (String entityName : ENTITY_NAMES) {
-            System.out.println("\tEntity: " + entityName);
-
-            SecondLevelCacheStatistics stats =
-                sesFactory.getStatistics().getSecondLevelCacheStatistics(entityName);
-
-            System.out.println("\t\tL2 cache entries: " + stats.getEntries());
-            System.out.println("\t\tHits: " + stats.getHitCount());
-            System.out.println("\t\tMisses: " + stats.getMissCount());
-        }
-
-        System.out.println("=====================================");
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples/src/main/java/org/apache/ignite/examples/datagrid/hibernate/Post.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/hibernate/Post.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/hibernate/Post.java
deleted file mode 100644
index 798411a..0000000
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/hibernate/Post.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.examples.datagrid.hibernate;
-
-import java.util.Date;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.ManyToOne;
-
-/**
- * An entity class representing a post, that a
- * {@link User} has made on some public service.
- */
-@Entity
-class Post {
-    /** ID. */
-    @Id
-    @GeneratedValue(strategy=GenerationType.AUTO)
-    private long id;
-
-    /** Author. */
-    @ManyToOne
-    private User author;
-
-    /** Text. */
-    private String text;
-
-    /** Created timestamp. */
-    private Date created;
-
-    /**
-     * Default constructor (required by Hibernate).
-     */
-    Post() {
-        // No-op.
-    }
-
-    /**
-     * Constructor.
-     *
-     * @param author Author.
-     * @param text Text.
-     */
-    Post(User author, String text) {
-        this.author = author;
-        this.text = text;
-        created = new Date();
-    }
-
-    /**
-     * @return ID.
-     */
-    public long getId() {
-        return id;
-    }
-
-    /**
-     * @param id New ID.
-     */
-    public void setId(long id) {
-        this.id = id;
-    }
-
-    /**
-     * @return Author.
-     */
-    public User getAuthor() {
-        return author;
-    }
-
-    /**
-     * @param author New author.
-     */
-    public void setAuthor(User author) {
-        this.author = author;
-    }
-
-    /**
-     * @return Text.
-     */
-    public String getText() {
-        return text;
-    }
-
-    /**
-     * @param text New text.
-     */
-    public void setText(String text) {
-        this.text = text;
-    }
-
-    /**
-     * @return Created timestamp.
-     */
-    public Date getCreated() {
-        return (Date)created.clone();
-    }
-
-    /**
-     * @param created New created timestamp.
-     */
-    public void setCreated(Date created) {
-        this.created = (Date)created.clone();
-    }
-
-    /** {@inheritDoc} */
-    @Override public String toString() {
-        return "Post [id=" + id +
-            ", text=" + text +
-            ", created=" + created +
-            ']';
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples/src/main/java/org/apache/ignite/examples/datagrid/hibernate/User.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/hibernate/User.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/hibernate/User.java
deleted file mode 100644
index b7d5299..0000000
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/hibernate/User.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.examples.datagrid.hibernate;
-
-import java.util.HashSet;
-import java.util.Set;
-import javax.persistence.CascadeType;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.OneToMany;
-import org.hibernate.annotations.NaturalId;
-
-/**
- * A user entity class. Represents a user of some public service,
- * having a number of personal information fields as well as a
- * number of posts written.
- */
-@Entity
-class User {
-    /** ID. */
-    @Id
-    @GeneratedValue(strategy=GenerationType.AUTO)
-    private long id;
-
-    /** Login. */
-    @NaturalId
-    private String login;
-
-    /** First name. */
-    private String firstName;
-
-    /** Last name. */
-    private String lastName;
-
-    /** Posts. */
-    @OneToMany(mappedBy = "author", cascade = CascadeType.ALL)
-    private Set<Post> posts = new HashSet<>();
-
-    /**
-     * Default constructor (required by Hibernate).
-     */
-    User() {
-        // No-op.
-    }
-
-    /**
-     * Constructor.
-     *
-     * @param login Login.
-     * @param firstName First name.
-     * @param lastName Last name.
-     */
-    User(String login, String firstName, String lastName) {
-        this.login = login;
-        this.firstName = firstName;
-        this.lastName = lastName;
-    }
-
-    /**
-     * @return ID.
-     */
-    public long getId() {
-        return id;
-    }
-
-    /**
-     * @param id New ID.
-     */
-    public void setId(long id) {
-        this.id = id;
-    }
-
-    /**
-     * @return Login.
-     */
-    public String getLogin() {
-        return login;
-    }
-
-    /**
-     * @param login New login.
-     */
-    public void setLogin(String login) {
-        this.login = login;
-    }
-
-    /**
-     * @return First name.
-     */
-    public String getFirstName() {
-        return firstName;
-    }
-
-    /**
-     * @param firstName New first name.
-     */
-    public void setFirstName(String firstName) {
-        this.firstName = firstName;
-    }
-
-    /**
-     * @return Last name.
-     */
-    public String getLastName() {
-        return lastName;
-    }
-
-    /**
-     * @param lastName New last name.
-     */
-    public void setLastName(String lastName) {
-        this.lastName = lastName;
-    }
-
-    /**
-     * @return Posts.
-     */
-    public Set<Post> getPosts() {
-        return posts;
-    }
-
-    /**
-     * @param posts New posts.
-     */
-    public void setPosts(Set<Post> posts) {
-        this.posts = posts;
-    }
-
-    /** {@inheritDoc} */
-    @Override public String toString() {
-        return "User [id=" + id +
-            ", login=" + login +
-            ", firstName=" + firstName +
-            ", lastName=" + lastName +
-            ']';
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples/src/main/java/org/apache/ignite/examples/datagrid/hibernate/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/hibernate/package-info.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/hibernate/package-info.java
deleted file mode 100644
index 4bb876b..0000000
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/hibernate/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * <!-- Package description. -->
- * Hibernate example.
- */
-package org.apache.ignite.examples.datagrid.hibernate;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernatePersonStore.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernatePersonStore.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernatePersonStore.java
deleted file mode 100644
index f8831ab..0000000
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernatePersonStore.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.examples.datagrid.store.hibernate;
-
-import java.util.List;
-import java.util.UUID;
-import javax.cache.integration.CacheLoaderException;
-import javax.cache.integration.CacheWriterException;
-import org.apache.ignite.cache.store.CacheStore;
-import org.apache.ignite.cache.store.CacheStoreAdapter;
-import org.apache.ignite.cache.store.CacheStoreSession;
-import org.apache.ignite.examples.datagrid.store.Person;
-import org.apache.ignite.lang.IgniteBiInClosure;
-import org.apache.ignite.resources.CacheStoreSessionResource;
-import org.hibernate.HibernateException;
-import org.hibernate.Session;
-
-/**
- * Example of {@link CacheStore} implementation that uses Hibernate
- * and deals with maps {@link UUID} to {@link Person}.
- */
-public class CacheHibernatePersonStore extends CacheStoreAdapter<Long, Person> {
-    /** Auto-injected store session. */
-    @CacheStoreSessionResource
-    private CacheStoreSession ses;
-
-    /** {@inheritDoc} */
-    @Override public Person load(Long key) {
-        System.out.println(">>> Store load [key=" + key + ']');
-
-        Session hibSes = ses.attachment();
-
-        try {
-            return (Person)hibSes.get(Person.class, key);
-        }
-        catch (HibernateException e) {
-            throw new CacheLoaderException("Failed to load value from cache store [key=" + key + ']', e);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public void write(javax.cache.Cache.Entry<? extends Long, ? extends Person> entry) {
-        Long key = entry.getKey();
-        Person val = entry.getValue();
-
-        System.out.println(">>> Store write [key=" + key + ", val=" + val + ']');
-
-        Session hibSes = ses.attachment();
-
-        try {
-            hibSes.saveOrUpdate(val);
-        }
-        catch (HibernateException e) {
-            throw new CacheWriterException("Failed to put value to cache store [key=" + key + ", val" + val + "]", e);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @SuppressWarnings({"JpaQueryApiInspection"})
-    @Override public void delete(Object key) {
-        System.out.println(">>> Store delete [key=" + key + ']');
-
-        Session hibSes = ses.attachment();
-
-        try {
-            hibSes.createQuery("delete " + Person.class.getSimpleName() + " where key = :key").
-                setParameter("key", key).
-                executeUpdate();
-        }
-        catch (HibernateException e) {
-            throw new CacheWriterException("Failed to remove value from cache store [key=" + key + ']', e);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public void loadCache(IgniteBiInClosure<Long, Person> clo, Object... args) {
-        if (args == null || args.length == 0 || args[0] == null)
-            throw new CacheLoaderException("Expected entry count parameter is not provided.");
-
-        final int entryCnt = (Integer)args[0];
-
-        Session hibSes = ses.attachment();
-
-        try {
-            int cnt = 0;
-
-            List list = hibSes.createCriteria(Person.class).
-                setMaxResults(entryCnt).
-                list();
-
-            if (list != null) {
-                for (Object obj : list) {
-                    Person person = (Person)obj;
-
-                    clo.apply(person.getId(), person);
-
-                    cnt++;
-                }
-            }
-
-            System.out.println(">>> Loaded " + cnt + " values into cache.");
-        }
-        catch (HibernateException e) {
-            throw new CacheLoaderException("Failed to load values from cache store.", e);
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernateStoreExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernateStoreExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernateStoreExample.java
deleted file mode 100644
index fbb761a..0000000
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernateStoreExample.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.examples.datagrid.store.hibernate;
-
-import java.util.UUID;
-import javax.cache.configuration.Factory;
-import javax.cache.configuration.FactoryBuilder;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.store.CacheStoreSessionListener;
-import org.apache.ignite.cache.store.hibernate.CacheHibernateStoreSessionListener;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.examples.ExamplesUtils;
-import org.apache.ignite.examples.datagrid.store.Person;
-import org.apache.ignite.transactions.Transaction;
-
-import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
-
-/**
- * Demonstrates usage of cache with underlying persistent store configured.
- * <p>
- * This example uses {@link CacheHibernatePersonStore} as a persistent store.
- * <p>
- * Remote nodes can be started with {@link ExampleNodeStartup} in another JVM which will
- * start node with {@code examples/config/example-ignite.xml} configuration.
- */
-public class CacheHibernateStoreExample {
-    /** Hibernate configuration resource path. */
-    private static final String HIBERNATE_CFG =
-        "/org/apache/ignite/examples/datagrid/store/hibernate/hibernate.cfg.xml";
-
-    /** Cache name. */
-    private static final String CACHE_NAME = CacheHibernateStoreExample.class.getSimpleName();
-
-    /** Heap size required to run this example. */
-    public static final int MIN_MEMORY = 1024 * 1024 * 1024;
-
-    /** Number of entries to load. */
-    private static final int ENTRY_COUNT = 100_000;
-
-    /** Global person ID to use across entire example. */
-    private static final Long id = Math.abs(UUID.randomUUID().getLeastSignificantBits());
-
-    /**
-     * Executes example.
-     *
-     * @param args Command line arguments, none required.
-     * @throws IgniteException If example execution failed.
-     */
-    public static void main(String[] args) throws IgniteException {
-        ExamplesUtils.checkMinMemory(MIN_MEMORY);
-
-        // To start ignite with desired configuration uncomment the appropriate line.
-        try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
-            System.out.println();
-            System.out.println(">>> Cache store example started.");
-
-            CacheConfiguration<Long, Person> cacheCfg = new CacheConfiguration<>(CACHE_NAME);
-
-            // Set atomicity as transaction, since we are showing transactions in example.
-            cacheCfg.setAtomicityMode(TRANSACTIONAL);
-
-            // Configure Hibernate store.
-            cacheCfg.setCacheStoreFactory(FactoryBuilder.factoryOf(CacheHibernatePersonStore.class));
-
-            // Configure Hibernate session listener.
-            cacheCfg.setCacheStoreSessionListenerFactories(new Factory<CacheStoreSessionListener>() {
-                @Override public CacheStoreSessionListener create() {
-                    CacheHibernateStoreSessionListener lsnr = new CacheHibernateStoreSessionListener();
-
-                    lsnr.setHibernateConfigurationPath(HIBERNATE_CFG);
-
-                    return lsnr;
-                }
-            });
-
-            cacheCfg.setReadThrough(true);
-            cacheCfg.setWriteThrough(true);
-
-            try (IgniteCache<Long, Person> cache = ignite.getOrCreateCache(cacheCfg)) {
-                // Make initial cache loading from persistent store. This is a
-                // distributed operation and will call CacheStore.loadCache(...)
-                // method on all nodes in topology.
-                loadCache(cache);
-
-                // Start transaction and execute several cache operations with
-                // read/write-through to persistent store.
-                executeTransaction(cache);
-            }
-        }
-    }
-
-    /**
-     * Makes initial cache loading.
-     *
-     * @param cache Cache to load.
-     */
-    private static void loadCache(IgniteCache<Long, Person> cache) {
-        long start = System.currentTimeMillis();
-
-        // Start loading cache from persistent store on all caching nodes.
-        cache.loadCache(null, ENTRY_COUNT);
-
-        long end = System.currentTimeMillis();
-
-        System.out.println(">>> Loaded " + cache.size() + " keys with backups in " + (end - start) + "ms.");
-    }
-
-    /**
-     * Executes transaction with read/write-through to persistent store.
-     *
-     * @param cache Cache to execute transaction on.
-     */
-    private static void executeTransaction(IgniteCache<Long, Person> cache) {
-        try (Transaction tx = Ignition.ignite().transactions().txStart()) {
-            Person val = cache.get(id);
-
-            System.out.println("Read value: " + val);
-
-            val = cache.getAndPut(id, new Person(id, "Isaac", "Newton"));
-
-            System.out.println("Overwrote old value: " + val);
-
-            val = cache.get(id);
-
-            System.out.println("Read value: " + val);
-
-            tx.commit();
-        }
-
-        System.out.println("Read value after commit: " + cache.get(id));
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/Person.hbm.xml
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/Person.hbm.xml b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/Person.hbm.xml
deleted file mode 100644
index 035ab98..0000000
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/Person.hbm.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?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.
--->
-
-
-<!DOCTYPE hibernate-mapping PUBLIC
-        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
-        "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
-
-<hibernate-mapping default-access="field">
-    <class name="org.apache.ignite.examples.datagrid.store.Person" table="PERSONS">
-        <!-- ID. -->
-        <id name="id"/>
-
-        <!-- We only map data we are interested in. -->
-        <property name="firstName"/>
-        <property name="lastName"/>
-    </class>
-</hibernate-mapping>

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/hibernate.cfg.xml
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/hibernate.cfg.xml b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/hibernate.cfg.xml
deleted file mode 100644
index 80a43e7..0000000
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/hibernate.cfg.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<?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.
--->
-
-<!DOCTYPE hibernate-configuration PUBLIC
-        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
-        "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
-
-<!--
-    Hibernate configuration.
--->
-<hibernate-configuration>
-    <session-factory>
-        <!-- Database connection settings (private in-memory database). -->
-        <property name="connection.url">jdbc:h2:mem:example;DB_CLOSE_DELAY=-1</property>
-
-        <!-- Only validate the database schema on startup in production mode. -->
-        <property name="hbm2ddl.auto">update</property>
-
-        <!-- Do not output SQL. -->
-        <property name="show_sql">false</property>
-
-        <!-- Mappings. -->
-        <mapping resource="org/apache/ignite/examples/datagrid/store/hibernate/Person.hbm.xml"/>
-    </session-factory>
-</hibernate-configuration>

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/package-info.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/package-info.java
deleted file mode 100644
index 7a6d6de..0000000
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * <!-- Package description. -->
- * Contains Hibernate-based cache store implementation.
- */
-package org.apache.ignite.examples.datagrid.store.hibernate;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples/src/test/java/org/apache/ignite/examples/HibernateL2CacheExampleMultiNodeSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java/org/apache/ignite/examples/HibernateL2CacheExampleMultiNodeSelfTest.java b/examples/src/test/java/org/apache/ignite/examples/HibernateL2CacheExampleMultiNodeSelfTest.java
deleted file mode 100644
index 1ca9b59..0000000
--- a/examples/src/test/java/org/apache/ignite/examples/HibernateL2CacheExampleMultiNodeSelfTest.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.examples;
-
-import org.apache.ignite.examples.datagrid.hibernate.HibernateL2CacheExample;
-
-/**
- * Multi-node test for {@link HibernateL2CacheExample}.
- */
-public class HibernateL2CacheExampleMultiNodeSelfTest extends HibernateL2CacheExampleSelfTest {
-    /** {@inheritDoc} */
-    @Override protected void beforeTest() throws Exception {
-        for (int i = 0; i < RMT_NODES_CNT; i++)
-            startGrid("node-" + i, "examples/config/example-ignite.xml");
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples/src/test/java/org/apache/ignite/examples/HibernateL2CacheExampleSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java/org/apache/ignite/examples/HibernateL2CacheExampleSelfTest.java b/examples/src/test/java/org/apache/ignite/examples/HibernateL2CacheExampleSelfTest.java
deleted file mode 100644
index 5f55e82..0000000
--- a/examples/src/test/java/org/apache/ignite/examples/HibernateL2CacheExampleSelfTest.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.examples;
-
-import org.apache.ignite.examples.datagrid.hibernate.HibernateL2CacheExample;
-import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
-
-/**
- * Tests the {@link HibernateL2CacheExample}.
- */
-public class HibernateL2CacheExampleSelfTest extends GridAbstractExamplesTest {
-    /**
-     * @throws Exception If failed.
-     */
-    public void testHibernateL2CacheExample() throws Exception {
-        HibernateL2CacheExample.main(EMPTY_ARGS);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples/src/test/java/org/apache/ignite/testsuites/IgniteExamplesSelfTestSuite.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java/org/apache/ignite/testsuites/IgniteExamplesSelfTestSuite.java b/examples/src/test/java/org/apache/ignite/testsuites/IgniteExamplesSelfTestSuite.java
index 4669ae4..57ff3ff 100644
--- a/examples/src/test/java/org/apache/ignite/testsuites/IgniteExamplesSelfTestSuite.java
+++ b/examples/src/test/java/org/apache/ignite/testsuites/IgniteExamplesSelfTestSuite.java
@@ -32,8 +32,6 @@ import org.apache.ignite.examples.DeploymentExamplesMultiNodeSelfTest;
 import org.apache.ignite.examples.DeploymentExamplesSelfTest;
 import org.apache.ignite.examples.EventsExamplesMultiNodeSelfTest;
 import org.apache.ignite.examples.EventsExamplesSelfTest;
-import org.apache.ignite.examples.HibernateL2CacheExampleMultiNodeSelfTest;
-import org.apache.ignite.examples.HibernateL2CacheExampleSelfTest;
 import org.apache.ignite.examples.IgfsExamplesSelfTest;
 import org.apache.ignite.examples.LifecycleExamplesSelfTest;
 import org.apache.ignite.examples.MemcacheRestExamplesMultiNodeSelfTest;
@@ -78,7 +76,6 @@ public class IgniteExamplesSelfTestSuite extends TestSuite {
         suite.addTest(new TestSuite(SpringBeanExamplesSelfTest.class));
         suite.addTest(new TestSuite(IgfsExamplesSelfTest.class));
         suite.addTest(new TestSuite(CheckpointExamplesSelfTest.class));
-        suite.addTest(new TestSuite(HibernateL2CacheExampleSelfTest.class));
         suite.addTest(new TestSuite(ClusterGroupExampleSelfTest.class));
 
         // Multi-node.
@@ -91,7 +88,6 @@ public class IgniteExamplesSelfTestSuite extends TestSuite {
         suite.addTest(new TestSuite(TaskExamplesMultiNodeSelfTest.class));
         suite.addTest(new TestSuite(MemcacheRestExamplesMultiNodeSelfTest.class));
         suite.addTest(new TestSuite(MonteCarloExamplesMultiNodeSelfTest.class));
-        suite.addTest(new TestSuite(HibernateL2CacheExampleMultiNodeSelfTest.class));
 
         return suite;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples/src/test/java8/org/apache/ignite/java8/examples/HibernateL2CacheExampleMultiNodeSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/examples/HibernateL2CacheExampleMultiNodeSelfTest.java b/examples/src/test/java8/org/apache/ignite/java8/examples/HibernateL2CacheExampleMultiNodeSelfTest.java
deleted file mode 100644
index 737d498..0000000
--- a/examples/src/test/java8/org/apache/ignite/java8/examples/HibernateL2CacheExampleMultiNodeSelfTest.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.java8.examples;
-
-/**
- * Multi-node test for {@link org.apache.ignite.examples.java8.datagrid.hibernate.HibernateL2CacheExample}.
- */
-public class HibernateL2CacheExampleMultiNodeSelfTest extends HibernateL2CacheExampleSelfTest {
-    /** {@inheritDoc} */
-    @Override protected void beforeTest() throws Exception {
-        for (int i = 0; i < RMT_NODES_CNT; i++)
-            startGrid("node-" + i, "examples/config/example-ignite.xml");
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/examples/src/test/java8/org/apache/ignite/java8/examples/HibernateL2CacheExampleSelfTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/examples/HibernateL2CacheExampleSelfTest.java b/examples/src/test/java8/org/apache/ignite/java8/examples/HibernateL2CacheExampleSelfTest.java
deleted file mode 100644
index 8c7a2de..0000000
--- a/examples/src/test/java8/org/apache/ignite/java8/examples/HibernateL2CacheExampleSelfTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.java8.examples;
-
-//import org.apache.ignite.examples.java8.datagrid.hibernate.*;
-
-import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest;
-
-/**
- * Tests the {@link org.apache.ignite.examples.java8.datagrid.hibernate.HibernateL2CacheExample}.
- */
-public class HibernateL2CacheExampleSelfTest extends GridAbstractExamplesTest {
-    /**
-     * TODO: IGNITE-711 next example(s) should be implemented for java 8
-     * or testing method(s) should be removed if example(s) does not applicable for java 8.
-     *
-     * @throws Exception If failed.
-     */
-//    public void testHibernateL2CacheExample() throws Exception {
-//        HibernateL2CacheExample.main(EMPTY_ARGS);
-//    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/c4b0877f/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 208dbbc..7b8763f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -458,7 +458,6 @@
             </modules>
         </profile>
 
-
         <profile>
             <id>lgpl</id>
             <modules>
@@ -466,6 +465,63 @@
                 <module>modules/geospatial</module>
                 <module>modules/schedule</module>
             </modules>
+
+            <build>
+                <plugins>
+                    <plugin>
+                        <artifactId>maven-assembly-plugin</artifactId>
+                        <dependencies>
+                            <dependency>
+                                <groupId>org.apache.apache.resources</groupId>
+                                <artifactId>apache-source-release-assembly-descriptor</artifactId>
+                                <version>1.0.4</version>
+                            </dependency>
+                        </dependencies>
+                        <executions>
+                            <execution>
+                                <id>release-lgpl</id>
+                                <phase>prepare-package</phase>
+                                <goals>
+                                    <goal>single</goal>
+                                </goals>
+                                <configuration>
+                                    <descriptors>
+                                        <descriptor>assembly/release-${ignite.edition}-lgpl.xml</descriptor>
+                                    </descriptors>
+                                    <finalName>release-package</finalName>
+                                    <appendAssemblyId>false</appendAssemblyId>
+                                </configuration>
+                            </execution>
+                        </executions>
+                    </plugin>
+
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-antrun-plugin</artifactId>
+                        <version>1.7</version>
+                        <inherited>false</inherited>
+                        <executions>
+                            <execution>
+                                <id>release-postprocessing-lgpl</id>
+                                <goals>
+                                    <goal>run</goal>
+                                </goals>
+                                <phase>package</phase>
+                                <configuration>
+                                    <target>
+                                        <replaceregexp file="${basedir}/target/release-package/examples-lgpl/pom.xml"
+                                                       byline="true">
+                                            <regexp pattern="to_be_replaced_by_ignite_version"/>
+                                            <substitution expression="${project.version}"/>
+                                        </replaceregexp>
+                                    </target>
+                                </configuration>
+                            </execution>
+                        </executions>
+                    </plugin>
+
+                </plugins>
+            </build>
         </profile>
 
         <profile>
@@ -477,6 +533,13 @@
         </profile>
 
         <profile>
+            <id>examples-lgpl</id>
+            <modules>
+                <module>examples-lgpl</module>
+            </modules>
+        </profile>
+
+        <profile>
             <id>apache-release</id>
             <build>
                 <plugins>


[05/50] [abbrv] ignite git commit: ignite-1526: full support of IBM JDK by Ignite

Posted by ag...@apache.org.
ignite-1526: full support of IBM JDK by Ignite


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

Branch: refs/heads/ignite-1016
Commit: a1e5cc5783fc4b20f8c01f3b7af17a9ac772afd6
Parents: d917733
Author: Andrey Gura <ag...@gridgain.com>
Authored: Fri Oct 9 13:54:56 2015 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Fri Oct 9 13:54:56 2015 +0300

----------------------------------------------------------------------
 .../discovery/GridDiscoveryManager.java         |   17 +-
 .../internal/portable/PortableContext.java      |    7 +
 .../portable/api/PortableMarshaller.java        |   14 +-
 .../ignite/internal/util/GridJavaProcess.java   |   12 +-
 .../ignite/internal/util/lang/GridFunc.java     |   12 +
 .../apache/ignite/marshaller/Marshaller.java    |    2 +-
 .../optimized/OptimizedMarshallerUtils.java     |    6 +-
 .../cache/GridCacheAbstractFullApiSelfTest.java |  486 ++++---
 .../CacheNoValueClassOnServerNodeTest.java      |    1 +
 ...tomicClientOnlyMultiNodeFullApiSelfTest.java |   71 +-
 ...achePartitionedMultiNodeFullApiSelfTest.java |  129 +-
 .../testframework/junits/GridAbstractTest.java  |  116 +-
 .../junits/IgniteTestResources.java             |    8 +-
 .../junits/common/GridCommonAbstractTest.java   |   15 +-
 .../junits/multijvm/AffinityProcessProxy.java   |  440 ++++--
 .../multijvm/IgniteCacheProcessProxy.java       | 1346 ++++++++++++++----
 .../multijvm/IgniteClusterProcessProxy.java     |  115 +-
 .../multijvm/IgniteEventsProcessProxy.java      |   50 +-
 .../junits/multijvm/IgniteNodeRunner.java       |   39 +-
 .../junits/multijvm/IgniteProcessProxy.java     |  107 +-
 .../cache/CacheConfigurationP2PTest.java        |    3 +
 21 files changed, 2185 insertions(+), 811 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/a1e5cc57/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 a6f5f08..2ed4520 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
@@ -987,19 +987,24 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
 
         boolean locP2pEnabled = locNode.attribute(ATTR_PEER_CLASSLOADING);
 
-        boolean warned = false;
+        boolean ipV4Warned = false;
+
+        boolean jvmMajVerWarned = false;
 
         for (ClusterNode n : nodes) {
             int rmtJvmMajVer = nodeJavaMajorVersion(n);
 
-            if (locJvmMajVer != rmtJvmMajVer)
-                throw new IgniteCheckedException("Local node's java major version is different from remote node's one" +
-                    " [locJvmMajVer=" + locJvmMajVer + ", rmtJvmMajVer=" + rmtJvmMajVer + "]");
+            if (locJvmMajVer != rmtJvmMajVer && !jvmMajVerWarned) {
+                U.warn(log, "Local java version is different from remote [loc=" +
+                    locJvmMajVer + ", rmt=" + rmtJvmMajVer + "]");
+
+                jvmMajVerWarned = true;
+            }
 
             String rmtPreferIpV4 = n.attribute("java.net.preferIPv4Stack");
 
             if (!F.eq(rmtPreferIpV4, locPreferIpV4)) {
-                if (!warned)
+                if (!ipV4Warned)
                     U.warn(log, "Local node's value of 'java.net.preferIPv4Stack' " +
                         "system property differs from remote node's " +
                         "(all nodes in topology should have identical value) " +
@@ -1008,7 +1013,7 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
                         ", rmtAddrs=" + U.addressesAsString(n) + ']',
                         "Local and remote 'java.net.preferIPv4Stack' system properties do not match.");
 
-                warned = true;
+                ipV4Warned = true;
             }
 
             // Daemon nodes are allowed to have any deployment they need.

http://git-wip-us.apache.org/repos/asf/ignite/blob/a1e5cc57/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
index 2ee96b7..1ad42ab 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
@@ -967,6 +967,9 @@ public class PortableContext implements Externalizable {
         }
     }
 
+    /**
+     * Basic class ID mapper.
+     */
     private static class BasicClassIdMapper implements PortableIdMapper {
         /** {@inheritDoc} */
         @Override public int typeId(String clsName) {
@@ -1121,6 +1124,10 @@ public class PortableContext implements Externalizable {
         /** Whether the following type is registered in a cache or not */
         private final boolean registered;
 
+        /**
+         * @param id Id.
+         * @param registered Registered.
+         */
         public Type(int id, boolean registered) {
             this.id = id;
             this.registered = registered;

http://git-wip-us.apache.org/repos/asf/ignite/blob/a1e5cc57/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableMarshaller.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableMarshaller.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableMarshaller.java
index de0df8d..3dfbdf0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableMarshaller.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableMarshaller.java
@@ -29,12 +29,6 @@ import org.apache.ignite.internal.portable.GridPortableMarshaller;
 import org.apache.ignite.internal.portable.PortableContext;
 import org.apache.ignite.marshaller.AbstractMarshaller;
 import org.apache.ignite.marshaller.MarshallerContext;
-import org.apache.ignite.internal.portable.api.PortableException;
-import org.apache.ignite.internal.portable.api.PortableIdMapper;
-import org.apache.ignite.internal.portable.api.PortableObject;
-import org.apache.ignite.internal.portable.api.PortableProtocolVersion;
-import org.apache.ignite.internal.portable.api.PortableSerializer;
-import org.apache.ignite.internal.portable.api.PortableTypeConfiguration;
 import org.jetbrains.annotations.Nullable;
 
 /**
@@ -336,7 +330,7 @@ public class PortableMarshaller extends AbstractMarshaller {
 
     /** {@inheritDoc} */
     @Override public <T> T unmarshal(InputStream in, @Nullable ClassLoader clsLdr) throws IgniteCheckedException {
-        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+        ByteArrayOutputStream buf = new ByteArrayOutputStream();
 
         byte[] arr = new byte[4096];
         int cnt;
@@ -345,11 +339,11 @@ public class PortableMarshaller extends AbstractMarshaller {
         // returns number of bytes remaining.
         try {
             while ((cnt = in.read(arr)) != -1)
-                buffer.write(arr, 0, cnt);
+                buf.write(arr, 0, cnt);
 
-            buffer.flush();
+            buf.flush();
 
-            return impl.deserialize(buffer.toByteArray(), clsLdr);
+            return impl.deserialize(buf.toByteArray(), clsLdr);
         }
         catch (IOException e) {
             throw new PortableException("Failed to unmarshal the object from InputStream", e);

http://git-wip-us.apache.org/repos/asf/ignite/blob/a1e5cc57/modules/core/src/main/java/org/apache/ignite/internal/util/GridJavaProcess.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/GridJavaProcess.java b/modules/core/src/main/java/org/apache/ignite/internal/util/GridJavaProcess.java
index 92c20fe..3371eb8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/GridJavaProcess.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/GridJavaProcess.java
@@ -89,7 +89,7 @@ public final class GridJavaProcess {
      */
     public static GridJavaProcess exec(Class cls, String params, @Nullable IgniteLogger log,
         @Nullable IgniteInClosure<String> printC, @Nullable GridAbsClosure procKilledC) throws Exception {
-        return exec(cls.getCanonicalName(), params, log, printC, procKilledC, null, null);
+        return exec(cls.getCanonicalName(), params, log, printC, procKilledC, null, null, null);
     }
 
     /**
@@ -108,7 +108,7 @@ public final class GridJavaProcess {
     public static GridJavaProcess exec(Class cls, String params, @Nullable IgniteLogger log,
         @Nullable IgniteInClosure<String> printC, @Nullable GridAbsClosure procKilledC,
         @Nullable Collection<String> jvmArgs, @Nullable String cp) throws Exception {
-        return exec(cls.getCanonicalName(), params, log, printC, procKilledC, jvmArgs, cp);
+        return exec(cls.getCanonicalName(), params, log, printC, procKilledC, null, jvmArgs, cp);
     }
 
     /**
@@ -116,9 +116,10 @@ public final class GridJavaProcess {
      *
      * @param clsName Class with main() method to be run.
      * @param params main() method parameters.
+     * @param log Log to use.
      * @param printC Optional closure to be called each time wrapped process prints line to system.out or system.err.
      * @param procKilledC Optional closure to be called when process termination is detected.
-     * @param log Log to use.
+     * @param javaHome Java home location. The process will be started under given JVM.
      * @param jvmArgs JVM arguments to use.
      * @param cp Additional classpath.
      * @return Wrapper around {@link Process}
@@ -126,7 +127,7 @@ public final class GridJavaProcess {
      */
     public static GridJavaProcess exec(String clsName, String params, @Nullable IgniteLogger log,
         @Nullable IgniteInClosure<String> printC, @Nullable GridAbsClosure procKilledC,
-        @Nullable Collection<String> jvmArgs, @Nullable String cp) throws Exception {
+        @Nullable String javaHome, @Nullable Collection<String> jvmArgs, @Nullable String cp) throws Exception {
         if (!(U.isLinux() || U.isMacOs() || U.isWindows()))
             throw new Exception("Your OS is not supported.");
 
@@ -140,7 +141,8 @@ public final class GridJavaProcess {
 
         List<String> procCommands = new ArrayList<>();
 
-        String javaBin = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java";
+        String javaBin = (javaHome == null ? System.getProperty("java.home") : javaHome) +
+            File.separator + "bin" + File.separator + "java";
 
         procCommands.add(javaBin);
         procCommands.addAll(jvmArgs == null ? U.jvmArgs() : jvmArgs);

http://git-wip-us.apache.org/repos/asf/ignite/blob/a1e5cc57/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
index ffeeca0..43bc5f3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
@@ -103,6 +103,9 @@ public class GridFunc {
 
     /** */
     private static final IgniteClosure IDENTITY = new C1() {
+        /** */
+        private static final long serialVersionUID = -6338573080046225172L;
+
         @Override public Object apply(Object o) {
             return o;
         }
@@ -1196,6 +1199,9 @@ public class GridFunc {
         A.notNull(nodeId, "nodeId");
 
         return new P1<T>() {
+            /** */
+            private static final long serialVersionUID = -7082730222779476623L;
+
             @Override public boolean apply(ClusterNode e) {
                 return e.id().equals(nodeId);
             }
@@ -1705,6 +1711,9 @@ public class GridFunc {
         assert c != null;
 
         return new GridSerializableList<T2>() {
+            /** */
+            private static final long serialVersionUID = 3126625219739967068L;
+
             @Override public T2 get(int idx) {
                 return trans.apply(c.get(idx));
             }
@@ -1766,6 +1775,9 @@ public class GridFunc {
         assert m != null;
 
         return isEmpty(p) || isAlwaysTrue(p) ? m : new GridSerializableMap<K, V>() {
+            /** */
+            private static final long serialVersionUID = 5531745605372387948L;
+
             /** Entry predicate. */
             private IgnitePredicate<Entry<K, V>> ep = new P1<Map.Entry<K, V>>() {
                 @Override public boolean apply(Entry<K, V> e) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/a1e5cc57/modules/core/src/main/java/org/apache/ignite/marshaller/Marshaller.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/Marshaller.java b/modules/core/src/main/java/org/apache/ignite/marshaller/Marshaller.java
index 3e815fd..a76daa8 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/Marshaller.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/Marshaller.java
@@ -92,7 +92,7 @@ public interface Marshaller {
     public byte[] marshal(@Nullable Object obj) throws IgniteCheckedException;
 
     /**
-     * Unmarshals object from the output stream using given class loader.
+     * Unmarshals object from the input stream using given class loader.
      * This method should not close given input stream.
      *
      * @param <T> Type of unmarshalled object.

http://git-wip-us.apache.org/repos/asf/ignite/blob/a1e5cc57/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerUtils.java b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerUtils.java
index 4abbd04..584083c 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerUtils.java
@@ -42,6 +42,10 @@ class OptimizedMarshallerUtils {
     /** */
     private static final Unsafe UNSAFE = GridUnsafe.unsafe();
 
+    /** Use default {@code serialVersionUid} for {@link Serializable} classes. */
+    private static final boolean USE_DFLT_SUID =
+        Boolean.valueOf(System.getProperty("ignite.marsh.optimized.useDefaultSUID", Boolean.TRUE.toString()));
+
     /** */
     static final long HASH_SET_MAP_OFF;
 
@@ -283,7 +287,7 @@ class OptimizedMarshallerUtils {
      */
     @SuppressWarnings("ForLoopReplaceableByForEach")
     static short computeSerialVersionUid(Class cls, List<Field> fields) throws IOException {
-        if (Serializable.class.isAssignableFrom(cls) && !Enum.class.isAssignableFrom(cls))
+        if (USE_DFLT_SUID && Serializable.class.isAssignableFrom(cls) && !Enum.class.isAssignableFrom(cls))
             return (short)ObjectStreamClass.lookup(cls).getSerialVersionUID();
 
         MessageDigest md;

http://git-wip-us.apache.org/repos/asf/ignite/blob/a1e5cc57/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
index 2a64963..ec3ea0c 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
@@ -19,6 +19,7 @@ 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;
 import java.util.Collection;
@@ -49,6 +50,7 @@ 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.CacheEntryProcessor;
 import org.apache.ignite.cache.CacheMemoryMode;
@@ -75,6 +77,7 @@ import org.apache.ignite.internal.util.typedef.internal.U;
 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.spi.discovery.tcp.TcpDiscoverySpi;
 import org.apache.ignite.spi.swapspace.inmemory.GridTestSwapSpaceSpi;
 import org.apache.ignite.testframework.GridTestUtils;
@@ -117,48 +120,37 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
     /** */
     public static final CacheEntryProcessor<String, Integer, String> ERR_PROCESSOR =
         new CacheEntryProcessor<String, Integer, String>() {
+            /** */
+            private static final long serialVersionUID = 0L;
+
             @Override public String process(MutableEntry<String, Integer> e, Object... args) {
                 throw new RuntimeException("Failed!");
             }
         };
 
     /** Increment processor for invoke operations. */
-    public static final EntryProcessor<String, Integer, String> INCR_PROCESSOR = new EntryProcessor<String, Integer, String>() {
-        @Override public String process(MutableEntry<String, Integer> e, Object... args) {
-            assertNotNull(e.getKey());
-
-            Integer old = e.getValue();
-
-            e.setValue(old == null ? 1 : old + 1);
-
-            return String.valueOf(old);
-        }
-    };
+    public static final EntryProcessor<String, Integer, String> INCR_PROCESSOR = new IncrementEntryProcessor();
 
     /** Increment processor for invoke operations with IgniteEntryProcessor. */
     public static final CacheEntryProcessor<String, Integer, String> INCR_IGNITE_PROCESSOR =
         new CacheEntryProcessor<String, Integer, String>() {
+            /** */
+            private static final long serialVersionUID = 0L;
+
             @Override public String process(MutableEntry<String, Integer> e, Object... args) {
                 return INCR_PROCESSOR.process(e, args);
             }
         };
 
     /** Increment processor for invoke operations. */
-    public static final EntryProcessor<String, Integer, String> RMV_PROCESSOR = new EntryProcessor<String, Integer, String>() {
-        @Override public String process(MutableEntry<String, Integer> e, Object... args) {
-            assertNotNull(e.getKey());
-
-            Integer old = e.getValue();
-
-            e.remove();
-
-            return String.valueOf(old);
-        }
-    };
+    public static final EntryProcessor<String, Integer, String> RMV_PROCESSOR = new RemoveEntryProcessor();
 
     /** Increment processor for invoke operations with IgniteEntryProcessor. */
     public static final CacheEntryProcessor<String, Integer, String> RMV_IGNITE_PROCESSOR =
         new CacheEntryProcessor<String, Integer, String>() {
+            /** */
+            private static final long serialVersionUID = 0L;
+
             @Override public String process(MutableEntry<String, Integer> e, Object... args) {
                 return RMV_PROCESSOR.process(e, args);
             }
@@ -346,21 +338,8 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
             assert jcache(i).localSize() != 0 || F.isEmpty(keysCol);
         }
 
-        for (int i = 0; i < gridCount(); i++) {
-            executeOnLocalOrRemoteJvm(i, new TestIgniteIdxRunnable() {
-                @Override public void run(int idx) throws Exception {
-                    GridCacheContext<String, Integer> ctx = context(idx);
-
-                    int sum = 0;
-
-                    for (String key : map.keySet())
-                        if (ctx.affinity().localNode(key, new AffinityTopologyVersion(ctx.discovery().topologyVersion())))
-                            sum++;
-
-                    assertEquals("Incorrect key size on cache #" + idx, sum, jcache(idx).localSize(ALL));
-                }
-            });
-        }
+        for (int i = 0; i < gridCount(); i++)
+            executeOnLocalOrRemoteJvm(i, new CheckCacheSizeTask(map));
 
         for (int i = 0; i < gridCount(); i++) {
             Collection<String> keysCol = mapped.get(grid(i).localNode());
@@ -1350,13 +1329,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
 
         assertEquals((Integer)3, cache.get("k1"));
 
-        EntryProcessor<String, Integer, Integer> c = new EntryProcessor<String, Integer, Integer>() {
-            @Override public Integer process(MutableEntry<String, Integer> e, Object... args) {
-                e.remove();
-
-                return null;
-            }
-        };
+        EntryProcessor<String, Integer, Integer> c = new RemoveAndReturnNullEntryProcessor();
 
         assertNull(cache.invoke("k1", c));
         assertNull(cache.get("k1"));
@@ -1364,11 +1337,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
         for (int i = 0; i < gridCount(); i++)
             assertNull(jcache(i).localPeek("k1", ONHEAP));
 
-        final EntryProcessor<String, Integer, Integer> errProcessor = new EntryProcessor<String, Integer, Integer>() {
-            @Override public Integer process(MutableEntry<String, Integer> e, Object... args) {
-                throw new EntryProcessorException("Test entry processor exception.");
-            }
-        };
+        final EntryProcessor<String, Integer, Integer> errProcessor = new FailedEntryProcessor();
 
         GridTestUtils.assertThrows(log, new Callable<Void>() {
             @Override public Void call() throws Exception {
@@ -2001,7 +1970,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
             assertFalse(cacheAsync.<Boolean>future().get());
         }
 
-        cache.localEvict(Arrays.asList("key2"));
+        cache.localEvict(Collections.singletonList("key2"));
 
         // Same checks inside tx.
         Transaction tx = inTx ? transactions().txStart() : null;
@@ -2357,27 +2326,8 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
             for (int i = 0; i < cnt; i++)
                 cache.remove(String.valueOf(i));
 
-            for (int g = 0; g < gridCount(); g++) {
-                executeOnLocalOrRemoteJvm(g, new TestIgniteIdxRunnable() {
-                    @Override public void run(int idx) throws Exception {
-                        for (int i = 0; i < cnt; i++) {
-                            String key = String.valueOf(i);
-
-                            GridCacheContext<String, Integer> cctx = context(idx);
-
-                            GridCacheEntryEx entry = cctx.isNear() ? cctx.near().dht().peekEx(key) :
-                                cctx.cache().peekEx(key);
-
-                            if (grid(idx).affinity(null).mapKeyToPrimaryAndBackups(key).contains(grid(idx).localNode())) {
-                                assertNotNull(entry);
-                                assertTrue(entry.deleted());
-                            }
-                            else
-                                assertNull(entry);
-                        }
-                    }
-                });
-            }
+            for (int g = 0; g < gridCount(); g++)
+                executeOnLocalOrRemoteJvm(g, new CheckEntriesDeletedTask(cnt));
         }
     }
 
@@ -2587,8 +2537,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
         c.add(null);
 
         GridTestUtils.assertThrows(log, new Callable<Void>() {
-            @Override
-            public Void call() throws Exception {
+            @Override public Void call() throws Exception {
                 cache.removeAll(c);
 
                 return null;
@@ -2725,7 +2674,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
     public void testRemoveAfterClear() throws Exception {
         IgniteEx ignite = grid(0);
 
-        boolean affNode = ((IgniteKernal)ignite).context().cache().internalCache(null).context().affinityNode();
+        boolean affNode = ignite.context().cache().internalCache(null).context().affinityNode();
 
         if (!affNode) {
             if (gridCount() < 2)
@@ -2766,13 +2715,6 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
     }
 
     /**
-     *
-     */
-    private void xxx() {
-        System.out.printf("");
-    }
-
-    /**
      * @throws Exception In case of error.
      */
     public void testClear() throws Exception {
@@ -3597,26 +3539,9 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
             info("Local keys (primary + backup): " + locKeys);
         }
 
-        for (int i = 0; i < gridCount(); i++) {
-            grid(i).events().localListen(new IgnitePredicate<Event>() {
-                @Override public boolean apply(Event evt) {
-                    info("Received event: " + evt);
-
-                    switch (evt.type()) {
-                        case EVT_CACHE_OBJECT_SWAPPED:
-                            swapEvts.incrementAndGet();
-
-                            break;
-                        case EVT_CACHE_OBJECT_UNSWAPPED:
-                            unswapEvts.incrementAndGet();
-
-                            break;
-                    }
-
-                    return true;
-                }
-            }, EVT_CACHE_OBJECT_SWAPPED, EVT_CACHE_OBJECT_UNSWAPPED);
-        }
+        for (int i = 0; i < gridCount(); i++)
+            grid(i).events().localListen(
+                new SwapEvtsLocalListener(swapEvts, unswapEvts), EVT_CACHE_OBJECT_SWAPPED, EVT_CACHE_OBJECT_UNSWAPPED);
 
         cache.localEvict(F.asList(k2, k3));
 
@@ -3934,7 +3859,6 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
                 map.put(entry.getKey(), entry.getValue());
         }
 
-        assert map != null;
         assert map.size() == 2;
         assert map.get("key1") == 1;
         assert map.get("key2") == 2;
@@ -3951,32 +3875,8 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
         if (nearEnabled())
             assertEquals(keys.size(), jcache().localSize(CachePeekMode.ALL));
         else {
-            for (int i = 0; i < gridCount(); i++) {
-                executeOnLocalOrRemoteJvm(i, new TestIgniteIdxRunnable() {
-                    @Override public void run(int idx) throws Exception {
-                        GridCacheContext<String, Integer> ctx = context(idx);
-
-                        if (ctx.cache().configuration().getMemoryMode() == OFFHEAP_TIERED)
-                            return;
-
-                        int size = 0;
-
-                        for (String key : keys) {
-                            if (ctx.affinity().localNode(key, ctx.discovery().topologyVersionEx())) {
-                                GridCacheEntryEx e =
-                                    ctx.isNear() ? ctx.near().dht().peekEx(key) : ctx.cache().peekEx(key);
-
-                                assert e != null : "Entry is null [idx=" + idx + ", key=" + key + ", ctx=" + ctx + ']';
-                                assert !e.deleted() : "Entry is deleted: " + e;
-
-                                size++;
-                            }
-                        }
-
-                        assertEquals("Incorrect size on cache #" + idx, size, jcache(idx).localSize(ALL));
-                    }
-                });
-            }
+            for (int i = 0; i < gridCount(); i++)
+                executeOnLocalOrRemoteJvm(i, new CheckEntriesTask(keys));
         }
     }
 
@@ -3989,21 +3889,8 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
             assertEquals("Invalid key size: " + jcache().localSize(ALL),
                 keys.size(), jcache().localSize(ALL));
         else {
-            for (int i = 0; i < gridCount(); i++) {
-                executeOnLocalOrRemoteJvm(i, new TestIgniteIdxRunnable() {
-                    @Override public void run(int idx) throws Exception {
-                        GridCacheContext<String, Integer> ctx = context(idx);
-
-                        int size = 0;
-
-                        for (String key : keys)
-                            if (ctx.affinity().localNode(key, ctx.discovery().topologyVersionEx()))
-                                size++;
-
-                        assertEquals("Incorrect key size on cache #" + idx, size, jcache(idx).localSize(ALL));
-                    }
-                });
-            }
+            for (int i = 0; i < gridCount(); i++)
+                executeOnLocalOrRemoteJvm(i, new CheckKeySizeTask(keys));
         }
     }
 
@@ -4061,27 +3948,8 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
      * @param cnt Keys count.
      * @return Collection of keys for which given cache is primary.
      */
-    protected List<String> primaryKeysForCache(final IgniteCache<String, Integer> cache, final int cnt, final int startFrom) {
-        return executeOnLocalOrRemoteJvm(cache, new TestCacheCallable<String, Integer, List<String>>() {
-            @Override public List<String> call(Ignite ignite, IgniteCache<String, Integer> cache) throws Exception {
-                List<String> found = new ArrayList<>();
-
-                Affinity<Object> affinity = ignite.affinity(cache.getName());
-
-                for (int i = startFrom; i < startFrom + 100_000; i++) {
-                    String key = "key" + i;
-
-                    if (affinity.isPrimary(ignite.cluster().localNode(), key)) {
-                        found.add(key);
-
-                        if (found.size() == cnt)
-                            return found;
-                    }
-                }
-
-                throw new IgniteException("Unable to find " + cnt + " keys as primary for cache.");
-            }
-        });
+    protected List<String> primaryKeysForCache(IgniteCache<String, Integer> cache, int cnt, int startFrom) {
+        return executeOnLocalOrRemoteJvm(cache, new CheckPrimaryKeysTask(startFrom, cnt));
     }
 
     /**
@@ -4272,18 +4140,8 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
      * Checks iterators are cleared.
      */
     private void checkIteratorsCleared() {
-        for (int j = 0; j < gridCount(); j++) {
-            executeOnLocalOrRemoteJvm(j, new TestIgniteIdxRunnable() {
-                @Override public void run(int idx) throws Exception {
-                    GridCacheQueryManager queries = context(idx).queries();
-
-                    Map map = GridTestUtils.getFieldValue(queries, GridCacheQueryManager.class, "qryIters");
-
-                    for (Object obj : map.values())
-                        assertEquals("Iterators not removed for grid " + idx, 0, ((Map)obj).size());
-                }
-            });
-        }
+        for (int j = 0; j < gridCount(); j++)
+            executeOnLocalOrRemoteJvm(j, new CheckIteratorTask());
     }
 
     /**
@@ -5226,4 +5084,280 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
         /** */
         ONE_BY_ONE
     }
+
+    /**
+     *
+     */
+    private static class RemoveEntryProcessor implements EntryProcessor<String, Integer, String>, Serializable {
+        /** {@inheritDoc} */
+        @Override public String process(MutableEntry<String, Integer> e, Object... args) {
+            assertNotNull(e.getKey());
+
+            Integer old = e.getValue();
+
+            e.remove();
+
+            return String.valueOf(old);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class IncrementEntryProcessor implements EntryProcessor<String, Integer, String>, Serializable {
+        /** {@inheritDoc} */
+        @Override public String process(MutableEntry<String, Integer> e, Object... args) {
+            assertNotNull(e.getKey());
+
+            Integer old = e.getValue();
+
+            e.setValue(old == null ? 1 : old + 1);
+
+            return String.valueOf(old);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class CheckEntriesTask extends TestIgniteIdxRunnable {
+        /** Keys. */
+        private final Collection<String> keys;
+
+        /**
+         * @param keys Keys.
+         */
+        public CheckEntriesTask(Collection<String> keys) {
+            this.keys = keys;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void run(int idx) throws Exception {
+            GridCacheContext<String, Integer> ctx = ((IgniteKernal)ignite).<String, Integer>internalCache().context();
+
+            if (ctx.cache().configuration().getMemoryMode() == OFFHEAP_TIERED)
+                return;
+
+            int size = 0;
+
+            for (String key : keys) {
+                if (ctx.affinity().localNode(key, ctx.discovery().topologyVersionEx())) {
+                    GridCacheEntryEx e =
+                        ctx.isNear() ? ctx.near().dht().peekEx(key) : ctx.cache().peekEx(key);
+
+                    assert e != null : "Entry is null [idx=" + idx + ", key=" + key + ", ctx=" + ctx + ']';
+                    assert !e.deleted() : "Entry is deleted: " + e;
+
+                    size++;
+                }
+            }
+
+            assertEquals("Incorrect size on cache #" + idx, size, ignite.cache(ctx.name()).localSize(ALL));
+        }
+    }
+
+    /**
+     *
+     */
+    private static class CheckCacheSizeTask extends TestIgniteIdxRunnable {
+        private final Map<String, Integer> map;
+
+        /**
+         * @param map Map.
+         */
+        public CheckCacheSizeTask(Map<String, Integer> map) {
+            this.map = map;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void run(int idx) throws Exception {
+            GridCacheContext<String, Integer> ctx = ((IgniteKernal)ignite).<String, Integer>internalCache().context();
+
+            int size = 0;
+
+            for (String key : map.keySet())
+                if (ctx.affinity().localNode(key, new AffinityTopologyVersion(ctx.discovery().topologyVersion())))
+                    size++;
+
+            assertEquals("Incorrect key size on cache #" + idx, size, ignite.cache(ctx.name()).localSize(ALL));
+        }
+    }
+
+    /**
+     *
+     */
+    private static class CheckPrimaryKeysTask implements TestCacheCallable<String, Integer, List<String>> {
+        /** Start from. */
+        private final int startFrom;
+
+        /** Count. */
+        private final int cnt;
+
+        /**
+         * @param startFrom Start from.
+         * @param cnt Count.
+         */
+        public CheckPrimaryKeysTask(int startFrom, int cnt) {
+            this.startFrom = startFrom;
+            this.cnt = cnt;
+        }
+
+        /** {@inheritDoc} */
+        @Override public List<String> call(Ignite ignite, IgniteCache<String, Integer> cache) throws Exception {
+            List<String> found = new ArrayList<>();
+
+            Affinity<Object> affinity = ignite.affinity(cache.getName());
+
+            for (int i = startFrom; i < startFrom + 100_000; i++) {
+                String key = "key" + i;
+
+                if (affinity.isPrimary(ignite.cluster().localNode(), key)) {
+                    found.add(key);
+
+                    if (found.size() == cnt)
+                        return found;
+                }
+            }
+
+            throw new IgniteException("Unable to find " + cnt + " keys as primary for cache.");
+        }
+    }
+
+    /**
+     *
+     */
+    private static class CheckIteratorTask extends TestIgniteIdxCallable<Void> {
+        /**
+         * @param idx Index.
+         */
+        @Override public Void call(int idx) throws Exception {
+            GridCacheContext<String, Integer> ctx = ((IgniteKernal)ignite).<String, Integer>internalCache().context();
+            GridCacheQueryManager queries = ctx.queries();
+
+            Map map = GridTestUtils.getFieldValue(queries, GridCacheQueryManager.class, "qryIters");
+
+            for (Object obj : map.values())
+                assertEquals("Iterators not removed for grid " + idx, 0, ((Map)obj).size());
+
+            return null;
+        }
+    }
+
+    /**
+     *
+     */
+    private static class RemoveAndReturnNullEntryProcessor implements
+        EntryProcessor<String, Integer, Integer>, Serializable {
+
+        /** {@inheritDoc} */
+        @Override public Integer process(MutableEntry<String, Integer> e, Object... args) {
+            e.remove();
+
+            return null;
+        }
+    }
+
+    /**
+     *
+     */
+    private static class SwapEvtsLocalListener implements IgnitePredicate<Event> {
+        @LoggerResource
+        private IgniteLogger log;
+
+        /** Swap events. */
+        private final AtomicInteger swapEvts;
+
+        /** Unswap events. */
+        private final AtomicInteger unswapEvts;
+
+        /**
+         * @param swapEvts Swap events.
+         * @param unswapEvts Unswap events.
+         */
+        public SwapEvtsLocalListener(AtomicInteger swapEvts, AtomicInteger unswapEvts) {
+            this.swapEvts = swapEvts;
+            this.unswapEvts = unswapEvts;
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean apply(Event evt) {
+            log.info("Received event: " + evt);
+
+            switch (evt.type()) {
+                case EVT_CACHE_OBJECT_SWAPPED:
+                    swapEvts.incrementAndGet();
+
+                    break;
+                case EVT_CACHE_OBJECT_UNSWAPPED:
+                    unswapEvts.incrementAndGet();
+
+                    break;
+            }
+
+            return true;
+        }
+    }
+
+    private static class CheckEntriesDeletedTask extends TestIgniteIdxRunnable {
+        private final int cnt;
+
+        public CheckEntriesDeletedTask(int cnt) {
+            this.cnt = cnt;
+        }
+
+        @Override public void run(int idx) throws Exception {
+            for (int i = 0; i < cnt; i++) {
+                String key = String.valueOf(i);
+
+                GridCacheContext<String, Integer> ctx = ((IgniteKernal)ignite).<String, Integer>internalCache().context();
+
+                GridCacheEntryEx entry = ctx.isNear() ? ctx.near().dht().peekEx(key) : ctx.cache().peekEx(key);
+
+                if (ignite.affinity(null).mapKeyToPrimaryAndBackups(key).contains(((IgniteKernal)ignite).localNode())) {
+                    assertNotNull(entry);
+                    assertTrue(entry.deleted());
+                }
+                else
+                    assertNull(entry);
+            }
+        }
+    }
+
+    /**
+     *
+     */
+    private static class CheckKeySizeTask extends TestIgniteIdxRunnable {
+        /** Keys. */
+        private final Collection<String> keys;
+
+        /**
+         * @param keys Keys.
+         */
+        public CheckKeySizeTask(Collection<String> keys) {
+            this.keys = keys;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void run(int idx) throws Exception {
+            GridCacheContext<String, Integer> ctx = ((IgniteKernal)ignite).<String, Integer>internalCache().context();
+
+            int size = 0;
+
+            for (String key : keys)
+                if (ctx.affinity().localNode(key, ctx.discovery().topologyVersionEx()))
+                    size++;
+
+            assertEquals("Incorrect key size on cache #" + idx, size, ignite.cache(null).localSize(ALL));
+        }
+    }
+
+    /**
+     *
+     */
+    private static class FailedEntryProcessor implements EntryProcessor<String, Integer, Integer>, Serializable {
+        /** {@inheritDoc} */
+        @Override public Integer process(MutableEntry<String, Integer> e, Object... args) {
+            throw new EntryProcessorException("Test entry processor exception.");
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/a1e5cc57/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNoValueClassOnServerNodeTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNoValueClassOnServerNodeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNoValueClassOnServerNodeTest.java
index da694b5..c6ce81e 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNoValueClassOnServerNodeTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheNoValueClassOnServerNodeTest.java
@@ -111,6 +111,7 @@ public class CacheNoValueClassOnServerNodeTest extends GridCommonAbstractTest {
                         }
                     },
                     null,
+                    null,
                     jvmArgs,
                     cp
                 );

http://git-wip-us.apache.org/repos/asf/ignite/blob/a1e5cc57/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest.java
index 1511c45..927ee62 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest.java
@@ -22,6 +22,7 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -29,6 +30,7 @@ import java.util.concurrent.atomic.AtomicInteger;
 import javax.cache.expiry.Duration;
 import javax.cache.expiry.TouchedExpiryPolicy;
 import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteLogger;
 import org.apache.ignite.cache.CacheAtomicityMode;
 import org.apache.ignite.cache.CachePeekMode;
 import org.apache.ignite.configuration.CacheConfiguration;
@@ -37,6 +39,7 @@ import org.apache.ignite.events.Event;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.resources.LoggerResource;
 
 import static java.util.concurrent.TimeUnit.MILLISECONDS;
 import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
@@ -106,9 +109,11 @@ public class GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest extends GridCache
 
         affinityNodes(); // Just to ack cache configuration to log..
 
-        checkKeySize(map.keySet());
+        Set<String> keys = new LinkedHashSet<>(map.keySet());
 
-        checkSize(map.keySet());
+        checkKeySize(keys);
+
+        checkSize(keys);
 
         int fullCacheSize = 0;
 
@@ -317,24 +322,8 @@ public class GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest extends GridCache
         Collection<String> locKeys = new HashSet<>();
 
         for (int i = 0; i < gridCount(); i++) {
-            grid(i).events().localListen(new IgnitePredicate<Event>() {
-                @Override public boolean apply(Event evt) {
-                    info("Received event: " + evt);
-
-                    switch (evt.type()) {
-                        case EVT_CACHE_OBJECT_SWAPPED:
-                            swapEvts.incrementAndGet();
-
-                            break;
-                        case EVT_CACHE_OBJECT_UNSWAPPED:
-                            unswapEvts.incrementAndGet();
-
-                            break;
-                    }
-
-                    return true;
-                }
-            }, EVT_CACHE_OBJECT_SWAPPED, EVT_CACHE_OBJECT_UNSWAPPED);
+            grid(i).events().localListen(
+                new LocalListener(swapEvts, unswapEvts), EVT_CACHE_OBJECT_SWAPPED, EVT_CACHE_OBJECT_UNSWAPPED);
         }
 
         cache.localEvict(Collections.singleton(k2));
@@ -416,4 +405,46 @@ public class GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest extends GridCache
         assertEquals(cnt, swapEvts.get());
         assertEquals(cnt, unswapEvts.get());
     }
+
+    /**
+     *
+     */
+    private static class LocalListener implements IgnitePredicate<Event> {
+        /** Logger. */
+        @LoggerResource
+        private IgniteLogger log;
+
+        /** Swap events. */
+        private final AtomicInteger swapEvts;
+
+        /** Unswap events. */
+        private final AtomicInteger unswapEvts;
+
+        /**
+         * @param swapEvts Swap events.
+         * @param unswapEvts Unswap events.
+         */
+        public LocalListener(AtomicInteger swapEvts, AtomicInteger unswapEvts) {
+            this.swapEvts = swapEvts;
+            this.unswapEvts = unswapEvts;
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean apply(Event evt) {
+            log.info("Received event: " + evt);
+
+            switch (evt.type()) {
+                case EVT_CACHE_OBJECT_SWAPPED:
+                    swapEvts.incrementAndGet();
+
+                    break;
+                case EVT_CACHE_OBJECT_UNSWAPPED:
+                    unswapEvts.incrementAndGet();
+
+                    break;
+            }
+
+            return true;
+        }
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/a1e5cc57/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java
index c04bf2e..a2440e2 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java
@@ -20,11 +20,14 @@ package org.apache.ignite.internal.processors.cache.distributed.near;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.HashSet;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteAtomicLong;
 import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteLogger;
 import org.apache.ignite.cache.CacheMemoryMode;
 import org.apache.ignite.cache.CachePeekMode;
 import org.apache.ignite.cache.affinity.Affinity;
@@ -36,6 +39,8 @@ import org.apache.ignite.internal.IgniteEx;
 import org.apache.ignite.internal.IgniteKernal;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.resources.IgniteInstanceResource;
+import org.apache.ignite.resources.LoggerResource;
 
 import static org.apache.ignite.cache.CacheMode.PARTITIONED;
 import static org.apache.ignite.cache.CacheMode.REPLICATED;
@@ -93,7 +98,7 @@ public class GridCachePartitionedMultiNodeFullApiSelfTest extends GridCacheParti
 
         atomicClockModeDelay(c0);
 
-        c1.removeAll(putMap.keySet());
+        c1.removeAll(new HashSet<>(putMap.keySet()));
 
         for (int i = 0; i < size; i++) {
             assertNull(c0.get(i));
@@ -159,22 +164,8 @@ public class GridCachePartitionedMultiNodeFullApiSelfTest extends GridCacheParti
             info("Finished putting value [i=" + i + ']');
         }
 
-        for (int i = 0; i < gridCount(); i++) {
-            executeOnLocalOrRemoteJvm(i, new TestIgniteIdxRunnable() {
-                @Override public void run(int idx) throws Exception {
-                    assertEquals(0, context(idx).tm().idMapSize());
-
-                    IgniteCache<Object, Object> cache = grid(idx).cache(null);
-                    ClusterNode node = grid(idx).localNode();
-
-                    for (int k = 0; k < size; k++) {
-                        if (affinity(cache).isPrimaryOrBackup(node, k))
-                            assertEquals("Check failed for node: " + node.id(), k,
-                                cache.localPeek(k, CachePeekMode.ONHEAP, CachePeekMode.OFFHEAP));
-                    }
-                }
-            });
-        }
+        for (int i = 0; i < gridCount(); i++)
+            executeOnLocalOrRemoteJvm(i, new CheckAffinityTask(size));
 
         for (int i = 0; i < size; i++) {
             info("Putting value 2 [i=" + i + ']');
@@ -199,28 +190,9 @@ public class GridCachePartitionedMultiNodeFullApiSelfTest extends GridCacheParti
 
         final IgniteAtomicLong unswapEvts = grid(0).atomicLong("unswapEvts", 0, true);
 
-        for (int i = 0; i < gridCount(); i++) {
-            final int iCopy = i;
-
-            grid(i).events().localListen(new IgnitePredicate<Event>() {
-                @Override public boolean apply(Event evt) {
-                    info("Received event: " + evt);
-
-                    switch (evt.type()) {
-                        case EVT_CACHE_OBJECT_SWAPPED:
-                            grid(iCopy).atomicLong("swapEvts", 0, false).incrementAndGet();
-
-                            break;
-                        case EVT_CACHE_OBJECT_UNSWAPPED:
-                            grid(iCopy).atomicLong("unswapEvts", 0, false).incrementAndGet();
-
-                            break;
-                    }
-
-                    return true;
-                }
-            }, EVT_CACHE_OBJECT_SWAPPED, EVT_CACHE_OBJECT_UNSWAPPED);
-        }
+        for (int i = 0; i < gridCount(); i++)
+            grid(i).events().localListen(
+                    new SwapUnswapLocalListener(), EVT_CACHE_OBJECT_SWAPPED, EVT_CACHE_OBJECT_UNSWAPPED);
 
         jcache().put("key", 1);
 
@@ -254,13 +226,8 @@ public class GridCachePartitionedMultiNodeFullApiSelfTest extends GridCacheParti
 
             boolean nearEnabled = nearEnabled(c);
 
-            if (nearEnabled) {
-                executeOnLocalOrRemoteJvm(i, new TestIgniteIdxRunnable() {
-                    @Override public void run(int idx) throws Exception {
-                        assertTrue(((IgniteKernal)ignite(idx)).internalCache().context().isNear());
-                    }
-                });
-            }
+            if (nearEnabled)
+                executeOnLocalOrRemoteJvm(i, new IsNearTask());
 
             Integer nearPeekVal = nearEnabled ? 1 : null;
 
@@ -476,4 +443,74 @@ public class GridCachePartitionedMultiNodeFullApiSelfTest extends GridCacheParti
             assertFalse(affinity(cache).isPrimaryOrBackup(other, key));
         }
     }
+
+    /**
+     *
+     */
+    private static class SwapUnswapLocalListener implements IgnitePredicate<Event> {
+        /** Logger. */
+        @LoggerResource
+        private IgniteLogger log;
+
+        /** Ignite. */
+        @IgniteInstanceResource
+        private Ignite ignite;
+
+        /** {@inheritDoc} */
+        @Override public boolean apply(Event evt) {
+            log.info("Received event: " + evt);
+
+            switch (evt.type()) {
+                case EVT_CACHE_OBJECT_SWAPPED:
+                    ignite.atomicLong("swapEvts", 0, false).incrementAndGet();
+
+                    break;
+                case EVT_CACHE_OBJECT_UNSWAPPED:
+                    ignite.atomicLong("unswapEvts", 0, false).incrementAndGet();
+
+                    break;
+            }
+
+            return true;
+        }
+    }
+
+    /**
+     *
+     */
+    private static class CheckAffinityTask extends TestIgniteIdxRunnable {
+        /** Size. */
+        private final int size;
+
+        /**
+         * @param size Size.
+         */
+        public CheckAffinityTask(int size) {
+            this.size = size;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void run(int idx) throws Exception {
+            assertEquals(0, ((IgniteKernal)ignite).<String, Integer>internalCache().context().tm().idMapSize());
+
+            IgniteCache<Object, Object> cache = ignite.cache(null);
+            ClusterNode node = ((IgniteKernal)ignite).localNode();
+
+            for (int k = 0; k < size; k++) {
+                if (affinity(cache).isPrimaryOrBackup(node, k))
+                    assertEquals("Check failed for node: " + node.id(), k,
+                        cache.localPeek(k, CachePeekMode.ONHEAP, CachePeekMode.OFFHEAP));
+            }
+        }
+    }
+
+    /**
+     *
+     */
+    private static class IsNearTask extends TestIgniteIdxRunnable {
+        /** {@inheritDoc} */
+        @Override public void run(int idx) throws Exception {
+            assertTrue(((IgniteKernal)ignite).internalCache().context().isNear());
+        }
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/a1e5cc57/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 f54fe06..d133a84 100644
--- 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
@@ -73,6 +73,7 @@ import org.apache.ignite.lang.IgniteClosure;
 import org.apache.ignite.marshaller.Marshaller;
 import org.apache.ignite.marshaller.MarshallerExclusions;
 import org.apache.ignite.marshaller.jdk.JdkMarshaller;
+import org.apache.ignite.resources.IgniteInstanceResource;
 import org.apache.ignite.spi.checkpoint.sharedfs.SharedFsCheckpointSpi;
 import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
 import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
@@ -1471,6 +1472,8 @@ public abstract class GridAbstractTest extends TestCase {
 
         if (!isMultiJvmObject(ignite))
             try {
+                job.setIgnite(ignite);
+
                 return job.call(idx);
             }
             catch (Exception e) {
@@ -1532,11 +1535,7 @@ public abstract class GridAbstractTest extends TestCase {
 
         IgniteProcessProxy proxy = (IgniteProcessProxy)ignite;
 
-        return proxy.remoteCompute().call(new IgniteCallable<R>() {
-            @Override public R call() throws Exception {
-                return job.call(idx);
-            }
-        });
+        return proxy.remoteCompute().call(new ExecuteRemotelyTask<>(job, idx));
     }
 
     /**
@@ -1546,15 +1545,7 @@ public abstract class GridAbstractTest extends TestCase {
      * @param job Job.
      */
     public static <R> R executeRemotely(IgniteProcessProxy proxy, final TestIgniteCallable<R> job) {
-        final UUID id = proxy.getId();
-
-        return proxy.remoteCompute().call(new IgniteCallable<R>() {
-            @Override public R call() throws Exception {
-                Ignite ignite = Ignition.ignite(id);
-
-                return job.call(ignite);
-            }
-        });
+        return proxy.remoteCompute().call(new TestRemoteTask<>(proxy.getId(), job));
     }
 
     /**
@@ -1571,6 +1562,8 @@ public abstract class GridAbstractTest extends TestCase {
         final String cacheName = cache.getName();
 
         return proxy.remoteCompute().call(new IgniteCallable<R>() {
+            private static final long serialVersionUID = -3868429485920845137L;
+
             @Override public R call() throws Exception {
                 Ignite ignite = Ignition.ignite(id);
                 IgniteCache<K,V> cache = ignite.cache(cacheName);
@@ -1745,6 +1738,22 @@ public abstract class GridAbstractTest extends TestCase {
     }
 
     /**
+     * @param name Name.
+     * @param remote Remote.
+     * @param thisRemote This remote.
+     */
+    public static IgniteEx grid(String name, boolean remote, boolean thisRemote) {
+        if (!remote)
+            return (IgniteEx)G.ignite(name);
+        else {
+            if (thisRemote)
+                return IgniteNodeRunner.startedInstance();
+            else
+                return IgniteProcessProxy.ignite(name);
+        }
+    }
+
+    /**
      *
      */
     private static interface WriteReplaceOwner {
@@ -1781,6 +1790,67 @@ public abstract class GridAbstractTest extends TestCase {
     }
 
     /**
+     * Remote computation task.
+     */
+    private static class TestRemoteTask<R> implements IgniteCallable<R> {
+        /** */
+        private static final long serialVersionUID = 0L;
+
+        /** Node ID. */
+        private final UUID id;
+
+        /** Job. */
+        private final TestIgniteCallable<R> job;
+
+        /**
+         * @param id Id.
+         * @param job Job.
+         */
+        public TestRemoteTask(UUID id, TestIgniteCallable<R> job) {
+            this.id = id;
+            this.job = job;
+        }
+
+        /** {@inheritDoc} */
+        @Override public R call() throws Exception {
+            Ignite ignite = Ignition.ignite(id);
+
+            return job.call(ignite);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class ExecuteRemotelyTask<R> implements IgniteCallable<R> {
+        /** Ignite. */
+        @IgniteInstanceResource
+        protected Ignite ignite;
+
+        /** Job. */
+        private final TestIgniteIdxCallable<R> job;
+
+        /** Index. */
+        private final int idx;
+
+        /**
+         * @param job Job.
+         * @param idx Index.
+         */
+        public ExecuteRemotelyTask(TestIgniteIdxCallable<R> job, int idx) {
+            this.job = job;
+            this.idx = idx;
+        }
+
+        /** {@inheritDoc} */
+        @Override public R call() throws Exception {
+            job.setIgnite(ignite);
+
+            return job.call(idx);
+        }
+    }
+
+    /**
      * Test counters.
      */
     protected class TestCounters {
@@ -1923,17 +1993,27 @@ public abstract class GridAbstractTest extends TestCase {
     }
 
     /** */
-    public static interface TestIgniteIdxCallable<R> extends Serializable {
+    public static abstract class TestIgniteIdxCallable<R> implements Serializable {
+        @IgniteInstanceResource
+        protected Ignite ignite;
+
+        /**
+         * @param ignite Ignite.
+         */
+        public void setIgnite(Ignite ignite) {
+            this.ignite = ignite;
+        }
+
         /**
          * @param idx Grid index.
          */
-        R call(int idx) throws Exception;
+        protected abstract R call(int idx) throws Exception;
     }
 
     /** */
-    public abstract static class TestIgniteIdxRunnable implements TestIgniteIdxCallable<Object> {
+    public abstract static class TestIgniteIdxRunnable extends TestIgniteIdxCallable<Void> {
         /** {@inheritDoc} */
-        @Override public Object call(int idx) throws Exception {
+        @Override public Void call(int idx) throws Exception {
             run(idx);
 
             return null;

http://git-wip-us.apache.org/repos/asf/ignite/blob/a1e5cc57/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteTestResources.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteTestResources.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteTestResources.java
index eb72252..406318f 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteTestResources.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteTestResources.java
@@ -42,6 +42,9 @@ import org.jetbrains.annotations.Nullable;
  * Test resources for injection.
  */
 public class IgniteTestResources {
+    /** Marshaller class name. */
+    public static final String MARSH_CLASS_NAME = "test.marshaller.class";
+
     /** */
     private static final IgniteLogger rootLog = new GridTestLog4jLogger(false);
 
@@ -230,8 +233,9 @@ public class IgniteTestResources {
      * @throws IgniteCheckedException If failed.
      */
     @SuppressWarnings("unchecked")
-    public synchronized Marshaller getMarshaller() throws IgniteCheckedException {
-        String marshallerName = GridTestProperties.getProperty(GridTestProperties.MARSH_CLASS_NAME);
+    public static synchronized Marshaller getMarshaller() throws IgniteCheckedException {
+        String marshallerName =
+            System.getProperty(MARSH_CLASS_NAME, GridTestProperties.getProperty(GridTestProperties.MARSH_CLASS_NAME));
 
         Marshaller marsh;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a1e5cc57/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 4bcf51e..e4c2129 100644
--- 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
@@ -246,10 +246,12 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest {
     protected static <K, V> boolean nearEnabled(final IgniteCache<K,V> cache) {
         CacheConfiguration cfg = GridAbstractTest.executeOnLocalOrRemoteJvm(cache,
             new TestCacheCallable<K, V, CacheConfiguration>() {
-            @Override public CacheConfiguration call(Ignite ignite, IgniteCache<K, V> cache) throws Exception {
-                return ((IgniteKernal)ignite).<K, V>internalCache(cache.getName()).context().config();
-            }
-        });
+                private static final long serialVersionUID = 0L;
+
+                @Override public CacheConfiguration call(Ignite ignite, IgniteCache<K, V> cache) throws Exception {
+                    return ((IgniteKernal)ignite).<K, V>internalCache(cache.getName()).context().config();
+                }
+            });
 
         return isNearEnabled(cfg);
     }
@@ -285,10 +287,13 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest {
      * @throws Exception If failed.
      */
     @SuppressWarnings("unchecked")
-    protected static <K> void loadAll(Cache<K, ?> cache, final Set<K> keys, final boolean replaceExistingValues) throws Exception {
+    protected static <K> void loadAll(Cache<K, ?> cache, final Set<K> keys, final boolean replaceExistingValues)
+        throws Exception {
         IgniteCache<K, Object> cacheCp = (IgniteCache<K, Object>)cache;
 
         GridAbstractTest.executeOnLocalOrRemoteJvm(cacheCp, new TestCacheRunnable<K, Object>() {
+            private static final long serialVersionUID = -3030833765012500545L;
+
             @Override public void run(Ignite ignite, IgniteCache<K, Object> cache) throws Exception {
                 final AtomicReference<Exception> ex = new AtomicReference<>();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a1e5cc57/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/AffinityProcessProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/AffinityProcessProxy.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/AffinityProcessProxy.java
index e1959e5..57fbcfc 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/AffinityProcessProxy.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/AffinityProcessProxy.java
@@ -19,12 +19,12 @@ package org.apache.ignite.testframework.junits.multijvm;
 
 import java.util.Collection;
 import java.util.Map;
-import java.util.UUID;
+import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCompute;
-import org.apache.ignite.Ignition;
 import org.apache.ignite.cache.affinity.Affinity;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.lang.IgniteCallable;
+import org.apache.ignite.resources.IgniteInstanceResource;
 import org.jetbrains.annotations.Nullable;
 
 /**
@@ -38,160 +38,388 @@ public class AffinityProcessProxy<K> implements Affinity<K> {
     /** Cache name. */
     private final String cacheName;
 
-    /** Grid id. */
-    private final UUID gridId;
-
     /**
      * @param cacheName Cache name.
-     * @param proxy Ignite ptocess proxy.
+     * @param proxy Ignite process proxy.
      */
     public AffinityProcessProxy(String cacheName, IgniteProcessProxy proxy) {
         this.cacheName = cacheName;
-        gridId = proxy.getId();
-        compute = proxy.remoteCompute();
-    }
-
-    /**
-     * Returns cache instance. Method to be called from closure at another JVM.
-     *
-     * @return Cache.
-     */
-    private Affinity<Object> affinity() {
-        return Ignition.ignite(gridId).affinity(cacheName);
+        this.compute = proxy.remoteCompute();
     }
 
     /** {@inheritDoc} */
     @Override public int partitions() {
-        return (int)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return affinity().partitions();
-            }
-        });
+        return compute.call(new PartitionsTask(cacheName));
     }
 
     /** {@inheritDoc} */
-    @Override public int partition(final K key) {
-        return (int)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return affinity().partition(key);
-            }
-        });
+    @Override public int partition(K key) {
+        return compute.call(new PartitionTask<>(cacheName, key));
     }
 
     /** {@inheritDoc} */
-    @Override public boolean isPrimary(final ClusterNode n, final K key) {
-        return (boolean)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return affinity().isPrimary(n, key);
-            }
-        });
+    @Override public boolean isPrimary(ClusterNode n, K key) {
+        return compute.call(new PrimaryOrBackupNodeTask<>(cacheName, key, n, true, false));
     }
 
     /** {@inheritDoc} */
-    @Override public boolean isBackup(final ClusterNode n, final K key) {
-        return (boolean)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return affinity().isBackup(n, key);
-            }
-        });
+    @Override public boolean isBackup(ClusterNode n, K key) {
+        return compute.call(new PrimaryOrBackupNodeTask<>(cacheName, key, n, false, true));
     }
 
     /** {@inheritDoc} */
-    @Override public boolean isPrimaryOrBackup(final ClusterNode n, final K key) {
-        return (boolean)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return affinity().isPrimaryOrBackup(n, key);
-            }
-        });
+    @Override public boolean isPrimaryOrBackup(ClusterNode n, K key) {
+        return compute.call(new PrimaryOrBackupNodeTask<>(cacheName, key, n, true, true));
     }
 
     /** {@inheritDoc} */
-    @Override public int[] primaryPartitions(final ClusterNode n) {
-        return (int[])compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return affinity().primaryPartitions(n);
-            }
-        });
+    @Override public int[] primaryPartitions(ClusterNode n) {
+        return compute.call(new GetPartitionsTask(cacheName, n, true, false));
     }
 
     /** {@inheritDoc} */
-    @Override public int[] backupPartitions(final ClusterNode n) {
-        return (int[])compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return affinity().backupPartitions(n);
-            }
-        });
+    @Override public int[] backupPartitions(ClusterNode n) {
+        return compute.call(new GetPartitionsTask(cacheName, n, false, true));
     }
 
     /** {@inheritDoc} */
-    @Override public int[] allPartitions(final ClusterNode n) {
-        return (int[])compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return affinity().allPartitions(n);
-            }
-        });
+    @Override public int[] allPartitions(ClusterNode n) {
+        return compute.call(new GetPartitionsTask(cacheName, n, true, true));
     }
 
     /** {@inheritDoc} */
-    @Override public Object affinityKey(final K key) {
-        return compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return affinity().affinityKey(key);
-            }
-        });
+    @Override public Object affinityKey(K key) {
+        return compute.call(new AffinityKeyTask<>(cacheName, key));
     }
 
     /** {@inheritDoc} */
-    @Override public Map<ClusterNode, Collection<K>> mapKeysToNodes(final Collection<? extends K> keys) {
-        return (Map<ClusterNode, Collection<K>>)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return affinity().mapKeysToNodes(keys);
-            }
-        });
+    @Override public Map<ClusterNode, Collection<K>> mapKeysToNodes(Collection<? extends K> keys) {
+        return compute.call(new MapKeysToNodesTask<>(cacheName, keys));
     }
 
     /** {@inheritDoc} */
-    @Nullable @Override public ClusterNode mapKeyToNode(final K key) {
-        return (ClusterNode)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return affinity().mapKeyToNode(key);
-            }
-        });
+    @Nullable @Override public ClusterNode mapKeyToNode(K key) {
+        return compute.call(new MapKeyToNodeTask<>(cacheName, key));
     }
 
     /** {@inheritDoc} */
-    @Override public Collection<ClusterNode> mapKeyToPrimaryAndBackups(final K key) {
-        return (Collection<ClusterNode>)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return affinity().mapKeyToPrimaryAndBackups(key);
-            }
-        });
+    @Override public Collection<ClusterNode> mapKeyToPrimaryAndBackups(K key) {
+        return compute.call(new MapKeyToPrimaryAndBackupsTask<>(cacheName, key));
     }
 
     /** {@inheritDoc} */
-    @Override public ClusterNode mapPartitionToNode(final int part) {
-        return (ClusterNode)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return affinity().mapPartitionToNode(part);
-            }
-        });
+    @Override public ClusterNode mapPartitionToNode(int part) {
+        return compute.call(new MapPartitionToNode<>(cacheName, part));
     }
 
     /** {@inheritDoc} */
-    @Override public Map<Integer, ClusterNode> mapPartitionsToNodes(final Collection<Integer> parts) {
-        return (Map<Integer, ClusterNode>)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return affinity().mapPartitionsToNodes(parts);
-            }
-        });
+    @Override public Map<Integer, ClusterNode> mapPartitionsToNodes(Collection<Integer> parts) {
+        return compute.call(new MapPartitionsToNodes<>(cacheName, parts));
     }
 
     /** {@inheritDoc} */
-    @Override public Collection<ClusterNode> mapPartitionToPrimaryAndBackups(final int part) {
-        return (Collection<ClusterNode>)compute.call(new IgniteCallable<Object>() {
-            @Override public Object call() throws Exception {
-                return affinity().mapPartitionToPrimaryAndBackups(part);
-            }
-        });
+    @Override public Collection<ClusterNode> mapPartitionToPrimaryAndBackups(int part) {
+        return compute.call(new MapPartitionsToPrimaryAndBackupsTask<>(cacheName, part));
+    }
+
+    /**
+     *
+     */
+    private static class PrimaryOrBackupNodeTask<K> extends AffinityTaskAdapter<K, Boolean> {
+        /** Key. */
+        private final K key;
+
+        /** Node. */
+        private final ClusterNode n;
+
+        /** Primary. */
+        private final boolean primary;
+
+        /** Backup. */
+        private final boolean backup;
+
+        /**
+         * @param cacheName Cache name.
+         * @param key Key.
+         * @param n N.
+         */
+        public PrimaryOrBackupNodeTask(String cacheName, K key, ClusterNode n,
+            boolean primary, boolean backup) {
+            super(cacheName);
+            this.key = key;
+            this.n = n;
+            this.primary = primary;
+            this.backup = backup;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Boolean call() throws Exception {
+            if (primary && backup)
+                return affinity().isPrimaryOrBackup(n, key);
+            else if (primary)
+                return affinity().isPrimary(n, key);
+            else if (backup)
+                return affinity().isBackup(n, key);
+            else
+                throw new IllegalStateException("primary or backup or both flags should be switched on");
+        }
+    }
+
+    /**
+     *
+     */
+    private static class MapKeyToPrimaryAndBackupsTask<K> extends AffinityTaskAdapter<K, Collection<ClusterNode>> {
+        /** Key. */
+        private final K key;
+
+        /**
+         * @param cacheName Cache name.
+         * @param key Key.
+         */
+        public MapKeyToPrimaryAndBackupsTask(String cacheName, K key) {
+            super(cacheName);
+            this.key = key;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Collection<ClusterNode> call() throws Exception {
+            return affinity().mapKeyToPrimaryAndBackups(key);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class PartitionsTask extends AffinityTaskAdapter<Void, Integer> {
+        /**
+         * @param cacheName Cache name.
+         */
+        public PartitionsTask(String cacheName) {
+            super(cacheName);
+        }
+
+        /** {@inheritDoc} */
+        @Override public Integer call() throws Exception {
+            return affinity().partitions();
+        }
+    }
+
+    /**
+     *
+     */
+    private static class PartitionTask<K> extends AffinityTaskAdapter<K, Integer> {
+        /** Key. */
+        private final K key;
+
+        /**
+         * @param cacheName Cache name.
+         * @param key Key.
+         */
+        public PartitionTask(String cacheName, K key) {
+            super(cacheName);
+            this.key = key;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Integer call() throws Exception {
+            return affinity().partition(key);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class GetPartitionsTask extends AffinityTaskAdapter<Void, int[]> {
+        /** Node. */
+        private final ClusterNode n;
+
+        /** Primary. */
+        private final boolean primary;
+
+        /** Backup. */
+        private final boolean backup;
+
+        /**
+         * @param cacheName Cache name.
+         * @param n N.
+         * @param primary Primary.
+         * @param backup Backup.
+         */
+        public GetPartitionsTask(String cacheName, ClusterNode n, boolean primary, boolean backup) {
+            super(cacheName);
+            this.n = n;
+            this.primary = primary;
+            this.backup = backup;
+        }
+
+        /** {@inheritDoc} */
+        @Override public int[] call() throws Exception {
+            if (primary && backup)
+                return affinity().allPartitions(n);
+            else if (primary)
+                return affinity().primaryPartitions(n);
+            else if (backup)
+                return affinity().backupPartitions(n);
+            else
+                throw new IllegalStateException("primary or backup or both flags should be switched on");
+        }
+    }
+
+    /**
+     *
+     */
+    private static class AffinityKeyTask<K> extends AffinityTaskAdapter<K, Object> {
+        /** Key. */
+        private final K key;
+
+        /**
+         * @param cacheName Cache name.
+         * @param key Key.
+         */
+        public AffinityKeyTask(String cacheName, K key) {
+            super(cacheName);
+            this.key = key;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Object call() throws Exception {
+            return affinity().affinityKey(key);
+        }
+    }
+
+    /**
+     * @param <K>
+     */
+    private static class MapKeysToNodesTask<K> extends AffinityTaskAdapter<K, Map<ClusterNode, Collection<K>>> {
+        /** Keys. */
+        private final Collection<? extends K> keys;
+
+        /**
+         * @param cacheName Cache name.
+         * @param keys Keys.
+         */
+        public MapKeysToNodesTask(String cacheName, Collection<? extends K> keys) {
+            super(cacheName);
+            this.keys = keys;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Map<ClusterNode, Collection<K>> call() throws Exception {
+            return affinity().mapKeysToNodes(keys);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class MapKeyToNodeTask<K> extends AffinityTaskAdapter<K, ClusterNode> {
+        /** Key. */
+        private final K key;
+
+        /**
+         * @param cacheName Cache name.
+         * @param key Key.
+         */
+        public MapKeyToNodeTask(String cacheName, K key) {
+            super(cacheName);
+            this.key = key;
+        }
+
+        /** {@inheritDoc} */
+        @Override public ClusterNode call() throws Exception {
+            return affinity().mapKeyToNode(key);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class MapPartitionToNode<K> extends AffinityTaskAdapter<K, ClusterNode> {
+        /** Partition. */
+        private final int part;
+
+        /**
+         * @param cacheName Cache name.
+         * @param part Partition.
+         */
+        public MapPartitionToNode(String cacheName, int part) {
+            super(cacheName);
+            this.part = part;
+        }
+
+        /** {@inheritDoc} */
+        @Override public ClusterNode call() throws Exception {
+            return affinity().mapPartitionToNode(part);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class MapPartitionsToNodes<K> extends AffinityTaskAdapter<K, Map<Integer, ClusterNode>> {
+        /** Parts. */
+        private final Collection<Integer> parts;
+
+        /**
+         * @param cacheName Cache name.
+         * @param parts Parts.
+         */
+        public MapPartitionsToNodes(String cacheName, Collection<Integer> parts) {
+            super(cacheName);
+            this.parts = parts;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Map<Integer, ClusterNode> call() throws Exception {
+            return affinity().mapPartitionsToNodes(parts);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class MapPartitionsToPrimaryAndBackupsTask<K> extends AffinityTaskAdapter<K, Collection<ClusterNode>> {
+        /** Partition. */
+        private final int part;
+
+        /**
+         * @param cacheName Cache name.
+         * @param part Partition.
+         */
+        public MapPartitionsToPrimaryAndBackupsTask(String cacheName, int part) {
+            super(cacheName);
+            this.part = part;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Collection<ClusterNode> call() throws Exception {
+            return affinity().mapPartitionToPrimaryAndBackups(part);
+        }
+    }
+
+    /**
+     *
+     */
+    private abstract static class AffinityTaskAdapter<K, R> implements IgniteCallable<R> {
+        /** Ignite. */
+        @IgniteInstanceResource
+        protected Ignite ignite;
+
+        /** Cache name. */
+        protected final String cacheName;
+
+        /**
+         * @param cacheName Cache name.
+         */
+        public AffinityTaskAdapter(String cacheName) {
+            this.cacheName = cacheName;
+        }
+
+        /**
+         * @return Affinity.
+         */
+        protected Affinity<K> affinity() {
+            return ignite.affinity(cacheName);
+        }
     }
 }
\ No newline at end of file


[43/50] [abbrv] ignite git commit: Muted test CacheAffinityCallSelfTest.testAffinityCallNoServerNode

Posted by ag...@apache.org.
Muted test CacheAffinityCallSelfTest.testAffinityCallNoServerNode


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

Branch: refs/heads/ignite-1016
Commit: 6ffd5ce310b13bd63d4eee3abfb434cd7f76e0eb
Parents: 75fb19d
Author: ashutak <as...@gridgain.com>
Authored: Tue Oct 20 15:55:58 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Tue Oct 20 15:55:58 2015 +0300

----------------------------------------------------------------------
 .../internal/processors/cache/CacheAffinityCallSelfTest.java     | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/6ffd5ce3/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheAffinityCallSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheAffinityCallSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheAffinityCallSelfTest.java
index b9ff46c..8530fbb 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheAffinityCallSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheAffinityCallSelfTest.java
@@ -134,6 +134,8 @@ public class CacheAffinityCallSelfTest extends GridCommonAbstractTest {
      * @throws Exception If failed.
      */
     public void testAffinityCallNoServerNode() throws Exception {
+        fail("https://issues.apache.org/jira/browse/IGNITE-1741");
+
         startGridsMultiThreaded(SERVERS_COUNT + 1);
 
         final Integer key = 1;
@@ -210,4 +212,4 @@ public class CacheAffinityCallSelfTest extends GridCommonAbstractTest {
             return null;
         }
     }
-}
\ No newline at end of file
+}